- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在自学使用java
进行套接字编程,并且在编译时遇到此问题。我在主类Book
内声明了一个内部类library_s
,并且编译器无法识别在Status
类中定义的变量Book
。我将Book
用作static class
,因为我读到枚举仅存在于静态类中。我想要一个C语言中的"struct"
的类似物,因为我对此很熟悉。我看过其他各种类似的错误,但是它们都没有帮助。请帮忙。谢谢!
public class library_s extends Thread{
private ServerSocket lib_server;
LinkedList<Book> library = new LinkedList<Book>();
//constructor
public library_s(int port) throws IOException{
lib_server = new ServerSocket(port);
lib_server.setSoTimeout(10000);
}
public void run(){
Socket server = lib_server.accept();
System.out.println("Connected to " + server.getRemoteSocketAddress());
DataInputStream is = new DataInputStream(server.getInputStream());
DataOutputStream os = new DataOutputStream(server.getOutputStream());
for(library b : library){
if(b.BookName == is.readUTF(){
if(b.Status == FORISSUE){
//enter rest of the body here
}
}
}
public static class Book{
public String BookName;
public static enum Status {FORISSUE, ISSUED, RENEW, RESERVE};
public Book(String bn){
this.BookName = bn;
this.Status = FORISSUE;
}
}
public static void main(String [] args){
int port = Integer.parseInt(args[0]);
try{
Thread t = new library_s(port);
t.start();
} catch (IOException e){
e.printStackTrace();
}
}
}
}
library_s.java:64: error: cannot find symbol
if(b.Status == FORISSUE){
^
symbol: variable Status
location: variable b of type Book
library_s.java:64: error: cannot find symbol
if(b.Status == FORISSUE){
^
最佳答案
您在类enum
中声明了Book
,因此无法从外部(其他类)识别它。
为了对其进行修复,可以使用与程序包中其他任何类相同的方式声明library_s
内或Book
外的枚举,或者,如果要将该枚举保留在Book
类内,则可以使用以下命令进行访问:
Book.Status.FORISSUE
关于java - 错误: cannot find symbol java for inner class,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25368907/
class Outer { class Inner { } } public class Demo { public static void main(
我在我的 PC 上使用 bitnami WAMP 创建了一个 mysql 服务器,并使用流畅的 SQL 创建了两个表 table_a 和 table_b: CREATE TABLE `table_a`
select sld.linkid,sld.accept,scd.catid,scd.catname,scd.caturl,scd1.parentcatid from sound_li
为什么在实例化通用外部类(连同内部类)时使用菱形运算符会在代码段 2 中产生错误,而代码段 1 却完全没问题? 我知道稀有类型是被禁止的,但我的情况不是稀有类型——在稀有类型中,外部和内部都是通用的,
这不是那么重要(请注意),但它是一个语法特殊性,它是关于可移植性的,我没有找到引用可靠资源或规范的问题(或答案),所以我很好奇: 省略 INNER 是否安全关键字,如果我明确想要 INNER JOIN
同一查询的这两个版本之间的性能有什么区别吗? --Version 1 SELECT p.Name, s.OrderQty FROM Product p INNER JOIN SalesOrderDet
阅读 Doctrine 2 文档时 at this page我可以看到他们有两种方法来指定内部连接的条件: // Example - $qb->expr()->innerJoin('u.Group',
我想知道我怎么能直接从外部类型到达内部类,就好像它是一个静态成员一样: public class Hello { public class UnderHello { v
我有一个这样的界面: public interface SuperInterface { public interface SubInterface { public void
假设有两个表: students (student_id INT, class_id INT); instructors (instructor_id INT, class_id INT); 这两者之
有表 A 和表 B。我想将这些表连接到两列,但仅限于表 A 的选定行。 查询场景: SELECT B.* FROM B INNER JOIN (SELECT * FROM A WHERE A.COLU
今天我了解了SQL Server中的一个东西,叫做INNER LOOP JOIN . 这是什么意思? (谷歌没有提供帮助……或者我应该说……有关它的博客文章有点……技术性,让我大吃一惊)。 此外,在哪
我开始学习 SQL。而且我发现我们经常可以在 JOIN 或内部选择语句的帮助下获得相同的结果。 问题 1(广泛):JOIN 在哪里比内部选择更快,反之亦然? 问题 2(窄):您能解释一下是什么导致了以
我真的很努力地完成这项任务,因此非常感谢任何帮助或指导。 表格: module_uploads +--------------------------+
仅当连接表中存在记录时,我才尝试根据连接表中的条件从用户表中选择一行。如果记录不存在,我想返回该行。我只想在存在 INNER JOIN 记录且 contact_blocked != 1 时不返回该行。
我有一个包含字符的数据库。由于角色的名称不仅在名称与角色分开时才使用。由于有 Male 和 Female 字符,我将它们保存在不同的表中: tbl_player, tbl_maleName, tbl_
[决定如何表述问题并不容易...] 这是一个 example jsfiddle . 紫色的 div ('#inner') 高 1000 像素。 如何制作红色 div ('#out') 的滚动条 - 控
我正在为 wordpress 中的帖子开发一个过滤器,它使用来自 postmeta 的数据:我的日期过滤器正在运行并给我这个查询: 工作查询结果: SELECT SQL_CALC_FOUND_ROWS
我有使用引导类并动态添加 带有引导类和 clearfix 的元素 var li = $("").addClass("list-group-item clearfix"); var div = $(
我已经为 Test_flow 创建了简单的测试套件,但是当我尝试运行该流程时出现错误。 java.lang.RuntimeException: org.mule.api.config.Configur
我是一名优秀的程序员,十分优秀!