- package bankobject;
-
import java.io.*;
-
import javax.swing.JOptionPane;
-
-
class Number {
-
String studentName;
-
String teacherName;
-
int[] Number;
-
-
public Number () {
-
studentName = JOptionPane.showInputDialog("Please Enter student name");
-
teacherName = JOptionPane.showInputDialog("Please Enter the teacher name ");
-
int numNumber = Integer.parseInt(JOptionPane.showInputDialog("Please enter the number of numbers"));
-
Number[] obj = new Number [numNumber];
-
for (i = 0; i < numNumber.length; i++)
-
obj [i] = new Number ();
-
}
-
I want the array to take as many numbers object, by using a for loop and instantiate each number object by calling the Number constructor.
11 11654
I think you meant to write this: - for (int i = 0; i < numNumber; i++)
There are also several logical errors in your code that you need to attend to. In your Number class you create an array full of Number objects -- that could lead to an infinite loop if you keep creating non-empty arrays. I think you meant the user interaction code to be elsewhere, perhaps in the main method, which hasn't shown up, yet. Also you have an int array called Number -- surely pure confusion on your part?
There are also several logical errors in your code that you need to attend to. In your Number class you create an array full of Number objects -- that could lead to an infinite loop if you keep creating non-empty arrays. I think you meant the user interaction code to be elsewhere, perhaps in the main method, which hasn't shown up, yet. Also you have an int array called Number -- surely pure confusion on your part?
Yeah, I meant for (int i = 0; i < numNumber; i++); forget the int there.
in the attributes list I wanted to make an array of number objects then in the constructor I would prompt the user for the number of number objects and use a for loop to instantiate each number account using the number constructor for each.
in the main method I would just instantiate two number objects.
The problem I'm having is in the for loop and getting the error " int cannot be dereferenced error message" I know I have to do something with it because it's a primitive, just don't know how in an array and for loop.
Don't know if this will fix your problem, but it looks like you declare a private data member of the Number class called int[] Number - that;s bound to give you problems. Consider a better name for it.
Don't know if this will fix your problem, but it looks like you declare a private data member of the Number class called int[] Number - that;s bound to give you problems. Consider a better name for it.
maybe int [] grade is better.
Still doesn't work since the error is coming with this line
for (int i = 0; i < numNumber; i++)
I don't get syntax errors from your code when I change it as I indicated.
There are also several logical errors in your code that you need to attend to. In your Number class you create an array full of Number objects -- that could lead to an infinite loop if you keep creating non-empty arrays. I think you meant the user interaction code to be elsewhere, perhaps in the main method, which hasn't shown up, yet. Also you have an int array called Number -- surely pure confusion on your part?
If I have two classes which are number and student how would I call them up in the main method when I just instantiate a number object. Meaning the input attributes in the student class.
Both classes are composition of each other.
If I have two classes which are number and student how would I call them up in the main method when I just instantiate a number object. Meaning the input attributes in the student class.
Both classes are composition of each other.
I don't understand what you are trying to say. perhaps is you posted some code to explain what you are trying to do.
Since the student class is part of the number class when I do the output it isn't going to work with the student class because I only made a new object in the number class.
-
public Number () {
-
...
-
int numNumber = Integer.parseInt(JOptionPane.showInputDialog("Please enter the number of numbers"));
-
Number[] obj = new Number [numNumber];
-
for (i = 0; i < numNumber.length; i++)
-
obj [i] = new Number ();
-
}
-
I can't get past this constructor. Do you understand it? When you construct a Number object, you prompt the user for a size, allocate an array and then construct more Number objects, each of which will prompt the user for a size, allocate an array and then construct more Number objects, each of which will prompt the user for a size, allocate an array ...
I think you need to start over again. I still have no idea what you are trying to do, and I'm not convinced anyone does, including yourself. First, answer these questions. - What is a Number object? What are its key responsibilities?
- What is a Student object? What are its key responsibilities?
- What is a StudentObject object? What are its key responsibilities?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Christopher Brandsdal |
last post by:
Hi!
I get an error when I run my code
Is there any other way to get te information from my form?
Heres the error I get and the code beneath.
Line 120 is market with ''''''''''''Line...
|
by: Carel Lotz |
last post by:
H
We have ported our VB 6 application into VB .NET but are still integrating with a few COM + applications written in VB6 running on our application server (Win 2000 Server). We have the proxies...
|
by: Bob |
last post by:
I am displaying a form with a datagrid populated from a select of database
records which now exceed 12,000 when I select them all.
The form displays just fine with all 12,000+ entries but when I...
|
by: Bob |
last post by:
I am displaying a form with a datagrid populated from a select of database
records which now exceed 12,000 when I select them all.
The form displays just fine with all 12,000+ entries but when I...
|
by: B. Penn |
last post by:
Hi,
I was testing pointers and found that I could still dereference a
pointer and access the value/variable it pointed to after deleting it,
which confused me for "the variable it pointed to is...
|
by: baustin75 |
last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie
only when debugging in php designer 2005
--------------------------------------------------------------------------------
...
|
by: CM |
last post by:
Hi there:
I have a web project which can be open and run without problem. I didn't
open the web application for a period and during which I didn't modified any
IIS items, but now I cannot open any...
|
by: Chris |
last post by:
I posted this in the C# language group, then thought it
might be more appropriate in this group. I would not
cross-post except I want the answer so badly.
I built small C# Web and Web Service...
|
by: Christophe |
last post by:
class A {}
class B {}
interface MyInterface
{
void method(A a);
void method(B b);
}
|
by: shanemh |
last post by:
I'm starting out with c++ and for some reason I cant get my brain
around this one:
If I have the following:
void Foo (someClass& x)
{}
int Main (void)
{
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |