I recently start studying JAVA, and I find this code:
public class Dublicate{
public static void main(String[] args){
int r=0;
for(int i=0;i<(args[0]).length();i++){
char ch=args[0].CharAt(i);
r=r*10+ch-'0';
}
System.out.println(r);
}
}
I don’t really confident that this code will work properly, I don’t confident in
args[0], but this code don’t what to compile:
Dublicate.java:6: cannot find symbol
symbol : method CharAt(int)
location: class java.lang.String
char ch=a.CharAt(i);
^
1 error
How I can solve this problem?
P.S. Also if I write:
int i=4;
String a = "argsas";
char ch=a.CharAt(i);
I also get Error:
Dublicate.java:5: cannot find symbol
symbol : method CharAt(int)
location: class java.lang.String
char ch=a.CharAt(i);
^
1 error
Update:
Yeah, lovercase works thank you all!!!
It’s “charAt” – lower case. .NET starts method with upper case as a convention; Java uses lower case. If you found this code somewhere, it’s a bad choice.