| | |
two compiler errors to do with arrays
![]() |
•
•
Join Date: Oct 2004
Posts: 44
Reputation:
Solved Threads: 0
I have two erros which I have tried everything to fix them
C:\Documents and Settings\java:14: array required, but java.lang.String found
ID[count] = ID;
^
C:\Documents and Settings\java:15: array required, but int found
mark[count] = mark;
heres the code
class Module
{
String[] ID = new String[10];
int[] score = new int[10];
int setID(String ID, int mark, int count){
//id, mark and count get passed from the main method
ID[count] = ID;
score[count] = mark;
}
C:\Documents and Settings\java:14: array required, but java.lang.String found
ID[count] = ID;
^
C:\Documents and Settings\java:15: array required, but int found
mark[count] = mark;
heres the code
class Module
{
String[] ID = new String[10];
int[] score = new int[10];
int setID(String ID, int mark, int count){
//id, mark and count get passed from the main method
ID[count] = ID;
score[count] = mark;
}
Would you mind posting the full code in the code brackets so I can get a feel for what your trying to do?
PETA People for the Eating of Tasty Animals.
FireFox
Hijack This
Ad-Aware
Hijack this tutorial
Microsoft AntiSpyware
CompUchat
FireFox
Hijack This
Ad-Aware
Hijack this tutorial
Microsoft AntiSpyware
CompUchat
•
•
Join Date: Oct 2004
Posts: 44
Reputation:
Solved Threads: 0
heres the main method then
import javax.swing.*;
public class Test{
/** Main method */
public static void main(String[] args) {
for(int count = 0;count<10;count++){
String ID = JOptionPane.showInputDialog(null,
"Enter the Students ID",
"Programming 2",
JOptionPane.QUESTION_MESSAGE);
String num = JOptionPane.showInputDialog(null,
"Enter the Students score",
"Programming 2",
JOptionPane.QUESTION_MESSAGE);
int mark = Integer.parseInt(num);
Module withData = new Module(ID, mark, count);
System.out.println("Student data = "+ withData.setID());
}
import javax.swing.*;
public class Test{
/** Main method */
public static void main(String[] args) {
for(int count = 0;count<10;count++){
String ID = JOptionPane.showInputDialog(null,
"Enter the Students ID",
"Programming 2",
JOptionPane.QUESTION_MESSAGE);
String num = JOptionPane.showInputDialog(null,
"Enter the Students score",
"Programming 2",
JOptionPane.QUESTION_MESSAGE);
int mark = Integer.parseInt(num);
Module withData = new Module(ID, mark, count);
System.out.println("Student data = "+ withData.setID());
}
![]() |
Similar Threads
- Weird compiler errors (C++)
- Object compiler errors (C++)
- c++ compiler confused by earlier errors bailing out (C++)
Other Threads in the Java Forum
- Previous Thread: Creating a GUI that accepts user input help
- Next Thread: Set Size for JSlider
| Thread Tools | Search this Thread |
android api applet application apps array arrays automation awt bidirectional binary birt bluetooth businessintelligence busy_handler(null) card chat class classes client code collision columns component constructor crashcourse database designadrawingapplicationusingjavajslider draw eclipse error errors eventlistener exception expand fractal game givemetehcodez graphics gui guidancer html ide image inetaddress integer intellij j2me java javafx javamicroeditionuseofmotionsensor javaprojects jme jni jpanel jtree julia linux list loop machine map method methods mobile mobiledevelopmentcreatejar myaggfun netbeans newbie oracle physics plazmic print problem program programming project recursion scanner server set sharepoint smart sms smsspam sort sortedmaps sql string subclass support swing textfield threads tree trolltech unlimited utility webservices windows






