>From the String source (I'm getting too used to sniff inside Sun's code to
see what it is doing):

    public boolean equals(Object anObject) {
        if (this == anObject) {
            return true;
        }
        if (anObject instanceof String) {
            String anotherString = (String)anObject;
            int n = count;
            if (n == anotherString.count) {
                char v1[] = value;
                char v2[] = anotherString.value;
                int i = offset;
                int j = anotherString.offset;
                while (n-- != 0) {
                    if (v1[i++] != v2[j++])
                        return false;
                }
                return true;
            }
        }
        return false;
    }

Not too bad if the compared strings don't have the same length. Anyway I
think switch will be always better than if...else.

IMHO I use to work only with int and translate them to String only for
printing and for input.

> -----Mensaje original-----
> De: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]En nombre de marc
> fleury
> Enviado el: jueves, 07 de febrero de 2002 8:30
> Para: Jboss-Development@Lists. Sourceforge. Net
> Asunto: [JBoss-dev] so how fast is string comparison
>
>
> when we do
>
> if (string.equals("this"))
>
> else if (string.equals("that"))
>
> how much slower is it than
>
> switch (stringAsInt)
> case THIS:
>
> case THAT:
>
> I assume a lot as String manipulation is just dead slow, but I could be
> wrong, I really don't know.
>
> marcf
>
>
> _______________________________________________
> Jboss-development mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-development
>
>


_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to