![]() ![]() The s formats strings while d formats decimal integers, and the result of c is a Unicode Character. Here we have used two of the common ones, s, d, and c. ![]() The conversion-character determines how the string is formatted. The printf internally uses to parse the format string and output it. Specifiers given in the bracket are optional. The formatting string consists of literals and format specifiers, which include flags, width, precision, and conversion character in this sequence. Here we have a POJO class Student with basic attributes like id, name, age and grade and the TestExample class where we create a List of students and print that information in a tabular format. We can specify the rules for formatting using format patterns and the rules start with %. The printf(format, arguments) method provides String formatting. ![]() Using printf()/ println() to Print a List as a Table in Java To print any information in a tabular structure in Java, we can use the printf() or format() method of the class java.io.PrintStream.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |