Results 1 to 5 of 5
- 11-27-2011, 09:09 PM #1
Member
- Join Date
- Nov 2011
- Posts
- 3
- Rep Power
- 0
Problem with Array and Joptionpane
Hi all. I am new to Java and I have this problem. I need to create an array with 100 numbers in it. After that a pop up window will prompt the user to import a number from 1 to 100.
Then another window will inform him that his number is in the X index of the array. So far I have written this:
Any sugestion pls?Java Code:package elearning; import javax.swing.JOptionPane; public class BigArray { /** * @param args */ public static void main(String[] args) { String entervalue; int[] array = new int[100]; // create my array for (int i = 0; i < array.length; i++){ array[i]= i+1; for (int element : array){ entervalue = JOptionPane.showInputDialog (null, "give a number from" + array[0] + "to" + array.length); array[i] = Integer.parseInt( entervalue ); if (array[i] == element) break; } JOptionPane.showMessageDialog(null, "The number " + array[i] + " is in" +array + " τof array", "Message", JOptionPane.INFORMATION_MESSAGE ); System.exit (0); } } }Last edited by Norm; 11-27-2011 at 10:57 PM. Reason: added code tags
- 11-27-2011, 10:58 PM #2
Re: Problem with Array and Joptionpane
Do you have any specific questions or problems with your code?
- 11-28-2011, 12:23 AM #3
Member
- Join Date
- Nov 2011
- Posts
- 3
- Rep Power
- 0
Re: Problem with Array and Joptionpane
my code apparently is wrong and I can't find the reason
- 11-28-2011, 12:25 AM #4
Re: Problem with Array and Joptionpane
Thanks for letting us know. Do you have a question?
- 11-28-2011, 12:33 AM #5
Similar Threads
-
Problem with Array and Joptionpane
By tkas in forum New To JavaReplies: 3Last Post: 11-28-2011, 01:12 AM -
How to display array integer in JOptionPane message dialog ?
By Reero8532 in forum New To JavaReplies: 13Last Post: 03-20-2010, 01:03 AM -
using javax.swing.JOptionPane in array
By icedragon770 in forum AWT / SwingReplies: 12Last Post: 11-10-2008, 08:27 AM -
JOptionPane problem
By MomenT in forum New To JavaReplies: 22Last Post: 10-02-2008, 05:56 PM -
String array for Choice, JOptionPane doesn't show
By themburu in forum Java AppletsReplies: 5Last Post: 05-29-2008, 01:10 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks