Results 1 to 2 of 2
- 07-20-2008, 02:09 PM #1
Member
- Join Date
- Jun 2008
- Posts
- 48
- Rep Power
- 0
[SOLVED] Unable to access array defiened in constructor in other methods.
/* taking user i/p for row & column size of an array..
* using constructor to collect the value which i m passing from main method
* i m type casting the i/p taken in main using Scanner class .
* Problem -->> unable to access the stud array in other methods .
*/
import java.io.*;
import java.util.Scanner;
class inuser {
public inuser(int r,int c) {
int stud[][] = new int[r][c];
for(int x=0;x<r;x++) {
for(int y=0;y<c;y++) {
int mul=(x+1)*(y+1);
stud[x][y]=mul;
}
}
} // constructor closed
public void dispaly(int r,int c) {
for(int x=0;x<r;x++) {
for(int y=0;y<c;y++) {
System.out.print("\t"+stud[x][y]);
}
System.out.println("");
}
}
public static void main(String args[]) throws IOException {
System.out.println("enter row value");
Scanner s=new Scanner(System.in);
int r=s.nextInt();
System.out.println("entred value ="+r);
System.out.println("enter Column value");
int c=s.nextInt();
System.out.println("entred value ="+c);
inuser in=new inuser(r,c);
in.display(r,c);
}
}
- 07-20-2008, 04:42 PM #2
Similar Threads
-
Array Constructor
By Javanoob828282 in forum New To JavaReplies: 1Last Post: 04-30-2008, 10:25 PM -
Calling constructor of parent class from a constructor
By Java Tip in forum Java TipReplies: 0Last Post: 12-19-2007, 09:10 AM -
Calling constructor of same class from a constructor
By Java Tip in forum Java TipReplies: 0Last Post: 12-19-2007, 09:01 AM -
problems with asigning elements of an array to a constructor
By rednessc in forum New To JavaReplies: 1Last Post: 12-14-2007, 07:25 AM -
How to access array stored in database through JSTL
By saurabh.joshi in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 11-19-2007, 01:46 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks