Results 1 to 3 of 3
  1. #1
    ST34LTH is offline Member
    Join Date
    Nov 2010
    Posts
    4
    Rep Power
    0

    Default General Java Help

    Hey Ive been learning to use Java through videos and thankfully its going pretty good, just some things I dont understand listed below:

    Java Code:
    	public String toString()
    	{
    		return String.format("%d:%02d:%02d %s", ((hour==0||hour==12)?12:hour%12), min, sec,(hour<12? "AM": "PM"));
    		
    	}
    In the above statement can someone tel me what "%" and "%s" does,


    Java Code:
    	public void saying()
    	{
    		System.out.printf("Your first GF was %s\n", getName());
    	}
    and this one can someone tell me what "%s\n" does,

    This has just been playing on my head abit, tried google but that didnt help.

    Thanks very much for your time and support

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,434
    Blog Entries
    7
    Rep Power
    20

    Default

    Read the API documentation for the Formatter class; that class formats Strings according to those % format specifiers and its used by other classes.

    kind regards,

    Jos

  3. #3
    ST34LTH is offline Member
    Join Date
    Nov 2010
    Posts
    4
    Rep Power
    0

Similar Threads

  1. general help.
    By socboy6579 in forum New To Java
    Replies: 1
    Last Post: 10-24-2010, 10:41 PM
  2. general help.
    By socboy6579 in forum New To Java
    Replies: 1
    Last Post: 10-24-2010, 09:20 PM
  3. General Question about Java
    By bayan in forum New To Java
    Replies: 6
    Last Post: 05-26-2010, 11:16 AM
  4. general advice needed
    By mac in forum New To Java
    Replies: 1
    Last Post: 03-18-2010, 03:25 PM
  5. general confused about java question (easy!)
    By sweetjava in forum New To Java
    Replies: 1
    Last Post: 08-09-2009, 02:03 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
  •