Computing.Net > Forums > Windows XP > java programming

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

java programming

Reply to Message Icon

Name: somjeet
Date: October 8, 2009 at 10:17:28 Pacific
OS: Windows XP
Subcategory: General
Tags: Java
Comment:

import java.io.DataInputStream;

class student
{
String name = new String("");
String sub[] = new String[4];
String roll = new String(" ");
int marks[],i;
String grade = new String("");
DataInputStream ds = new DataInputStream(System.in);
void get()
{
System.out.println("Enter");
}
void getdata()
{
System.out.println("Enter name of student: ");
try
{
name = ds.readLine();
}
catch(Exception e)
{}
System.out.println("Enter roll of student: ");
try
{
roll = ds.readLine();
}
catch(Exception e)
{}
for(i=1;i<=4;i++)
{
System.out.println("Enter Subject"+i+"of Student: ");
try
{
sub[i] = ds.readLine();
}
catch(Exception e)
{}
System.out.println("Enter Marks for Subject"+i);
try
{
marks[i] = Integer.parseInt(ds.readLine());
}
catch(Exception e)
{}
}
}
}

class m_stud
{
public static void main(String a[])
{
student[] s = new student[4];
int i=1;
for(i=1;i<=4;i++)
{
s[i].get();
}
}
}

this code doesnot work in java... it shows an error like Exception in thread "main" java.lang.NullPointerException
at m_stud.main(m_stud.java:59).
pls help



Sponsored Link
Ads by Google

Response Number 1
Name: Ewen
Date: October 8, 2009 at 15:33:40 Pacific
Reply:

Post this in the Programming Forum... link on the right of this page.

Home Page http://ewen.uuuq.com/


0
Reply to Message Icon

Related Posts

See More


image hard drive Remote desktop XP SP2 log...


Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: java programming

Swing/Java program closing down www.computing.net/answers/windows-xp/swingjava-program-closing-down-/62881.html

Java Program www.computing.net/answers/windows-xp/java-program/121110.html

Java j2re crashes windows programs www.computing.net/answers/windows-xp/java-j2re-crashes-windows-programs/149530.html