Not able to get all the values in Array of object

public class A{

public static void firstMethod(){

B b = new B();

......

b.setting

sampleMethod(c);

..

}

public static void sampleMetod(C[] c)

long id;

long code;

for(int i=0;i<10;i++){

id = value.getId();

code = value.getCode();

}

...

}

public class B{

....

long id;

long code;

C[] c = new C[];

public C[] setting(){

....

for(int i=0;i<10;i++)

// here i'm getting 10 values form Table

id = 10000

code = 11111

c.setId(id);

c.setCode(code);

....

return c

}

}

public calss C {

long id;

long code;

....

public static void setId(long id){}

public static void setCode(long code){}

public static long getId(){

return Id;

}

public static long getCode(){

return Code;

}

}

I try to invoke setting() method in classB from class A. it will return array of object class C.

In Class A, when i try to get the values whatever set it in Class C using array of object class C, i'm not getting all the values. i got only the last value of array.

can u pls help me how to get all the values?

Thanks for ur help in advance.

[1347 byte] By [Ayyappan_13a] at [2007-11-26 13:11:39]
# 1
When you post code, please use[code] and [/code] tags as described in [url= http://forum.java.sun.com/help.jspa?sec=formatting ]Formatting tips[/url] on the message entry page. It makes it much easier to read.
cotton.ma at 2007-7-7 17:27:31 > top of Java-index,Java Essentials,Java Programming...
# 2

public class A{

public static void firstMethod(){

B b = new B();

......

b.setting

sampleMethod(c);

..

}

public static void sampleMetod(C[] c)

long id;

long code;

for(int i=0;i<10;i++){

id = value.getId();

code = value.getCode();

}

...

}

public class B{

....

long id;

long code;

C[] c = new C[];

public C[] setting(){

....

for(int i=0;i<10;i++)

// here i'm getting 10 values form Table

id = 10000

code = 11111

c.setId(id);

c.setCode(code);

....

return c

}

}

public calss C {

long id;

long code;

....

public static void setId(long id){}

public static void setCode(long code){}

public static long getId(){

return Id;

}

public static long getCode(){

return Code;

}

}

I try to invoke setting() method in classB from class A. it will return array of object class C.

In Class A, when i try to get the values whatever set it in Class C using array of object class C, i'm not getting all the values. i got only the last value of array.

can u pls help me how to get all the values?

Thanks for ur help in advance.

Ayyappan_13a at 2007-7-7 17:27:31 > top of Java-index,Java Essentials,Java Programming...
# 3

for(int i=0;i<10;i++)

// here i'm getting 10 values form Table

id = 10000

code = 11111

c[i].setId(id);

c[i].setCode(code);

....

return c

}

You need to indes into the array. There is no way this code even compiles though, so maybe I misunderstand the problem.

~Tim

SomeoneElsea at 2007-7-7 17:27:31 > top of Java-index,Java Essentials,Java Programming...
# 4

there was some typo mistake in my previous post

public class A{

public static void firstMethod(){

B b = new B();

......

b.setting

sampleMethod(c);

..

}

public static void sampleMetod(C[] c)

long id;

long code;

for(int i=0;i<10;i++){

id = c.getId();

code = c.getCode();

}

...

}

public class B{

....

long id;

long code;

C[] c = new C[];

public C[] setting(){

....

for(int i=0;i<10;i++)

// here i'm getting 10 values form Table

id = 10000

code = 11111

c.setId(id);

c.setCode(code);

....

return c

}

}

public calss C {

long id;

long code;

....

public static void setId(long id){

c.id=id;

}

public static void setCode(long code){

c.code=code;

}

public static long getId(){

return Id;

}

public static long getCode(){

return Code;

}

}

I try to invoke setting() method in classB from class A. it will return array of object class C.

In Class A, when i try to get the values whatever set it in Class C using array of object class C, i'm not getting all the values. i got only the last value of array.

can u pls help me how to get all the values?

Thanks for ur help in advance.

Ayyappan_13a at 2007-7-7 17:27:32 > top of Java-index,Java Essentials,Java Programming...
# 5
Your code still has about a dozen compiler errors, you should work on getting the basics fixed first. Start here, it'll teach you how to fix the problems: http://java.sun.com/docs/books/tutorial/
hunter9000a at 2007-7-7 17:27:32 > top of Java-index,Java Essentials,Java Programming...