Quote:
Originally Posted by Crunkles 
I'd agree with this. It looks like some of his braces throughout the code are out of place.
Here's the original; shouldn't it be something more like this:
I'm no expert on java, but syntax is universal. From my observation, he either had too many brackets at the end, within his code or both.

I'd agree with this. It looks like some of his braces throughout the code are out of place.
Code:
import javax.swing.JOptionPane;
public class MyOwnWhileProject {
public MyOwnWhileProject() {
}
public static void main(String[] args) {
String names []={"Beah","Bianca","Lance","Belle","Nico","Yza","Gem","Ethan"};
/**
for (int i=0; i<names.length; i++){
if (names [i ].equals(searchName)){
foundName = true;
break;
*/
}
}
if (foundName)
JOptionPane.showMessageDialog(null, searchName + " is found!");
else
JOptionPane.showMessageDialog(null, searchName + " is not found!");
}
}
Code:
import javax.swing.JOptionPane;
public class MyOwnWhileProject {
public MyOwnWhileProject() { }
public static void main(String[] args) {
String names []={"Beah","Bianca","Lance","Belle","Nico","Yza","Gem","Ethan"};
int i =0;
while(i<names.length){
if(names[i].equals(searchName)){
foundName = true;
break;}
i++;}
}
if (foundName)
JOptionPane.showMessageDialog(null, searchName + " is found!");
else
JOptionPane.showMessageDialog(null, searchName + " is not found!");}
I believe all of the brackets were fine (outside of 2 the were left out of the commented code), but I do like the way you cleaned them up. OP please pay attention to this!
Quote:
This is true. I left it there because that's the way the OP coded it ans may be unique to OP's coding style. There could also be other factors to the assignment such as returning the first name found, but that's just me trying to justify the original code









