Tuesday 15 February 2011

How to Merge multiple arrays into a matrix in JAVA? -



How to Merge multiple arrays into a matrix in JAVA? -

is there easy way merge multiple, char arrays char matrix? have 8 arrays below 64 chars each , want merge matrix 8 rows , 64 cols.

package august26; import java.util.scanner; public class xbits { public static void main(string[] args) { scanner input = new scanner(system.in); long n1 = input.nextint(); long n2 = input.nextint(); long n3 = input.nextint(); long n4 = input.nextint(); long n5 = input.nextint(); long n6 = input.nextint(); long n7 = input.nextint(); long n8 = input.nextint(); string s1 = string.format("%64s", long.tobinarystring(n1)).replace(' ', '0'); string s2 = string.format("%64s", long.tobinarystring(n2)).replace(' ', '0'); string s3 = string.format("%64s", long.tobinarystring(n3)).replace(' ', '0'); string s4 = string.format("%64s", long.tobinarystring(n4)).replace(' ', '0'); string s5 = string.format("%64s", long.tobinarystring(n5)).replace(' ', '0'); string s6 = string.format("%64s", long.tobinarystring(n6)).replace(' ', '0'); string s7 = string.format("%64s", long.tobinarystring(n7)).replace(' ', '0'); string s8 = string.format("%64s", long.tobinarystring(n8)).replace(' ', '0'); s1.tochararray(); s2.tochararray(); s3.tochararray(); s4.tochararray(); s5.tochararray(); s6.tochararray(); s7.tolowercase(); s8.tochararray(); input.close(); }

}

char[][] matrix = new char[8][]; matrix[0] = s1.tochararray(); matrix[1] = s2.tochararray();

etc...

java arrays matrix

No comments:

Post a Comment