Java Output Formatting

Sort by

recency

|

1456 Discussions

|

  • + 0 comments

    It really highlights how formatting can control the presentation of output—especially useful in console-based applications. 11xplay

  • + 0 comments

    lol guys this is what i did import java.util.Scanner;

    public class Solution { static void f1(String s){ // String s = "cpp 65"; String[] parts = s.split(" "); String str = parts[0]; String num = parts[1]; String fin = ""; if (num.length()==2){ fin = "0" + num; } else if (num.length()==1){ fin = "00" + num; } else { fin = num; } int space = 15-str.length(); String gap = ""; for(int i=0;i

  • + 0 comments

    Java is such a powerful and versatile programming language! Its platform independence and strong object-oriented features make it a go-to choice for building everything from desktop applications to enterprise systems and Android apps. 11xplay

  • + 0 comments

    As far as I know Java 7 does not receive free public updates anymore. That means the version's relevance is minimal, if not null. Hackerrank should definitely check on this.

  • + 0 comments

    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();
    
    
                        //this line is the key
            System.out.printf("%-15s%03d\n", s1, x);
    
        }
        System.out.println("================================");
    }
    

    }