导航:首页 > 编程语言 > java联系人

java联系人

发布时间:2023-01-10 01:40:49

1. java如何实现手机通讯录“添加”联系人电话、姓名、功能

引流操作方式很简单1养号申请2打开Excel导入电话号码选择本地号段,导入Excel,然后按照尾号0001开始下拉拖动将得到的号码导入手机中。3添加好友打开

2. 编写Java程序实现一个通讯录

去问 JAVA 老师

3. 在Java中如何将联系人信息写入数据库

首先在数据库中定义一个联系人的表,然后在Java中通过表单和联系的类进行关联,通过类与数据库字段的映射关系写入表中。

4. java个人通讯录管理系统

import java.util.Arrays;

public class AddressBook
{
private int totalContacts; // 现在通讯录中的总数

private int maxContacts; // 通讯录的最大值

private Contact[] contacts; // 通讯录的array

/**
* Constructor. 设定这个通讯录最初的大小为10人上限.
*/
public AddressBook()
{
totalContacts = 0;
maxContacts = 10;
contacts = new Contact[totalContacts];
}

/**
* 得到一个联系通过通讯录中的名字
*
* @param name
* 要去得到的联系人名字
* @return 这个联系人, 没有的话为null
*/
public Contact getContactByName(String name)
{
for(int i = 0; i < totalContacts; i++)
{
Contact c = contacts[i];
if(name.equals(c.getName()))
{
return c;
}
}
return null;
}

/**
* 在这个contacts array的最后给这个通讯录添加联系人.
* 如果联系人已经存在且号码参数不为0的话,联系人的号码会更新或者地址参数不是null的话,地址会更新。.
* 如果totalContacts达到maxContacts的值的话,在新的联系人被添加前,这个contacts
* array的size会乘以双倍并且maxContacts也乘以双倍。
*
* @param contact
* 要加到这个通讯录的联系人
* @return true 如果这个联系人添加成功, 否则 false;
*/
public boolean addContact(Contact contact)
{
for(int i = 0; i < contacts.length; i++)
{
Contact ct = contacts[i];
if(ct.equals(contact))
{
if(ct.getNumber() != 0)
{
ct.setNumber(contact.getNumber());
}
if(null != ct.getAddress())
{
ct.setAddress(contact.getAddress());
}
return true;
}
}
if(totalContacts == maxContacts)
{
totalContacts *= 2;
maxContacts *= 2;
}
Contact[] cs = new Contact[totalContacts + 1];
System.array(contacts, 0, cs, 0, totalContacts);
cs[cs.length - 1] = contact;
contacts = cs;
totalContacts++;
return true;
}

/**
* 检查是否联系人已经存在
*
* @param contact
* 要去检查的contact
* @return true 如果这个联系人被找到,否则false
*/
public boolean contains(Contact contact)
{
for(int i = 0; i < totalContacts; i++)
{
if(contacts[i].equals(contact))
{
return true;
}
}
return false;
}

public void printAddressBook()
{
for(int i = 0; i < totalContacts; i++)
{
System.out.println(contacts[i]);
}
}

/**
* 在AddressBook中还有一个方法!
* 从通讯录中移除一个指定的联系人,之后把其他的入口左移,这样在联系人间就没有空隙了,
* For example:
* before -> {C1, C2, C3, C4, C5, C6, C7, C8, C9, null} remove C6
* after -> {C1, C2, C3, C4, C5, C7, C8, C9, null, null}
*
* @param contact
* 要移除的联系人,
* @return true 如果这个联系人被成功移除了,否则false;
*/
public boolean removeContact(Contact contact)
{
if(totalContacts == 0)
{
return false;
}
for(int i = 0; i < totalContacts; i++)
{
Contact ct = contacts[i];
if(ct.equals(contact))
{
Contact[] cs = new Contact[totalContacts];
System.array(contacts, 0, cs, 0, i);
System.array(contacts, i + 1, cs, i, cs.length - i - 1);
contacts = cs;
totalContacts--;
return true;
}
}
return false;
}

@Override
public String toString()
{
return String.format("AddressBook [totalContacts=%s, maxContacts=%s, contacts=%s]", totalContacts, maxContacts,
Arrays.toString(contacts));
}
}

//--------------------------------------------------

public class Contact
{
private String name;

private long number;

private String address;

public String getName()
{
return name;
}

public void setName(String name)
{
this.name = name;
}

public long getNumber()
{
return number;
}

public void setNumber(long number)
{
this.number = number;
}

public String getAddress()
{
return address;
}

public void setAddress(String address)
{
this.address = address;
}

@Override
public boolean equals(Object obj)
{
if(!(obj instanceof Contact))
{
return false;
}
Contact contact = (Contact) obj;
if(this.getName().equals(contact.getName())
&&
this.getAddress().equals(contact.getAddress())
&&
this.getNumber() == contact.getNumber())
{
return true;
}
return false;
}

@Override
public String toString()
{
return String.format("Contact [name=%s, number=%s, address=%s]", name, number, address);
}
}

//---------------------------------------------

public class Test
{
public static void main(String[] args)
{
AddressBook ab = new AddressBook();
for(int i = 0; i < 10; i++)
{
Contact contact = new Contact();
int x = i + 1;
contact.setName("C" + x);
contact.setAddress("china");
contact.setNumber(x);
ab.addContact(contact);
}
System.out.println(ab);
Contact c = new Contact();
c.setName("C6");
c.setAddress("china");
c.setNumber(6);
ab.removeContact(c);
System.out.println(ab);
}
}

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

具体方法如下:

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

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 = 0; i < size; i++) {

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 = 0; i < size && i < contacts.length;

i++) {

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

index = i;

break;

}

}


if (index == -1) {

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

} else {

for (int i = index; i < size; i++) {

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 = 0; i < 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);

}

}

6. 求解java,想点击table的某一行后,然后点击“查看联系人”按钮,弹出显示联系人的框子,代码如下

selectRow 看一下这个值是不是-1 如果是-1 那就说明回去行的时候出错

7. java中做一个简单的通讯录包含名字年龄性别电话类别

将 java的字段 名字 年龄 性别 等等 放在一个javabean里面,自动生成get set 方法(假设是person类)
然后在你想显示的页面,用List<person> ,将你的联系人信息 add到集合中,最后在你要显示的界面把集合的数据取出来 放进布局就可以了。

8. 实现一个小型通讯录。Java

Friend类:public class Friend {
/*
* 姓名
*/
private String name;
/*
* 电话
*/
private String telephone;
/*
* 邮箱
*/
private String email;
/*
* 公司
*/
private String company; public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} public String getTelephone() {
return telephone;
} public void setTelephone(String telephone) {
this.telephone = telephone;
} public String getEmail() {
return email;
} public void setEmail(String email) {
this.email = email;
} public String getCompany() {
return company;
} public void setCompany(String company) {
this.company = company;
} public String toString() {
StringBuffer str = new StringBuffer(); str.append("姓名:" + name).append("\n");
str.append("电话:" + telephone).append("\n");
str.append("邮箱:" + email).append("\n");
str.append("公司:" + company).append("\n");
str.append("-----------------------------------------\n");
return str.toString();
}
}AddFriend类:public class AddFriend { /**
* 主方法 程序的入口
*/
public static void main(String[] args) {
List<Friend> friendList = new ArrayList<Friend>();
char isGo = 'Y';
int i = 0;
do {
Friend friend = new Friend();
System.out.println("请输入第" + (i + 1) + "位朋友的姓名:");
InputStreamReader reader = new InputStreamReader(System.in);
String str = "";
try {
str = (new BufferedReader(reader)).readLine();
} catch (IOException e) {
e.printStackTrace();
}
friend.setName(str); System.out.println("请输入第" + (i + 1) + "位朋友的电话:"); try {
str = (new BufferedReader(reader)).readLine();
} catch (IOException e) {
e.printStackTrace();
}
if (str.matches("\\d*") && str.length() == 11) {// 判断用户输入的电话是否符合标准
friend.setTelephone(str);
} else {
System.out.println("电话号码输入有误,请重新输入!");
continue;
} System.out.println("请输入第" + (i + 1) + "位朋友的邮箱:"); try {
str = (new BufferedReader(reader)).readLine();
} catch (IOException e) {
e.printStackTrace();
}
friend.setEmail(str); System.out.println("请输入第" + (i + 1) + "位朋友的公司:"); try {
str = (new BufferedReader(reader)).readLine();
} catch (IOException e) {
e.printStackTrace();
}
friend.setCompany(str); friendList.add(friend); i++; System.out.println("是否继续添加?(Y/N):");
String go = "";
try {
go = (new BufferedReader(reader)).readLine();
} catch (IOException e) {
e.printStackTrace();
}
isGo = go.charAt(0);
} while (isGo == 'Y' || isGo == 'y'); for (int j = 0; j < friendList.size(); j++) {
System.out.println(friendList.get(j).toString());
}
}
}

阅读全文

与java联系人相关的资料

热点内容
win7美化命令行终端 浏览:795
免加密狗图片 浏览:485
一只透明的鸟是什么app 浏览:817
空气压缩机油批发商 浏览:69
linuxifexist 浏览:4
加密tf卡拷入文件 浏览:399
山西php工资 浏览:673
福州看病预约用什么小程序app 浏览:238
php保留两位小数不四舍五入 浏览:292
黑马程序员路径大全 浏览:1000
saas平台PHP 浏览:333
云服务器科学计算配置怎么选 浏览:649
jar解压命令 浏览:609
php正则问号 浏览:299
无线已加密不可上网是怎么了 浏览:464
什么app可以免费做手机 浏览:376
异性下载什么app 浏览:680
51单片机程序单步视频 浏览:241
家庭宽带如何连接服务器 浏览:121
汽车高压泵解压 浏览:772