import java.util.*;
import java.lang.*;
import java.io.*;
public class UserValidator {
void validateName(String name) {
if (name != null)
System.out.println("Set your name");
else {
System.out.println("User name: " + name);
}
}
void validateAge(double age, double height) {
if (age > 30 || height > 160) {
System.out.println("User is older than 30 and higher ten 160cm");
} else {
System.out.println("User is younger than 30 or lower than 160");
}
}
class Apllication {
public static void main(String[] args) throws java.lang.Exception {
String name = "Adam";
double age = 40.5;
double height = 178;
UserValidator user = new UserValidator();
System.out.println(validateName);
System.out.println(validateAge);
}
}
}
why does not see validateName and age?
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
Lisa L
22 May 2022, 13:01
validate name is not a field or variable but a instance method. You need to invoke it on an UserValidator object. It also does not have a return value, means you can not pass the ret val as argument to the println method.
If you're using a Java version < 17 then you may want to make Apllication a regular class and not an inner one. Inner classes can only have static members from Jave 17 on. 0
Karol Grzeszczak
22 May 2022, 13:59
love you *_*
0