but if we assume the rest of the code as following:
public class Main {
public static void main(String args[]){
Course x=new Course();
Activity y=new Activity();
String [B]input[/B]=args[0];
x.register(input);
y.registerA(input);
}
}
public class Course {
Names n=new Names();
public void register(String k){
n.check(k);
}
}
public class Activity extends Course{
public void registerA(String e){
n.checkA(e);
}
}
public class Names {
int i;
String[] [B]list[/B]={"mos","mona","ali"};
Result m=new Result();
void check(String s){
for(i=0;i<=2;i++){
if (list[i]==s) {m.success();
break;
}
else if (i==2) {
m.fail();}
else {
continue;
}
}
}
void checkA(String b){
for(i=0;i<=2;i++){
if (list[i]==b) {m.successA();
break;
}
else if (i==2) {m.failA();}
else {
continue;
}
}
}
}
public class Result {
public void success(){
System.out.println("reg in course");}
public void fail(){
System.out.println("u r not registered");
}
public void failA(){
System.out.println("u r not registered in act");
}
public void successA(){
System.out.println("in the act");
}
}
why the compiler assumed that the reference to the element value in the
list array is equals to the reference of the "
input" object when the value actually referenced by the array?? you have an illustration to this??