Java Cheat sheet
1. Get the class name of an object: this.getClass().getName()
2. Static Java Class
Only nested class can be declared as static.
Nested class is a class defined within another class. Such class can be static or non-static. Non-static inner class also called inner class.
Different:
1) Nested static class doesn’t need reference of Outer class, but Non-static nested class or Inner class requires Outer class reference.
2) Inner class(or non-static nested class) can access both static and non-static members of Outer class. A static class cannot access non-static members of the Outer class. It can access only static members of Outer class.
(from http://www.geeksforgeeks.org/static-class-in-java/)
2. Static Java Class
Only nested class can be declared as static.
Nested class is a class defined within another class. Such class can be static or non-static. Non-static inner class also called inner class.
Different:
1) Nested static class doesn’t need reference of Outer class, but Non-static nested class or Inner class requires Outer class reference.
2) Inner class(or non-static nested class) can access both static and non-static members of Outer class. A static class cannot access non-static members of the Outer class. It can access only static members of Outer class.
(from http://www.geeksforgeeks.org/static-class-in-java/)
还没人赞这篇日记