eclipse 中main()函数中的String[] args如何使用?通过String[] args验证账号密码的登录类?静态的主方法怎样才能调用非static的方法——通过生成对象?在类中制作一个方法——能够修改对象的属性值?

eclipse 中main()函数中的String[] args如何使用?

eclipse 中main()函数中的String[] args如何使用?通过String[] args验证账号密码的登录类?静态的主方法怎样才能调用非static的方法——通过生成对象?在类中制作一个方法——能够修改对象的属性值?

右击你的项目,选择run as中选择 run configuration,选择arguments总的program arguments,在其中输入即可。

通过String[] args验证账号密码的登录类,如何制作?

package com.swift;

public class LoginArgs
{
public static void main(String args[])
{
new operate(args);
}
}
class login
{
private String name;
private String password;
public login(String name,String password)
{
this.name=name;
this.password=password;
}
public boolean validate()
{
if (this.name.equals("abc")&&this.password.equals("123"))
{
return true;
}
else
{
return false;
}
}
}
class operate
{
private String args[];
public operate(String a[])
{
this.args=a;
if (this.args.length!=2)
{
System.out.println("参数输入不正确!");
System.exit(1);
}
if (new login(this.args[0],this.args[1]).validate())
{
System.out.println("登陆成功!");
}
else
{
System.out.println("登陆失败!");
}
}
}

静态的主方法怎样才能调用非static的方法——通过生成对象?

eclipse 中main()函数中的String[] args如何使用?通过String[] args验证账号密码的登录类?静态的主方法怎样才能调用非static的方法——通过生成对象?在类中制作一个方法——能够修改对象的属性值?


在类中制作一个方法——能够修改对象的属性值?

eclipse 中main()函数中的String[] args如何使用?通过String[] args验证账号密码的登录类?静态的主方法怎样才能调用非static的方法——通过生成对象?在类中制作一个方法——能够修改对象的属性值?

原理,要想到temp在栈空间中指向在堆空间中的实际参数(对象)per的值,那修改的就是堆中的对象。

上一篇:mysql sql优化实例


下一篇:《深入解析sas:数据处理、分析优化与商业应用》一1.4 SAS文件和逻辑库