People, this is all my code is. I am trying to change an Integer Object to a primitive int, to use them in the getValue and Compute(Integer i) methods
. Compiler Says NO..
I have tried both the solutions below ... and got the following errors
i.intValue(); // no method intValue in Integer
Integer sum = new Integer("s"); //cannot isntatiate an integer.
I just formatted my computer and installed eclipse 3.5.2
I'm not sure if i'm doing anything wrong..but is there a library that i should install..my solutions seem logical to me .what is going on here?

public class FunctorAdd<Integer> implements Functor<Integer> {

	private int sum;
	
	@Override
	public Integer getValue() {
	
		
		return sum;
	}

	@Override
	public void compute(Integer i) {
	
		sum += i.intVlaue(); 
		// TODO Auto-generated method stub
		
	}

}

Thanks ... but i had intValue() in my programm..
I just discovered the solution altho i'm still not sure why..
I removed <Integer> from the class declaration and now it works..

public class FunctorAdd implements Functor<Integer> {

still dont know why! :)

Could you post the exact error...
It will be helpful to trace the problem.
Everything looks ok except the instantiation code -

Integer it = new Integer("S");

The argument should be a tring literal which can be parsed to Integer,
like "10", "7" etc.

Thanks ... but i had intValue() in my programm..
I just discovered the solution altho i'm still not sure why..
I removed <Integer> from the class declaration and now it works..

public class FunctorAdd implements Functor<Integer> {

still dont know why! :)

Edited 6 Years Ago by java_programmer: n/a

When you implement an Interface with some generic argument, you don't require to declare the class with generic argument.

Instead of

public class FunctorAdd<Integer> implements Functor<Integer> {

you have to define the class as

public class FunctorAdd implements Functor<Integer> {

People, this is all my code is. I am trying to change an Integer Object to a primitive int, to use them in the getValue and Compute(Integer i) methods
. Compiler Says NO..
I have tried both the solutions below ... and got the following errors
i.intValue(); // no method intValue in Integer
Integer sum = new Integer("s"); //cannot isntatiate an integer.
I just formatted my computer and installed eclipse 3.5.2
I'm not sure if i'm doing anything wrong..but is there a library that i should install..my solutions seem logical to me .what is going on here?

public class FunctorAdd<Integer> implements Functor<Integer> {

	private int sum;
	
	@Override
	public Integer getValue() {
	
		
		return sum;
	}

	@Override
	public void compute(Integer i) {
	
		sum += i.intVlaue(); 
		// TODO Auto-generated method stub
		
	}

}
This article has been dead for over six months. Start a new discussion instead.