Hi
Am try to convert a Char Char A = 'F'; to an Integer without Changing 'F' to a numeric value. Then Set it at something like list.set(4, A). Is this possible?
Molayo Decker wrote:Hi
Am try to convert a Char Char A = 'F'; to an Integer without Changing 'F' to a numeric value. Then Set it at something like list.set(4, A). Is this possible?
What do you mean by this? An integer IS a numerical value. By the way, so is char.
Am writing a code to replace all numbers in an array that are divisible by another number to be replaced by F or B
So if 3 is divisible by 3 replace 3 in the array {1,2,F,4,5,6,7}. Am trying to set 3 to F by using the set method but it only takes two integers or two strings. set (int, String)
Ouch! What dreadful variable names. Try
myList.set(0, (int)'F'); If you have a List<Integer>, you can put ints into it and they will undergo boxing conversion. You cannot (I think) put chars directly because they cannot undergo widening (=cast to int) and boxing conversion together. If you cast it to an int, then you only need boxing conversion and that can be done automatically.