/*
* StringDemo.java
*
* Copyright 2013 Ajay Bhatia <ajay@dumb-box>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*/
public class StringDemo {
public static void main (String args[]) {
String str1 = "BCA";
String str2 = "bca";
if (str1.equalsIgnoreCase(str2))
System.out.println("EQUAL");
else
System.out.println("NOT EQUAL");
String newStr = "This is at least a partial credits-file "
+ " of people that have contributed to the Linux project."
+ " It is sorted by name and name formatted to allow easy "
+ "grepping and beautification by scripts. The fields "
+ "are: name (N), email (E), web-address (W), PGP key "
+ " ID and fingerprint (P), description (D), and "
+ "snail-mail address (S)."
+ "Thanks,"
+ "Linus";
for (int i = 0; i < newStr.length(); i++) {
if (newStr.charAt(i) == ' ') {
System.out.print(newStr.charAt(i));
i++;
System.out.print(String.valueOf(newStr.charAt(i)).toUpperCase());
continue;
}
System.out.print(newStr.charAt(i));
}
}
}
* StringDemo.java
*
* Copyright 2013 Ajay Bhatia <ajay@dumb-box>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*/
public class StringDemo {
public static void main (String args[]) {
String str1 = "BCA";
String str2 = "bca";
if (str1.equalsIgnoreCase(str2))
System.out.println("EQUAL");
else
System.out.println("NOT EQUAL");
String newStr = "This is at least a partial credits-file "
+ " of people that have contributed to the Linux project."
+ " It is sorted by name and name formatted to allow easy "
+ "grepping and beautification by scripts. The fields "
+ "are: name (N), email (E), web-address (W), PGP key "
+ " ID and fingerprint (P), description (D), and "
+ "snail-mail address (S)."
+ "Thanks,"
+ "Linus";
for (int i = 0; i < newStr.length(); i++) {
if (newStr.charAt(i) == ' ') {
System.out.print(newStr.charAt(i));
i++;
System.out.print(String.valueOf(newStr.charAt(i)).toUpperCase());
continue;
}
System.out.print(newStr.charAt(i));
}
}
}
Comments
Post a Comment
Post Your Valuable Comments