Characters, Strings and Text Processing in Java
|
|
- Jasper Moore
- 5 years ago
- Views:
Transcription
1 Characters, Strings and Text Processing in Java Concepts: Characters, Code Points, Encodings Unicode: A to Z and more Jonas Kvarnström.liu.se 2012 Jonas Kvarnström.liu.se 2012 Characters 3 Character Repertoires 4 Step 1: A character Abstract definition: "An atom of information" Concrete examples: A B C D # "! ( ) å ä ö ċ õ ĕ ķ Ħ Ŗ ǽ Ґ ы Ω Ą Ж ΐ ਈਉਊਏਓਔਕਖਗਘਛ RM ریال 略 X Step 2: A character repertoire Just an unordered set of available characters ASCII: 128 characters, including 33 control characters ISO 646 SE: Like ASCII, but remove [ ]{\, add åäöåäö ISO Latin 1: Adds 32 control, 96 symbols (west Europe) ISO Latin 2: Adds 32 control, 96 symbols (east/central) Java 7 uses Unicode 6.0: Graphic characters: 109,242 Formatting: 142 Control: 65 Private Use: 137,468 Surrogate: 2,048 Non character: 66 Reserved: 865,081 More information:
2 Coded Character Sets 5 Coded Character Sets (2) 6 Step 3: A coded character set Assigns an integer for each character in the repertoire ASCII: values 0 to = tab, 10 = line feed, 32 = space, 65 = A, 66 = B, ISO Latin 1: Like ASCII, with additional at EBCDIC (IBM mainframes): 129 = a, 130 = b,, 137 = i, 145 = j, Coded Character Sets (3) 7 Character Encodings 8 Unicode someexamples: FF Like ISO Latin-1 03D0..03D6 GREEK BETA SYMBOL..GREEK PI SYMBOL 05B0..05B9 HEBREW POINT SHEVA..HEBREW POINT HOLAM 0A01 GURMUKHI SIGN ADAK BINDI ਈਉਊਏਓਔਕਖਗਘਛ 0EDC..0EDD LAO HO NO..LAO HO MO ໜໝༀ A HOUSE..APL FUNCTIONAL SYMBOL ALPHA 2E80..2E99 CJK RADICAL REPEAT..CJK RADICAL RAP 33E0 IDEOGRAPHIC TELEGRAPH SYMBOL FOR DAY ONE 1039F UGARITIC WORD DIVIDER FFFD <private-use >..<private-use-10fffd> Step 4: Character encoding We have a number for each character In a computer, this number must be coded into one or more bytes! At most 256 characters? Simple one byte per character Unicode: Won t even fit in two bytes! Most common encoding: UTF 8, variable F: 0xxxxxxx (same as ASCII!) FF: 110xxxxx 10xxxxxx FFFF: 1110xxxx 10xxxxxx 10xxxxxx FFFFF: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx Efficient for English and similar languages Informative bit pattern! Example for UTF 8: Räksmörgås, 72 c3 a4 6b 73 6d c3 b c3 a5 73 In ISO Latin 1, this byte sequence would mean "rã ksmã rgã s"
3 Characters in Java 10 Characters Strings StringBuilders The char data type: 16 bits wide, storing Unicode characters from 0 to char c = 'x'; char c = 120; // Makes c an 'x', since Unicode character #120 is an 'x'. Escape codes represent unprintable characters '\nnn': Character with octal value nnn ('\012' == character 10 = line feed) '\unnnn': Character with hex value nnnn ('\u03d0' == greek beta) '\b': Backspace (ASCII 8) '\t': Tab (ASCII 9) '\n': Newline (ASCII 10) '\f': Form feed (ASCII 12) '\r': Carriage return (ASCII 13) '\'': Single quote (quote backslash quote quote) '\\': A backslash Jonas Kvarnström.liu.se 2012 The Character Class 11 Strings 1: Strings are s 12 Static utility methods in wrapper class java.lang.character Character types islowercase(), isuppercase(), istitlecase(), isdigit(), isletter(), isletterordigit(), iswhitespace(), Use these methods to accept greek lower case, kyrillic upper case, non arabic digits, and so on Character ch;...; if (ch.isletter()) {... Case conversion tolowercase(), touppercase(), totitlecase() The letter 'lj': Lower case 'lj'. Upper case 'LJ'. Title case 'Lj'. Strings in Java are objects, not primitive types or arrays str Immutable: Any modifications actually create new String objects String str = "Hello"; String literal in quotes escape codes can be used 5 ( 5) [0] H [1] e String pointer String object Character array used internally for storage Uses UTF-16 to support all of Unicode
4 Strings 2: Literals 13 Strings 3: Useful Methods 14 Even string literals represent objects Can be used directly, without being assigned to variables System.out.println("Hello".()); // 5 Represents a String object with 5 characters For every string literal in a class, a String object is interned Pre allocated in a global pool So never write new String("Hello"); you will just create an additional copy! Global Pool of String Literals 5 ( 5) [0] H [1] e String: Useful methods Length "foo".() 3 Specific character "abcdefgabc".charat(1) 'b' Substring (end index is exclusive!) "abcdefgabc".substring(3,7) "defg" Without initial/trailing whitespace "\nfoo".trim() "foo" Split around regular expression "foo:bar::gazonk".split(":") {"foo", "bar", "", "gazonk" "foo:bar::gazonk".split("o*") {"f", ":bar::gaz", "nk" and many more String conversions touppercase(), tolowercase() Strings 4: String Comparisons 15 Strings 5: String Comparisons 16 Comparing Strings equals(string other), equalsignorecase(string other) True if the strings are equal, false otherwise As usual, == tests whether they are stored in the same location! compareto(string other), comparetoignorecase(string other) 1 if this before other, 0 if equal, 1 if this after other Comparing Strings: == or equals()? String str1 = xy ; String str2 = x + y ; System.out.println(str1 == str2); System.out.println(str1.equals(str2)); // false // true str1 2 ( 2) [0] x [1] y str2 2 ( 2) [0] x [1] y
5 Strings 6: String Comparisons Different countries have different sorting rules Comparing á to a, sorting ß as ss, sorting ä as a with umlaut (German) or after å (Swedish) Use Collator, RuleBasedCollator for searching and sorting 17 // Uses system locale Collator collator = Collator.getInstance(); // Explicitly specify locale Locale sverige = Locale.forLanguageTag( sv-se ); Collator collator2 = Collator.getInstance(sverige); collator.compare( åäö", ÅÄÖ") // -1, 0, 1 Locale: Specifies language, country, Jonas Kvarnström.liu.se 2012 Formatting 1: Primitive to String 19 Formatting 2: to String 20 Convert primitive datatypes to text: Use the static String.valueOf() methods static String valueof(char c) { static String valueof(int i) { static String valueof(boolean b) { String str = String.valueOf(127); // "127" Every object has a string representation java.lang. has a tostring() method Returns a String representing the object System.out.println( o) calls o.tostring() Example: public class Circle { private double x, y, r; private Circle(double x, double y, double r) { this.x = x; this.y = y; this.r = r; public static void main(string[] args) { System.out.println(new Circle(2.0, 4.0, 5.0)); >> java Circle Circle@a5e17120
6 Formatting 3: to String 21 Formatting 4: String Concatenation 22 Why returns the class name + "@" + a unique ID The method should be overridden! Example: public class Circle { public String tostring() { return "Circle[" + x + ", " + y + ", " + r + ']'; public static void main(string[] args) { System.out.println(new Circle(2.0, 4.0, 5.0)); java Circle Circle[2.0, 4.0, 5.0] In the previous slide: "Circle[" + x + ", " + y + ", " + r + ']' Java overloads the + operator for string concatenation. How, when String objects are immutable? StringBuilder: Used for concatenating / manipulating char sequences Used implicitly for "+" on Strings translation by the Java compiler final StringBuilder buf = new StringBuilder(""); buf.append("circle["); buf.append(x); buf.append(", "); buf.append(y); buf.append(", "); buf.append(r); buf.append(']'); return buf.tostring(); Make a String with the same contents as the StringBuilder Formatting 5: Immutable Strings! 23 Formatting 6: StringBuilder Example 24 Constructing Strings in loops: Remember, String objects are immutable! public class ArrayList { private [] elements; private int size; public String tostring() { String result = "ArrayList<"; for (int i= 0; i< size; i++) { if (i!= 0) result = result + ", "; result = result + elements[i].tostring(); result = result + ">"; return result; Copy string into StringBuffer Append a few characters Copy StringBuffer into new String Discard old String and StringBuffer For efficiency, use StringBuilder directly (In loops and similar situations) public class ArrayList { private [] elements; private int size; public String tostring() { final StringBuilder buf = new StringBuilder(); buf.append("arraylist<"); for (int i = 0; i < size; i++) { if (i!= 0) buf.append(", "); buf.append(elements[i].tostring()); buf.append(">"); return buf.tostring(); Append a few characters Copy StringBuffer into new String Discard StringBuffer
7 Formatting 7: Detailed Control 25 Formatting 8: Detailed Control 26 For more detailed control over output: String.format() static method In PrintStream: printf() System.out.printf("Hello, %s!\n", person.name);// And so on String s1 = String.format("Hello, %s! You are %d years old.\n", person.name, person.age); // Minimum 30, maximum 40 characters (padded with spaces) String s2 = String.format("Hello, %30.40s!\n", person.name); For even more control over output, create a Formatter StringBuilder sb = new StringBuilder(); Formatter formatter = new Formatter(sb, Locale.US); // Here we specify an explicit locale String s3 = String.format(Locale.FRANCE, "e = %+10.4f", Math.E); // "e = +2,7183" // Advanced formatting: Use the same parameter multiple times Cadar c = new GregorianCadar(1995, MAY, 23); String s4 = String.format("Duke's Birthday: %1$tm %1$te,%1$tY", c); // s.equals("duke's Birthday: May 23, 1995") Parsing: String to Primitive 27 Convert text to primitive data: Use the corresponding wrapper class In class Integer: static int parseint(string str); In class Float: static float parsefloat(string str); In class Double: static double parsedouble(string str); float val = Float.parseFloat("127"); // 127.0f To split strings into "words", see also: StringTokenizer splits strings at given break characters (such as whitespace) String.split() splits strings using regular expression patterns StreamTokenizer for Java like languages (parses comments, ) BreakIterator for natural languagetext
Assoc. Prof. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.
Assoc. Prof. Marenglen Biba (C) 2010 Pearson Education, Inc. All Advanced Java This chapter discusses class String, class StringBuilder and class Character from the java.lang package. These classes provide
More informationAssoc. Prof. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.
Assoc. Prof. Marenglen Biba (C) 2010 Pearson Education, Inc. All This chapter discusses class String, from the java.lang package. These classes provide the foundation for string and character manipulation
More informationJava characters Lecture 8
Java characters Lecture 8 Waterford Institute of Technology January 31, 2016 John Fitzgerald Waterford Institute of Technology, Java characters Lecture 8 1/33 Presentation outline Estimated duration presentation
More informationStrings, Strings and characters, String class methods. JAVA Standard Edition
Strings, Strings and characters, String class methods JAVA Standard Edition Java - Character Class Normally, when we work with characters, we use primitive data types char. char ch = 'a'; // Unicode for
More informationA variable is a name for a location in memory A variable must be declared
Variables A variable is a name for a location in memory A variable must be declared, specifying the variable's name and the type of information that will be held in it data type variable name int total;
More informationSTRINGS AND STRINGBUILDERS. Spring 2019
STRINGS AND STRINGBUILDERS Spring 2019 STRING BASICS In Java, a string is an object. Three important pre-built classes used in string processing: the String class used to create and store immutable strings
More informationUTF and Turkish. İstinye University. Representing Text
Representing Text Representation of text predates the use of computers for text Text representation was needed for communication equipment One particular commonly used communication equipment was teleprinter
More informationMore on variables and methods
More on variables and methods Robots Learning to Program with Java Byron Weber Becker chapter 7 Announcements (Oct 12) Reading for Monday Ch 7.4-7.5 Program#5 out Character Data String is a java class
More informationStrings, characters and character literals
Strings, characters and character literals Internally, computers only manipulate bits of data; every item of data input can be represented as a number encoded in base 2. However, when it comes to processing
More informationRepresenting Characters and Text
Representing Characters and Text cs4: Computer Science Bootcamp Çetin Kaya Koç cetinkoc@ucsb.edu Çetin Kaya Koç http://koclab.org Winter 2018 1 / 28 Representing Text Representation of text predates the
More informationAn overview of Java, Data types and variables
An overview of Java, Data types and variables Lecture 2 from (UNIT IV) Prepared by Mrs. K.M. Sanghavi 1 2 Hello World // HelloWorld.java: Hello World program import java.lang.*; class HelloWorld { public
More information"Hello" " This " + "is String " + "concatenation"
Strings About Strings Strings are objects, but there is a special syntax for writing String literals: "Hello" Strings, unlike most other objects, have a defined operation (as opposed to a method): " This
More informationWe now start exploring some key elements of the Java programming language and ways of performing I/O
We now start exploring some key elements of the Java programming language and ways of performing I/O This week we focus on: Introduction to objects The String class String concatenation Creating objects
More informationSOFTWARE DEVELOPMENT 1. Strings and Enumerations 2018W A. Ferscha (Institute of Pervasive Computing, JKU Linz)
SOFTWARE DEVELOPMENT 1 Strings and Enumerations 2018W (Institute of Pervasive Computing, JKU Linz) CHARACTER ENCODING On digital systems, each character is represented by a specific number. The character
More informationChapter 10: Text Processing and More about Wrapper Classes
Chapter 10: Text Processing and More about Wrapper Classes Starting Out with Java: From Control Structures through Objects Fourth Edition by Tony Gaddis Addison Wesley is an imprint of 2010 Pearson Addison-Wesley.
More informationJava Basic Datatypees
Basic Datatypees Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in the memory. Based on the data type of a variable,
More informationData Types Literals, Variables & Constants
C/C++ PROGRAMMING Data Types Literals, Variables & Constants Copyright 2013 Dan McElroy Under the Hood As a DRIVER of an automobile, you may not need to know everything that happens under the hood, although
More informationGetting started with Java
Getting started with Java Magic Lines public class MagicLines { public static void main(string[] args) { } } Comments Comments are lines in your code that get ignored during execution. Good for leaving
More informationStrings. Strings and their methods. Dr. Siobhán Drohan. Produced by: Department of Computing and Mathematics
Strings Strings and their methods Produced by: Dr. Siobhán Drohan Department of Computing and Mathematics http://www.wit.ie/ Topics list Primitive Types: char Object Types: String Primitive vs Object Types
More informationCS 1301 Ch 8, Part A
CS 1301 Ch 8, Part A Sections Pages Review Questions Programming Exercises 8.1 8.8 264 291 1 30 2,4,6,8,10,12,14,16,18,24,28 This section of notes discusses the String class. The String Class 1. A String
More informationCST242 Strings and Characters Page 1
CST242 Strings and Characters Page 1 1 2 3 4 5 6 Strings, Characters and Regular Expressions CST242 char and String Variables A char is a Java data type (a primitive numeric) that uses two bytes (16 bits)
More informationIndex COPYRIGHTED MATERIAL
Index COPYRIGHTED MATERIAL Note to the Reader: Throughout this index boldfaced page numbers indicate primary discussions of a topic. Italicized page numbers indicate illustrations. A abstract classes
More informationString. Other languages that implement strings as character arrays
1. length() 2. tostring() 3. charat() 4. getchars() 5. getbytes() 6. tochararray() 7. equals() 8. equalsignorecase() 9. regionmatches() 10. startswith() 11. endswith() 12. compareto() 13. indexof() 14.
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationChapter 2: Using Data
Chapter 2: Using Data TRUE/FALSE 1. A variable can hold more than one value at a time. F PTS: 1 REF: 52 2. The legal integer values are -2 31 through 2 31-1. These are the highest and lowest values that
More informationAbout Codefrux While the current trends around the world are based on the internet, mobile and its applications, we try to make the most out of it. As for us, we are a well established IT professionals
More informationCOMP6700/2140 Data and Types
COMP6700/2140 Data and Types Alexei B Khorev and Josh Milthorpe Research School of Computer Science, ANU February 2017 Alexei B Khorev and Josh Milthorpe (RSCS, ANU) COMP6700/2140 Data and Types February
More informationJava Programming. MSc Induction Tutorials Stefan Stafrace PhD Student Department of Computing
Java Programming MSc Induction Tutorials 2011 Stefan Stafrace PhD Student Department of Computing s.stafrace@surrey.ac.uk 1 Tutorial Objectives This is an example based tutorial for students who want to
More informationRepresenting Characters, Strings and Text
Çetin Kaya Koç http://koclab.cs.ucsb.edu/teaching/cs192 koc@cs.ucsb.edu Çetin Kaya Koç http://koclab.cs.ucsb.edu Fall 2016 1 / 19 Representing and Processing Text Representation of text predates the use
More informationB.V. Patel Institute of BMC & IT, UTU 2014
BCA 3 rd Semester 030010301 - Java Programming Unit-1(Java Platform and Programming Elements) Q-1 Answer the following question in short. [1 Mark each] 1. Who is known as creator of JAVA? 2. Why do we
More informationPrinceton University. Computer Science 217: Introduction to Programming Systems. Data Types in C
Princeton University Computer Science 217: Introduction to Programming Systems Data Types in C 1 Goals of C Designers wanted C to: Support system programming Be low-level Be easy for people to handle But
More informationChapter 2 Elementary Programming
Chapter 2 Elementary Programming Part I 1 Motivations In the preceding chapter, you learned how to create, compile, and run a Java program. Starting from this chapter, you will learn how to solve practical
More informationObject oriented programming. Instructor: Masoud Asghari Web page: Ch: 3
Object oriented programming Instructor: Masoud Asghari Web page: http://www.masses.ir/lectures/oops2017sut Ch: 3 1 In this slide We follow: https://docs.oracle.com/javase/tutorial/index.html Trail: Learning
More informationJava Notes. 10th ICSE. Saravanan Ganesh
Java Notes 10th ICSE Saravanan Ganesh 13 Java Character Set Character set is a set of valid characters that a language can recognise A character represents any letter, digit or any other sign Java uses
More informationClass. Chapter 6: Data Abstraction. Example. Class
Chapter 6: Data Abstraction In Java, there are three types of data values primitives arrays objects actually, arrays are a special type of object Class In Java, objects are used to represent data values
More informationCOMP 202. Built in Libraries and objects. CONTENTS: Introduction to objects Introduction to some basic Java libraries string
COMP 202 Built in Libraries and objects CONTENTS: Introduction to objects Introduction to some basic Java libraries string COMP 202 Objects and Built in Libraries 1 Classes and Objects An object is an
More informationCSCI 2010 Principles of Computer Science. Data and Expressions 08/09/2013 CSCI
CSCI 2010 Principles of Computer Science Data and Expressions 08/09/2013 CSCI 2010 1 Data Types, Variables and Expressions in Java We look at the primitive data types, strings and expressions that are
More informationChapter 2: Using Data
Chapter 2: Using Data TRUE/FALSE 1. A variable can hold more than one value at a time. F PTS: 1 REF: 52 2. The legal integer values are -2 31 through 2 31-1. These are the highest and lowest values that
More informationCharacter Encodings. Fabian M. Suchanek
Character Encodings Fabian M. Suchanek 22 Semantic IE Reasoning Fact Extraction You are here Instance Extraction singer Entity Disambiguation singer Elvis Entity Recognition Source Selection and Preparation
More informationChapter 2 ELEMENTARY PROGRAMMING
Chapter 2 ELEMENTARY PROGRAMMING Lecture notes for computer programming 1 Faculty of Engineering and Information Technology Prepared by: Iyad Albayouk ١ Objectives To write Java programs to perform simple
More informationZheng-Liang Lu Java Programming 45 / 79
1 class Lecture2 { 2 3 "Elementray Programming" 4 5 } 6 7 / References 8 [1] Ch. 2 in YDL 9 [2] Ch. 2 and 3 in Sharan 10 [3] Ch. 2 in HS 11 / Zheng-Liang Lu Java Programming 45 / 79 Example Given a radius
More informationStrings and Arrays. Hendrik Speleers
Hendrik Speleers Overview Characters and strings String manipulation Formatting output Arrays One-dimensional Two-dimensional Container classes List: ArrayList and LinkedList Iterating over a list Characters
More informationCS 137 Part 6. ASCII, Characters, Strings and Unicode. November 3rd, 2017
CS 137 Part 6 ASCII, Characters, Strings and Unicode November 3rd, 2017 Characters Syntax char c; We ve already seen this briefly earlier in the term. In C, this is an 8-bit integer. The integer can be
More informationCOE318 Lecture Notes Week 5 (Oct 3, 2011)
COE318 Software Systems Lecture Notes: Week 5 1 of 6 COE318 Lecture Notes Week 5 (Oct 3, 2011) Topics Announcements Strings static and final qualifiers Stack and Heap details Announcements Quiz: Today!
More informationCreating Strings. String Length
Strings Strings, which are widely used in Java programming, are a sequence of characters. In the Java programming language, strings are objects. The Java platform provides the String class to create and
More informationReview Chapters 1 to 4. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013
Review Chapters 1 to 4 Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 Introduction to Java Chapters 1 and 2 The Java Language Section 1.1 Data & Expressions Sections 2.1 2.5 Instructor:
More informationClasses and Objects Part 1
COMP-202 Classes and Objects Part 1 Lecture Outline Object Identity, State, Behaviour Class Libraries Import Statement, Packages Object Interface and Implementation Object Life Cycle Creation, Destruction
More informationLab 14 & 15: String Handling
Lab 14 & 15: String Handling Prof. Navrati Saxena TA: Rochak Sachan String Handling 9/11/2012 22 String Handling Java implements strings as objects of type String. Once a String object has been created,
More informationOhad Barzilay and Oranit Dror
The String Class Represents a character string (e.g. "Hi") Implicit constructor: String quote = "Hello World"; string literal All string literals are String instances Object has a tostring() method More
More information1 class Lecture2 { 2 3 "Elementray Programming" / References 8 [1] Ch. 2 in YDL 9 [2] Ch. 2 and 3 in Sharan 10 [3] Ch.
1 class Lecture2 { 2 3 "Elementray Programming" 4 5 } 6 7 / References 8 [1] Ch. 2 in YDL 9 [2] Ch. 2 and 3 in Sharan 10 [3] Ch. 2 in HS 11 / Zheng-Liang Lu Java Programming 41 / 68 Example Given the radius
More informationCSE1710. Big Picture. Today is last day covering Ch 6. Tuesday, Dec 02 is designated as a study day. No classes. Thursday, Dec 04 is last lecture.
CSE1710 Click to edit Master Week text 12, styles Lecture 23 Second level Third level Fourth level Fifth level Fall 2014! Thursday, Nov 27, 2014 1 Big Picture Today is last day covering Ch 6 Tuesday, Dec
More information4 Programming Fundamentals. Introduction to Programming 1 1
4 Programming Fundamentals Introduction to Programming 1 1 Objectives At the end of the lesson, the student should be able to: Identify the basic parts of a Java program Differentiate among Java literals,
More informationFall 2017 CISC124 9/16/2017
CISC124 Labs start this week in JEFF 155: Meet your TA. Check out the course web site, if you have not already done so. Watch lecture videos if you need to review anything we have already done. Problems
More informationChapter 3. Information Representation
Chapter 3 Information Representation Instruction Set Architecture APPLICATION LEVEL HIGH-ORDER LANGUAGE LEVEL ASSEMBLY LEVEL OPERATING SYSTEM LEVEL INSTRUCTION SET ARCHITECTURE LEVEL 3 MICROCODE LEVEL
More informationIntro to Strings. Lecture 7 COP 3252 Summer May 23, 2017
Intro to Strings Lecture 7 COP 3252 Summer 2017 May 23, 2017 Strings in Java In Java, a string is an object. It is not a primitive type. The String class is used to create and store immutable strings.
More informationEng. Mohammed Abdualal
Islamic University of Gaza Faculty of Engineering Computer Engineering Department Computer Programming Lab (ECOM 2124) Lab 2 String & Character Eng. Mohammed Abdualal String Class In this lab, you have
More informationTCL - STRINGS. Boolean value can be represented as 1, yes or true for true and 0, no, or false for false.
http://www.tutorialspoint.com/tcl-tk/tcl_strings.htm TCL - STRINGS Copyright tutorialspoint.com The primitive data-type of Tcl is string and often we can find quotes on Tcl as string only language. These
More informationTools : The Java Compiler. The Java Interpreter. The Java Debugger
Tools : The Java Compiler javac [ options ] filename.java... -depend: Causes recompilation of class files on which the source files given as command line arguments recursively depend. -O: Optimizes code,
More informationProgramming in C++ 4. The lexical basis of C++
Programming in C++ 4. The lexical basis of C++! Characters and tokens! Permissible characters! Comments & white spaces! Identifiers! Keywords! Constants! Operators! Summary 1 Characters and tokens A C++
More informationOOP-Lecture Java Loop Controls: 1 Lecturer: Hawraa Sh. You can use one of the following three loops: while Loop do...while Loop for Loop
Java Loop Controls: You can use one of the following three loops: while Loop do...while Loop for Loop 1- The while Loop: A while loop is a control structure that allows you to repeat a task a certain number
More informationExercises Software Development I. 03 Data Representation. Data types, range of values, internal format, literals. October 22nd, 2014
Exercises Software Development I 03 Data Representation Data types, range of values, ernal format, literals October 22nd, 2014 Software Development I Wer term 2013/2014 Priv.-Doz. Dipl.-Ing. Dr. Andreas
More informationCHAPTER 2 Java Fundamentals
CHAPTER 2 Java Fundamentals Copyright 2016 Pearson Education, Inc., Hoboken NJ Chapter Topics Chapter 2 discusses the following main topics: The Parts of a Java Program The print and println Methods, and
More informationAns: Store s as an expandable array of chars. (Double its size whenever we run out of space.) Cast the final array to a String.
CMSC 131: Chapter 21 (Supplement) Miscellany Miscellany Today we discuss a number of unrelated but useful topics that have just not fit into earlier lectures. These include: StringBuffer: A handy class
More informationJAVA Programming Fundamentals
Chapter 4 JAVA Programming Fundamentals By: Deepak Bhinde PGT Comp.Sc. JAVA character set Character set is a set of valid characters that a language can recognize. It may be any letter, digit or any symbol
More informationBasics of Java Programming
Basics of Java Programming Lecture 2 COP 3252 Summer 2017 May 16, 2017 Components of a Java Program statements - A statement is some action or sequence of actions, given as a command in code. A statement
More informationClass Library java.lang Package. Bok, Jong Soon
Class Library java.lang Package Bok, Jong Soon javaexpert@nate.com www.javaexpert.co.kr Object class Is the root of the class hierarchy. Every class has Object as a superclass. If no inheritance is specified
More informationThe Irving K. Barber School of Arts and Sciences COSC 111 Final Exam Winter Term II Instructor: Dr. Bowen Hui. Tuesday, April 19, 2016
First Name (Print): Last Name (Print): Student Number: The Irving K. Barber School of Arts and Sciences COSC 111 Final Exam Winter Term II 2016 Instructor: Dr. Bowen Hui Tuesday, April 19, 2016 Time: 6:00pm
More informationCS Programming I: Using Objects
CS 200 - Programming I: Using Objects Marc Renault Department of Computer Sciences University of Wisconsin Madison Fall 2017 TopHat Sec 3 (PM) Join Code: 719946 TopHat Sec 4 (AM) Join Code: 891624 Binary
More informationJava Identifiers. Java Language Essentials. Java Keywords. Java Applications have Class. Slide Set 2: Java Essentials. Copyright 2012 R.M.
Java Language Essentials Java is Case Sensitive All Keywords are lower case White space characters are ignored Spaces, tabs, new lines Java statements must end with a semicolon ; Compound statements use
More informationBuilding Strings and Exploring String Class:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 Lecture Notes K.Yellaswamy Assistant Professor CMR College of Engineering & Technology Building Strings and Exploring
More informationData and Expressions. Outline. Data and Expressions 12/18/2010. Let's explore some other fundamental programming concepts. Chapter 2 focuses on:
Data and Expressions Data and Expressions Let's explore some other fundamental programming concepts Chapter 2 focuses on: Character Strings Primitive Data The Declaration And Use Of Variables Expressions
More informationExpressions and Data Types CSC 121 Spring 2015 Howard Rosenthal
Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types
More informationJava Strings Java, winter semester
Java Strings 1 String instances of java.lang.string compiler works with them almost with primitive types String constants = instances of the String class immutable!!! for changes clases StringBuffer, StringBuilder
More informationFull file at
Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class
More informationCSE1710. Big Picture. Tuesday, Dec 02 is designated as a study day. No classes. Thursday, Dec 04 is last lecture.
CSE1710 Click to edit Master Week text 12, styles Lecture 22 Second level Third level Fourth level Fifth level Fall 2014 Tuesday, Nov 25, 2014 1 Big Picture Tuesday, Dec 02 is designated as a study day.
More informationLecture Notes K.Yellaswamy Assistant Professor K L University
Lecture Notes K.Yellaswamy Assistant Professor K L University Building Strings and Exploring String Class: -------------------------------------------- The String class ------------------- String: A String
More informationCMSC131. Introduction to your Introduction to Java. Why Java?
CMSC131 Introduction to your Introduction to Java Why Java? It s a popular language in both industry and introductory programming courses. It makes use of programming structures and techniques that can
More informationSTUDENT LESSON A10 The String Class
STUDENT LESSON A10 The String Class Java Curriculum for AP Computer Science, Student Lesson A10 1 STUDENT LESSON A10 The String Class INTRODUCTION: Strings are needed in many programming tasks. Much of
More informationCS Programming I: Using Objects
CS 200 - Programming I: Using Objects Marc Renault Department of Computer Sciences University of Wisconsin Madison Spring 2018 TopHat Sec 3 (AM) Join Code: 427811 TopHat Sec 4 (PM) Join Code: 165455 Binary
More informationTUGCE KEMEROZ - ASLI OZKAN - AYSE TARTAN. Week 12/02/ /02/2007 Lecture Notes:
1 INSTRUCTOR: FAZLI CAN TUGCE KEMEROZ - ASLI OZKAN - AYSE TARTAN Week 12/02/2007-16/02/2007 Lecture Notes: When we write a program we must design our programs to take correct output. For correct output,
More informationCS112 Lecture: Characters and Strings
CS112 Lecture: Characters and Strings Objectives: Last Revised 3/21/06 1. To introduce the data type char and related basic information (escape sequences, Unicode). 2. To introduce the library classes
More informationImports. Lexicon. Java/Lespérance 1. PROF. Y. LESPÉRANCE Dept. of Electrical Engineering & Computer Science
Lexicon CS1022 MOBIL COMPUTING PROF Y LSPÉRANC Dept of lectrical ngineering & Computer Science 1 2 Imports 3 Imported Class = DelegaKon 4 Java/Lespérance 1 Lexicon Class Header Class Body, a Block import
More informationFeatures of C. Portable Procedural / Modular Structured Language Statically typed Middle level language
1 History C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC
More informationLecture Notes. System.out.println( Circle radius: + radius + area: + area); radius radius area area value
Lecture Notes 1. Comments a. /* */ b. // 2. Program Structures a. public class ComputeArea { public static void main(string[ ] args) { // input radius // compute area algorithm // output area Actions to
More informationContents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix
PGJC4_JSE8_OCA.book Page ix Monday, June 20, 2016 2:31 PM Contents Figures Tables Examples Foreword Preface xix xxi xxiii xxvii xxix 1 Basics of Java Programming 1 1.1 Introduction 2 1.2 Classes 2 Declaring
More informationClass definition. complete definition. public public class abstract no instance can be created final class cannot be extended
JAVA Classes Class definition complete definition [public] [abstract] [final] class Name [extends Parent] [impelements ListOfInterfaces] {... // class body public public class abstract no instance can
More informationChapter 2 Primitive Data Types and Operations. Objectives
Chapter 2 Primitive Data Types and Operations Prerequisites for Part I Basic computer skills such as using Windows, Internet Explorer, and Microsoft Word Chapter 1 Introduction to Computers, Programs,
More informationString is one of mostly used Object in Java. And this is the reason why String has unique handling in Java(String Pool). The String class represents
String is one of mostly used Object in Java. And this is the reason why String has unique handling in Java(String Pool). The String class represents character strings. All string literals in Java programs,
More informationVariables, Constants, and Data Types
Variables, Constants, and Data Types Strings and Escape Characters Primitive Data Types Variables, Initialization, and Assignment Constants Reading for this lecture: Dawson, Chapter 2 http://introcs.cs.princeton.edu/python/12types
More informationJava Programming Language Mr.Rungrote Phonkam
3 Java Programming Language Mr.Rungrote Phonkam rungrote@it.kmitl.ac.th Contents 1. Identify 2. Method Member 3. Literals 4. Data Type 6. Variable 1. Identify ก ก Class, Data, Method, Variable, Label,
More informationFormatted Output Pearson Education, Inc. All rights reserved.
1 29 Formatted Output 2 OBJECTIVES In this chapter you will learn: To understand input and output streams. To use printf formatting. To print with field widths and precisions. To use formatting flags in
More informationMore on Strings. Lecture 10 CGS 3416 Fall October 13, 2015
More on Strings Lecture 10 CGS 3416 Fall 2015 October 13, 2015 What we know so far In Java, a string is an object. The String class is used to create and store immutable strings. Some String class methods
More information3 The Building Blocks: Data Types, Literals, and Variables
chapter 3 The Building Blocks: Data Types, Literals, and Variables 3.1 Data Types A program can do many things, including calculations, sorting names, preparing phone lists, displaying images, validating
More informationWelcome to the Using Objects lab!
Welcome to the Using Objects lab! Learning Outcomes By the end of this lab: 1. Be able to define chapter 3 terms. 2. Describe reference variables and compare with primitive data type variables. 3. Draw
More informationBasic Operations jgrasp debugger Writing Programs & Checkstyle
Basic Operations jgrasp debugger Writing Programs & Checkstyle Suppose you wanted to write a computer game to play "Rock, Paper, Scissors". How many combinations are there? Is there a tricky way to represent
More informationInf1-OOP. Data Types. Defining Data Types in Java. type value set operations. Overview. Circle Class. Creating Data Types 1.
Overview Inf1-OOP Creating Data Types 1 Circle Class Object Default Perdita Stevens, adapting earlier version by Ewan Klein Format Strings School of Informatics January 11, 2015 HotelRoom Class More on
More informationObjects and Types. COMS W1007 Introduction to Computer Science. Christopher Conway 29 May 2003
Objects and Types COMS W1007 Introduction to Computer Science Christopher Conway 29 May 2003 Java Programs A Java program contains at least one class definition. public class Hello { public static void
More informationA Java program contains at least one class definition.
Java Programs Identifiers Objects and Types COMS W1007 Introduction to Computer Science Christopher Conway 29 May 2003 A Java program contains at least one class definition. public class Hello { public
More informationCSE 373. Data Types and Manipulation; Arrays. slides created by Marty Stepp
CSE 373 Data Types and Manipulation; Arrays slides created by Marty Stepp http://www.cs.washington.edu/373/ University of Washington, all rights reserved. 1 Numeric data type kind of number memory (bits)
More informationChapter 02: Using Data
True / False 1. A variable can hold more than one value at a time. ANSWER: False REFERENCES: 54 2. The int data type is the most commonly used integer type. ANSWER: True REFERENCES: 64 3. Multiplication,
More information