===Representation:
Use tool "Power Designer" to Desgin and generate the code
------------- ---------------
Classname Person
-------------- ----------------
properties +String name
-------------- - int age
method ----------------
-------------- +void setAge
----------------
2011年12月24日星期六
2011年12月23日星期五
第6天 第1节: 面向对象(基础)
OOA: Analysis + OOD: Design + OOP: Programming
==Object Oriented Features
1. encapsulation
2. Inheritance
3. Polymorphism
==Class and objects
1. default properties and methods are public
2. don't have to have constructor and disconstructor
3. object creation steps
step1: Person per=null; ==> per is on stack
step2: per = new Person(); ==> create object properties on heap
Note: method on globl instruction area when class created.
4. reference
Person per1 = new Person();
Person per2 = new Person();
Person per3 = per1;
per2 = per1; ==> the original object referred by per2 will be collected by java
==Object Oriented Features
1. encapsulation
2. Inheritance
3. Polymorphism
==Class and objects
1. default properties and methods are public
2. don't have to have constructor and disconstructor
3. object creation steps
step1: Person per=null; ==> per is on stack
step2: per = new Person(); ==> create object properties on heap
Note: method on globl instruction area when class created.
4. reference
Person per1 = new Person();
Person per2 = new Person();
Person per3 = per1;
per2 = per1; ==> the original object referred by per2 will be collected by java
第5天第7节: 新特性对数组的支持
After JDK1.5
==foreach for array
int y[]={1,3,5,};
for(int z:y)System.out.print(z+"\t"); ==>1 3 5
==varying number of args
int y[]={1,3,5}
fun(1,3,5,7);
fun(1);
fun(y);
public static void fun(int ... arg) {
for(int x:arg)System.out.print(x+"\t");
System.out.println();
}
==foreach for array
int y[]={1,3,5,};
for(int z:y)System.out.print(z+"\t"); ==>1 3 5
==varying number of args
int y[]={1,3,5}
fun(1,3,5,7);
fun(1);
fun(y);
public static void fun(int ... arg) {
for(int x:arg)System.out.print(x+"\t");
System.out.println();
}
第5天第6节: 数组与方法
==definition
int a[] = new int[10] ;
int[] a = new int[10];
int a[]={1,3,5,7,9};
both allocates memeoty on heap
a.length ==>10;
Two steps:
1. int a[] = null; ==> creates variable a on stack
2. a = new int[10] ==> allocates memory on heap
==reference
int b[]=a;
==2D array
int a[][] = new int[10][2] ;
int[][] a = new int[10][2];
int b[][]=a;
a.length ==> 12
a[1].length ==> 2
==Method or Fucntion
naming rule: the first letter of first word is little, the first letter of rest word is capital
function overload: different arg type or different number of args, but not different return type
recursive call: may cause stack overflow
==passing and returning array:
public static void main (String argvs[] ) {
int x[]={1,3,5,8};
int y[];
y=print(x);
System.out.println();
for(int i=0;i<y.length;i++)System.out.print("y["+i+"]="+y[i]+"\t");
System.out.println();
}
public static int[] print(int tx[]) {
for(int i=0;i<tx.length;i++)System.out.print("tx["+i+"]="+tx[i]+"\t");
int ty[]={2,4,6};
return ty;
}
==Array utility
java.util.Array.sort(y);
System.arraycopy(x,<start_pos>,y,<start_pos>,<num_of_iterm>)
int a[] = new int[10] ;
int[] a = new int[10];
int a[]={1,3,5,7,9};
both allocates memeoty on heap
a.length ==>10;
Two steps:
1. int a[] = null; ==> creates variable a on stack
2. a = new int[10] ==> allocates memory on heap
==reference
int b[]=a;
==2D array
int a[][] = new int[10][2] ;
int[][] a = new int[10][2];
int b[][]=a;
a.length ==> 12
a[1].length ==> 2
==Method or Fucntion
naming rule: the first letter of first word is little, the first letter of rest word is capital
function overload: different arg type or different number of args, but not different return type
recursive call: may cause stack overflow
==passing and returning array:
public static void main (String argvs[] ) {
int x[]={1,3,5,8};
int y[];
y=print(x);
System.out.println();
for(int i=0;i<y.length;i++)System.out.print("y["+i+"]="+y[i]+"\t");
System.out.println();
}
public static int[] print(int tx[]) {
for(int i=0;i<tx.length;i++)System.out.print("tx["+i+"]="+tx[i]+"\t");
int ty[]={2,4,6};
return ty;
}
==Array utility
java.util.Array.sort(y);
System.arraycopy(x,<start_pos>,y,<start_pos>,<num_of_iterm>)
第5天第5节: 基本程序控制语句
==if
if ...
if...else...
if...else if... else ...
switch...case:...default:... break;
==do
while....
do....while...
for...
break;
continue;
if ...
if...else...
if...else if... else ...
switch...case:...default:... break;
==do
while....
do....while...
for...
break;
continue;
使用EditPlus配置Java编译环境
在配置EditPlus之前是先将Java的运行环境安装且调试好,然后进入EditPlus,从菜单“工具
(Tools)”;“配置用户工具...”进入用户工具设置,选择“组和工具条目”中的“Group 1”,点击面板右边的“组名称...”按钮,将文本Group1”修改成“Java编译程序”,点击“添加工具”按钮,选择应用程序,然后就是修改属性:
1. 添加编译功能
“菜单文本”里的内容修改为“Javac”;
“命令”选择安装JDK后的Bin目录中的编译程序javac.exe,我的JDK 安装路径为“C:\Program
Files\JDK\j2sdk1.4.2_08”,那么此路径为“C:\Program Files\Java\jdk1.5.0\bin\javac.exe”;
“参数”选择“文件名”,即显示为“$(FileName)”;
“初始目录”选择“文件目录”,显示为“$(FileDir)”;选择“捕获输出”复选框
2. 添加执行功能
“菜单文本”里的内容修改为“Java”;
“命令”选择安装JDK后的BIN目录中的编译程序java.exe,路径为“C:\Program Files\Java\jdk1.5.0\bin\java.exe”;“参数”选择“不带扩展名的文件名”,即显示为“$(FileNameNoExt)”;
“初始目录”选择“文件目录”,显示为“$(FileDir)”;选择“捕获输出”复选框!
这样就完成了EditPlus的基本设置,可以写一段Java程序进行调试,通过Ctrl+1进行编译,使用Ctrl+2运行程序,还可以添加工具栏按钮。
错误提示都会显示在输出窗口中,双击某一行错误信息,EditPlus会自动定位到出错行,怎么样?一个简单的Java IDE界面就出现了。
ps: 要把你写的.java代码保存到你的java文件夹里才行
(Tools)”;“配置用户工具...”进入用户工具设置,选择“组和工具条目”中的“Group 1”,点击面板右边的“组名称...”按钮,将文本Group1”修改成“Java编译程序”,点击“添加工具”按钮,选择应用程序,然后就是修改属性:
1. 添加编译功能
“菜单文本”里的内容修改为“Javac”;
“命令”选择安装JDK后的Bin目录中的编译程序javac.exe,我的JDK 安装路径为“C:\Program
Files\JDK\j2sdk1.4.2_08”,那么此路径为“C:\Program Files\Java\jdk1.5.0\bin\javac.exe”;
“参数”选择“文件名”,即显示为“$(FileName)”;
“初始目录”选择“文件目录”,显示为“$(FileDir)”;选择“捕获输出”复选框
2. 添加执行功能
“菜单文本”里的内容修改为“Java”;
“命令”选择安装JDK后的BIN目录中的编译程序java.exe,路径为“C:\Program Files\Java\jdk1.5.0\bin\java.exe”;“参数”选择“不带扩展名的文件名”,即显示为“$(FileNameNoExt)”;
“初始目录”选择“文件目录”,显示为“$(FileDir)”;选择“捕获输出”复选框!
这样就完成了EditPlus的基本设置,可以写一段Java程序进行调试,通过Ctrl+1进行编译,使用Ctrl+2运行程序,还可以添加工具栏按钮。
错误提示都会显示在输出窗口中,双击某一行错误信息,EditPlus会自动定位到出错行,怎么样?一个简单的Java IDE界面就出现了。
ps: 要把你写的.java代码保存到你的java文件夹里才行
[solution] How to add menu and toolbar into gvim
==Add menu is easy. Add the following into your .vimrc on Linux or _vimrc on Windows
amenu &Often.&Easy\ Mode :set im!<cr>
amenu &Often.Line\ &Wrap :set wrap!<cr>
amenu &Often.Line\ &Number :set nu!<cr>
Step A: Creating 16x16 16 color bmp file
amenu &Often.&Easy\ Mode :set im!<cr>
amenu &Often.Line\ &Wrap :set wrap!<cr>
amenu &Often.Line\ &Number :set nu!<cr>
This will create three menus Often->Easy Mode, Often->Line Wrap and Often->Line Number. The letter after & is for keyboard shortcuts
==Add Toolbar is two steps.
Step A: Creating 16x16 16 color bmp file
1. Create a 16x16 icon in Visual Studio, and save to .ico file
2. Rename .ico file into .bmp file and open in mspaint
3. Save to 16 color .bmp file ( overwriting the original one ) -- must step
4. Place the .bmp file in .vim/bitmaps on Linux or vimfiles\bitmaps\
Step B: Add the following into your .vimrc on Linux or _vimrc on Windows
amenu ToolBar.easy :set im!<cr>
amenu ToolBar.linewrap :set wrap!<cr>
amenu ToolBar.linenum :set nu!<cr>
Where easy, linewrap and linenum are the filename of .bmp file ( without extension )
订阅:
博文 (Atom)