• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

please explain the code

 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 79177
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic