• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

conversion from c# to java

 
Avi Sridhar
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

Thanks for helping me out with answers here. I have one more question regarding conversion of c# into java.



Is this the right way to do this . I see there is something wrong.

Please let me know.

Thanks
 
Campbell Ritchie
Sheriff
Posts: 48381
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hardly a beginner's topic!

No, it is not the right way to do it. If you take the value of a char, you might get 'A' = 0x41 (65). You could try several things:

  • Integer.parseInt(myString.substring( . . .
  • Character#getNumericValue
  • charAt() - '0'
  • and there are bound to be others.
  • At least the parsing methods will throw a nice Exception if your char isn't a number!
     
    Avi Sridhar
    Ranch Hand
    Posts: 48
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by Campbell Ritchie:
    Hardly a beginner's topic!

    No, it is not the right way to do it. If you take the value of a char, you might get 'A' = 0x41 (65). You could try several things:

  • Integer.parseInt(myString.substring( . . .
  • Character#getNumericValue
  • charAt() - '0'
  • and there are bound to be others.
  • At least the parsing methods will throw a nice Exception if your char isn't a number!

    Thanks for the reply.

    Reg. this : Integer.parseInt(myString.substring( . . .

    did you mean

     
    Campbell Ritchie
    Sheriff
    Posts: 48381
    56
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by Avi Sridhar:

    Thanks for the reply.

    Reg. this : Integer.parseInt(myString.substring( . . .

    did you mean

    Yes.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic