打印Inet4Address变量时没什么问题。
我得到了一个'运算符+未定义参数类型字符串,void'异常。
我将在班上展示一部分:
public class Command{
private Inet4Address A;
public Inet4Address getA(){
return A;
}
public void showConf(){
System.out.println("Interface A: IP: " + getA().getHostAddress()); // there is a problem
}
}
任何简单的解决方案?
答案 0 :(得分:1)
null
hade a constructor
作为回报,尝试创建Inet4Address
并初始化public class Command{
private String url = "google.com";
private Inet4Address A = null;
public Command() {
super();
try {
A = (Inet4Address) Inet4Address.getByName(url);
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String[] args) {
new Command().showConf();
}
public Inet4Address getA(){
return A;
}
public void showConf(){
System.out.println("Interface A: IP: " + getA().getHostAddress());
}
}
来解决此问题:
Interface A: IP: 64.15.126.118
输出:
CREATE TABLE user (
username text,
password text,
email text,
company text,
PRIMARY KEY (username)
);