第一本十四章带参方法

package com.pp;

public class qq {
 String shu[] = new String[10];

 public void shu(String name) {
  for (int i = 0; i < shu.length; i++) {
   if (shu[i] == null) {
    shu[i] = name;
    break;
   }
  }
 }

 public boolean s(String bb, String aa) {
  boolean hehe = false;
  for (int i = 0; i < shu.length; i++) {
   if (aa.equals(shu[i])) {
    shu[i] = bb;
    hehe = true;
    break;
   }
  }
  return hehe;
 }

 public void he() {
  for (int i = 0; i < shu.length; i++) {
   System.out.println(shu[i]);
  }
 }
}

第二页
package com.pp;

import java.util.Scanner;

public class qw {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		qq a = new qq();
		Scanner input = new Scanner(System.in);
		for (int i = 0; i < 5; i++) {
			System.out.println("请输入客户姓名");
			String ming = input.next();
			a.shu(ming);
		}
		System.out.println("客户姓名列表");
		a.he();
		System.out.println("请输入要替换的名字");
		String x = input.next();
		System.out.println("请输入替换的名字");
		String xi = input.next();
		if (a.s(xi, x)) {
			System.out.println("存在.替换");
		} else {
			System.out.println("不存咋");
		}
		a.he();

	}

}

 
  


 

你可能感兴趣的:(第一本十四章带参方法)