java程序设计实验报告数组和字符串广州航海学院(用java编写数组)
编一个JAVA程序,字符串数组中查找一个指定的字符串。
List list = SearchL;
String s1 = list.getString(list.getSelectedIndex());
int i1 = s1.lastIndexOf(':', s1.length());
String s4 = s1.substring(i1 + 1, s1.length());
int j1 = Integer.parseInt(s4, 10);
DrawStr.cline = j1;
GuoCPU.setCurrent(BackDis);
DrawStr.cline = j1;
} else
if (OpenFun == 2)
{
List list1 = SearchL;
int k = list1.getSelectedIndex();
String s2 = list1.getString(list1.getSelectedIndex());
String s5 = s2.substring(0, 3);
System.out.println("285241331= " + s5);
int k1 = Integer.parseInt(s5) - 1;
System.out.println("filej1= " + k1);
System.out.println("搜索文本FilePaths[filej-1]=" + FilePaths[k1]);
GuoCPU.ExplorerFile(FilePaths[k1]);
}
} else
if (command == CyberSearch)
{
Search_Str = Search_TextFiled.getString();
int j = Search_CH.getSelectedIndex();
if (j == 0)
{
System.out.println("搜索文本");
SearchL.deleteAll();
SearchS(Res_StrS, Search_Str, 0, Res_StrS.length - 1);
} else
if (j == 1)
{
System.out.println("搜索文件");
详情:
java面向对象程序设计实验报告怎么写
1。People.java
public class People {
//性别(sex)及出生日期(date);方法成员有:获取人的性别和出生日期及构造方法。要求构造方法可以设置性别和出生日期的初始值。
private int sex;
private Date birth;
public People (int sex, Date birth) {
this.sex = sex;
this.birth = birth;
}
public int getSex() {
return this.sex;
}
public Date getBirth() {
return this.birth;
}
}
2。Student.java
public class Student extends People{
private int sex;
private Date birth;
private String name;
private int stuno;
private double grate;
private String studentNative;
public Student(int sex, Date birth, String name, int stuno, double grate, String studentNative) {
super(sex, birth);
this.name = name;
this.stuno = stuno;
this.grate = grate;
this.studentNative = studentNative;
}
public Date getBirth() {
return birth;
}
public double getGrate() {
return grate;
}
public String getName() {
return name;
}
public int getSex() {
return sex;
}
public String getStudentNative() {
return studentNative;
}
public int getStuno() {
return stuno;
}
}
3。测试类自己编写就好了,创建一个People和Student的对象,然后设置值,取值就可以了。
五。
1.构造方法没有返回值,方法名和类名一样.
2.继承是指子类可以拥有父类的方法和属性;多态是指父类的引用可以指向子类对象的实例
3.重写
4.重载
写java程序 一维数组实验 : 定义一个整型数组a【10】,并初始化,求出数组的最大值和最
public class TestMaxAndMin {
public static void main(String[] args) {
int[] arr = new int[10];
arr[0]=12;
arr[1]=13;
arr[2]=14;
arr[3]=15;
arr[4]=16;
arr[5]=17;
arr[6]=18;
arr[7]=19;
arr[8]=23;
arr[9]=22;
for(int i=0;iarr.length-1;i++){
int temp;
for(int j=0;jarr.length-i-1;j++){
if(arr[j]arr[j+1]){
temp = arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
}
for(Integer h:arr){
System.out.println(h);
}
}
}
就是排序嘛,这是冒泡排序,第一个最小,最后一个最大。