Download presentation
Presentation is loading. Please wait.
1
AP Java Unit 3 Strings & Arrays
2
Lesson 5: Arrays of objects
3
In Java arrays can hold either primitive data or object data.
Arrays of objects Click for Help Primitive? Primitive data are values like ints or chars. The variable can only hold one thing at a time. In Java arrays can hold either primitive data or object data. Object? In Java an Object is a variable of a class type. It can hold lots of data and has methods. It is different then a primitive type.
4
Examples: Arrays of objects
String movies[] = new String[5]; movies[0] = “Maltese Falcon”; System.out.print(list[0].length); Dot operator goes after the [ ] Prints 14
5
Answers Now you try some:
Use this array: String movies[] = new String[5]; Now you try some: Add the movie “Don’t Eat the Daisies” to the second spot. Print the charAt(3) for the movie in the second spot. Print the movie in the first spot in all uppercase letters. #1 movies[1] = “Don’t Eat the Daisies”; Remember 1 is the second spot in the array since the array starts at 0 #2 System.out.print(movies[1].charAt(3)); Answers #3 System.out.print(movies[0].toUpperCase());
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.