-3

in the if statement is returning as unexpected type– required: variable found: value. I tried == and that obviously didn't work.

public class Array
{
    private College[] coll;

    public Array(College[] coll){
        this.coll = coll;
    }

    public String changeTheValue(String name,int number){
        String result= new String();
        for(int i = 0 ; i < this.coll.length-1;i++){
            if(this.coll[i].getName() == name){
                this.coll[i].getNumber() = number;
                res += "Successfully changed the value of name "+this.coll[i].getName()+" "+this.coll[i].getNumber()+"\n";
            }
            else {
                res +=this.coll[i].getName()+" not found."; 
            }

        }

        return result;
    }
}
Cœur
  • 37,241
  • 25
  • 195
  • 267
  • 2
    Always provide a [mcve] as *text* in a question. Please bear in mind that the purpose of this site is to provide a repository of high-quality questions and answers. A question which is a title and then just a link to a screenshot is *not* a high-quality question. – Jon Skeet Apr 09 '17 at 16:12
  • [Why may I not upload images of code on SO when asking a question?](https://meta.stackoverflow.com/q/285551/5221149) – Andreas Apr 09 '17 at 16:17
  • [How do I compare strings in Java?](http://stackoverflow.com/q/513832/5221149) – Andreas Apr 09 '17 at 16:19
  • 2
    Possible duplicate of [How do I compare strings in Java?](http://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java) – Joe C Apr 09 '17 at 16:27

1 Answers1

2

this.maha[i].getNilai() is returning you a value to which you are trying to set a value and hence you get that error.

You need a setter function

like

this.maha[i].setNilai(number);
Shubham Khatri
  • 270,417
  • 55
  • 406
  • 400