2.15 Strings

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Declaring a string

You can declare a string variable just like an int, double, or char. String has a capital "S", however. String wordRelative = " ";

Using a scanner with Strings

wordRelative = scnr.next(); scnr.next(); gets the next input string only up to the next input space, tab, or newline. So typing Betty Sue will only store Betty. Sue will be used for the next input, regardless of what is entered at that point. scnr.nextLine(); reads all user text on the input line up to the newline character resulting from pressing ENTER

String

A sequence of characters. String literal uses double quotes as in "Julia". Various characters may be included: Letters Numbers Spaces Symbols

String Index

Every character in a string has a position number called an index. someString.charAt(0) determines the character at index 0.

String Object

An object consists of internal data items plus operations that can be performed on that data. Two different strings can refer to the same string object.


संबंधित स्टडी सेट्स

Write the chemical formula (ionic)

View Set

Chapter 4 Consolidated Financial Statements and Outside Ownership

View Set

Social Psychology - TESU - Module 1

View Set

Law in Accounting: Chapter 23 Agency Relationships in Business

View Set

ACCT 3230 - Chapter 13 - LearnSmart

View Set

Understanding Business Chapter 9 (77 terms)

View Set