log4j is a logging utility written in Java.It can be used as a debugging utility.log4j is one of widely used Java logging frameworks.log4j allows you to log to a file, console, remote server etc.
log4j has six logging levels from highest to lowest:
1. FATAL
2. ERROR
3. WARN
4. INFO
5. DEBUG
6. TRACE
You can configure log4j either using properties file or XML file.log4j configuration file contains
3 main components:
1. Loggers
2. Appenders
3. Layouts
The advantage of logging using log4j is that logging can be turned on or off without actually modifying the application that uses log4j.The application can be allowed to run with logging turned off until there's problem and later if there is any problem the user can turned on logging to see where is the problem.
Regards,
Tausif Khan, Nagpur
Wednesday, August 29, 2007
Thursday, August 16, 2007
Need a Dose again????????????
He guys,
It was really depressing not see a single blog since a week or more.Ya, there was some inconsistency in the class last week but atleast we must keep blogging regularly.I felt so and hence i m blogging though i dont have any valuable contents.But i will try to gather something useful and i promise I will be Back, very soon!!!
Till then, take care and Keep Blogging, else we might have one more class of heavy doses from Tushar Sir!!!
Take care,
Regards,
S A Vakeel
It was really depressing not see a single blog since a week or more.Ya, there was some inconsistency in the class last week but atleast we must keep blogging regularly.I felt so and hence i m blogging though i dont have any valuable contents.But i will try to gather something useful and i promise I will be Back, very soon!!!
Till then, take care and Keep Blogging, else we might have one more class of heavy doses from Tushar Sir!!!
Take care,
Regards,
S A Vakeel
Monday, August 6, 2007
Inner classes
Hi everyone!!!
I really mised out the weekend!It was like i had not attended the class from a month.Neways, Mangesh helped me a lot by letting me know what had been taught on Friday.Thanx Mangesh!!!
Here, i m irting about inner classes.Hope it ould help u ppl in ome way!!
Inner classes are a feature added to Java with the release of JDK 1.1. Inner classes, sometimes also called as Nested classes, can give your programs additional carity and make them more concise.
Basically, an inner class is same as any other class except that it is declared inside an opening and closing braces of some construct that may be a class or a method.Following is an example of inner classes:
public class OuterOne{
private int x;
public class InnerOne{
private int y;
public innerMethod(){
System.out.println("Y = " + y);
}
}
public void outerMethod(){
System.out.println(" X = " + x);
}
}
When an inner class is declared like this, the enclosing class name becomes part of the fully qualified name of the inner class.In this case, the full names of the two classes are OuterOne and OuterOne.Innerone. itis possible since an inner class belongs to its enclosing class similar to the way a class belongs to a package.
Following example shows an extended view at the inner classes where the inner class uses the members of the enclosing class.
public class OuterOne{
private int x;
public class InnerOne{
private int y;
public innerMethod(){
System.out.println("Enclosing X = " + y);
System.out.println("Y = " + y);
}
}
public void outerMethod(){
System.out.println(" X = " + x);
}
}
Sometimes you might to create an instance of an inner class from a static method, or in some situation where ther is no this object available. The situtaion arises in a main() method.You can ahieve this by using new operator as :
public sytatic void main(String[] args){
OuterOne.InnerOne inner = new OuterOne().InnerOne();
inner.innerMethod();
}
We can also define classes inside Methods.The first point to be noted here is that anything declared inside a method is not a member of the class, but is local to the method.The imediate consequence is that classes declared in methods are private to the method and cannot be marked with any access modifier, neither can they be marked as static.
The second and most important point to be noted here is that the classes defined inside a method can access variables of the enclosing methods if and only if those variables are defined as FINAL.
The reason is that: An onject declared inside a mehod is likely to outlive the method invocation.Since the local variables and method arguments are conventionally destroyed when their method exits,these variables will be invalid for access by inner class methods after the enclosing method exits. By allowing the methods to access only final variables, it is possible to maintain a copy of the variables with the object itself, therby extending their lifetime.
Anonymous classes: Some classes that you define inside a method do not need a name , such classes are called as Anonymous classes.
Anonymous classes are mainly used to extend some class or implement an interface.This restricts you to extend more than one class and implement more than one interface.
Since there is no name given to the anonymous classes, we cannot use the new keyword in the usual way.The definition, contsruction and instantiation of an anonymous class all occur in the same place.This is explained in the next example:
public void aMethod(){
theButton.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
System.out.pritnln("The action has occurred");
}
}
);
}
This example may look somewhat weird to you since we have not learnt ActionListener yet.So lets check this example for our IStatusPrinter interface where we will use the Flexigame object to set the IStatusPrinter reference:
Flexigame fgame = new Flexigame("Cricket");
fgame.setStatusPrinter(
new IStatusPrinter(){
public void start(){
System.out.println("Starting the Game thgrough Anonymous class");
}
public void stop(){
System.out.println("Stopping the Game thgrough Anonymous class");
}
});
Thats all for now, guys!!!
See u soon with more stuff!!!
Take care,
Regards,
S A Vakeel
I really mised out the weekend!It was like i had not attended the class from a month.Neways, Mangesh helped me a lot by letting me know what had been taught on Friday.Thanx Mangesh!!!
Here, i m irting about inner classes.Hope it ould help u ppl in ome way!!
Inner classes are a feature added to Java with the release of JDK 1.1. Inner classes, sometimes also called as Nested classes, can give your programs additional carity and make them more concise.
Basically, an inner class is same as any other class except that it is declared inside an opening and closing braces of some construct that may be a class or a method.Following is an example of inner classes:
public class OuterOne{
private int x;
public class InnerOne{
private int y;
public innerMethod(){
System.out.println("Y = " + y);
}
}
public void outerMethod(){
System.out.println(" X = " + x);
}
}
When an inner class is declared like this, the enclosing class name becomes part of the fully qualified name of the inner class.In this case, the full names of the two classes are OuterOne and OuterOne.Innerone. itis possible since an inner class belongs to its enclosing class similar to the way a class belongs to a package.
Following example shows an extended view at the inner classes where the inner class uses the members of the enclosing class.
public class OuterOne{
private int x;
public class InnerOne{
private int y;
public innerMethod(){
System.out.println("Enclosing X = " + y);
System.out.println("Y = " + y);
}
}
public void outerMethod(){
System.out.println(" X = " + x);
}
}
Sometimes you might to create an instance of an inner class from a static method, or in some situation where ther is no this object available. The situtaion arises in a main() method.You can ahieve this by using new operator as :
public sytatic void main(String[] args){
OuterOne.InnerOne inner = new OuterOne().InnerOne();
inner.innerMethod();
}
We can also define classes inside Methods.The first point to be noted here is that anything declared inside a method is not a member of the class, but is local to the method.The imediate consequence is that classes declared in methods are private to the method and cannot be marked with any access modifier, neither can they be marked as static.
The second and most important point to be noted here is that the classes defined inside a method can access variables of the enclosing methods if and only if those variables are defined as FINAL.
The reason is that: An onject declared inside a mehod is likely to outlive the method invocation.Since the local variables and method arguments are conventionally destroyed when their method exits,these variables will be invalid for access by inner class methods after the enclosing method exits. By allowing the methods to access only final variables, it is possible to maintain a copy of the variables with the object itself, therby extending their lifetime.
Anonymous classes: Some classes that you define inside a method do not need a name , such classes are called as Anonymous classes.
Anonymous classes are mainly used to extend some class or implement an interface.This restricts you to extend more than one class and implement more than one interface.
Since there is no name given to the anonymous classes, we cannot use the new keyword in the usual way.The definition, contsruction and instantiation of an anonymous class all occur in the same place.This is explained in the next example:
public void aMethod(){
theButton.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
System.out.pritnln("The action has occurred");
}
}
);
}
This example may look somewhat weird to you since we have not learnt ActionListener yet.So lets check this example for our IStatusPrinter interface where we will use the Flexigame object to set the IStatusPrinter reference:
Flexigame fgame = new Flexigame("Cricket");
fgame.setStatusPrinter(
new IStatusPrinter(){
public void start(){
System.out.println("Starting the Game thgrough Anonymous class");
}
public void stop(){
System.out.println("Stopping the Game thgrough Anonymous class");
}
});
Thats all for now, guys!!!
See u soon with more stuff!!!
Take care,
Regards,
S A Vakeel
Thursday, August 2, 2007
Object Property
Variables of the class are related to the object of the that class irrespective whether those are private,public or protected. This is because we can make use of the variables of other class in our class by using the . .
Similar to this we can access non static methods using the object of that respective class, thus these are also related to objec property of class.
We Know that static inner class not related to the object property of enclosing class.Thus we can not have access inside static inner classs of the nonstatic methods and non final variables of the enclosing class.
Similar to this we can access non static methods using the object of that respective class, thus these are also related to objec property of class.
We Know that static inner class not related to the object property of enclosing class.Thus we can not have access inside static inner classs of the nonstatic methods and non final variables of the enclosing class.
by,
Mangesh S.S.Waghaye.
Mangesh S.S.Waghaye.
Wednesday, August 1, 2007
Abstract Classes Vs Interfaces
If we are developing some application in which an entity can have more than one implementation, then it is a good practise to use interfaces and implement classes using interfaces.
If some of the functionality of an entity is already known and other methods can have different
implementations, then creating an abstract class is better.
All the methods declared in Interfaces are implicitly abstract. An Abstract class can have
one or more abstract methods as well as concrete methods having implementations.
Interfaces can't have methods that have implementations.
You can implement any number of classes but you can't extends more than class at a time.
We cannot create object of Interface but we can create object of Abstract class.
These are few basic differences between Abstract Classes and Interfaces.
Regards,
Tausif Khan, Nagpur
If some of the functionality of an entity is already known and other methods can have different
implementations, then creating an abstract class is better.
All the methods declared in Interfaces are implicitly abstract. An Abstract class can have
one or more abstract methods as well as concrete methods having implementations.
Interfaces can't have methods that have implementations.
You can implement any number of classes but you can't extends more than class at a time.
We cannot create object of Interface but we can create object of Abstract class.
These are few basic differences between Abstract Classes and Interfaces.
Regards,
Tausif Khan, Nagpur
Inner Classes
Inner Classes :-
the class inside onother class is called inner class. but their are some limitations about inner classes......
1. they should be static always...
2. they can be private, but only used by their outer class( Enclosing class )...
3. they can be public also.....
4. they can implement interfaces....
5. they can not extend.....
their are 4 types of inner classes..
1. static inner class.
2. local inner class.
3. Anonomus inner class :-
this is some wt difficult for me to understand.... but (sobiya mam and vakeel ne firse samjhaya then ab jake thoda bahot samajha hai....) still i m trying to get understand it more clearly.........
Ragards,
Rachana Kulkarni.
the class inside onother class is called inner class. but their are some limitations about inner classes......
1. they should be static always...
2. they can be private, but only used by their outer class( Enclosing class )...
3. they can be public also.....
4. they can implement interfaces....
5. they can not extend.....
their are 4 types of inner classes..
1. static inner class.
2. local inner class.
3. Anonomus inner class :-
this is some wt difficult for me to understand.... but (sobiya mam and vakeel ne firse samjhaya then ab jake thoda bahot samajha hai....) still i m trying to get understand it more clearly.........
Ragards,
Rachana Kulkarni.
MUST DO IT!!!
Hey everyone!
Here are ome rules that i think we must follow while submitting the assignments (Im telling this coz i myself have done lots of mistakes while submitting the assignments)
First of all, the library files (.jar) that we are using in the main project need not to be sent explicitly.It gets encapsulated with the main project which is using it in the 'lib' folder.
While making the jar file of the Main project, take care of setting the Main class of the jar in the tab "Manifest specification" which will help you executing th main file from the jar itself.
And one important thing, while using the jar file as a library in the main project, we will have to use the
"IMPORT" statements.
Thats all for now,
take care
regards,
S A Vakeel
Here are ome rules that i think we must follow while submitting the assignments (Im telling this coz i myself have done lots of mistakes while submitting the assignments)
First of all, the library files (.jar) that we are using in the main project need not to be sent explicitly.It gets encapsulated with the main project which is using it in the 'lib' folder.
While making the jar file of the Main project, take care of setting the Main class of the jar in the tab "Manifest specification" which will help you executing th main file from the jar itself.
And one important thing, while using the jar file as a library in the main project, we will have to use the
"IMPORT" statements.
Thats all for now,
take care
regards,
S A Vakeel
Subscribe to:
Posts (Atom)