[英]Unreachable statement in class call in java
我在 Java 编码,在 android 工作室开发移动应用程序。 我创建了一个 class User
package com.sourcey.materiallogindemo;
public class User {
String email;
String name ;
String mobile ;
String password ;
public User(String email, String name, String mobile, String password) {
this.email = email;
this.name = name;
this.mobile = mobile;
this.password = password;
}
在同一个 package 中,我需要在另一个 class 中使用这个 class
{User mUser = new User(email, name, mobile, password);}
并出现错误:
删除无法访问的语句
我不明白为什么 class 用户无法访问?
您的User
class 似乎没有问题。 您尝试在其中使用User
class 的其他 class 中似乎存在问题。
您可能在定义变量之前从方法返回,因此永远不会到达代码行。 通过提供第二个 class 的全部内容,我可以将我的答案更新为更精确的答案。
在受影响的 class 中检查您的return
方式。 它必须出现在方法的末尾。
您可能在用户实例化之前抛出了一个检查异常
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.