|
-
July 9th, 2011, 05:55 AM
#1
java code review?
Hi
I have some code segments. can someone please review it and tell me the problems if any?
1.)
String a=null;
if (a!=null & a.length()>10) {
System.out.println(“Inside if”);
}
System.out.println(“Outside if”);
2.)
int m = 0;
while( m++ < 2 )
System.out.println( m );
3.)
Hashtable hashtable = new Hashtable();
hashtable.put("One", “1”);
hashtable.put("Two", “2”);
hashtable.put("One", “1”);
while(hashtable.keys().hasMoreElements() ){
System.out.println(hashtable.keys().nextElement());
}
Thanks for your time.
Regards
Arvind
-
July 9th, 2011, 07:25 AM
#2
Re: java code review?
Have you compiled and executed all the the code samples?
What was the results?
The compiler is very good at find syntax errors.
Executing a program often finds logic errors.
Norm
-
July 9th, 2011, 09:06 AM
#3
Re: java code review?
Given the code, this looks very much like a homework exercise.
However, if you make some effort to review the code yourself, we'll tell you what we think of your review.
It is easier to measure something than to understand what you have measured...
Anon.
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
-
July 9th, 2011, 01:48 PM
#4
Re: java code review?
 Originally Posted by dlorde
It is easier to measure something than to understand what you have measured...
Anon.
Love the quote!
But yes, it appears to be a homework assignment. Why don't you just run it and see what it does. Then read through the code and try to understand how these results were produced? If you fail to do this last part, you can always come back and ask for help.
Hope this helped,
Laurent
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|