01:198:111 Lecture Notes - Lecture 15: Substring

209 views2 pages
Verified Note

Document Summary

A string is a collection of characters. Strings have double quotes to denote they are strings. A string in java is an object. Our dna sequence is a string of (a,g,t,c,) A whole book is one long string. Strings are objects, objects are refereces, strings have methods. This means once a string is constructed, it means that you cannot change any characters within the string. Comparing strings reference the same spot in the memory, abc . String s2= abc ; \both s1 and s2 point to the same place, since they both. String s3=new string( abc ); \this creates a new object that stores the. System. out. println(s1==s3); \this statement is false characters abc in it and thus is different from the s1 and s2. Better way to compare if(s1. compareto(s2)==0) or if(s1. equals(s2)) This is defined in the java as . substring(n,m-1) So in the case of string c = abc . substring(2,3) you will get just c".

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents

Related Questions