confused on JSP Call JavaBeans

The Bean is :
package example_h;
import java.util.*;

public class CalBean
{
private double[] num;
public CalBean()
{
num = new double[2];
num[0] = 1;
num[1]=2;
}
public double getAverage()
{
double sum = 0;
for (int i=0;i

calculate data




Arrays

averrage:





The running result is

Arrays 45.046.047.0 averrage:
2.0

the average value is calculated properly however the array value displayed wrongly .
I do not quite understand on


There is no numList property in Bean , but actual 1,2,3 has passed to bean correctly .

Could someone give a hint?



Comments

  • The numList property is derived from the accessor methods as follows...

    getX
    setX

    x is the property name.

    so...

    setNumList
    getNumList

    numList is taken to be the property name.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion