 |
|
 |
When posting your question please:- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode HTML tags when pasting" checkbox before pasting anything inside the PRE block, and make sure "Ignore HTML tags in this message" check box is unchecked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question in one forum from another, unrelated forum (such as the lounge). It will be deleted.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-fou
|
|
|
|
 |
|
 |
Hey guys,
I'd like to set the Ringer and Media volume to high automatically when detecting a magnet (I have an Xperia ARC), i could not find such an App that could do that.
Does anyone know how to make this ? is it possible ?
I know about Tasker, but it currently doesn't support the magnetic sensor
Any help is appreciated.
Thank!
|
|
|
|
 |
|
 |
...so there is actually a "magnetic sensor" ?
Just by interest: why would I like to have the phone get loud when "magnetic enlightened"?
|
|
|
|
 |
|
 |
I want code for connect Google earth with JSP code
and JSP code for make web application delivery online
|
|
|
|
 |
|
 |
how much $$ is in your buget? We might need it all.
|
|
|
|
 |
|
 |
Hi all,
Near one or two years (version Java at that time is 1.5x), I have a short code to compare 2 Strings in java like bellow:
String a = "abc";
String b ="abc";//this is load from the database.
CODE 1
if(a==b){
System.out.println("equal");
}else {
System.out.println("dif");
}
and I got the result is dif
I remember because after I change the code to
String a = "abc";
String b ="abc";//this is load from the database.
CODE 2
if(a.equals(b)){
System.out.println("equal");
}else {
System.out.println("dif");
}
It give me the result is equal
Is it true or my eyes is wrong?
Now the CODE 1 always gives the result is equal
modified 4 days ago.
|
|
|
|
 |
|
 |
This is as expected, in Java there is no operator overloading and == always does a reference equality check. To do a value equality check, you need to use .equals (after doing a null check).
|
|
|
|
 |
|
 |
Code1 compares the objects and if they are equal, also both Objects have the same value they are still different objects.
Code2 checks character wise for the value.
It's a common failure.[^].
|
|
|
|
 |
|
 |
sharkbc wrote: Now the CODE 1 always gives the result is equal
Is it true or my eyes is wrong?
Java, regardless of version, has always operated in that way (equals is required.)
So something is wrong in how you are validating this.
Perhaps because despite what your comment says you are not in fact loading it from the database. (An very odd corner case would involve how you are 'loading' it from the database and would indicate an error in the load process.)
|
|
|
|
 |
|
 |
hi Jschell,
I've just modify my question, it must be
...
Is it true or my eyes is wrong?
Now the CODE 1 always gives the result is equal
Im sure at that time, the database is not change and i do not change any other code in the programe, because after we got the mistake, we debug the code and get it.
We just only change if(a==b) to if(a.equals(b))
|
|
|
|
 |
|
|
 |
|
 |
The real problem is that we do not know what you are actually doing.
Again the following has always been true regardless of java version for the major java vendors...
Equality compares references
The method equals() compares value (content of string.)
As I said there are ways which MIGHT present seemingly different results dependent on the specifics of what is going on. But you haven't presented the specifics.
And based ONLY on the code you posted you are comparing references for what you refer to "CODE 1". And reference equality will be equal.
So what are some possible causes for some other difference for some OTHER code?
1. You were not using a real version of java, it was some odd variant.
2. There was something odd about the way in which your database code worked.
3. There was something odd about your data
4. You misinterpreted what was happening before.
5. The real code would make it explicitly obvious why a difference was occurring.
6. The method intern() was being called somewhere (incorrectly called.)
|
|
|
|
 |
|
 |
Where is a initialised from? It is possible that the two objects are the same and then == will return true.
For future reference, if you want to compare two objects always use the equals() method.
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
|
|
|
|
 |
|
 |
sir i need to compress a video file dont know how to compress a video file in java. thanks in advace....
|
|
|
|
 |
|
 |
Firstly, remove your duplicate question above.
Secondly, a quick search[^] will get more information then a generic question here.
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
|
|
|
|
 |
|
 |
Hello,
Nice to see a knowledgeable and very helping web site.. I am new member in Java. But i am perfect programmer. I am interested in Java language ,, kindly guide me .. if anyone respond to me i shall be very thankful.
Ch. Kashif Nadeem
|
|
|
|
 |
|
 |
Start here[^], and if you have a more specific question then please ask it.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
 |
|
|
 |
|
 |
Message Automatically Removed
|
|
|
|
 |
|
 |
Message Automatically Removed
|
|
|
|
 |
|
 |
Message Automatically Removed
|
|
|
|
 |
|
 |
need java code for image segmentation
|
|
|
|
 |
|
 |
That's nice. Have you tried writing something?
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
|
|
|
|
 |
|
 |
List<ImageSegment> segments = image.doSegmentation();
The implementation of doSegmentation is left as an exercise for the reader.
(Seriously, what sort of idiocy does it take to think that you can ask a one line, poorly formatted request for someone to do your entire project, and get anything other than downvotes and sarcastic responses?)
|
|
|
|
 |
|
 |
List<OrderedPair> list1 = new ArrayList<OrderedPair>() ;
OrderedPair e0 = new OrderedPair(); e0.index=0; e0.value=1;
OrderedPair e1 = new OrderedPair(); e1.index=2; e1.value=2;
OrderedPair e2 = new OrderedPair(); e2.index=3; e2.value=3;
ListIterator<OrderedPair> iterator = list1.listIterator();
iterator.add(e0);
iterator.add(e1);
iterator.add(e2);
OrderedPair op1 = (OrderedPair) iterator.previous();
System.out.print("index = "); System.out.print(op1.index);
System.out.print(", value = "); System.out.print(op1.value);
System.out.println();
OrderedPair op2 = (OrderedPair) iterator.previous();
System.out.print("index = "); System.out.print(op2.index);
System.out.print(", value = "); System.out.print(op2.value);
System.out.println();
OrderedPair op3 = (OrderedPair) iterator.previous();
System.out.print("index = "); System.out.print(op3.index);
System.out.print(", value = "); System.out.print(op3.value);
System.out.println();
Above is the code block which works fine on one system but the previous() method on some other system doesnt move the iterator backwards and results in the same object .
Any idea why such a behaviour?
Pritha
|
|
|
|
 |