Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By fatabass

Thread: Assigning text to something

  1. #1
    phantomcraft is offline Member
    Join Date
    Feb 2013
    Location
    The Netherlands
    Posts
    17
    Rep Power
    0

    Default Assigning text to something

    Hey i want something like System.out.println ("Hello "name" how are you?"); but i don't really know how this works, how can I assign a name to "name"? Sorry if i'm confusing

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Assigning text to something

    Quote Originally Posted by phantomcraft View Post
    Hey i want something like System.out.println ("Hello "name" how are you?"); but i don't really know how this works, how can I assign a name to "name"? Sorry if i'm confusing
    Please clarify your problem.

  3. #3
    fatabass is offline Senior Member
    Join Date
    Nov 2011
    Location
    Turkey
    Posts
    380
    Blog Entries
    24
    Rep Power
    3

    Default Re: Assigning text to something

    Try:

    System.out.println("Hello " + variableName + ". How are you?");

    I am sure there are better ways as well, look at: printf() method.
    Fubarable likes this.

  4. #4
    Ronin is offline Senior Member
    Join Date
    Oct 2010
    Posts
    317
    Rep Power
    4

    Default Re: Assigning text to something

    Just to add to fatabass' post, you would preceed their code with something like the following.
    Java Code:
    String variableName = "phantomcraft";
    This will hard code the value of the variable 'variableName' into your program. The next step could be to accept names from user input, in which case you will need to make use of the Scanner class. This will let you read input from the keyboard.

    Regards.
    Last edited by Ronin; 02-27-2013 at 01:36 PM. Reason: typo

Similar Threads

  1. Assigning int value to a string input
    By Liam2013 in forum New To Java
    Replies: 11
    Last Post: 11-02-2012, 10:07 AM
  2. Assigning text in JTable by clicking a button
    By Aiquoc in forum New To Java
    Replies: 3
    Last Post: 06-01-2011, 03:29 PM
  3. Coin assigning program
    By Jamesing in forum New To Java
    Replies: 10
    Last Post: 03-11-2011, 05:57 AM
  4. Need some help with assigning & Exceptions
    By Jubic in forum New To Java
    Replies: 7
    Last Post: 06-07-2010, 05:53 AM
  5. Assigning Words to an Array
    By ScaryJello in forum New To Java
    Replies: 10
    Last Post: 02-17-2009, 04:40 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •