i am new in java...so some one can plez help me..
Round Data
2 2 4
3 3 6 9
4 4 8 12 16
Nested loop *Help*
Started by nishanjo, Aug 02 2009 11:33 PM
7 replies to this topic
#1
Posted 02 August 2009 - 11:33 PM
|
|
|
#2
Posted 02 August 2009 - 11:38 PM
a little explanation please? What exactly must happen?
#3
Posted 02 August 2009 - 11:45 PM
i need output like this...
2 2 4
3 3 6 9
4 4 8 12 16
2 2 4
3 3 6 9
4 4 8 12 16
#4
Posted 02 August 2009 - 11:56 PM
public class Looping {
private String string="";
public Looping() {
for(int j=2 ; j<5 ; j++) {
string= ""+j+" ";
for(int i=1 ; i!=j+1 ; i++){
string+=""+ j*i +" ";
}
System.out.println(string);
}
}
}
Main if you need it:
public static void main(String[] args) {
Looping loop = new Looping();
}
#5
Posted 03 August 2009 - 02:47 AM
Oxano, we don't usually help people unless they show an effort.
If you are confused with nested loops you might want to look up a reference on how loops work. There is nothing special about a loop but a loop inside another loop.
There are some examples here: http://forum.codecal...p-examples.html
Nested for loops for C++
If you are confused with nested loops you might want to look up a reference on how loops work. There is nothing special about a loop but a loop inside another loop.
There are some examples here: http://forum.codecal...p-examples.html
Nested for loops for C++
#6
Posted 03 August 2009 - 04:26 AM
Sorry, being too friendly again ;)
#7
Posted 03 August 2009 - 04:31 AM
It's fine! :)
#8
Posted 03 August 2009 - 05:33 AM
i don't know java, but you would have something like this: in some kind of pseudo-code
for i = 2 to 4 do:
print i + " "
for j = 1 to 3 do:
print i*j + " "
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall
I study Information Systems at Karlstad University when I'm not on CodeCall


Sign In
Create Account

Back to top









