You can use this new feature to quickly format strings into table :
public class Table{
public static void main(String args[]){
String format = "|%1$-10s|%2$-10s|%3$-20s|\n";
System.out.format(format, "FirstName", "Init.", "LastName");
System.out.format(format, "Ajay", "", "Kumar");
System.out.format(format, "Sunil", "Dr", "Bainsla");
System.out.format(String.format(format, (Object[])ex));
}
}
Output:
|FirstName |Init. |LastName |
|Ajay | |Kumar |
|Sunil |Dr |Bainsla |
No comments:
Post a Comment