urgentttttttt compare 3 strings

please give me code to compare 3 strings and give them in alphabetical order
[83 byte] By [mady_kiran@yahoo.coma] at [2007-11-27 8:24:15]
# 1
yeah good luck with that
OnBringera at 2007-7-12 20:13:14 > top of Java-index,Java Essentials,New To Java...
# 2
urgentttttttt eh? Dammit, I must be too late again! Sorry
georgemca at 2007-7-12 20:13:14 > top of Java-index,Java Essentials,New To Java...
# 3
You must use the String.compareTo() method.
java_knighta at 2007-7-12 20:13:14 > top of Java-index,Java Essentials,New To Java...
# 4
can u give me some code for that
mady_kiran@yahoo.coma at 2007-7-12 20:13:14 > top of Java-index,Java Essentials,New To Java...
# 5
If you look at the API, you'll know how to write the code. It is not hard, I can assure you.
java_knighta at 2007-7-12 20:13:14 > top of Java-index,Java Essentials,New To Java...
# 6
private boolean stringsEqual(String[] strings){for (int i = 1; i < strings.length(); i++){if (!strings.equals(strings[0])) return false;}return true;}
Aditya.Velalaa at 2007-7-12 20:13:14 > top of Java-index,Java Essentials,New To Java...
# 7

> can u give me some code for that

In case you haven't figured it out yet, it is very unlikely that you will get code. The quickest way to a solution is by looking up the API, write some code that you think should work, test it and then if it doesn't work, ask a specific question on what is wrong with your code (that you will of course include in code-tags).

EvilBroa at 2007-7-12 20:13:14 > top of Java-index,Java Essentials,New To Java...
# 8

> private boolean stringsEqual(String[] strings)

1) Spoonfeeding a newbie to help him cheat at his homework/exam is not the right thing to do

2) You need to use code tags (as you can see, your array brackets got converted as the italic text tag)

3) It is not even the correct code!

java_knighta at 2007-7-12 20:13:14 > top of Java-index,Java Essentials,New To Java...
# 9
Oh my god, the stress has broken her 't' key, we should help her right away!
RedUnderTheBeda at 2007-7-12 20:13:14 > top of Java-index,Java Essentials,New To Java...
# 10
> please give me code to compare 3 strings and give> them in alphabetical orderYou say it's urgentSo urgent, so oh oh urgentJust wait and seeHow urgent my love can beIt's urgent
petes1234a at 2007-7-12 20:13:14 > top of Java-index,Java Essentials,New To Java...
# 11
> urgentttttttt Nassssty hobbitses.~
yawmarka at 2007-7-12 20:13:14 > top of Java-index,Java Essentials,New To Java...
# 12
if(String1 < String2 < String3) return String1;
mkoryaka at 2007-7-12 20:13:14 > top of Java-index,Java Essentials,New To Java...
# 13
> if(String1 < String2 < String3) return String1;Oh please let him reply with: "I tried that, but it didn't work."
EvilBroa at 2007-7-12 20:13:14 > top of Java-index,Java Essentials,New To Java...
# 14
> > if(String1 < String2 < String3) return String1;> Oh please let him reply with: "I tried that, but it> didn't work."Happens all the time. ;-)
CaptainMorgan08a at 2007-7-12 20:13:14 > top of Java-index,Java Essentials,New To Java...
# 15
http://geeklondon.com/blog/view/it-is-urgent
dcmintera at 2007-7-21 22:39:32 > top of Java-index,Java Essentials,New To Java...
# 16
> http://geeklondon.com/blog/view/it-is-urgentMy favorite part - "molested by lemurs". I wish I could start every day with a mental picture like that. High-larious!
cimmerian76a at 2007-7-21 22:39:32 > top of Java-index,Java Essentials,New To Java...
# 17
if ( string1.equals(string2) && string1.equals(string3) ){...}Does it work?
Bruno_Grassellia at 2007-7-21 22:39:32 > top of Java-index,Java Essentials,New To Java...
# 18
> Does it work?Please see point 1) of my previous post.And of course it works, but this is not the complete answer.
java_knighta at 2007-7-21 22:39:32 > top of Java-index,Java Essentials,New To Java...
# 19

> Does it work?

This works:package javaforum;

import java.math.BigInteger;

import java.util.SortedSet;

import java.util.TreeSet;

public class StringCompare {

public static void main(String[] args) throws Exception {

String [] vals = {"foo", "bar", "a", "xyzzy", "aardvark"};

SortedSet<BigInteger> set = new TreeSet<BigInteger>();

for (String s : vals) {

set.add(new BigInteger(s.getBytes("UTF-8")));

}

for (BigInteger bi : set) {

System.out.println(new String(bi.toByteArray(), "UTF-8"));

}

}

}

...if your strings are fixed-length and right-padded with whitespace.

I think.

Dunno that I'd turn it in in response to this assignment, tho.

G

ggaineya at 2007-7-21 22:39:32 > top of Java-index,Java Essentials,New To Java...
# 20

String[] stuff( String[] strSomeStuff )

{

String strPreviousVal = strSomeStuff[0];

for(int x = 0; x < strSomeStuff .length; x++)

{

String strTemp;

if(strSomeStuff[x].compareTo(strPreviousVal) < 0 )

{

strTemp = strSomeStuff[x];

strSomeStuff[x] = strPreviousVal;

strSomeStuff[x-1] = strTemp;

}

strPreviousVal = strSomeStuff[x];

}

return strSomeStuff;

}

Message was edited by:

ZimmerS1337

ZimmerS1337a at 2007-7-21 22:39:33 > top of Java-index,Java Essentials,New To Java...
# 21

> > private boolean stringsEqual(String[] strings)

>

> 1) Spoonfeeding a newbie to help him cheat at his

> homework/exam is not the right thing to do

> 2) You need to use code tags (as you can see, your

> array brackets got converted as the italic text tag)

> 3) It is not even the correct code!

> Please see point 1) of my previous post.

> And of course it works, but this is not the complete answer.

Ok, I agree... sorry!

Bruno_Grassellia at 2007-7-21 22:39:33 > top of Java-index,Java Essentials,New To Java...