Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: chr array to int

  1. #1
    Junior Member
    Join Date
    Jun 2011
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default chr array to int

      String word="welcome";
             char Char[] = word.toCharArray();
          // complete String str value is been converted in to char array data by
          // the method
             System.out.println(Char);
    i am plan the welcome change to INT, how to change when is Char array?


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: chr array to int

    		String word = "welcome";
    		char Char[] = word.toCharArray();
     
    		for(int j = 0; j < Char.length; j++){
    			int n  = Char[j];
    			System.out.println(n);
    		}
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: chr array to int

    Given the String "welcome", what do you want to convert it to?
    What do you want to print out?

  4. #4
    Junior Member
    Join Date
    Jun 2011
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: chr array to int

    i want to change to int.

  5. #5
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: chr array to int

    Do you realise how vague your answer is. What int. The String "welcome" has no meaningful int value. Do you want its length? A sum of the ascii values? Some other highly complicated algorithm? What??????

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: chr array to int

    i want to change to int.
    Can you give a concrete answer. Like "welcome" should convert to 435643429.
    Then explain the algorithm that you used to make that conversion:
    first letter * 23 + second letter *11 + ....

Similar Threads

  1. Char array to a String array with hex
    By fortune2k in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 20th, 2014, 01:01 PM
  2. Replies: 2
    Last Post: May 13th, 2011, 03:08 AM
  3. Replies: 2
    Last Post: May 6th, 2011, 05:19 PM
  4. prininting out a 4x4 array according to an order by a 1d array
    By fortune2k in forum Collections and Generics
    Replies: 7
    Last Post: November 25th, 2010, 12:54 PM
  5. 2d (4x4) array insdie a 1d array. (Block cipher)
    By fortune2k in forum Collections and Generics
    Replies: 13
    Last Post: November 23rd, 2010, 05:29 PM