DOC PREVIEW
TRINITY CSCI 1321 - Strings and Arrays

This preview shows page 1-2-3 out of 9 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 91Strings and Arrays2/5/20092Opening Discussion■Do you have any questions about the assignment?■What is the syntax of generics?■What are enums?■What is the syntax of Java enums?■Minute Essay commentsComparing Java to SmalltalkYou don't have to use Eclipse to program Java. There are other IDEs, like NetBeans, or oyu could use vi. API is pretty essential.Java 5 was released in September 2004.My research work uses both Java and C++.Java is created by a large team of people.Meaning of abstract.3Strings■How did you represent a string in C? How do we represent a string in Java?■Let's go look at the API for String to see what the Java developers have provided us with.■Strings are immutable so it is very inefficient to build big strings from a lot of little pieces. If you need to do that, use StringBuffer.■It is the only class with an overloaded operator, + for string concatenation.■Functions that look like they mutate the String return a new String instead.■To get a single character, use charAt.4Text/In Class Project■In class we will be going through the same project that is developed in the textbook. It is a drawing program with a somewhat different structure than paint.■In addition to drawing, the application will also have command processing that we can use to extend the power of the application.5Code■To give us a chance to play with strings some let's go ahead and write the beginnings of the command processor.■We want a class that will take a string, break off the first word as the command, then execute the command with the rest of the string as the arguments.■We should go ahead and make two commands, echo and add, that we can test it with.6Regular Expressions■You'll notice that some of the methods in String say that they take regular expressions (regex). This is a topic that we won't directly cover in this class, but it is a very powerful technique for you to learn.■The java.util.regex package contains the two main classes that are used for regular expressions. The Pattern class has a lot of description about them at the top.7Arrays■Array syntax in Java is just like it was in C as far as using the arrays. There are significant differences though.■Array types are made by putting [] after a regular type.■Array types are object types so your variables are references and should be instantiated with new.■Arrays have bounds checking and know their length.■You can't make arrays of generics.■Each element in the array is like a variable. So for primitives they store values while for object values they are references.8Code■Our command parser was pretty lame in how it picked the command. The definitely isn't a very flexible I want to write a class called ArrayMap and use it to make the code more flexible.9Minute Essay■Write the following method:String replaceAll(String s,char f,char t)■This method should return a new string where all instances of f in s have been replaced with t.■Remember to submit your design for assignment #1 today.■Interclass Problem – Write a program where a user types in a line of text and you print out each word in the line and the number of characters in


View Full Document

TRINITY CSCI 1321 - Strings and Arrays

Documents in this Course
Recursion

Recursion

11 pages

Iterators

Iterators

10 pages

Actors

Actors

9 pages

Recursion

Recursion

15 pages

Recursion

Recursion

10 pages

Threads

Threads

7 pages

Trees

Trees

11 pages

Load more
Download Strings and Arrays
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Strings and Arrays and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Strings and Arrays 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?