Hi I am trying to return a boolean value into another method, but it's not working.

public static boolean ItemFound(boolean item, String desc1, String desc2, JTextArea txt){
        	
 		      if(item == true)
		     		txt.setText(desc1);
	      	if(item == false){
						txt.setText(desc2);
						item = true;
						}
						return item;
        	
        }

and inside the other method I have

new ItemFound(pistol, "No other items found in Bedroom", "You found Pistol", txt);

the error I get is:
cannot find symbol constructor ItemFound(boolean,java.lang.String,java.lang.String,javax.swing.JTextArea)

static methods should be called like this...
ClassName.MethodName(params);
while your approach is trying to call the constructor.
it will be ....
className.ItemFound(pistol, "No other items found in Bedroom", "You found Pistol", txt);

Hi I am trying to return a boolean value into another method, but it's not working.

public static boolean ItemFound(boolean item, String desc1, String desc2, JTextArea txt){
        	
 		      if(item == true)
		     		txt.setText(desc1);
	      	if(item == false){
						txt.setText(desc2);
						item = true;
						}
						return item;
        	
        }

and inside the other method I have

new ItemFound(pistol, "No other items found in Bedroom", "You found Pistol", txt);

the error I get is:
cannot find symbol constructor ItemFound(boolean,java.lang.String,java.lang.String,javax.swing.JTextArea)

Thanks guys I managed to figure it out. I just made a constructor and then a method and called the method.

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.