Linked Questions
20 questions linked to/from Creating an array of objects in Java
6
votes
2
answers
23k
views
How to initialize array of custom class objects? [duplicate]
It sounds easy but i've been trying to do it for quite sometime, I want to initialize my custom class object array using curly braces
Here is the failed example:
class:
class Tranforminfo{
...
-1
votes
3
answers
6k
views
Initializing an array of non primitive type [duplicate]
I have a class called Seat as follows:
public class Seat {
private String seatType; // E for economy, B for business class
private boolean Available; // false:booked, true:available
...
0
votes
2
answers
2k
views
Java new Object[]{...} syntax [duplicate]
I don't recognize this kind of form Java syntax for constructor - granted I do very little Java now (taken from there):
new PersistentArrayMap(new Object[]{formKey, form});
I was expecting something ...
0
votes
1
answer
219
views
Noob Null Pointer Exception error [duplicate]
I'm getting an NullPointerException error and cant figure out why. I've included all three classes which I'm working on and made ////note where eclipse is saying the error is coming from in the main ...
1
vote
1
answer
104
views
Why am I getting a NullPointer Exception with my array? [duplicate]
Can't for the life of me figure out why I'm getting an error here. It lets me put in the input, but then quits out and says theres a NullPointerException at the line that starts with "emp[i].setName".
...
0
votes
1
answer
91
views
Adding variables which are initialized later in arraylist or array with a loop [duplicate]
My question is, how i can add variables which are initialized later in the program to a array or arraylist with a loop.
Example:
JButton btn1, btn2, btn3;
...
private void createIco(){
btn1 = ...
-1
votes
2
answers
116
views
i cannot understand contact [] Myfriends line [duplicate]
package com.company;
public class ContactsManager {
Contact [] myFriends;
int friendsCount;
// Constructor:
ContactsManager(){
friendsCount = 0;
...
5
votes
4
answers
60k
views
How to create an Array of Objects in Java
I'm trying to create an array of objects as defined by a subclass (I think that's the correct terminology). I can see that the question is recurring, but implementation is still problematic.
My code
...
7
votes
4
answers
2k
views
Array of Object in Java vs C++
My Background is C++ and in c++ we can easily create array of object using simple syntax. className obj[n]; and also constructor will call n time.
But When I tried to create array of object in java ...
2
votes
6
answers
552
views
What is this java.lang.NullPointerException?
I coded a short script to learn about Java array:
class Dog {
String name;
void bark() {
System.out.println(name + " is barking");
}
void eat() {
System.out.println(name + " is ...
2
votes
5
answers
487
views
Create an Array of Objects from Arrays in Java
I am new to Android and Java and can't figure out this seemingly basic for loop setup to create an array of objects from the data in two other arrays.
It works this way, but this doesn't feel very ...
1
vote
1
answer
684
views
Array of record in java
I'm new in Java but have some experience in Delphi and Object pascal.
I want to define a array of a record like as below example:
TMyItems = record
Items: TItems;
count: integer;
end;
...
1
vote
1
answer
489
views
Four element array object setter method?
I've coded a program named TestStudent class that creates four element array of Student object. User is prompt to enter the student id, name, department and classification level. Here's the code :
...
0
votes
0
answers
230
views
Error while reading from csv "java.lang.Object cannot be cast to [Ljava.lang.Object;"
I have successfully added Csv reading functionality to my application. The setup that work is I have a base class called CSVReader. For each csv file, I create A new Class and it extends from ...
0
votes
0
answers
68
views
I would like help creating an array of objects
I am working on a project where i am trying to implement a queue using an array. In the queue will be a list of people with some information attached. I was looking to get help on creating an array of ...