Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 10 of 10

Thread: Java joption

  1. #1
    Member
    Join Date
    Oct 2012
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java joption

    use joption only
    enter 5 integers


    enter a number: 5
    Output: 5
    Enter a number: 6
    Output: 5 6
    Enter A Number: 5
    Output: Please Do not Input same Number
    Enter a Number: 7
    Output: 5 6 7
    and so on till 5 numbers are being inputted
    here is my current Code

    import javax.swing.*;
    public class unique {
    int number[] = new int[5];
    public unique()
    {
     
    }
    public void Uniquetest(){
    for(int i=0;i<5;i++){
    number[i]=Integer.parseInt(JOptionPane.showInputDialog("Ent er a Number: "));
    }
    }
    }


  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: Java joption

    Quote Originally Posted by darking123 View Post
    ...
    here is my current Code
    ...
    That's nice.

    Do you have an answerable question? Please feel free to ask one at any time.

  3. #3
    Member
    Join Date
    Oct 2012
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java joption

    my question/problem is how will i code inside my method to do the example i provided

  4. #4
    Junior Member Motion's Avatar
    Join Date
    Jul 2012
    Posts
    21
    My Mood
    Happy
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java joption

    Pls your question is not clear...and the code you posted above is something else.
    elaborate your question if you wanna get help

  5. #5
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: Java joption

    Quote Originally Posted by darking123 View Post
    my question/problem is how will i code inside my method to do the example i provided
    We shouldn't do this for you, but rather you really should try to do this on your own first, else you're just cheating yourself out of good experience. Please do so, and if your attempt doesn't work, come on back, show your attempt and ask any specific questions you may have over your code.

  6. #6
    Member
    Join Date
    Oct 2012
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java joption

    my problem is how can i compare the inputs from each other?

  7. #7
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    20,969
    Thanks
    51
    Thanked 2,268 Times in 2,240 Posts

    Default Re: Java joption

    how can i compare the inputs from each other
    There are several operators that can be used to compare the contents of int variables.
    See: Equality, Relational, and Conditional Operators (The Java™ Tutorials > Learning the Java Language > Language Basics)
    If you don't understand my answer, don't ignore it, ask a question.

  8. #8
    Member
    Join Date
    Oct 2012
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java joption

    what if i want to compare the values stored in my string array to the value stored in my int array

  9. #9
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    20,969
    Thanks
    51
    Thanked 2,268 Times in 2,240 Posts

    Default Re: Java joption

    The elements of one array will have to be converted so that they are the same type as are in the other array.
    If you don't understand my answer, don't ignore it, ask a question.

  10. #10
    Junior Member Motion's Avatar
    Join Date
    Jul 2012
    Posts
    21
    My Mood
    Happy
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java joption

    convert the string to int, then your comparison will work

Similar Threads

  1. Help incorporating a Joption Pane
    By Dysun in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 15th, 2012, 05:25 PM
  2. JOption Output Message
    By richW in forum What's Wrong With My Code?
    Replies: 4
    Last Post: February 15th, 2012, 10:17 PM
  3. JOption to JFrame HELP...messed my program up
    By scottgilliland2003 in forum What's Wrong With My Code?
    Replies: 9
    Last Post: December 20th, 2011, 07:18 PM
  4. [SOLVED] I have a problem with this Joption programme.
    By Leprechaun_hunter in forum What's Wrong With My Code?
    Replies: 7
    Last Post: April 12th, 2011, 03:31 AM
  5. JOption Pane help
    By dallas1125 in forum AWT / Java Swing
    Replies: 5
    Last Post: November 18th, 2009, 04:08 PM