学过comp1005的高手们进来一下。

遛弯的害虫

虫子家族
注册
2002-11-09
消息
968
荣誉分数
0
声望点数
0
我现在学到method,我不太懂那个keyword "this" 怎么个用法,或者是什么意思?有没有高手可以给我讲解一下的?谢谢啦~
 
代码:
Class aTest{
 public boolean triggle;
 public class aTest(){
  System.out.println("just a test");
  triggle = false;
 }
 public void anotherLine(){
  System.out.println("another line");
  triggle = true;
 }
 public void checkIfAnotherLine(){
  if(this.triggle){
   System.out.println("another line has been printed");
  }else{
   System.out.println("another line hasn't been printed");
  }
 }
 public void main(string []args){
   aTest helloworld = aTest();
   helloworld.anotherLine();
   helloworld.checkIfAnotherLine();
   aTest anotherHello = aTest();
   anotherHello.checkIfAnotherLine();
 }
}

this 可以呃?用
例如
String str;
public void testClass(string str){
this.str = str;
}

or

public class TestClass(){
str = "";
}
public class TestClass(TestClass bClass){
this.str = bClass.getStrValue();
}

也杂有一些 代瘁?邋了,半年多?? java了 ,good luck la,不清楚的?在办傥
 
this.str = str
把parameter里钷的str值付於?前class 的 public string str
很多?候 可以不用this的 ,不咿市?了?劫?更明锢?

this = ?前 呃?OBJECT
 
最初由 遛弯的害虫 发布
我现在学到method,我不太懂那个keyword "this" 怎么个用法,或者是什么意思?有没有高手可以给我讲解一下的?谢谢啦~
你上个term不是学了么?重修么?:D
 
呃?西也就那?啦,很?聊的?西
我也就拿了?C+, ?有F,D就可以撒
 
后退
顶部