Hi Sonam,
You trying to create receive a string 'name', display it in JOptionPane
AND store it in array of strings in one step.
To fix your problem:
1. To receive andf display a string 'name' in JOptionPane
// TODO code application logic here
String name ="";
name=JOptionPane.showInputDialog("Enter your full name");
2. To add a sting to the array of string such as
String people[] = new String[3];
I hope it helps,
Moria.
________________________________
From: [email protected]
[mailto:[email protected]] On Behalf Of sonam
dalal
Sent: Tuesday, September 08, 2009 11:49 AM
To: [email protected]
Subject: [java programming] Javaintro-Java Array Homework
Hey all!
i'm having a little bit of a problem with the java array homework
First i tried to just start off by take string input with JOptionPane,
but it is showing error while printing the input
my program is as follows:
import javax.swing.JOptionPane;
/**
*
* @author SONAM DALAL
*/
public class JavaArray {
public JavaArray(){
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
String name[]=new String[30];
name[30]=JOptionPane.showInputDialog("Enter your full name");
String msg="Hello "+name+"!!!" ;
JOptionPane.showMessageDialog(null,msg);
}
}
Also how do you you use the split concept to print first name
separately?
This homework is kinda confusing!!
Thanks a lot!
________________________________
Match 'n' Make new friends with the cool match-meter. Join the Planet
with you Hotmail ID. Drag n' drop <http://www.WindowsLivePlanet.com>
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---