Monday, May 24, 2010

Java strings...?

i need to compare to strings (or even chars if it's easier for you)


meaning i have


static int[] x = new int[30];


static string[] a = new string[100];





and somewhere i have to do this:


if (a[x[k-1]]==a[x[k]] %26amp;%26amp; a[x[k]]!="e" || a[x[k]]!="i") - which is fine in C++ but not in java. how do i compare 2 strings





PS i just need to know how to convert == and !=. and i don't want any references to the string class

Java strings...?
In java you do not use == or != when comparing strings. Instead use:





if (myString.equals("e")) -- to replace ==


if !(myString.equals("i")) -- to replace !=
Reply:If you prefer to use equal() method to compare the two strings. You can download the example code here :

elephant ear

No comments:

Post a Comment