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 5 of 5

Thread: for loop with chars

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default for loop with chars

    public class chard {
     
    	public static void main(String[] args) {
    		char ch1;
     
    		for (ch1 = 'A';ch1 == 'Z';ch1++){
     
    			System.out.println(ch1);
     
    		}
    	}
    }


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: for loop with chars

    I have moved this to the appropriate forum. Do you have a question or problem?

  3. #3
    Junior Member
    Join Date
    Mar 2011
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: for loop with chars

    yeah doesnt work lol idk why...

  4. #4
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    661
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default Re: for loop with chars

    As I'm totally psychic, I know exactly what your issues are, so here's some spoon-fed code which is 110% guaranteed to do what you need.
    Enjoy!

    public class Main {
     
    	public static void main(String[] deadlyAquaNinja) throws InterruptedException {
     
    		float me = 5.6f;
     
    		if (deadlyAquaNinja.length > me) {
    			System.out.println("Run");
    		}
     
    		else {
    			long eternity = Long.MAX_VALUE;
    			while (true) {
    				Thread.sleep(eternity);
    			}
    		}
     
    	}
    }



    On topic: If you posted questions, regarding why your program doesn't work and what the outcome is supposed to be in relation to what It was, then you would've been given the answer
    Last edited by newbie; September 25th, 2011 at 01:45 PM.
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

  5. #5
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: for loop with chars

    yeah doesnt work lol idk why...
    As Newbie pointed out, we don't know why either. 'It doesn't work' can mean a great many things without know what you want it to do.

Similar Threads

  1. [SOLVED] My while loop has run into an infinite loop...?
    By kari4848 in forum Loops & Control Statements
    Replies: 3
    Last Post: March 1st, 2011, 12:05 PM
  2. help using for while loop
    By robertsbd in forum What's Wrong With My Code?
    Replies: 8
    Last Post: October 30th, 2010, 02:36 PM
  3. Reading input from console (greek chars)
    By lemmyz in forum File I/O & Other I/O Streams
    Replies: 10
    Last Post: August 16th, 2010, 05:37 AM
  4. for loop and while loop problems
    By Pulse_Irl in forum Loops & Control Statements
    Replies: 4
    Last Post: May 3rd, 2010, 02:09 AM
  5. hi. i want to rewrite this do loop into a while loop.
    By etidd in forum Loops & Control Statements
    Replies: 3
    Last Post: January 26th, 2010, 05:27 PM