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.


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

Results 1 to 2 of 2

Thread: Help with beginners code?

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Thanked 0 Times in 0 Posts

    Default Help with beginners code?

    I'm taking an Intro to Java course. Just so happens that both my class and lab are totally online, and I've never done any programming before in my life. I have to write a program that will prompt the user for random characters, and then output that string in a few different ways. The place I'm stuck right now is how to assign some sort of designation to said characters. I know for numbers, to use something like:

    double number = input.nextInt();

    How would I do that for a string of random letters, numbers, and symbols, to have just one name for all of them?

    Also, for one of the outputs, not only do I need to have them in reverse (using stringBuilder.reverse), but only a selected number of characters, with the number being defined by the user (as shown in the example above). Where would I insert the variable "number" into stringBuilder.reverse to make it do that properly?

  2. #2
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    My Mood
    Thanked 93 Times in 86 Posts

    Default Re: Help with beginners code?

    Input String:
    String astring = input.nextLine();
    You cannot specify a number of chars for String builder. Have a look at String.substring(.....)

Similar Threads

  1. Beginners needing help
    By Govna242 in forum Object Oriented Programming
    Replies: 8
    Last Post: February 28th, 2013, 06:26 PM
  2. Could use some beginners tip here..
    By obie in forum What's Wrong With My Code?
    Replies: 9
    Last Post: December 16th, 2012, 03:55 PM
  3. Beginners Java Help !
    By Cluelius in forum Loops & Control Statements
    Replies: 4
    Last Post: October 22nd, 2012, 01:24 PM
    By javabeginners in forum Java Theory & Questions
    Replies: 13
    Last Post: November 15th, 2011, 12:50 PM
    By Olenger in forum Java Theory & Questions
    Replies: 1
    Last Post: October 18th, 2011, 07:06 PM