خرید بک لینک

Vote count: 0

Why isn't the following code working ? String s = "fecbda"; Arrays.sort(s.toCharArray()); System.out.println(s);

asked 3 mins ago

1 Answer

Vote count: 0

Strings are immutable so you can't change them, and you shouldn't expect this to do anything.

What you might have intended is

String s = "fecbda"; 
char[] chars = s.toCharArray();
Arrays.sort(chars); 
String s2 = new String(chars);
System.out.println(s2);

answered 28 secs ago

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 22 فروردين 1395 ساعت: 6:01

صفحه بندی