Albdestroyer
Posts:
5,165
Registered:
Sep 24, '06
Extended Info (if available)
Real Post Cnt: 5,165
User ID: 1,173,396
|
Subject:
Java programming help.
|
Very new to java, and I'm using jOptionPane right now. I'm supposed to prompt for the users first and last name, and output just the first name. No f***ing clue how to do that. I know how to get it to output both in a dialog box. Any help will be appreciated. that's me code so far. public class Program313 { public static void main( String [ ] args ) { String name = JOptionPane.showInputDialog( null, "Please enter your first and last names"); JOptionPane.showMessageDialog( null, "Hello, " + name); } }
-----signature-----
(none)
|
Link to this post
|
Immortal_Haze
Posts:
16,105
Registered:
Jan 31, '02
Extended Info (if available)
Real Post Cnt: 15,927
User ID: 639,213
|
Subject:
Java programming help.
|
link The brute force, easy way.
-----signature-----
"Those who have long enjoyed such privileges as we enjoy forget in time that men have died to win them." FDR
|
Link to this post
|
Poit-Narf
Title: Cleric of Juan
Posts:
47,276
Registered:
Jul 11, '04
Extended Info (if available)
Real Post Cnt: 46,296
User ID: 943,679
|
Subject:
Java programming help.
|
Read this.
-----signature-----
"I think so, Brain, but there's still a bug stuck in here from last time." Rift: Deepstrike/Guardian Poit (Mage), Point (Rogue), Popit (Cleric), Poiyt (Warrior) http://immortal-guild.com/ "You're so heterophobic" -Lyli
|
Link to this post
|
Albdestroyer
Posts:
5,165
Registered:
Sep 24, '06
Extended Info (if available)
Real Post Cnt: 5,165
User ID: 1,173,396
|
Subject:
Java programming help.
|
I feel like those two things are a bit more advanced than where I am. these are the directions. Write a program that reads a full name from a dialogbox; you should expect the first and last name to be separated by a space. Retrieve the first name and output it.
-----signature-----
(none)
|
Link to this post
|
gatzby
Title: Insanity Personified
Posts:
5,770
Registered:
Jul 26, '01
Extended Info (if available)
Real Post Cnt: 4,742
User ID: 281,513
|
Subject:
Java programming help.
|
http://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html#input
-----signature-----
Radio Shack TRS 80 | 640k | 5.25 Drive INTEGRATED! A stretched thread = A useless thread
|
Link to this post
|
Immortal_Haze
Posts:
16,105
Registered:
Jan 31, '02
Extended Info (if available)
Real Post Cnt: 15,927
User ID: 639,213
|
Subject:
Java programming help.
|
gatzby posted: http://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html#input
He's already done that, he's asking how to parse a string using a space as a delimiter. Alb, here's a code example of what Poit referenced using split: link
-----signature-----
"Those who have long enjoyed such privileges as we enjoy forget in time that men have died to win them." FDR
|
Link to this post
|
Albdestroyer
Posts:
5,165
Registered:
Sep 24, '06
Extended Info (if available)
Real Post Cnt: 5,165
User ID: 1,173,396
|
Subject:
Java programming help.
|
Immortal_Haze posted:
gatzby posted: http://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html#input
He's already done that, he's asking how to parse a string using a space as a delimiter. Alb, here's a code example of what Poit referenced using split: link
That helps me, thanks. I guess I needed to see it laid out in a code example, heh.
-----signature-----
(none)
|
Link to this post
|
gatzby
Title: Insanity Personified
Posts:
5,770
Registered:
Jul 26, '01
Extended Info (if available)
Real Post Cnt: 4,742
User ID: 281,513
|
Subject:
Java programming help.
|
Teaches me to post while not paying attention, lol.
-----signature-----
Radio Shack TRS 80 | 640k | 5.25 Drive INTEGRATED! A stretched thread = A useless thread
|
Link to this post
|
Immortal_Haze
Posts:
16,105
Registered:
Jan 31, '02
Extended Info (if available)
Real Post Cnt: 15,927
User ID: 639,213
|
Subject:
Java programming help.
|
Albdestroyer posted: That helps me, thanks. I guess I needed to see it laid out in a code example, heh.
Don't sweat it, you'll find that a lot as you get used to syntax and whatnot. The Java documentation is a fantastic resource and very well done, but often you don't quite know the right question to ask when you're starting out.
-----signature-----
"Those who have long enjoyed such privileges as we enjoy forget in time that men have died to win them." FDR
|
Link to this post
|