location.java
来自「《J2ME实用教程》清华大学出版社出版」· Java 代码 · 共 29 行
JAVA
29 行
package com.j2medev.chapter4;
//Location代表查询的位置
public class Location {
private String[] location = new String[3];
public static final int CITY = 0;
public static final int REGION = 1;
public static final int COUNTRY = 2;
public Location() {
}
public String get(int field){
if(field < 0 || field > 2)
throw new IllegalArgumentException("The unit field is not defined");
return location[field];
}
public void set(int index,String value){
location[index] = value;
}
public String toString(){
return "city : "+location[0]+"\n"
+"region : "+location[1]+"\n"
+"country : "+location[2]+"\n";
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?