Left hand should be variable

If I do, it works

elements.getElement(j).getValues().getArray()[i]=(elements.getElement(j).getValues().getVariable(i)-minimum)/(maximum-minimum);

But if I do this, he tells me that it should be a variable

elements.getElement(j).getValues().getVariable(i)=(elements.getElement(j).getValues().getVariable(i)-minimum)/(maximum-minimum);

Two functions:

double[] getArray(){
    return array;
}

double getVariable(int position){
    return array[position];
}

I believe that what is ahead does not matter, and it works correctly, and the error should lie somewhere in the end. And how does this happen when I assign let say say this (1st line), it works, which means it is a variable, but when I try to assign something to it like (2nd line), it does not work . How dumb am I? What am I missing?

double max=elements.getElement(j).getValues().getVariable(i);
elements.getElement(j).getValues().getVariable(i)=0.0;
+4
source share
7 answers
getVariable(i)

Definitely different from

getArray()[i]

, [], l. (r-), assignemnt.

, , .

0 = 5 // this just won't work
array[0] = 5 // this will, because array[0] is a valid l-value

, .

void setVariable(int position, double value) {
    array[position] = value;
}

elements.getElement(j).getValues().setVariable(i, value);
+7

: , .

, , , : [] , [].

, [], , . [] double. double , , .

, :

void setVariable(int position, double newValue){
    array[position] = newValue;
}
...
elements.getElement(j)
    .getValues()
    .setVariable(i
    , (elements.getElement(j).getValues().getVariable(i)-minimum)/(maximum-minimum)
    );
+2

, [i], , Java .

getVariable(i) , , , , . ? , .

, setVariable .

void setVariable(int position, double value){
    array[position] = value;
}


elements.getElement(j).getValues().setVariable(i, 
    elements.getElement(j).getValues().getVariable(i)-minimum)/(maximum-minimum);
+2

, ,

elements.getElement(j).getValues().getVariable(i)

,

elements.getElement(j).getValues().getArray()[i]

. ? :

VALUE array[i]. array, .

+1

getVariable() a value. , primitive. :

int x = 7;

:

int x = getVariable(i);

, :

3 = 7;

3 a value, a variable. - , .

getArray() , , [], .

getArray()[i] = 5;
+1

.

countLetters("hello") ;

int count = countLetters("hello");
      <---------------------+

, , .

getValue(1) = 5;
  <------+X<--+

, .

+1

,

public int[] getArray(){
    return array;
}

public int getValue(int i){
   return array[i];
}

,

getArray()[0] = 2;
getValue(0) = 3;

, "" ,

int[] arrayFromMethod = getArray();
arrayFromMethod[0] = 2;

, int, .

// pretend array[0] is already 42
 42 = 3;  // Nope

,

int x = array[0];
x = 3;

because you embed a call when you say getValue(i) = 3that does not allocate a new variable. And even if this happened, the meaning would disappear as soon as the next statement was reached, therefore it has no meaning.

0
source

All Articles