- 博客(5)
- 资源 (6)
- 收藏
- 关注
原创 this VS static
1. this :代表对象,所在函数所属对象的引用 在定义功能时,如果该功能内部使用到了调用该功能的对象,这事就用this来表示这个对象 可以用于构造函数的调用 this (实际参数); this.成员属性/成员方法: this ():调用的是本类中对应参数的构造函数,必须定义在构造函数的第一行。2. static:是一个修饰符,用于修饰成员变量和成员函数...
2014-01-06 21:55:24 90
原创 java this的经典使用
class Leaf{ int i ; Leaf increment() { i++; return this; } public void print() { System.out.print("i"+i); } public static void main(String[] args) { Leaf lf = new Leaf(); ...
2014-01-06 21:49:19 54
原创 java,构造函数,重载
class Tree { int height; Tree() { print("Planting a seedling"); height = 0; } Tree(int i) { print("Creating new Tree that is "+ i + " feet tall"); height = i; } public vo...
2014-01-06 21:21:53 95
原创 java基础知识强转
public class CastingNumbers{ public static void main(String[] args) { double above = 0.7; double below= 0.4; System.out.println("above:"+above); System.out.println("below:"+below); ...
2014-01-02 23:26:39 74
原创 java基础知识switch case的使用
public class VowelsAndConsonants { public static void main(String[] args) { for (int i =0 ; i < 100 ; i++ ) { char c = (char)(Math.random()*26+ 'a'); switch(c) { case 'a': ...
2014-01-02 22:16:26 175
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人