0% found this document useful (0 votes)
2 views3 pages

Array List

The document contains Java code snippets for manipulating an ArrayList of Doubles, including removing elements outside a specified range. It also defines a method to calculate the length of the hailstone sequence and checks if the length exceeds the input number. Additionally, it includes a Car class with attributes for brand, year, and mileage, along with corresponding getter and setter methods and a method to update mileage when driving.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Array List

The document contains Java code snippets for manipulating an ArrayList of Doubles, including removing elements outside a specified range. It also defines a method to calculate the length of the hailstone sequence and checks if the length exceeds the input number. Additionally, it includes a Car class with attributes for brand, year, and mileage, along with corresponding getter and setter methods and a method to update mileage when driving.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

ArrayList <Double> cleanData = new ArrayList<Double>();

For(int i = 0; i < [Link](); i++){

If ([Link](i) < lower){

[Link](i);

If ([Link](i) > upper){

[Link](i);

[Link]();

public static int hailstoneLength(int n){

int count = 1;

while(n != 1){

if (n % 2 == 0){

n = n / 2;

else

n = n * 3 + 1;

return count;

Public static boolean isLongSeq(int n)


If ( hailstoneLength(n) > n)

return true;

}else

return false;

public class Car

private String brand;

private int year;

private double mileage;

public Car(String bra, int ye, double mile)

brand = bra;

year = ye;

mileage = mile;

public String getBrand()

return brand;

public int getYear()

return year;

}
public int getMileage()

return mileage;

public void setBrand(String b)

brand = b;

public void setYear(int y)

year = y;

public void setMileage(int m)

mileage = m;

public void drive (double miles)

mileage = mileage + miles;

You might also like