I have a problem with this code
public class JavaApplication٣ {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Rectangels vo = new Rectangels(4,40);
Rectangels vs = new Rectangels(3.5,35.9);
printing(vo);
printing(vs);
}
//the problem in this part the GetArea and GetPara can't reach the Rectangels class
static void printing(Rectangels val){
System.out.println("rectangel AREA :"+val.GetArea);
System.out.println("rectangel PARA :"+val.GetPara);
}
}
//the problem in this part the GetArea and GetPara can't reach the Rectangels class in NetBeans shows me "cannot find symbol"
class Rectangels{
double width=1;
double height=1;
Rectangels(){
}
Rectangels(double w , double h){
width=w;
height=h;
}
double GetArea(){
return width*height;
}
double GetPara(){
return 2*(width+height);
}
}
There is syntax error in your printing method, the method calls that obtain area and parameter from the rectangles instance should be followed by () as shown:
static void printing(Rectangels val){
System.out.println("rectangel AREA :"+val.GetArea());
System.out.println("rectangel PARA :"+val.GetPara());
}
}
You can check the following link for more details https://www.w3schools.com/java/java_methods.asp
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.