Answer the question
In order to leave comments, you need to log in
Why is the variable not being assigned?
I understand that it's a noob question, but I still couldn't figure it out because there's not enough time.
Why when passing a variable in this way, the variable takes the value of Null.
When I output this variable in this class, it outputs Null.
Explain if not difficult.
Answer the question
In order to leave comments, you need to log in
Probably because you're passing null to the method, aren't you?
Add
System.out.println(LOGIN == null);
to your code.
And read the java code convention, your class, method and variable names are just awful.
And how do you call your USER_NAME_AGREEMENT(String LOGIN) method?
Try running this class:
public class Test{
public static String userName;
public static void main(String args[]){
userNameAgreement("test login");
}
public static void userNameAgreement(String login){
userName = login;
System.out.println("Agreement: " + userName);
}
}
Check for null at the beginning of the method and you will be happy
. There will be something like
public String USER_NAME;
public void USER_NAME_AGREEMENT(String LOGIN) {
if (LOGIN == null) throw new IllegalArgumentException();
USER_NAME = LOGIN;
System.out.println("Agreement: " + USER_NAME);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question