+ 1
Find a string length error?help
import java.util.*; // Compiler version JDK 11.0.2 class Dcoder { public static void main(String args[]) { sterin str=new sachin_patel; int l= str.length(); System.out println(l); } }
2 Respostas
+ 6
May be it's mean :
String str = new String("sachin_patel");
+ 4
sterin is probably String
if sachin_patel is the class (?) there are missed ()
and dot after System.out
import java.util.*;
class Dcoder {
public static void main(String args[]) {
//sterin str = new sachin_patel;
sterin str = new sachin_patel(); //parentheses
int l = str.length();
//System.out println(l);
System.out.println(l); //dot
}
}
//hypothetic classes
class sterin {
String str="";
int length() { return str.length(); }
}
class sachin_patel extends sterin {}