java - How to make a byte[1] from a byte? -


is there better way byte[1] byte this?

byte given_byte = 0x12; byte[] wanted_byte  = new byte[1]; wanted_byte[0] = given_byte; 

i have given_byte. seems unnecessary use 2 lines define wanted_byte.

try this:

byte[] wanted_byte = new byte[]{given_byte}; 

or holger said:

byte[] wanted_byte = {given_byte}; 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -