Answers for "array in objects"

0

objects in array

let journal = [
  {events: ["work", "touched tree", "pizza",
            "running", "television"],
   squirrel: false},
  {events: ["work", "ice cream", "cauliflower",
            "lasagna", "touched tree", "brushed teeth"],
   squirrel: false},
  {events: ["weekend", "cycling", "break", "peanuts",
            "beer"],
   squirrel: true},
  /* and so on... */
];
Posted by: Guest on February-24-2022
0

Array of objects

class Police
{
	public int id;
	public String name;
	Police(int id, String name)
	{
		this.id = id;
		this.name = name;
	}
}
class PoliceClass
{
	public static void main (String[] args)
	{
		
		Police[] array;
		array = new Police[4];
		array[0] = new Police(3242,"Peter");
		array[1] = new Police(4353,"Adil");
		array[2] = new Police(6433,"Preet");
		array[3] = new Police(3434,"Ranjeet");

		for (int i = 0; i < array.length; i++)
			System.out.println("Police array Element at " + i + " : " +
						array[i].id +" "+ array[i].name);

}
}
Posted by: Guest on December-28-2021

Code answers related to "array in objects"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language