How to return the first character of a string if it's repeating?

How can I check if the first character in a string is repeating or not? I can't find the answer anywhere!

char HamBurger(String s){

for(int i=1;i
if(s[i]==s[0]){

return s[0];

}

}

return "_";

}

It's giving me errors like this

file.java on line 4: error: array required, but

String found

if(s[i]==s[j]){

^

file.java on line 4: error: array required, but

String found

if(s[i]==s[j]){

^

file.java on line 5: error: array required, but

String found

return s[j];

^

Sorry, I'm transitioning from C++ to Java, it's all very new to me!...

Read More »

By: StackOverFlow - Wednesday, 19 September

Related Posts