android - Converting Integer To Hex Java -


I need this fancy [] format for my app as I wrote in the headline.

The value is derived from a hashm which is filled with an XML file with this format [00 00 00 00, but I can call every Int is needed in front of 0x

I tried to "convert" it through "for-loop":

 for  (int i = 0; i & lt; value.length ; I ++) {value [i] = "0x" + value [i]; }   

but I can not convert from string to int this way.

Then I tried to change it directly in the XML file, but then my app crashed with NPE.

Now I want to know that there is a solution to my problem.

Edit:

I tried to do it first, but it does not work:

  Public int [] getValue (map map, string key) {map keyMap = map; Int [] value = {}; @SuppressWarnings ("Raw Type") Iterator IARR = Childmap. Enterreset () Iterator (); While (iter.hasNext ()) {@SuppressWarnings ("Rootsps") map. Entry Mientre = (map.entry) iter.next (); If (mEntry.getKey (.) Equals (key)) {value = (int []) mEntry.getValue (); } } return value; }   

Then I tried one of the answers and added for

  (int i = 0; i   

Now it works before returning ... but I do not know why this works: (

There is no form of any typed language int / number values, as in the form of a byte number of Java store int value 4, the use of two supplement Therefore, 0 or 0x0 or 00 (Octagon) or 0b is the same value: 32 in the binary word zero.

Second Editing:

I think you have a higher-engineered What should you use

  map & lt; string, int []> map;   

Then, if you map.get (Key), you will get what you are looking for.

New problem: The last solution worked because the values ​​that you read in XML are stored as a decimal: < / P>

  string s = "80"; int i = integer.valueOf (s); // it is equal to 80 (decimal value) int value = Integer.valueOf (String.valueOf (i), 16) ; // it stores 128, or 0x80 (hex value)    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -