Win a copy of Spring in Action (5th edition) this week in the Spring forum!

Syed Tabrez

Greenhorn
+ Follow
since Dec 22, 2009
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 Syed Tabrez

The insight into the process that Sun probably used to classify what to retain and what to change was good. Thank you.
8 years ago
Nice explanation, I esp liked the part where you highlighted Sun going the exra mile to accomodate bad code!!!.
Thank you Rob.
8 years ago



I was expecting the above code to throw a null pointer as the variable "a" is null.Can some one please tell me why it does not throw a NullPointerException.Thanks in advance.
8 years ago
Clarifying my statement
"Usually this line tends to handle the lower layer functionality of reading data from a file in a stream of bytes. "
FileInputStream has functionality to accomplish the reading of the file however in your code snippet you are not invoking any of that explicitly rather the parser I think will invoke it for you.
8 years ago
FileInputStream fin = new FileInputStream(args[1]); --------------> ???

Usually this line tends to handle the lower layer functionality of reading data from a file in a stream of bytes.
However in your specific case seems that after reading the file you need to parse the contents as xml content with a SAX parser which is what you are attempting here
parser.parse(is, this); ----------------------> ???

While parsing the contents in SAX based parsing you encounter callbacks indicating various situations like begin-of-an-xml tag,end-of-xml-tag along with associated data based on which you can do some meaning ful operation.

Hope this helps.
8 years ago
I was trying out a simple piece of code to test the exception handling with the following code snippet,

public class ExceptionTest{

public static void main(String ab[]){
System.out.println("test"+method1());
}

static int method1(){
int x= 5;
try{
System.out.println("x:"+x);
//some operation here that might generate an exception
return (x++);
}catch(IllegalArgumentException aee){
throw aee;
}finally{
System.out.println("x:"+x);
return (x++);
}

}
}


I see that the return in try is invoked and also the return from finally is also invoked(x gets incremented twice).
So is it safe to say that the first return(from try) is ignored all the time and the return in finally will always take precedence regardless of any exception ever generated or not ??
If this is so then why isn't the compiler complaining that the return in try block is meaningless ?
Code was tested out on eclipse 3.5.0 java 1.5.
If some one can shed some light on this would be grateful for the help.
8 years ago
Thank you for the clarification.
8 years ago
That makes it clear thanks Rob!!!
For some reason overlooked the fact that unary + or - indicates a positive or negative number ..... thank you for pointing this out.
8 years ago
Hi ,

I have some exisitng code that is assigning a String reference with the along the lines of the following assignment,
String a1 =+1+- - + - - + + 1+"";
which is undoubtedly not a nice way to code ......... but very surprisingly it compiles and runs fine!!!

If any one can please point out the reason why java compiler allows this without a warning even in eclipse 3.5.0 on java 1.5 will be grateful for the reply.

Thanks and regards,
Tabz
8 years ago