Are character immutable in java. If so, is there a way to change, update or read multiple char values in a single char variable.
String go = "djlfa";
Scanner sc = new Scanner(go);
for(int i = 0; i < go.length(); i++){
Character sym = new Character(sc.next().charAt(i));
System.out.print(sym);
}
So you're trying to put the string go
into the wrapper type Character
? If so: Character
can only store a single character - not 5 ( djlfa
) as you want to do it.
Are character immutable in java
Yes, there is no method to change the value of an existing Character
instance without calling the constructor again.
If so, is there a way to change, update or read multiple char values in a single char variable
No, this is whatString
s are for. They are also immutable .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.