komlaaa
asked on
return value
Hi,
if the user has not enter anything, i want to force him to enter the val. That is why what i am trying to do in this code. but i am getting the error:
sss/StudentPanel.java [206:1] missing return statement
}
How can i fix that?
public String getLast()
{
String last = (String)lastCombo.getSelec tedItem();
if(last == null || last == "")
{
JOptionPane.showMessageDia log(this,
"Plase Enter Student lastName",
"Error",JOptionPane.INFORM ATION_MESS AGE );
}
else
{
return last.trim();
}
}
if the user has not enter anything, i want to force him to enter the val. That is why what i am trying to do in this code. but i am getting the error:
sss/StudentPanel.java [206:1] missing return statement
}
How can i fix that?
public String getLast()
{
String last = (String)lastCombo.getSelec
if(last == null || last == "")
{
JOptionPane.showMessageDia
"Plase Enter Student lastName",
"Error",JOptionPane.INFORM
}
else
{
return last.trim();
}
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
1.) if (getLast()!=null) /* close the dialog window */
why should i close the dialog, the JOptionPane dialog is opened only when getLast() == null or Not, --- i think so.
2.) if(last == null || last == "")
do u think i should check for empty string ( last == "")
why should i close the dialog, the JOptionPane dialog is opened only when getLast() == null or Not, --- i think so.
2.) if(last == null || last == "")
do u think i should check for empty string ( last == "")
public String getLast() {
String last = (String)lastCombo.getSelec tedItem();
do {
JOptionPane.showMessageDia log(this, "Please select Student last name", "Error", JOptionPane.INFORMATION_ME SSAGE);
} while(last == null);
return last;
}
String last = (String)lastCombo.getSelec
do {
JOptionPane.showMessageDia
} while(last == null);
return last;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:-)
if (getLast()!=null) /* close the dialog window */