> 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).
> 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!
> 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
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
> > 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!