Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Extracting a char from a string in java

  • 09-05-2007 6:42am
    #1
    Closed Accounts Posts: 29


    Hi All,

    I would imagine that this is fairly straight foward but what I am tryin to do is compare two strings and depending on the outcome change the value in one string to the character value in another string

    This is the code I am trying
    if (number[i].charAt(0) != node.charAt(0))
       {
    
        //Hope to replace node with the first char in number[i]
    
       node = number[i].substring(0);
    
       System.out.print(node);
    
       }
    
    But for input such as 34 for number, when I print out node it is also 34. I have tired replace and changing the types to char arrays and then back again and it just falls over.

    Any suggestions would be great.


Comments

  • Registered Users, Registered Users 2 Posts: 37,485 ✭✭✭✭Khannie


    So....for input of 34, you want node to hold 3? Is that right?

    If so...node = number.substring(0,0);


Advertisement