• 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

unable to understand line no.7 of this below program

 
Ranch Hand
Posts: 339
  • 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 line no.7 of this below program.Please anyone explain how it works?



1>public class Testingassigningtochar {
2> public static void main(String[] args){
3> Testingassigningtochar t = new Testingassigningtochar ();
4> char c = 4 * 4;
5> String s = "bead";
6> s = t.pearl(s);
7> System.out.println(Byte.parseByte(s,c));
8> }
9> String pearl(String s){
10> return s.substring(0,1);
}
}
 
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello pradeep,

The parseXXX methods always returns the primitive associated the method you're invoking, in this case, the overloaded parseByte(String, int) returns a byte.

In the code you provided parseByte() method is receiving a String containing the value: b, and char c which contains the value 16. 16 is telling the method that the number you're passing is in Hexadecimal Notation, and b translated from Hex to Decimal equals to 11.

Hope that has helped,
Jose
 
pradeep singh
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Mr.Jose Campana .I am well understood now.Again thanks very much.
 
reply
    Bookmark Topic Watch Topic
  • New Topic