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 7 of 7

Thread: jump use

  1. #1
    Junior Member
    Join Date
    Apr 2010
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default jump use

    Hi all,
    I am collecting some input for keyboard.
    I am doing some operation on the acquired data.
    Things are fine till this but problem is that I wish to reuse the code I put for data collection when some condition go wrong.
    I have not much frequent user of jump, so I am unable to do the same can any one help me for this

    Regards,
    Tarun


  2. #2
    Junior Member
    Join Date
    Nov 2009
    Posts
    5
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: jump use

    Hey You can use label by using Continue

  3. #3
    Junior Member
    Join Date
    Apr 2010
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: jump use

    Thanx murli for reply but jump with continue is an control loop statement I tried but I am not clear how to use continue and label in a loop statement.
    And whether it is possible to do in without looping

    regards
    Tarun

  4. #4
    Junior Member
    Join Date
    Nov 2009
    Posts
    5
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: jump use

    Please post your complete Problem description..

  5. #5
    Junior Member
    Join Date
    Apr 2010
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: jump use

    I am trying to get selection from user from keyboard…….
    For some arithmetic operation as selected by the user……..
    After doing some operation
    I wish to ask again the user for new selection.
    As I have already put the code for user input and arithmetic operations I wish I could go back for user to input again or to quit…….

    Say I ask…..
    “Please input x for multiply z to divide or e to exit.”
    If user give input x
    I do multiply operation on the data I collected before
    Display the output and ask again
    “Do you wish some other operation y to continue or n to exit”
    If user input is y I go back to the line
    “Please input x for multiply z to divide or e to exit.” Again

    regards
    Tarun

  6. #6
    Junior Member
    Join Date
    Nov 2009
    Posts
    5
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: jump use

    Your Problem statement is not clear for me but I will try to suggest you as per my understanding of your problem.

    For above mention case no need to use labels you can mange simply by writing the while and dowhile loops
    efficiently.

    For reference consider below template of code

    char ch;
    Scanner sc=new Scanner(System.in);
    do
    {
    /********************
    *********************
    Add your input statements
    Here read data using scanner object
    for int using sc.nextInt()
    for string using sc.next();
    for double usinf sc.nextDouble();
    and perform operations
    ********************
    ********************
    *********************
    *********************/

    System.out.println("Press Y to Continue or N to Quit");
    ch=sc.next();
    }while(ch.compareToIgnoreCase(yes)==0)

    I hope above block will helpful for you.

  7. The Following User Says Thank You to murali1253 For This Useful Post:

    JavaPF (April 30th, 2010)

  8. #7
    Junior Member
    Join Date
    Apr 2010
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: jump use

    thanx for reply again...
    Hope it will do.....

Similar Threads

  1. How To Make The Program Jump To The Next Function..
    By Kumarrrr in forum What's Wrong With My Code?
    Replies: 7
    Last Post: March 3rd, 2010, 12:33 AM

Tags for this Thread