CECS 478 Lecture Notes - Lecture 5: Empty String, Substring

24 views2 pages

Document Summary

A string is an object, similar to the scanner object. Apply methods on an object: nextint( ) nextdouble( ) str. length 5 where length is the method or int str_length = str. length(); An empty string has length of 0. String str = ; (no space between quotation marks) String name = firstname + lastname harryhenry. = firstname + _ + lastname harry henry. String employee = 1234567 + _ + harry henry . String input: enter your last name: (user input) import java. util. scanner; public class name } public static void main(string[] args)} String lastname = in. next(): enter your first and last name:_ . String name = in. next(); (only reads data up to the space!) in. nextline(); Characters of a string: strings are sequences of characters: ; # a a b , char ch = a", string name = harry henry . Each character is in a box and has a position. The first character of the string has a position of 0.

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