need help with the code

hi, i'm new to javaq and tryinh to get the output something like this

hello1 hello hello hello

hello hello2 hello hello

hello hello hello3 hello

but cant seem to achieve it. could some one help me? thank you

this is my code so far:

import java.io.*;

public class Testing

{

public static void main(String [] args)

{

//outer loop, loop through number of lines

for( int i=1; i<=3; i++)

{

for (int j=1; j<=4; j++)

{

System.out.print("Hello\t" );

if (i=j)

{

System.out.print("Hello" +i);

}

}

System.out.println();

}

System.out.println("End of Program!");

}

}

[727 byte] By [fireportala] at [2007-11-27 10:00:10]
# 1

1) What specific problem are you having?

2) Next time, use a meaningful subject line. Yours conveys no useful information.

3) When you post code, please use[code] and [/code] tags as described in http://forum.java.sun.com/help.jspa?sec=formatting(Formatting tips) on the message entry page. It makes it much easier to read.

jverda at 2007-7-13 0:31:21 > top of Java-index,Java Essentials,New To Java...
# 2

This code is wrong.

System.out.print("Hello\t" );

if (i=j)

{

System.out.print("Hello" +i);

}

You need an if/else statement there and only print Hello without the number if you are not printing Hello with the number

cotton.ma at 2007-7-13 0:31:21 > top of Java-index,Java Essentials,New To Java...
# 3
And this won't even compileif (i=j)
jverda at 2007-7-13 0:31:21 > top of Java-index,Java Essentials,New To Java...
# 4

change it:

System.out.print("Hello\t" );

if (i=j)

{

System.out.print("Hello" +i);

}

for:

if (i==j) {

System.out.print("Hello" +i);

} else {

System.out.print("Hello " );

}

pbulgarellia at 2007-7-13 0:31:21 > top of Java-index,Java Essentials,New To Java...
# 5
Wouldn't it have been better to guide the OP toward figuring it out himself, rather than handing him the answer? How do you expect him to learn if you don't let him do his own work?
jverda at 2007-7-13 0:31:21 > top of Java-index,Java Essentials,New To Java...
# 6

> Wouldn't it have been better to guide the OP toward

> figuring it out himself, rather than handing him the

> answer? How do you expect him to learn if you don't

> let him do his own work?

He did it for the DUKES!!!!! Don't you know?!?! Those precious, unobtainable, all-important, do-my-homework-for-me DUKES!! Without them, you are NO ONE!!! REAL coders have tons and tons of these arbitrarily awarded, valuless, mebningless, immaterial e-points called duke stars! (How else would one be able to judge a developers ability to write code? Gosh, Jeff ... what were you thinking?

Navy_Codera at 2007-7-13 0:31:21 > top of Java-index,Java Essentials,New To Java...
# 7
Does that make him a Dukes wh髍e?
petes1234a at 2007-7-13 0:31:21 > top of Java-index,Java Essentials,New To Java...
# 8
> Does that make him a Dukes wh髍e?... something like that. ;-)
Navy_Codera at 2007-7-13 0:31:21 > top of Java-index,Java Essentials,New To Java...
# 9
> need help with the codeReally? I thought you were having problems with your haemorrhoids!
floundera at 2007-7-13 0:31:21 > top of Java-index,Java Essentials,New To Java...
# 10

> He did it for the DUKES!!!!! Don't you know?!?!

> Those precious, unobtainable, all-important,

> do-my-homework-for-me DUKES!! Without them, you are

> NO ONE!!! REAL coders have

> tons and tons of these arbitrarily awarded,

> valuless, mebningless, immaterial e-points called

> duke stars! (How else would one be able to judge a

> developers ability to write code? Gosh, Jeff ...

> what were you thinking?

And gee surprise surprise he didn't even get the dukes. I think a semi truck must have run over the poor OP.

warnerjaa at 2007-7-13 0:31:21 > top of Java-index,Java Essentials,New To Java...
# 11

> And gee surprise surprise he didn't even get the

> dukes. I think a semi truck must have run over the

> poor OP.

Naah ... he's just like all the other shitpuff kids that run around here and get others to do their homework assignment for them. Won't show up until the night before his next homework assignment is due...

Navy_Codera at 2007-7-13 0:31:21 > top of Java-index,Java Essentials,New To Java...
# 12
because he is stupid anyway, what is the use of forum in the first place sharing of ideas ryt?
dreamzeroa at 2007-7-13 0:31:21 > top of Java-index,Java Essentials,New To Java...
# 13

public class Temp

{

static public void main(String[] args)

{

int i,j,k;

for(i =0; i < 3; i++)

{

for(j = 0; j <= i; j++)

{

System.out.print("Hello ");

}

System.out.print(i+1 + " ");

for(k = 3; k >= j; k--)

{

System.out.print("Hello ");

}

System.out.println();

}

}

}

This code gives the oputput exact that of you have mentioned.

Friend4evera at 2007-7-13 0:31:21 > top of Java-index,Java Essentials,New To Java...