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

Thread: Question about else statement

  1. #1
    Member
    Join Date
    Aug 2012
    Posts
    67
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Question about else statement

    I've got this piece of code that says that a certain method works when the width is larger than the height:

    for (int i=0; i<=(width); i++) 
    		{
    			int diagonalRow = height-1;
    			for (int col=(width-height+i); col<width; col++) 
    			{
    				int pixelColor= leftImage.getRGB(col,diagonalRow);
    				img.setRGB(col, diagonalRow, pixelColor);
    				diagonalRow--;
    			}
    			repaint();
    			try { Thread.sleep(10); } catch (InterruptedException e) { };
    		}
    	}
    	else 
    	{
    		//Add code to consider image with larger height than width
     
    	}

    How do I make it to work the same way if the height is larger than the width using the else statement?


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 262 Times in 231 Posts

    Default Re: Question about else statement

    I would write down on paper what ever "make it to work the same way" is, and get a good understanding of what has to be done. Then I would decide how to go about doing that task, and write those plans down on paper.
    From there I would start working on the code.
    Code was provided to give you hints. If yours is to "work the same way" then the given code is probably pretty close to what you need to be writing, right?

Similar Threads

  1. if....else statement
    By Appu14 in forum What's Wrong With My Code?
    Replies: 9
    Last Post: September 2nd, 2012, 06:35 AM
  2. not a statement?
    By frozen java in forum What's Wrong With My Code?
    Replies: 4
    Last Post: October 23rd, 2011, 08:57 PM
  3. If Statement
    By Shyamz1 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 26th, 2010, 12:57 PM
  4. If statement
    By Dave in forum Loops & Control Statements
    Replies: 2
    Last Post: August 27th, 2009, 10:11 AM
  5. [SOLVED] Switch statement question
    By shikh_albelad in forum Loops & Control Statements
    Replies: 5
    Last Post: May 31st, 2009, 05:13 AM