• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problems with object orientation  RSS feed

 
Marvin Legend
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whats up guys !

I have a class in Java which is a server, I put this server class, the argument port, for example if I call this class I would like: new Server (5000); 5000 is the argument of this server class, so I created a new frame with a button class, and action of this button I call this class server 5 times, but with different arguments and looked like this:




But the problem is that when I click the button, the only server that initiates the first is on port 5000, I've done the debug here and noticed that only the first statement is executed, the other 4 are not, why is that?

I've tried to do so:



Still does not work, I did the debug in both cases and only the server port 5000 is started, someone help?
 
Paul Clapham
Sheriff
Posts: 22828
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your main problem is that none of that code will compile, so running it is pointless.

In the first version, you have several local variables declared, and they all have the same name. This isn't allowed, and when you compile the code the compiler will tell you so. Don't ignore what the compiler tells you.

In the second version your line which says "New Server (5000)" isn't valid because "New" followed by "Server" isn't grammatical. The other lines attempt to create a new object of type "server", but the first line doesn't. Remember that Java is a case-sensitive language so "New" and "new" are different, and likewise "Server" and "server" are different.

Anyway, I recommend getting your code to compile before you proceed. If you have trouble understanding the error messages from the compiler, then certainly ask us about those messages here.
 
Marvin Legend
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:Your main problem is that none of that code will compile, so running it is pointless.

In the first version, you have several local variables declared, and they all have the same name. This isn't allowed, and when you compile the code the compiler will tell you so. Don't ignore what the compiler tells you.

In the second version your line which says "New Server (5000)" isn't valid because "New" followed by "Server" isn't grammatical. The other lines attempt to create a new object of type "server", but the first line doesn't. Remember that Java is a case-sensitive language so "New" and "new" are different, and likewise "Server" and "server" are different.

Anyway, I recommend getting your code to compile before you proceed. If you have trouble understanding the error messages from the compiler, then certainly ask us about those messages here.


Bro !
I edit my quastion ! Look again ! I'm Brazilian, and i translate my question and the information was wrong ! the objects server are differentes ! The translator remove de numbers ! Right = server1, server2, server 3 .... Ok ?
 
Paul Clapham
Sheriff
Posts: 22828
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, my guess is that when you create a Server object, it goes into an endless loop. Perhaps you have some code which asks it to wait for a connection?
 
Charles D. Ward
Ranch Hand
Posts: 99
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Marvin Legend wrote:
I edit my quastion ! Look again ! I'm Brazilian, and i translate my question and the information was wrong ! the objects server are differentes ! The translator remove de numbers ! Right = server1, server2, server 3 .... Ok ?


Well then maybe you shouldn't attempt to translate CODE.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!