Answers for "printf java"

34

print in java

//print and create new line after
System.out.println("text");
System.out.println(String);
//You can use any variable type, not just strings, although
//they are the most common

//Print without creating a new line
System.out.print("text");
System.out.print(String);
Posted by: Guest on February-05-2020
2

printf java

//minus means left alingment, zero before 3 - left zero appending to the  integer
System.out.printf("%-14s %03d\n", s1, x);
Posted by: Guest on July-17-2021
1

java printf format string and int

import java.util.Scanner;

public class Solution {

    public static void main(String[] args) {
            Scanner sc=new Scanner(System.in);
            System.out.println("================================");
            for(int i=0;i<3;i++){
                String s1=sc.next();
                int x=sc.nextInt();
                //Complete this line                
                System.out.printf("%-15s%03d%n",s1,x);
            }
            System.out.println("================================");

    }
}
Posted by: Guest on August-23-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language