import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Scanner;
import java.io.File;
import java.io.IOException;
public class CylinderList2 {
private String listName = "";
private ArrayList<Cylinder> cyll =
new ArrayList<Cylinder>();
/**
* @param cyllIn Represents list of cylinder objects.
* @param listNameIn Represents name of list.
*/
public CylinderList2(String listNameIn,
ArrayList<Cylinder> cyllIn) {
listName = listNameIn;
cyll = cyllIn;
}
/**
* @return A String representing the name of the list. Returns a string that represents name of
* the list.
*/
public String getName() {
return listName;
}
/**
* @return The number of Cylinder objects. Returns the number of cylinder objects.
*/
public int numberOfCylinders() {
return cyll.size();
}
/**
* @return Total area. Returns total area of cylinder objects.
*/
public double totalArea() {
double tArea = 0;
int index = 0;
if (cyll.size() == 0) {
return 0;
}
while (index < cyll.size()) {
tArea += cyll.get(index).area();
index++;
}
return tArea;
}
/**
* @return Displays volume when method is called. Returns total volume of cylinder objects.
*/
public double totalVolume() {
double tVolume = 0;
int index = 0;
if (cyll.size() == 0) {
return 0;
}
while (index < cyll.size()) {
tVolume += cyll.get(index).volume();
index++;
}
return tVolume;
}
/**
* @return Displays height when method is called. Returns double representing total height of
* all cylinder objects.
*/
public double totalHeight()
{
double tHeight = 0;
int index = 0;
if (cyll.size() == 0)
{
return 0;
}
while (index < cyll.size())
{
tHeight += cyll.get(index).getHeight();
index++;
}
return tHeight;
}
}
I need to convert my ArrayList into Arrays but i am not too fond on how to do this. I am a beginner so I am still learning how to use arrays correctly. I get confused with the two because they're similar to me and I can't figure out exactly how to work with them. Any help would be appreciated