16-Strings&Numbers

16-Strings&Numbers - Chapter XVI String Methods and...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Chapter XVI String Methods and Number Systems Chapter XVI Topics 16.1 Introduction 16.2 Constructing String Objects 16.3 String Concatenation 16.4 Working with Substrings 16.5 Changing Strings 16.6 Converting Strings 16.7 Comparing Strings 16.8 Introduction to Number Systems 16.9 Counting in Other Number Systems 16.10 Counting in Base-16 16.11 Converting Any Base to Base-10 16.12 Converting Base-2 to Base-10 16.13 Converting Base-10 to Any Base 16.14 Base-2 and Base-16 Properties 16.15 Worked Out Exercises 16.16 Summary Chapter XVI String Methods and Number Systems 821 16.1 Introduction Strings are a set of characters in every conceivable arrangement and size. Strings are everywhere, both inside and outside the computer world. A sentence is a set of characters. A page is a set of sentences. A book is a set of pages. A library is a set of books. Given enough computer memory, an entire library can be stored in a computer. Word processing term papers, writing memoirs, sending email messages, responding to surveys, placing online orders and registering products all involve string processing . Every software package on the market includes string-processing components. Every programming language has special features that facilitate the manipulation of strings, and Java is no different. Finally, let us not forget that every program you write is one big collection of strings that work together, hopefully, to generate some desired and logical output. You have actually been using the String data type for quite some time and to a large degree you may think that it was a simple or primitive data type. This is not surprising. Consider the variable declarations in figure 16.1. Figure 16.1 int number; char letter; double gpa; boolean finished; String title; You see five declarations and each declaration starts with a data type followed by a variable identifier. It appears that all five of the declarations behave in the same way. You may note one peculiar difference; the String declaration is the only data type that starts with an upper-case letter. Now look at the value assignments for each one of the variables in figure 16.2. Figure 16.2 number = 2500; letter = 'A'; gpa = 3.785; finished = true; title = "Exposure Java"; 822 Exposure Java 2009, APCS Edition 08-08-09 The assignment statement seems to give secondary evidence that String belongs with the simple data types. By now you have seen that data structures behave quite differently from simple data types. Accessing any element in an array requires not only the array identifier, but also an index to access a specific array element. Access of any field in a record, which is an attribute of an object in Java , requires the object identifier and some accessing method....
View Full Document

Page1 / 64

16-Strings&Numbers - Chapter XVI String Methods and...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online