i'm unable to get my entered values i initialized array to enter student record and also write functions to get this done but when i call functions i can't get any value and all output is "null"

package javaapplication10;

import javax.swing.JOptionPane;
public class JavaApplication10 {

    public int x=10;
    public int rollno[];

    public String[] name;        
       public String[] sclass;
       public int[] marks;
       public void JavaApplication10()//constructor
       {
         rollno=new int[10];
         name=new String[10];
         sclass=new String[10];
         marks=new int[10];


       }

       public void addrec(int a,String b,String c,int d)
       {


       }
       public void deletrec()
       {

       }
       public void viewrec()
       {

           for (int i=0;i<=9;i++)
       System.out.println(rollno[i]+"\t"+name[i]+"\t"+sclass[i]+"\t"+marks[i]);

       }

    public static void main(String[] args) {
        // TODO code application logic here
      JavaApplication10 objjj=new  JavaApplication10();
      objjj.JavaApplication10();
      String r=JOptionPane.showInputDialog("enter the roll number");
      int R=Integer.parseInt(r);
     String n=JOptionPane.showInputDialog("enter the name of student");
     String c=JOptionPane.showInputDialog("enter the class of student");
     String m=JOptionPane.showInputDialog("enter the marks of student");
     int M=Integer.parseInt(m);
     objjj.addrec(R,n,c,M);
     objjj.viewrec();


    }

}

Well, your addrec() method has no code, so it won't do anything...

Member Avatar for Ralphael

In addition to the answer above you have to remove the "void" from your constructor and you shouldn't be calling your constructor as a method on line 42

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.