Skip to content

Tag: char

Converting a to a char[]

I want to give a function a char array from I only get an error message if I try to convert it like I do it now: This is the errormessage I get: It also shows this error on the other ones where I want to pass the char[] over. Need to add more text cause they say it

why can’t I add chars to a new string?

code: The second line is wrong for some reason and I don’t know why Answer The book is wrong, and Eclipse is right. In Java, you can write “abc” + whatever, or whatever + “abc”, and it concatenates the strings — because one side is a String. But in st.charAt(0)+st.charAt(st.length()-1)), neither side is a String. They’re both chars. So Java

Char variable minus char variable parse to Int in java

I know this is trivial, but I can’t find the proper explication. I have the following code How does this parsing work? Answer As long as the character is a digit, you can get the equivalent int value by subtracting ‘0’. The ASCII coding for ‘0’ is decimal 48, ‘1’ is decimal 49, etc. So ‘8’ – ‘0’ = 56