943,969 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 1983
  • Java RSS
Feb 21st, 2005
0

two compiler errors to do with arrays

Expand Post »
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;


}
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
ultimate_fusion is offline Offline
44 posts
since Oct 2004
Feb 21st, 2005
0

Re: two compiler errors to do with arrays

Would you mind posting the full code in the code brackets so I can get a feel for what your trying to do?
Reputation Points: 16
Solved Threads: 9
Master Poster
OurNation is offline Offline
780 posts
since Aug 2004
Feb 21st, 2005
0

Re: two compiler errors to do with arrays

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


}
Reputation Points: 10
Solved Threads: 0
Light Poster
ultimate_fusion is offline Offline
44 posts
since Oct 2004
Feb 21st, 2005
0

Re: two compiler errors to do with arrays

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];
Reputation Points: 113
Solved Threads: 19
Postaholic
server_crash is offline Offline
2,108 posts
since Jun 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Creating a GUI that accepts user input help
Next Thread in Java Forum Timeline: Set Size for JSlider





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC