JAVA通讯录 求一个JAVA编写的通讯录,基本的就可以。

Python016

JAVA通讯录 求一个JAVA编写的通讯录,基本的就可以。,第1张

具体方法如下:

1、定义封装一条记录的实体类

2、根据实际系统容量,定义一个数组

3、完成系统中显示全部记录的逻辑

4、完成系统中添加一条记录的逻辑

5、完成系统中删除一条记录的逻辑

6、完成系统中修改一条记录的逻辑

7、全部代码:

import java.util.Scanner

class Contact {

String cellPhone

String name

}

public class Main {

private static void menu () {

System.out.println("************** 菜单 ******"

+ "************")

System.out.println(" 1.显示全部通讯录")

System.out.println(" 2.增加一条记录")

System.out.println(" 3.删除一条记录")

System.out.println(" 4.修改一条记录")

System.out.println(" 0.退出")

}

public static void main(String[] args) {

Scanner scn = new Scanner(System.in)

Contact[] contacts = new Contact[200]

int size = 0

String cmd = ""

do {

menu()

System.out.print("请输入你得选择:(0-4)")

cmd = scn.nextLine()

if (cmd.equals("1")) {

if (size == 0)

System.out.println("系统当前无记录!")

else

for (int i = 0i <sizei++) {

System.out.println(contacts[i].name + ":"

+ contacts[i].cellPhone)

}

} else if (cmd.equals("2")) {

System.out.print("请输入手机号:")

String cellphone = scn.nextLine()

System.out.print("请输入姓名:")

String name = scn.nextLine()

Contact contact = new Contact()

contact.cellPhone = cellphone

contact.name = name

if (size <contacts.length) {

contacts[size++] = contact

System.out.println("添加成功!")

} else {

System.out.println("你最多只能添加" +

contacts.length + "条记录")

}

} else if (cmd.equals("3")) {

System.out.print("请输入要删除的手机号:")

String cellphone = scn.nextLine()

int index = -1

for (int i = 0i <size &&i <contacts.length

i++) {

if (contacts[i].cellPhone.equals(cellphone)) {

index = i

break

}

}

if (index == -1) {

System.out.println("该记录不存在!")

} else {

for (int i = indexi <sizei++) {

contacts[index] = contacts[index + 1]

}

contacts[size - 1] = null

size--

System.out.println("删除成功!")

}

} else if (cmd.equals("4")) {

System.out.print("请输入要修改的手机号:")

String cellphone = scn.nextLine()

int index = -1

for (int i = 0i <size &&i <contacts.length

i++) {

if (contacts[i].cellPhone.equals(cellphone)) {

index = i

break

}

}

if (index == -1) {

System.out.println("该记录不存在!")

} else {

System.out.print("请输入姓名:")

String name = scn.nextLine()

contacts[index].name = name

}

}

} while (!cmd.equals("0"))

System.out.println("退出成功!")

scn.close()

System.exit(0)

}

}

准备一张空的SIM卡,在JAVA手机上可以批量将电话号码复制到SIM卡上,再将卡插入安卓手机,将SIM卡通讯录复制到手机就可以了。一般手机都有复制通讯录的功能,仔细找找。

准备工作:一张无联系人的SIM卡。

步骤:

1:将SIM卡插入JAVA的手机内,打开通讯录,按菜单键呼出菜单,选择“将联系人复制到SIM卡”

2:将复制好的SIM卡插入安卓手机。

3:打开联系人,菜单键呼出菜单,点击设置-管理联系人-复制联系人-SIM卡

4:昨晚上面那些会打开选择联系人的页面,点全选-复制。等待进度条走完就可以了。

测试手机,JAVA系统的为山寨机。安卓系统为VIVO x1原生系统。