Say I have 2 columns of data. I want to display headers like "hour(24 hour)" and "Power(KW)" and then followed by a number of rows with 2 columns(hour and power). The hour should be under "hour" header and properly aligned and similarly for power. I want that all the data in the same column are aligned and doesn't go into the other column. I just want as simple method as possible. No fancy. Like in C, as simple as printf("%5d%10d") would work. I tried to do that using System.out.println(hour+"\t"+power); but the data were not aligned with column header. Any idea? Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.