String Formating

G

Guest

Hello everybody...

How can I string formating,
for example:
|1 |Michael |Brown
|2 |Cindy |Scott

I used sdk 1.5 and this format show error:(
System.out.format("|%1$-10s|%2$-10s|%3$-20s|\n", "L.", "Name", "Surname");


Thanks for your suggestion!
bay
 
R

Real Gagnon

I used sdk 1.5 and this format show error:(
System.out.format("|%1$-10s|%2$-10s|%3$-20s|\n", "L.", "Name",
"Surname");

Works fine here.

public class Divers {
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, "Real", "", "Gagnon");
System.out.format(format, "John", "D", "Doe");

String ex[] = { "John", "F.", "Kennedy" };

System.out.format(String.format(format, (Object[])ex));
}
}

bye.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top