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

Thread: How can I format my string output in Java?

  1. #1
    Junior Member
    Join Date
    Nov 2022
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How can I format my string output in Java?

    .
    Last edited by rosethecorgi; November 18th, 2022 at 08:54 PM.

  2. #2
    Member
    Join Date
    Jun 2022
    Posts
    41
    Thanks
    1
    Thanked 3 Times in 2 Posts

    Default Re: How can I format my string output in Java?

      int someInt = 3;
      float someFloat = 1.225;
     
      System.out.println(
        String.format("Integer value: %s, float value: %f", someInt, someFloat)
      );

    String formatting codes

Similar Threads

  1. NumberFormat to Java String Format
    By zng690 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: March 6th, 2014, 04:57 PM
  2. Replies: 6
    Last Post: June 3rd, 2013, 04:57 AM
  3. Having Java output in Tabular Format
    By jo15765 in forum Java Theory & Questions
    Replies: 17
    Last Post: May 3rd, 2012, 03:42 PM
  4. Issue with output format
    By mael331 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: September 25th, 2011, 02:12 PM
  5. Format Java output
    By wildman0501 in forum Java Theory & Questions
    Replies: 2
    Last Post: June 11th, 2011, 06:09 PM