954,518 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

two compiler errors to do with arrays

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;


}

ultimate_fusion
Light Poster
44 posts since Oct 2004
Reputation Points: 10
Solved Threads: 0
 

Would you mind posting the full code in the code brackets so I can get a feel for what your trying to do?

OurNation
Master Poster
780 posts since Aug 2004
Reputation Points: 16
Solved Threads: 9
 

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());


}

ultimate_fusion
Light Poster
44 posts since Oct 2004
Reputation Points: 10
Solved Threads: 0
 

The elements of ID, mark or whatever have to be of the same type as what those arrays are...

String[] ID = new String[12];

int[] mark = new int[12];

server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You