Now actually, when you try to compile the code, you'll get an error. The error
is somewhat curious. It says that gasInTank might not have been initialized.
So, the error here was that gasInTank, by putting the word double here, has
turned into a local variable. Not the instance variable that we intended. Let
me show you another useful way of thinking about instance variables.
Bueno, de hecho cuando tratan de compilar el código, reciben un error. El error
es algo curioso. Dice que es posible que «gasInTank» no se haya podido iniciar.
Bien, el error aquí fue que «gasInTank», poniendo la palabra doble aquí, se ha
convertido en una variable local. No es la variable de instancia que teníamos prevista. Permítanme
mostrarles otra forma útil de pensar en las variables de instancia.
En fait, lorsque vous essayez
de compiler le code,
vous obtenez une erreur.
L'erreur est quelque peu curieuse.
Il dit que gasInTank n'a peut-être
pas été initialisé.
Donc, l'erreur ici était que gasInTank,
en mettant le mot double ici,
est devenu une variable locale,
pas la variable d'instance
que nous voulions.
Laissez-moi vous montrer une autre façon
utile de penser aux variables d'instance.
実はこのコードをコンパイルしようとすると
エラーが出てしまいます
このエラーは興味深いですね “gasInTankは
初期化されていなかったかもしれない”とあります
ここのgasInTankにエラーがあるようです
doubleを入れてしまったため
インスタンス変数にしたかったのにも関わらず
ローカル変数へ変わってしまっています
インスタンス変数を考える際に役に立つ
別の方法をお見せしましょう
컴파일을 시도하면 바로 오류가 납니다. 오류가
조금 특이합니다. gasInTank가 초기화 되지 않았다고 말합니다.
그래서 여기에 오류는 gasInTank였습니다. double을 넣었더니
우리가 필요한 인스턴스 변수가 아닌 지역 변수로 변해버렸습니다.
인스턴스 변수에 대해서 더 좋은 정보를 알려드리겠습니다.
Thực tế thì, khi cố gắng biên dịch code này, bạn sẽ gặp phải một error.
Error này khá là kì lạ. Nó bảo là gasInTank có thể chưa được khởi tạo.
Vậy là, thằng gasInTank gây ra lỗi, do ta để kiểu double ở đây, làm nó
biến thành một local variable, chứ không phải là instance variable như ta muốn
Để tôi cho bạn thấy có một cách hữu ích khác khi dùng đến instance variable.