string manipulation

String manipulations:
charAt(indexNumber): it returns the char at the given index
length(): returns the total number of characters as int
		length is ALWAYS one unit above the maximum index number
		maxIndex: length()-1;
concat(Value): Concatenation, concats the given value to the String and returns a new value
toLowerCase(): converts to lowercase and returns a new String
toUpperCase(): converts to uppercase and returns a new String
trim(): removes the unused spaces , and returns new String
substring(beginning index, ending index): 
creates substring of the string value from the beginning index till the ending                   
substring(beginning index): 
creates substring of the string value from the beginning index till the end of the stringreplace(old Value, new Value): new value will be replaced with ALL the given old value, and returns new string 
replaceFirs(old Value, new Value): 
new value will be replaced with  the very first given old value, and returns new string
indexOf(Value): 
returns the index number of the first occurred character as an int             
indexOf(Value): returns the index number of first occurred character, as int
lastIndexOf(Value): return the index number of last occurred character, as int
isEmpty(): identifies if the string is empty
                true ==> string is empty,
                false ==> String is not empty
equals(str): checks if two string' visible texts are equal or not
                    cares about the case sensitivity
                        A == a  ==> false
 equalsIgnoreCase(str):  checks if two string' visible texts are equal or not
                 does not care case sensitivity
                    A == a ==> true
 contains(str): checks if the str is contained in the string. returns boolean
                    if str is conatined ==> true
                    otherwise ==> false
 startsWith(str): checks if the string starts with the given str. returns boolean
                if starts with str ==> true
                otherwise ==> false
endsWith(str): checks if the string ended with the given str. returns boolean
                 if ended with str ==> true
                    otherwise ==> false

3.8
5
Gsears 100 points

                                    boolean eq = name.equals(anotherName);                // equality

String fruit = "Apple";
int position = fruit.indexOf("pp");                   // 1 (if not found, -1)

int length = fruit.length()                           // 5 (lenght)

String sub = fruit.substring(1, 4);                   // exp: (1. index get into, 4. index does not)

String upper = fruit.toUpperCase();                   // APPLE

boolean empty = fruit.isEmpty();                      // false, with empty string true
boolean blank = fruit.isBlank();                      // false, only true with white space character

boolean startsWith = fruit.startsWith("app");         // true
boolean endWith = fruit.endsWith("le");               // true
boolean containsDoubleP = fruit.contains("pp");       // true
String part = fruit.substring(0, 2).toLowerCase();    // ap - can be join

3.8 (5 Votes)
0
Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source