Nirodha Abeywardana

Greenhorn
+ Follow
since Dec 12, 2006
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Nirodha Abeywardana

Anybody used Paul Singhera - Manning Publication book ?
I am going to start with SCBCD 1.3. What are the books available for that exam. Do you have any idea about Paul Singhera's book(Manning Publication). pls help me.
byte b = 27;

but only because the compiler automatically narrows the literal value to a byte if it is a compile time constant.The preceding code is identical to the following:

byte b = (byte) 27;

byte b = 3; // No problem, 3 fits in a byte
byte c = 8; // No problem, 8 fits in a byte
byte d = b + c; // Should be no problem, sum of the two bytes fits in a byte

But this gives a compiler error since "b+c" is not a compiler time const.
In this case you have to exlicitly cast as
byte c = (byte) (a + b);

byte d = 3 + 8; // This compiles successfully, since 3+8 is a compiler time const

"=" operator implecitly cast it if it can hold
short sh1 = (short)1 - (short)2;//1
Short sh = new Short((short)1 - (short)2);//2

(short)1 - (short)2 returns an int type, return value will be implecitly cast to short if it is enough to hold so line 1 compiled correctly.
But in line 2 there is no constructor for new Short(int) so compiler error given
Although there is significant overlap with the JDK 1.4 exam I guess that there is at least 30% new material to learn. Some of the new topics are

regular expressions
the Locale class
the Text class
serializing streams
generic collections
generic method parameters
input/output classes
for-each looping
locales (dates and currencies)
enums
autoboxing
OO concepts (coupling and cohesion)
jar files
sorting and searching collections
covariant returns
JavaBean naming
varargs
this is compiling with warnings. how this can be happan pls explain.
List myList = new ArrayList(); is same as List<Object> myList = new ArrayList<Object>();
method argument is type List<String>, but Object can not cast to String type implecitly

public class GenericsTest {
public static void main(String[] args) {
List myList = new ArrayList();
myList.add("Fred");
myList.add("Test0000");
myList.add("Test1111");
GenericsTest gt =new GenericsTest();
gt.takeListOfStrings(myList1);
}

void takeListOfStrings(List<String> strings) {
strings.add("foo");
}
}