Introduction to
Java
CST200 – Week 1: Introduction to Java
Instructor: Andreea Molnar
Outline
• Aims
• Basic Concepts
• Strings
• Arrays
Aim
• The aim of this presentation is to

emphasis on some of the material
covered by the pluralsigh videos.
Basic Concepts
• Expression: see more about them here:

http://www.d.umn.edu/~gshute/java/stat
ements.html

• Algorithm: s...
Strings and Arrays
The first letter of a String is at the
position 0 and the first value of an array
is at the position 0.
Strings
Any sequence of characters, for example:
String s = “Arizona”;
String s = “1457 Mesa”;
String s = “@u”;
Strings - Methods
You can find all the String methods at:
http://docs.oracle.com/javase/7/docs/api/j
ava/lang/String.html
Strings - Methods
public int length() – returns the length of
the string
String s = “CST 200”;
s.length() – will return 7 ...
Strings - Methods
public int length() – returns the length of 
the string
String s = “CST 200”;
s.length() – will return 7...
Strings - Methods
public char charAt(int index)– returns the 
character value at the specified index
String s = “CST 200”;...
Strings - Methods
public char charAt(int index)– returns the 
character value at the specified index
String s = “CST 200”;...
Strings - Methods
String s = “CST 200”;
C

S

T

0

1

2

2
3

0

0

4

5

6

System.out.println(s.charAt(0));//will print...
Strings - Methods
public int indexOf(String str) - returns the
index within this string of the first
occurrence of the spe...
Arrays
Array is a container that holds a fixed
number of values.
int[] array = {10, 20, 30, 50};
10

20

30

50

0

2

3

...
Arrays
int[] array = {10, 20, 30, 50};
10

20

30

50

0

1

2

3

To print the values of this array:
System.out.println(a...
Summary
• Expression definition
• Algorithm definition
• The first character of an array starts at
position 0

• The first...
Upcoming SlideShare
Loading in...5
×

Introduction to java

1,775

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,775
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
19
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Introduction to java"

  1. 1. Introduction to Java CST200 – Week 1: Introduction to Java Instructor: Andreea Molnar
  2. 2. Outline • Aims • Basic Concepts • Strings • Arrays
  3. 3. Aim • The aim of this presentation is to emphasis on some of the material covered by the pluralsigh videos.
  4. 4. Basic Concepts • Expression: see more about them here: http://www.d.umn.edu/~gshute/java/stat ements.html • Algorithm: see a definition here: http://en.wikipedia.org/wiki/Algorithm
  5. 5. Strings and Arrays The first letter of a String is at the position 0 and the first value of an array is at the position 0.
  6. 6. Strings Any sequence of characters, for example: String s = “Arizona”; String s = “1457 Mesa”; String s = “@u”;
  7. 7. Strings - Methods You can find all the String methods at: http://docs.oracle.com/javase/7/docs/api/j ava/lang/String.html
  8. 8. Strings - Methods public int length() – returns the length of the string String s = “CST 200”; s.length() – will return 7 as there are 7 characters in the string
  9. 9. Strings - Methods public int length() – returns the length of  the string String s = “CST 200”; s.length() – will return 7 as there are 7  characters in the string (space is count as  a separate character)
  10. 10. Strings - Methods public char charAt(int index)– returns the  character value at the specified index String s = “CST 200”; C T 0 index S 1 2 2 3 0 0 4 5 6
  11. 11. Strings - Methods public char charAt(int index)– returns the  character value at the specified index String s = “CST 200”; C S T 0 1 2 2 3 0 0 4 5 6 The first character of a String is at the  position 0!!!
  12. 12. Strings - Methods String s = “CST 200”; C S T 0 1 2 2 3 0 0 4 5 6 System.out.println(s.charAt(0));//will print C System.out.println(s.charAt(6));//will print 0 
  13. 13. Strings - Methods public int indexOf(String str) - returns the index within this string of the first occurrence of the specified substring String s = “CST 200”; C S T 0 1 2 2 3 0 0 4 5 6 System.out.println(s.indexOf(“T”)); //will print 3
  14. 14. Arrays Array is a container that holds a fixed number of values. int[] array = {10, 20, 30, 50}; 10 20 30 50 0 2 3 4 index
  15. 15. Arrays int[] array = {10, 20, 30, 50}; 10 20 30 50 0 1 2 3 To print the values of this array: System.out.println(array[0]);//will print 10 System.out.println(array[1]);//will print 20 System.out.println(array[2]);//will print 30
  16. 16. Summary • Expression definition • Algorithm definition • The first character of an array starts at position 0 • The first element of an array starts at the position 0
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×