Nested For Loops with Constants

Printable View

• 01-27-2014, 06:05 PM
MrDan
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.

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();
}

}

• 01-27-2014, 06:08 PM
PhHein
Re: Nested For Loops with Constants
Post the code you're having problems with. Your question is too unspecific.
• 01-27-2014, 06:20 PM
MrDan
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.
• 01-28-2014, 08:23 AM
kjkrum
Re: Nested For Loops with Constants
What's wrong with it?
• 01-29-2014, 04:25 AM
AlexGraal
Re: Nested For Loops with Constants
Here is the output of your code (I ran it):
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":
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.