Skip to content

Tag: java

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…