View Full Version : Two Dimensional Array

10-12-2008, 01:44 AM
I'm having trouble adjusting the output.. here's the code

class TwoDimensionalRequirement
public static void main(String[] args)
String[][] truthTable = new String [4][4];
String [] header= {"ConditionA", "ConditionB", "And", "Or"};

truthTable[0][0] = "False";
truthTable[0][1] = "False";
truthTable[0][2] = "False";
truthTable[0][3] = "False";
truthTable[1][0] = "False";
truthTable[1][1] = "True";
truthTable[1][2] = "False";
truthTable[1][3] = "True";
truthTable[2][0] = "True";
truthTable[2][1] = "False";
truthTable[2][2] = "False";
truthTable[2][3] = "True";
truthTable[3][0] = "True";
truthTable[3][1] = "True";
truthTable[3][2] = "True";
truthTable[3][3] = "True";


for (int row=0; row<truthTable.length; row++)
for (int column=0; column<truthTable[row].length; column++)






how do you make it:


there's an excess 5th column.. i want it be limited to 4 columns only..

10-12-2008, 03:20 AM
Can you explain the problem again? I don't quite understand what you're asking here.

01-28-2009, 09:35 PM
As your code is now. You're having the nested for loops print out each condition followed by two tab characters. What it looks like you want is for it to print out the values of each row on a seperate line.

HINT: Are you familiar with the println() method? You should be! The code you need is:


It does not need to replace anything. And it goes in a specific place. You should be able to figure it out. If not...:eek: