1 / 4

Various method signatures

Various method signatures. View findViewById ( int id); Intent this.getIntent (); int getAction (); Editable getText (); String getStringExtra (String key); int [] getIntArrayExtra (String key); ArrayList <String> getStrings ( int param ); double getDouble (Sting param );

Download Presentation

Various method signatures

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Various method signatures View findViewById(int id); Intent this.getIntent(); intgetAction(); Editable getText(); String getStringExtra(String key); int[] getIntArrayExtra(String key); ArrayList<String> getStrings(intparam); double getDouble(Sting param); String getString(); Int[][] getTwoDimIntArray(ArrayList<int> param); float getFloat(int param1, int param2); float[] getFloatArray(); void andYesSomeMethodsReturnNothing();

  2. Classes and Constructors Class name <name> A class is a template from which objects are made Attribute 1 Attribute 2 <name>(params) <…> method1(<params>) <…> method2(<params>) Constructor always has the same name as the class (there can be more!) When the constructor is called, Java allocates space in memory for the attributes: Attribute1 (uninitialized) Attrubute2 (uninitialized) The system “knows” that this object is an instance of the class The constructor can initialize the attributes Attribute1 (initialized) Attrubute2 (initialized)

  3. Classes and Constructors (2) MyClass So suppose our class in named MyClass Then an instance of the class is created by the statement in which the constructor is invoked: MyClassmyClass = new MyClass(3,4) int width intheigth MyClass(intw,int h) int area() When the constructor is called : MyClassmyClass = new MyClass(3,4) width (uninitialized) height (uninitialized) When the constructor is executed: 3 4 When the method area is called on the object myClass: int area = myClass.area(); the method area is called for the object that has width 4 and height 3 Within the methods, this always refers to the object on which the method is called, e.g. this.width = w; sets the width of the myClass object to 3

More Related