Declaring variables The type could be: int double char String name is anything you want like lowerCaseWord.

Slides:



Advertisements
Similar presentations
Java
Advertisements

Strings Testing for equality with strings.
1 Working with String Duo Wei CS110A_ Empty Strings An empty string has no characters; its length is 0. Not to be confused with an uninitialized.
C++ Basics March 10th. A C++ program //if necessary include headers //#include void main() { //variable declaration //read values input from user //computation.
Chapter 3 DATA: TYPES, CLASSES, AND OBJECTS. Chapter 3 Data Abstraction Abstract data types allow you to work with data without concern for how the data.
Java Programming Strings Chapter 7.
Constants and Data Types Constants Data Types Reading for this class: L&L,
Constants A constant is a variable whose value is expected to remain the same throughout a program It is considered “good programming style” to use constants.
Programming 2 CS112- Lab 2 Java
CIS 234: Strings. What Is a String? series of characters enclosed in double quotes characters can include letters (lower case and upper case), digits,
Strings In Java, strings are contained in an object that is an instance of the String class. String in java is the name of a class. That’s why it starts.
Fundamental Programming Structures in Java: Strings.
The Class String. String Constants and Variables  There is no primitive type for strings in Java.  There is a class called String that can be used to.
Lab session 3 and 4 Topics to be covered Escape sequences Escape sequences Variables /identifiers Variables /identifiers Constants Constants assignment.
The Java String Type CSC 1401: Introduction to Programming with Java Week 7 – Lecture 1 Wanda M. Kunkle.
Chapter 2 types, variables, methods Pages Horstmann.
1 Strings and String Operations  What is a Strings?  Internal Representation of Strings  Getting Substrings from a String  Concatenating Strings 
Strings.
CPS120: Introduction to Computer Science Variables and Constants Lecture 8 - B.
Java Data Types. Primitive Data Types Java has 8 primitive data types: – char: used to store a single character eg. G – boolean: used to store true or.
Primitive Variables.
Examples of comparing strings. “ABC” = “ABC”? yes “ABC” = “ ABC”? No! note the space up front “ABC” = “abc” ? No! Totally different letters “ABC” = “ABCD”?
CS177 Week2: Recitation Primitive data types and Strings with code examples.
Assignment An assignment statement changes the value of a variable The assignment operator is the = sign total = 55; Copyright © 2012 Pearson Education,
 Structures are like arrays except that they allow many variables of different types grouped together under the same name. For example you can create.
String Class. Variable Holds a primitive value or a reference to an object. Holds a primitive value or a reference to an object. A reference lets us know.
Coding Bat: Ends in ly Given a string of even length, return a string made of the middle two chars, so the string "string" yields "ri". The string.
CSC Programming I Lecture 9 September 11, 2002.
Chapter 3A Strings. Using Predefined Classes & Methods in a Program To use a method you must know: 1.Name of class containing method (Math) 2.Name of.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming strings.
Welcome to AP Computer Science A We use the Java language, but this class is much more rigorous than Intro to Java More programming, but also more theory.
Values, Types, and Variables. Values Data Information Numbers Text Pretty much anything.
Java – Variables and Constants By: Dan Lunney. Declaring Variables All variables must be declared before they can be used A declaration takes the form:
1 Predefined Classes and Objects Chapter 3. 2 Objectives You will be able to:  Use predefined classes available in the Java System Library in your own.
Strings CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Primitive Data Types 1 In PowerPoint, point at the speaker icon, then click the "Play" button.
Strings, Characters, and Regular Expressions Session 10 Mata kuliah: M0874 – Programming II Tahun: 2010.
CHAPTER 6 GC Strings. THE CLASS STRING  Contains operations to manipulate strings.  String:  Sequence of zero or more characters.  Enclosed.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
1 A Balanced Introduction to Computer Science, 2/E David Reed, Creighton University ©2008 Pearson Prentice Hall ISBN Chapter 15 JavaScript.
Characters must also be encoded in binary. ASCII maps characters to numbers.
Strings A String is a sequence of letters
Java String Methods - Codehs
String Methods Programming Guides.
Agenda Warmup Lesson 1.4 (double precision, String methods, etc)
Chapter 6 GC 101 Strings.
String class.
Method Mark and Lyubo.
String Objects & its Methods
Chapter 7: Strings and Characters
Unit-2 Objects and Classes
Part a: Fundamentals & Class String
String Methods: length substring
Tonga Institute of Higher Education
Coding Concepts (Data- Types)
Variables in C Declaring , Naming, and Using Variables.
Lecture 10 Strings CSE /26/2018.
JavaScript: Objects.
Agenda Warmup Lesson 1.6 (Do-while loops, sentinels, etc)
String Methods.
Agenda Warmup Lesson 1.4 (double precision, String methods, etc)
Exam Prep.
Each object belongs to a class
Boolean in C++ CSCE 121.
Variables and Constants
Strings in Java Strings in Java are also a reference type.
Pre-AP® Computer Science Quiz
String Methods Strings have actions known as method. We will review a few of the methods associated with strings that are a part of the built in Java.
What We Want To Do User enters: Mary Smith
Presentation transcript:

Declaring variables The type could be: int double char String name is anything you want like lowerCaseWord

Declaring Variables

Calling Methods This calls toLowerCase on name. It returns the name lower cased This calls length on name. It returns how many letters in the word This calls substring on name. It returns the name with cutting off the 1 st letter. So it would be “ozo” NOTE ALL OF THESE METHODS DO NOT AFFECT name

Saving method results

Bringing it all together So we will need to find a lower case version of the whole phrase, then cut off the first letter. We will also need to get the first letter capitalized and save that. That bring it all together and print it out.

So we will need to find a lower case version of the whole phrase, then cut off the first letter. First we lower case the phrase saving it as a String lowerCase Then cut off the 1 st letter of lowerCase and save that as cutOff This could be done shorter below:

We will also need to get the first letter capitalized and save that. This is a bit tricky, we are going to capitalize first, then get the first character. Again we call toUpperCase on phrase and save it as String upperCase The save first letter as char firstLetter Or shorter as:

In total