Posted by : Rhyf Ahmad Thursday, May 21, 2015

With the basic built-in Java data types that you've seen in the previous chapters, each identifier corresponds to a single variable. But when you want to handle sets of values of the same type — the first 1,000 primes, for example — you really don't want to have to name them individually. What you need is an array. You should first have a rough idea of what an array is and how it works. An array is an object that is a named set of variables of the same type.
Each variable in the array is called an array element. To reference a particular element in an array, you use the array name combined with an integer value of type int, called an index. You put the index between square brackets following the array name; for example, data[99] refers to the element in the data array corresponding to the index value 99. The index for an array element is the offset of that particular element from the beginning of the array. The first element has an index of 0, the second has an index of 1, the third an index of 2, and so on. Thus, data[99] refers to the hundredth element in the data array. The index value does not need to be an integer literal. It can be any expression that results in a value of type int that is equal to or greater than zero. Obviously a for loop is going to be very useful for processing array elements — which is one reason why you had to wait until now to hear about arrays.
The String, You will need to use character strings in most of your programs — headings, names, addresses, product descriptions, messages — the list is endless. In Java, ordinary strings are objects of the class String. The String class is a standard class that comes with Java, and it is specifically designed for creating and processing strings. The definition of the String class is in the java.lang package so it is accessible in all your programs by default. Character in strings are stored as Unicode UTF-16.

Contents:

Arrays
  1. Array Variables
  2. Defi ning an Array
  3. The Length of an Array
  4. Accessing Array Elements
  5. Reusing Array Variables
  6. Initializing Arrays
  7. Using Arrays
  8. Arrays of Arrays
  9. Arrays of Characters

Strings
  1. String Literals
  2. Creating String Objects
  3. Arrays of Strings

Operations on Strings
  1. Joining Strings
  2. Comparing Strings
  3. Sequencing Strings
  4. Accessing String Characters
  5. Searching Strings for Characters
  6. Searching for Substrings
  7. Extracting Substrings
  8. Modifi ed Versions of String Objects
  9. Creating Character Arrays from String Objects
  10. Using the Collection-Based for Loop with a String
  11. Obtaining the Characters in a String as an Array of Bytes
  12. Creating String Objects from Character Arrays

Mutable Strings
  1. Creating StringBuff er Objects
  2. The Capacity of a StringBuff er Object
  3. Changing the String Length for a StringBuff er Object
  4. Adding to a StringBuff er Object
  5. Finding the Position of a Substring
  6. Replacing a Substring in the Buff er
  7. Inserting Strings
  8. Extracting Characters from a Mutable String
  9. Other Mutable String Operations
  10. Creating a String Object from a StringBuff er Object 




Ebook Preview
Get the ebook now (2.17 MB)

If the link above doesn't work, try the link below


Mirror: Get the ebook now (2.17 MB)

Leave a Reply

You can leave a comment to request any article(s), software(s), ebook(s) or report the dead link.
Then I will reply as soon as I can :)

Subscribe to Posts | Subscribe to Comments

Welcome to My Blog

Recent Post

Recent Posts Widget
Instagram

- Copyright © Madriva -Robotic Notes- Powered by Blogger - Designed by Johanes Djogan -