-
Greetings stack overflow today i have a question about programming and I was making this program but what printed out it didn't what I have expected I was testing this program for a while and coding it but I just can't come up with something to make the right shape please help... This is the cod that I have been working on I want to make it with for loops and 2D arrays like a matrix with Strings but it just not working for me... I been trying to print out the first word
HELLO
but nothing it just printedHELLO E L L E L HELLO
in a single line of code Need to print out is:HELLO E L L E L HELLO
public class fancy_word { public static void main (String [] args) { //first a String 2d array using method 3 String PO[][] = { {"HELLO"}, {"E L"}, {"L"}, {"E L"}, {"HELLO"} }; /*String VIP [][] = { {"CAT","A","CAT"} }; String COD[][] = { {"A"} }; String U_45 [][] = { {"DOGHOUSE","O S","G U","HO","HO","G U","O S","DOGHOUSE"} }; String UI_98 [][] = { {"ONE","N","ONE"} }; String HKL_001 [][] = { {"IT","IT"} }; */ //Nested loop within math and if statements declaring for(int i = 0;i<PO.length;i++) { for(int LED = 0;LED<PO[i].length;LED++) { System.out.print(PO[i][LED]+" "); } } System.out.println(); }
}
vendredi 24 novembre 2017
How to make String pattern using 2D arrays?
Inscription à :
Publier les commentaires (Atom)
Aucun commentaire:
Enregistrer un commentaire