ArrayList - PowerPoint PPT Presentation

1 / 4
About This Presentation
Title:

ArrayList

Description:

ArrayList students = new ArrayList(); tempName=GetData.getString('Enter last name' ... { Collections.sort(lastNames); Collections.sort(firstNames); System.out. ... – PowerPoint PPT presentation

Number of Views:254
Avg rating:3.0/5.0
Slides: 5
Provided by: robert340
Category:

less

Transcript and Presenter's Notes

Title: ArrayList


1
ArrayList
  • CIS 362

2
Arrays as Classes - ArrayList
import java.util. public class Students
public static void main(String args)
String tempName ArrayList students new
ArrayList() tempNameGetData.getString("Ente
r last name") while(tempName.length()gt0)
students.add(tempName)
tempNameGetData.getString("Enter last name")
if (! students.isEmpty())
Collections.sort(students)
System.out.println("\n\nSTUDENTS")
Iterator x students.iterator() while
(x.hasNext()) System.out.println((String)
x.next())
3
Homework 3 part 5
  • Get the following program working.
  • Enter at least 10 names of people that you know.
  • What is wrong with this program? And why is it
    doing that?

import java.util. public class Students
public static void main(String args)
String tempName ArrayList firstNames new
ArrayList() ArrayList lastNames new
ArrayList() tempNameGetData.getString("Ente
r last name") while(tempName.length()gt0)
lastNames.add(tempName)
tempNameGetData.getString("Enter first name")
firstNames.add(tempName)
tempNameGetData.getString("Enter next student
last name")
4
Homework 3 - part 5, continued
if (! lastNames.isEmpty())
Collections.sort(lastNames)
Collections.sort(firstNames)
System.out.println("\n\nSTUDENTS")
Iterator x lastNames.iterator() Iterator
y firstNames.iterator() while
(x.hasNext()) y.hasNext()
System.out.println(y.next() " " x.next())
//end while //end if statement
//end main //end class
Write a Comment
User Comments (0)
About PowerShow.com