danqianchen
BAN USER
public class OutputWithoutLoop
{
public static void main(String[] args)
{
output(100);
}
public static void output(int number)
{
while(number > 0)
{
System.out.println(" number is :" + number);
number--;
}
}
}
very good example
- danqianchen April 19, 2012unchecked exception: error and runtime exception and its subclass
checked exception: is those subclasses of Exception that must be handled by try catch block, including IOException,SQLException and so on.
RepHi, I’m Jamie from the Portsmouth USA and I am working as an account manager. I work for a ...
Repstephenroach41, Android Engineer at Alliance Global Servies
Experienced and professional facilities coordinator with a commitment to customer service. An analytical business person as well as a practiced ...
Replonnacribbs, DIGITAL MARKETING at Athena Health
I am a Market Research Manager responsible for selecting the appropriate research methodology and supporting techniques to meet a defined ...
RepMariaHobbs, Consultant at Adobe
Hi, I am Maria Hobbs from NewYork.Teach career development courses for designated areas. Develop, evaluate and revise course materials ...
RepRebecaMoore, Consultant at AMD
I am working as an art teacher with “Glory High School,” and develop interests for art and creative expression in ...
public class TestPalindrome
- danqianchen April 19, 2012{
public static void main(String[] args)
{
String newString = "Murder for a jar of red rum.";
String otherString = newString.replaceAll( "\\W", "" );
System.out.println(otherString);
String otherString2 = reverse2(otherString);
System.out.println(otherString2);
System.out.println(otherString);
if(otherString.equalsIgnoreCase(otherString2))
System.out.println("Palindrome");
else
System.out.println("not Palindrome");
}
public static String reverse2(String str)
{
char[] a = str.toCharArray();
int middle = str.length()/2;
int length = str.length() - 1;
for(int i = 0; i <= middle; i++)
{
char temp = a[i];
//System.out.println("temp is:" + temp);
//System.out.println("a[i] is:" + a[i]);
//System.out.println("a[length-i] is:" + a[length-i]);
a[i] = a[length-i];
a[length-i] = temp;
}
return new String(a);
}
}