Computer Science, asked by deekshamahajan5374, 10 months ago

s1="Computer"ors2="Applications"
sopln(s2.lastIndexOf('i') give the output.​

Answers

Answered by RKREINGS
0

kon sa language hai bhai samjhnhi aa rha hai

Answered by mbd3636
0

Strings Packet 2015 January String Notes and String Samples Binary Hex TEST stringasst.java: 1. sumascii 2. RemoveSpecial 3. Palindromes 4. SentenceFun 5. PigLatin 6. 4-letter words 7. panagram Quiz practice (like quiz 1) Work on programs Quiz Strings Holiday Work on programs Work on programs Work on programs Quiz 2 Work on programs Review for test TEST *** IF YOU DO ALL STRING METHODS, YOU GET BONUS 5 POINTS ON YOUR TEST! Each method is worth 50 points up to 3 100s. The 7 th method will be bonus on your test. 1

Instantiating String Objects: String name = new String( Bob ); OR String name = Bob ; String name = ; // initialize to an empty string char data[] = { A, B, C }; String str = new String(data); Comparing Strings: Since String objects store addresses, we cannot compare them with ==, < or >. equals(string) OR equalsignorecase(string s) returns true or false o if (name1.equals(name2)) out.println( Names are the same ); else out.println( Names are different ); o if (name.equals( Bob )) out.println( Names are the same ); else out.println( Names are different ); o o if (name1.equalsignorecase(name2)) out.println( Names are the same ); else out.println( Names are different ); if (name.equalsignorecase( BoB )) out.println( Names are the same ); else out.println( Names are different ); compareto(string) OR comparetoignorecase(string) returns an int o returns 0 if strings hold same value o negative if calling object is less than argument o positive if calling object is greater than argument Example: name = Bob ; name2 = Bob ; int x = name.compareto(name2); //returns 0 //x stores the return value if (x == 0) out.println( Names are the same ); else out.println( Names are different ); //OR you can call the compareto method which each comparison if (name.compareto(name2) == 0) out.println( Names are the same ); else out.println( Names are different ); OR if (name.compareto(name2) == 0) out.println( Names are the same ); else if (name.compareto(name2) < 0) out.println(name + comes before + name2); else out.println(name2 + comes before + name); 2

if it is helpfull please like and follow me

Similar questions