ComputerForum.com ComputerForum.com  
TigerDirect
 
Go Back   Computer Forum > General Chat > General Computer Chat

Reply
 
LinkBack Thread Tools Display Modes
Old 05-10-2008, 07:43 AM   #1 (permalink)
Silver Member
 
Yoonsi's Avatar
 
Join Date: Aug 2006
Location: New Zealand
Posts: 231
Default Anyone here proficient in Java?

I'm taking a 101 course in Java, and i'm making a particular program... but I'm stuck at a certain point.

If the user input something like: 3 3 4 + -

with spaces between the values.
What I need to do is be able to separate the values into individual strings.
So I'd have one string with "3", one with "3", one with "4", one with "+" and one with "-"

It has me stumped...
Any ideas?

Thanks
Yoonsi
__________________
Black computer case filled with Jam.
Yoonsi is offline   Reply With Quote


Old 05-10-2008, 08:08 AM   #2 (permalink)
Gold Member
 
Join Date: Jan 2008
Location: NC (Home of the HEELS!!)
Age: 25
Posts: 299
Default

I studied some Java a little back, got any snippet of the code you are using right now?
__________________
System:
Asus P5VD2-VM SE mATX Board
2 GB of Crucial DDR2-PC5300 Ram
Intel Pentium D 3.2Ghz w/Thermaltake Fan/heatsink
Nvidia GeForce 8600GT 512MB Video card
Hitachi 500 GB SATA 2 Drive
Power Up Black ATX Mid-Tower Case
550 W/ Power supply
DVD Burner
Windows XP Home SP2
jbrdbr111x is offline   Reply With Quote
Old 05-10-2008, 08:18 AM   #3 (permalink)
Silver Member
 
Yoonsi's Avatar
 
Join Date: Aug 2006
Location: New Zealand
Posts: 231
Default

Thanks for the reply! Funnily enough, I think I have something that might work! If it doesn't though Ill post what I have.
__________________
Black computer case filled with Jam.
Yoonsi is offline   Reply With Quote
Old 05-10-2008, 08:22 AM   #4 (permalink)
Gold Member
 
Join Date: Jan 2008
Location: NC (Home of the HEELS!!)
Age: 25
Posts: 299
Default

Good luck!! = )
__________________
System:
Asus P5VD2-VM SE mATX Board
2 GB of Crucial DDR2-PC5300 Ram
Intel Pentium D 3.2Ghz w/Thermaltake Fan/heatsink
Nvidia GeForce 8600GT 512MB Video card
Hitachi 500 GB SATA 2 Drive
Power Up Black ATX Mid-Tower Case
550 W/ Power supply
DVD Burner
Windows XP Home SP2
jbrdbr111x is offline   Reply With Quote
Old 05-10-2008, 09:26 AM   #5 (permalink)
Silver Member
 
Yoonsi's Avatar
 
Join Date: Aug 2006
Location: New Zealand
Posts: 231
Default

Ugh....I've got nothing!
__________________
Black computer case filled with Jam.
Yoonsi is offline   Reply With Quote


Old 05-10-2008, 10:07 AM   #6 (permalink)
Silver Member
 
Yoonsi's Avatar
 
Join Date: Aug 2006
Location: New Zealand
Posts: 231
Default

Why wont this work...
It compliles fine, but when I run the program, I get an error StringIndexOutOfBoundsException: String index out of range exception -1

Code:
private int getMaxNumberOfTokens(String input) {
		String [] expressionArray;
		int numberOfTokens = 0;
		expressionArray = new String [input.length()];
		String expression = input;
		int i = 1;
		while ( i >= 1) {
			if (expression.length() > 1){
				expressionArray[i] = getToken(expression);
				numberOfTokens++;
				expression = removeBottomToken(expression);
				i++;
			} else {
				expressionArray[i] = getToken(expression);
				numberOfTokens++;
				i = 0;
			}

		}

		return numberOfTokens;
	}
__________________
Black computer case filled with Jam.
Yoonsi is offline   Reply With Quote
Old 05-10-2008, 04:23 PM   #7 (permalink)
Diamond Member
 
Emperor_nero's Avatar
 
Join Date: Sep 2006
Location: 127.0.0.1
Posts: 2,301
Default

I'm somewhat proficient.

What line are you getting the error on? I'm not quite sure I follow what your doing there.

Could you post your getToken() and removeBottomToken() code please?
__________________
I play Rugby, and no its not like it's sissy cousin with the pads.


Last edited by Emperor_nero; 05-10-2008 at 04:36 PM.
Emperor_nero is offline   Reply With Quote
Old 05-10-2008, 07:44 PM   #8 (permalink)
Gold Member
 
Join Date: Jan 2008
Location: NC (Home of the HEELS!!)
Age: 25
Posts: 299
Default

So, you want the program to add up, or what?
__________________
System:
Asus P5VD2-VM SE mATX Board
2 GB of Crucial DDR2-PC5300 Ram
Intel Pentium D 3.2Ghz w/Thermaltake Fan/heatsink
Nvidia GeForce 8600GT 512MB Video card
Hitachi 500 GB SATA 2 Drive
Power Up Black ATX Mid-Tower Case
550 W/ Power supply
DVD Burner
Windows XP Home SP2
jbrdbr111x is offline   Reply With Quote
Old 05-11-2008, 05:16 AM   #9 (permalink)
Silver Member
 
Yoonsi's Avatar
 
Join Date: Aug 2006
Location: New Zealand
Posts: 231
Default

Ah, so sorry everyone! I was so vague in what I asked....
well last night I was fully stressed, and was a bit tired...
Lesson learned: Don't program at 2am!! Anyway, I managed to get it all right this morning. Guess a good sleep just cleared up things in my mind...
Thanks everyone for your interest and I really appreciate it! If you want to see what I ended up with anyway, just let me know ^^

Yoonsi
__________________
Black computer case filled with Jam.
Yoonsi is offline   Reply With Quote
Old 05-11-2008, 05:36 AM   #10 (permalink)
Diamond Member
 
Emperor_nero's Avatar
 
Join Date: Sep 2006
Location: 127.0.0.1
Posts: 2,301
Default

Quote:
Originally Posted by Yoonsi View Post
Ah, so sorry everyone! I was so vague in what I asked....
well last night I was fully stressed, and was a bit tired...
Lesson learned: Don't program at 2am!! Anyway, I managed to get it all right this morning. Guess a good sleep just cleared up things in my mind...
Thanks everyone for your interest and I really appreciate it! If you want to see what I ended up with anyway, just let me know ^^

Yoonsi
Haha, wow that sounds so familiar, I've found that at about 12am my programming brain shuts and I can't do anymore.

Yeah it sounds interesting, I'd like to see it.
__________________
I play Rugby, and no its not like it's sissy cousin with the pads.

Emperor_nero is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java Programming - Need URGENT help with CITY JUMPER - Java Programming shariq Computer Games and Consoles 0 01-19-2007 08:04 AM
What does basic Java Programming language actually look like? leeroyMarv General Software 3 06-09-2006 03:48 AM
Java problem.. Hobo_man Operating Systems 2 03-03-2006 09:19 PM
Java Problems Hobo_man Operating Systems 1 03-03-2006 07:46 PM
Java Runtime error box on XP? leo Operating Systems 7 06-18-2005 12:31 AM


All times are GMT +1. The time now is 09:35 PM.


Powered by: vBulletin Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Copyright © 2002-2007 Computer Forum and Web Design Forum