Only nested classes can be static. By doing so you can use the nested class without having an instance of the outer class.
has chinese and english two versions
Listening: repeat watching them and follow the speaker to read aloud
|Q:||What are pass by reference and passby value?|
|A:||Pass By Reference means the passing the address itself rather than passing the value. Passby Value means passing a copy of the value to be passed.|
|Q:||What is HashMap and Map?|
|A:||Map is Interface and Hashmap is class that implements that.|
|Q:||Difference between Vector and ArrayList?|
|A:||Vector is synchronized whereas arraylist is not.|
|Q:||Difference between Swing and Awt?|
|A:||AWT are heavy-weight componenets. Swings are light-weight components. Hence swing works faster than AWT.|
|Q:||What is final?|
|A:||A final class can’t be extended ie., final class may not be subclassed. A final method can’t be overridden when its class is inherited. You can’t change value of a final variable (is a constant).|
Integer x = Integer.valueOf(str); // or int y = Integer.parseInt(str);
There is a slight difference between these methods:
- valueOf returns new instance of java.lang.Integer
- parseInt returns primitive int.
The same is for all cases: Short.valueOf/parseShort, Long.valueOf/parseLong etc.
- Vectors are synchronized, ArrayLists are not.
- Data Growth Methods
Use ArrayLists if there is no specific requirement to use Vectors.
If multiple threads access an ArrayList concurrently then we must externally synchronize the block of code which modifies the list either structurally or simply modifies an element. Structural modification means addition or deletion of element(s) from the list. Setting the value of an existing element is not a structural modification.
Collections.synchronizedList is normally used at the time of creation of the list to avoid any accidental unsynchronized access to the list.
Internally, both the ArrayList and Vector hold onto their contents using an Array. When an element is inserted into an ArrayList or a Vector, the object will need to expand its internal array if it runs out of room. A Vector defaults to doubling the size of its array, while the ArrayList increases its array size by 50 percent.
The default value any Object reference is
The default value for a
boolean is false.