Computing.Net > Forums > Programming > java for loops

java for loops

Reply to Message Icon

Original Message
Name: gimmpy225
Date: June 13, 2005 at 21:23:52 Pacific
Subject: java for loops
OS: Windows XP pro
CPU/Ram: Athlon 64 3000+ / 1 gig
Comment:

K, im currently learning java and I wanted to make a program that is short and prints all the unicode symbols out in the cmd prompt (preferably on the same line).

One way I was attempting to acheive this was with 2 for loops working together, 1 to iterate through an array of 9999 strings and 1 to put each unicode number in each of the cells of the array.

I just cant figure out how to do this..... would i really need 2 for loops?


Im writing this in Java.

not sure if I provided you with enough info on what im attempting to do so ill try to sum it up, Any way to print every unicode symbol to the screen.

GIMPS


Report Offensive Message For Removal


Response Number 1
Name: Guy
Date: June 15, 2005 at 20:03:20 Pacific
Reply: (edit)

Well, if I understand what you want, I think you should be able to do this with one for loop.

I'll leave you to figure that out.

Have you looked at all the infomation at:

http://www.unicode.org


?????

There is some Java specific stuff there.

Hope this gives you some ideas .......

Guy


Report Offensive Follow Up For Removal

Response Number 2
Name: gimmpy225
Date: June 16, 2005 at 00:00:32 Pacific
Reply: (edit)

well i thought 1 would work, but i cant figure out how to get it to iterate from 0001 to 9999

i mean how do i make it go from 0001 to 0009 then 0010 to 0099 then 0999 to 1000?

cause i can get 1000-9999 no problem, its those first ones i have no idea how to get, I guess if i used 4 for loops?

but even then I dont think java let me do

for(i=1;i<=9;i++)
{
a[--i]="\u000"i;
}

without having a fit about it lol.

ofcourse erlier in the code there was String[] a = new String[9998]
GIMPS


Report Offensive Follow Up For Removal

Response Number 3
Name: Guy
Date: June 16, 2005 at 11:28:39 Pacific
Reply: (edit)

Well, my first cut would be:

char[] uc = new char[1000];
for (int i = 0;i < 1000;i++)
{
uc[i] = (char)i;
}

You should also take a look at this sample code:

http://sunsite.tus.ac.jp/java/JDK1.1/docs/guide/awt/demos/symboltest/

Guy


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: java for loops

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 5 Days.
Discuss in The Lounge