Hello, I have this part of the code in one method
public lugar getlugar(int x){
lugar l2=(lugar)lugares.get(x);
return l2;
}
I want you to do me the favor of explaining me about the cast because I can not understand it.
This is my Main
public class Fabrica {
private String Descripcion;
private int capacidad;
ArrayList<lugar> lugares= new ArrayList<lugar>();
public static void main(String[] args){
Fabrica f=new Fabrica();
for (int x=0;x<10;x++) {
f.crearLugar();
}
f.numerolugares();
}
public void crearLugar(){
lugar l1=new lugar();
lugares.add(l1);
}
public void numerolugares(){
System.out.println("numero de lugares" +" "+ lugares.size());
}
public lugar getlugar(int x){
lugar l2=(lugar)lugares.get(x);
return l2;
}
public void agregarplaza(int p){
lugar l3=(lugar)getlugar(p);
l3.crearplazas();
}
public void getplaza(int p,int t){
lugar lugar1=(lugar)getlugar(p);
lugar1.crearplazas();
plazas plas=(plazas)lugar1.getplazas(t);
plas.Soy();
}
Place is a class that I have within the program and Places is the name my ArrayList has.