|
Nagy Vilmos wrote: The JRE requires a method with the signature
If you are using Java 1.5 or later you can also use the signature:
<br />
public static void main(String... args)<br />
There is a difference between the two, although not really significant for a main method. The following works with the vararg signature, not with the array signature:
<br />
MyClass.main("A", "B");<br />
This will not compile if you are using the main(String[] args) form. But how often do you do this with a main method anyway?
|
|
|
|
|
j
modified on Tuesday, September 13, 2011 8:00 AM
|
|
|
|
|
This is far too much code for anyone to read through. Explain what you are trying to do, what fails, and where it goes wrong.
|
|
|
|
|
I'll give you some general tips to start with:
0. The client needs to run on two threads, one to receive messages and one to send. Normally the main thread will be the sending thread and also the UI.
1. I would separate the communication from the processing into two classes. Have another class in the server, something like ClientSession that deals with any logic. This would have the name of the client session and a reference to the main chat server.
2. As with the connection, the server should be separated into UI and logic. By having these separated it will eb clearer to see what is what. A simple call-back from the server will update the UI.
3. Check your names, you have so many different styles it becomes confusing. Do not use underscores. All variables should use camel case likeThis and classes should be pascal case ThisWay .
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
if(ddirection > 8.00)
{
direction = Direction.DOWN;
}
if(ddirection < 0.00)
{
direction = Direction.UP;
}
if(direction == Direction.UP)
{
ddirection = ddirection + 0.05;
}
else
{
ddirection = ddirection + 0.05;
}
I am trying to make the double ddirection go up and down between 8.0 and 0.0
The above code does not work. What else can i do?
Direction is an enum, containing UP and DOWN. direction is a variable of type Direction.
|
|
|
|
|
How does it not work, is ddirection a local variable or a class one. If it is a local one what is the initial value.
That being said why are you doing the same thing in the direction == Direction.UP if block as in the else block.
|
|
|
|
|
I am not sure quite what your values may be for this variable, but if you want it to lie only within the range 0.0 to 8.0, then what is wrong with:
if(ddirection > 8.00)
{
ddirection = 8.00;
}
else if(ddirection < 0.00)
{
ddirection = 0.00;
}
|
|
|
|
|
Member 7991625 wrote: What else can i do?
fix it.
1. there is a blatant mistake, actually a very small one (about the size of half a character) with big consequences. And you should have gathered it by observing the actual behavior (or simply by reading the code, which is what you made us do).
2. once the big error is fixed, there still is a little extra flaw: you have organized it such that you first need to get outside the valid range in order to change directions. That isn't very good, you should predict you're going to leave the range and then prevent that.
|
|
|
|
|
half a character
@ Member
Rename that Double-Value, your variables are quite similar, which makes it harder than needed to read the code.
Easy to read == Easy to maintain.
(EDIT: did I really make a "==" )
regards Torsten
I never finish anyth...
|
|
|
|
|
I think that you want ddirection to oscillate between two values every time this code is executed so,
(initialize ddirection at 0.0
{
ddirection = 8.0 - ddirection;
direction = (ddirection == 0.0) ? direction.DOWN : direction.UP;
}
|
|
|
|
|
could any one can explain about ontology ?
|
|
|
|
|
|
but there were soo many definitions at soo many situations...
so i want to be clear what s ontology in information science...
its definition says conceptualization of a specific domaim...
what does that really mean... ?????
|
|
|
|
|
Sorry, I don't know, you will need to research it. This is a Java technical forum, and your question is some way outside of the subject.
|
|
|
|
|
sry.. ontology s a general concept..
there s a separate api fof this ontology is jena ontology tool.. so nly i askd
|
|
|
|
|
|
im new to this site..
im interested in java programming...
could any one help me how to begin it ???
|
|
|
|
|
|
can i get some tutorials and sample projects ?
|
|
|
|
|
|
Hi all,
I'm doing a sort of academic work for university and I'm looking for how JPA manages different data stores (I have to compare and contrast this with ADO.NET)...
Does anyone can give me an advide for some docs explain this behavior? I've found only that Java connects to every and only JDBC data sources defining properties for conn. in persistence.xml or using a JNDI connection wherever the JDBC data source is mapper in the application server....
Thanks
Ste
Ste
|
|
|
|
|
once you've connected to the DB, the mechanics of storage are down to the database itself. What is being stored is well documented in theJPA specification [links at the end of the page][^]
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
|
Wow, Java with command prompt!! Sure bring back memories.
My favorite IDE for Java is always NetBeans[^]. But make sure you ask for permission if you want to use NetBeans in class, some basic Java is easier to grasp in command prompt.
Excuse me for my improper grammar and typos.
It's because English is my primary language, not my first language.
My first languages are C# and Java.
VB, ASP, JS, PHP and SQL are my second language.
Indonesian came as my third language.
My fourth language? I'm still creating it, I'll let you know when it's done!
|
|
|
|
|
Okay, thanks. will do.
Sir.Dre
|
|
|
|