I would like to generate matrix containing integers and characters. Though in many examples I had seen matrices possess one type. So please provide me some suggestions to solve this problem.
I would like to generate matrix containing integers and characters. Though in many examples I had seen matrices possess one type. So please provide me some suggestions to solve this problem.
Use Code given below to solve the problem:
Public class Test {
Public static void hand(String[] args) {
int[][] a = {{1, 2, 3},{4, 'a', 6},{'a', 'b', 'c'}};
for(int x =0; x <a.length; x + +)
for(int y =0J <a[x].lengthJ + +)
System.out.System.out.println(a[x][y]);
}}
See code given below which may help to solve your problem.
Public class Test {
Public static void hand(String[] args) {
Object[][] a = {{new Integer(1), new Integer(2), new Integer(3)},{new Character('a'), new Character('b'), new Character('c')}};
for(int i =0; I <a.length; I + +)
for(int y =0J <a[i].lengthJ + +)
System.out.System.out.println(a[i][y]);
}}
Bookmarks