KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I've to write code for: I'd written the code: public class tables { public static void main(String[] args) { //int[][] table = new int[12][12]; String table=""; for(int i=1; i<13; i++){ for(int j=1; j<13; j++){ //table[i-1][j-1] = i*j; table+=(i*j)+" "; } System.out.println(table.trim()); table=""; } } } But the problem is with the output format. I need the output in a matrix like fashion, each number formatted to a width of 4 (the numbers are right-aligned and strip out leading/trailing spaces on each line). I'd tried google but not find any good solution to my problem. Can anybody help me out?
Tags (comma-separated)
Save Edits
Cancel