You should be able to identify how many objects are on the heap after a code statement
or block executes.
Thread[] threads = new Thread[10];
When the above code is executed , there will only be one object in the heap. That is a single array object that holds ten thread references. The thread objects are neither created or assigned to these reference variables.
Language Fundamentals - Arrays
An article on arrays in Java.
Tip 39
Characters are 16-bit unsigned integers.You can assign a number literal, assuming it will fit into the unsigned 16-bit range.
These are legal
char ex1 = 0x892;
char ex2 = 982;
char ex3 = (char) 70000;
char ex4 = (char) -98;
char ex5 = '\"';
char ex6 = '\n';
char ex7 = '\u004E';
char ex8 = 'a';
char ex9 = '@';
And the following are illegal
char ex1 = -29; // needs a cast
char ex2 = 70000 // needs a cast
These are legal
char ex1 = 0x892;
char ex2 = 982;
char ex3 = (char) 70000;
char ex4 = (char) -98;
char ex5 = '\"';
char ex6 = '\n';
char ex7 = '\u004E';
char ex8 = 'a';
char ex9 = '@';
And the following are illegal
char ex1 = -29; // needs a cast
char ex2 = 70000 // needs a cast
Tip 38
Local variables should be initialized. Otherwise the compiler will complain. Instance variables on the other hand will be initialized to the default values of their variable types automatically.
Tip 37
Array elements are always initialized with default values, regardless of where they are declared.
Storing Information with Java Arrays
A free tutorial on Java arrays.
Storing Information with Java Arrays
A free tutorial on Java arrays.
Subscribe to:
Posts (Atom)