import java.util.*;
public class course
{
static Scanner sc=new Scanner(System.in);
public static void main(String[]args)
{
String name,students,addStudent;
int numberOfStudents;
String courseName,getName,getStudents;
int getnumberOfStudents;
Course course1=new Course("C++");
Course course2=new Course("Java");
course1.addStudent("Peter");
course1.addStudent("Brian");
course1.addStudent("Anne");
course2.addStudent("Peter");
course1.addStudent("Steve");
System.out.println("Num of student in course1:"+course1.getnumberOfStudents());
String[]students=course1.getStudents();
for (int i = 0; i < course1.getNumberOfStudents(); i++)
System.out.println("Num of student in course2:"+course2.getnumberOfStudents());
String[]students=course2.getStudents();
for (int i = 0; i < course2.getNumberOfStudents(); i++)
}
}
what is the problem it does not generate the output the numOfStudents who take c++ n JAVA.please explain to me. i am not good in array...
xonxon
-4
Light Poster
Recommended Answers
Jump to Postimport java.util.*; public class course { static Scanner sc=new Scanner(System.in); public static void main(String[]args) { String name,students,addStudent; int numberOfStudents; String courseName,getName,getStudents; int getnumberOfStudents; Course course1=new Course("C++"); Course course2=new Course("Java"); course1.addStudent("Peter"); course1.addStudent("Brian"); course1.addStudent("Anne"); course2.addStudent("Peter"); course1.addStudent("Steve"); System.out.println("Num of student in course1:"+course1.getnumberOfStudents()); String[]students=course1.getStudents(); for (int i = 0; i < …
Jump to Poststart quote:
C:\Documents and Settings\Administrator\Desktop\course\src\course.java:37: illegal start of expression } ^ C:\Documents and Settings\Administrator\Desktop\course\src\course.java:38: reached end of file while parsing }2 errors Process completed.
…this is the error and i cant understand.
already change the getNumberOfStudents to getnum....
but same error generated
All 6 Replies
kekkaishi
18
Junior Poster
xonxon
-4
Light Poster
kekkaishi
18
Junior Poster
kekkaishi
18
Junior Poster
xonxon
-4
Light Poster
xonxon
-4
Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.