Can someone please explain to me why I cannot move variables from object to object. I've been getting no sleep and burning myself out learning java and it is driving me crazy here is the example.

import static java.lang.System.out;
class ONE	{
	public static void main(String[] args)	{



	TWO addition = new TWO();


	double test = 123.321;
	double test2 = 456.654;
	double test3 = 888.888;

	double sum =
		addition.getadded(test, test2);
		out.println(sum);


	}


}

and

import static java.lang.System.out;
class TWO	{

	double getadded(test, test2){
		return test + test2;

	}


}

and error

--------------------Configuration: <Default>--------------------
C:\Users\Empire\Desktop\java\testing\TWO.java:4: <identifier> expected
	double getadded(test, test2){
	                    ^
C:\Users\Empire\Desktop\java\testing\TWO.java:4: <identifier> expected
	double getadded(test, test2){
	                           ^
C:\Users\Empire\Desktop\java\testing\TWO.java:4: cannot find symbol
symbol  : class test
location: class TWO
	double getadded(test, test2){
	                ^
C:\Users\Empire\Desktop\java\testing\TWO.java:4: cannot find symbol
symbol  : class test2
location: class TWO
	double getadded(test, test2){
	                      ^
C:\Users\Empire\Desktop\java\testing\TWO.java:5: cannot find symbol
symbol  : variable test
location: class TWO
		return test + test2;
		       ^
C:\Users\Empire\Desktop\java\testing\TWO.java:5: cannot find symbol
symbol  : variable test2
location: class TWO
		return test + test2;
		              ^
C:\Users\Empire\Desktop\java\testing\TWO.java:5: incompatible types
found   : java.lang.String
required: double
		return test + test2;
		            ^
7 errors

Process completed.

thank you in advance

Recommended Answers

All 3 Replies

<identifier> expected

The compiler is looking for a data type like int or double.

Look at how to define a method.

You forgot to declare the paramaters' type in the getadded() method in class TWO. You have to write something like this:

public getadded(double test, double test2)

@PatrixCR That's close but its still missing something.

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.