本文介绍了"本"关键字JAVA / Android的编程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有是在下面,我想了解任何人可以帮助我了code块。

 公共类MainActivity扩展ActionBarActivity实现GestureDetector.OnGestureListener,GestureDetector.OnDoubleTapListener {
  保护无效的onCreate(){
      私人GestureDetectorCompat gestureDetector;
      this.gestureDetector =新GestureDetectorCompat(这一点,这一点);
      gestureDetector.setOnDoubleTapListener(本);   }
}


解决方案

这个关键字,它存在于许多OOP语言,是的当前实例的引用对象,你都包含在内存中。

您例如:

  this.gestureDetector =新GestureDetectorCompat(这一点,这一点);

您基本上是说:
这个实例 - 访问 gestureDetector 等于 GestureDetectorCompat 的新实例构造与2 PARAMATERS,在这种情况下,他们两位 MainActivity 的这个实例的引用。

随着人们都在说,这是一个根本性的本金和可能更利于您与移动到Android之前构建在Java中奠定坚实的基础开始。

There is a block of code which is given below which i am trying to understand can anybody help me.

public class MainActivity extends ActionBarActivity implements GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener {
  protected void onCreate(){
      private GestureDetectorCompat gestureDetector;
      this.gestureDetector = new GestureDetectorCompat(this,this);
      gestureDetector.setOnDoubleTapListener(this);

   }
}
解决方案

The this keyword, which exists in many OOP languages, is a reference to the current instance of the object in which you are contained in memory..

Your example:

this.gestureDetector = new GestureDetectorCompat(this,this);

You are basically saying:This instance - access gestureDetector is equal to a new instance of GestureDetectorCompat that is constructed with 2 paramaters, in this case, both of them references to this instance of MainActivity.

As people are saying, this is a fundamental principal and it may be more beneficial for you to start with building a strong foundation in Java before moving on to Android.

这篇关于"本"关键字JAVA / Android的编程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-25 02:23