sockets - error : cannot find symbol java for inner class -


i teaching myself socket programming using java, , encountering problem while compiling . have declared inner class book inside main class library_s , compiler not recognizing variable status defined in class book. using book static class because read enums exist in static classes. wanted analog "struct" in c because familiar that. have looked @ various other similar errors,, none of them helpful. please out. thank you!

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 " + server.getremotesocketaddress());      datainputstream = 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 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();    }   }  } } 

the compiler gives error

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){                               ^ 

you declared enum inside class book it's not recognized outside (other classes). in order fix it, either declare enum inside library_s or outside book same way other class in package, or, if want keep enum inside class book can access using:

book.status.forissue 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -