two compiler errors to do with arrays

Reply

Join Date: Oct 2004
Posts: 44
Reputation: ultimate_fusion is an unknown quantity at this point 
Solved Threads: 0
ultimate_fusion ultimate_fusion is offline Offline
Light Poster

two compiler errors to do with arrays

 
0
  #1
Feb 21st, 2005
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;


}
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 780
Reputation: OurNation is an unknown quantity at this point 
Solved Threads: 9
OurNation's Avatar
OurNation OurNation is offline Offline
Master Poster

Re: two compiler errors to do with arrays

 
0
  #2
Feb 21st, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 44
Reputation: ultimate_fusion is an unknown quantity at this point 
Solved Threads: 0
ultimate_fusion ultimate_fusion is offline Offline
Light Poster

Re: two compiler errors to do with arrays

 
0
  #3
Feb 21st, 2005
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());


}
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: two compiler errors to do with arrays

 
0
  #4
Feb 21st, 2005
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];
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC