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
		
	}

}

You have a typo there; it is intValue and not intVlaue.

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! :)

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
		
	}

}
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.