aspose file tools*
The moose likes Beginning Java and the fly likes please explain the code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "please explain the code" Watch "please explain the code" New topic
Author

please explain the code

Rakesh Keerthi
Ranch Hand

Joined: Jul 16, 2012
Posts: 144
Hi,

i am unable to understand what is going on in the below program part that is highlighted.



i think that charAt(i) is used to get the character at the i(index). but here it is something else it is returning some number. can anyone please explain.

Thanks
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39834
    
  28
You cannot put bold tags inside code tags; they do not work and I removed them. You had marked line 19.
That is quite easy. If you look here, you find that a char isn’t a letter, but a number between 0 and 0xffff (65535) inclusive. If it is a number, you can do arithmetic with it.
Where did you find that code? It has some interesting features, like the inappropriately‑named get method, the excessive use of static members, and the unusual close() call.
Please add this line after line 11 and before line 12:-
System.out.println("Goodbye.");
…and see what happens
The System.exit(0) call is probably completely unnecessary, and System.exit can be harmful in a multi‑threaded application, causing corrupted data in certain circumstances.
 
Don't get me started about those stupid light bulbs.
 
subject: please explain the code