Results 1 to 5 of 5
  1. #1
    MrDan is offline Member
    Join Date
    Oct 2013
    Posts
    4
    Rep Power
    0

    Default Nested For Loops with Constants

    I was hoping someone could explain the process how they are used. I'm failing to have a good understanding on how they work and coordinate with each other.

    PHP Code:
    public class tryit {
    	//constant value
    	public static final int BIG = 7;
    	//main
    	public static void main(String [] args){
    		
    		for(int i = 1; i <= BIG; i++){
    			//new for loop
    			for(int k = 1; k <= BIG ;k++){
    				System.out.print("*");
    		}
    			//for(int k = BIG; k <= ( BIG + 3 ); k++){
    				//System.out.print("&");
    				
    			//}
    			for(int k = 0; k <=  i; k++){
    				System.out.print("$");
    				
    			}
    			//for(int k = BIG; k >= i; k--){
    				//System.out.print("$");
    			//}
    			System.out.println();
    	}
    	
    }
    Last edited by MrDan; 01-27-2014 at 06:57 PM.

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    7

    Default Re: Nested For Loops with Constants

    Post the code you're having problems with. Your question is too unspecific.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    MrDan is offline Member
    Join Date
    Oct 2013
    Posts
    4
    Rep Power
    0

    Default Re: Nested For Loops with Constants

    I'm trying to understand how they can be manipulated and how to use them to directly impact the text, and make it look right.

  4. #4
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default Re: Nested For Loops with Constants

    What's wrong with it?
    Get in the habit of using standard Java naming conventions!

  5. #5
    AlexGraal is offline Señor Member
    Join Date
    Jan 2014
    Posts
    184
    Rep Power
    0

    Default Re: Nested For Loops with Constants

    Here is the output of your code (I ran it):
    XML Code:
    *******$$
    *******$$$
    *******$$$$
    *******$$$$$
    *******$$$$$$
    *******$$$$$$$
    *******$$$$$$$$
    Next time, you need to POST your output.


    I'm not even sure what your question is, but if you are asking about "BIG":
    Java Code:
    public static final int BIG = 7;
    It is a final variable - aka, it isn't editable. You can't change it. So you can't really manipulate it, if that is what you are asking about.

    I don't really understand what your program is supposed to do. Please clarify your question/desired output.

Similar Threads

  1. Nested Loops Help!
    By spendogw in forum New To Java
    Replies: 2
    Last Post: 03-16-2012, 05:20 AM
  2. Replies: 20
    Last Post: 03-22-2011, 05:02 AM
  3. Nested Loops
    By joemama in forum New To Java
    Replies: 1
    Last Post: 01-01-2011, 10:17 PM
  4. Nested Loops
    By candygirl198827 in forum New To Java
    Replies: 38
    Last Post: 12-01-2010, 07:03 AM
  5. Nested for loops
    By luke in forum New To Java
    Replies: 23
    Last Post: 10-21-2010, 03:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •