aspose file tools*
The moose likes Java in General and the fly likes void return type is not allowded HF SCJP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "void return type is not allowded HF SCJP" Watch "void return type is not allowded HF SCJP" New topic
Author

void return type is not allowded HF SCJP

Satyajeet Kadam
Ranch Hand

Joined: Oct 19, 2006
Posts: 215
Please see Page no28 Chapter 1 [Kathy Sierra]

<code>
package cert;

/**
*
* @author satya
*/


public class Roo
{
public String doRooThings()
{
return "Fun";
}

}


package notcert;
/*
* Main.java
*
* Created on January 14, 2007, 11:19 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
import cert.*;




class Cloo extends Roo
{
public void testCloo()
{
// System.out.println(this.testCloo());==> printes error "void type is noy allowded"
this.testCloo(); //now this works fine
}

}

</code>

Q1) Please let me know why "System.out.println(this.testCloo())" is not allowing not print value?
amit punekar
Ranch Hand

Joined: May 14, 2004
Posts: 516
Hi,
This is because System.out.println() expects either of the "boolean,char,char[] ,double ,float ,int,long,Object,String". Your method testCloo() returns void and hence the compiler error mentions that method returning void can not be used here.

thanks,
amit

P.S: Your subject of the post is confusing.


Regards,
Amit
Nicholas Jordan
Ranch Hand

Joined: Sep 17, 2006
Posts: 1282
Not sure what you are asking yet, but here is some code that will compile.
Please examine this code and clarifiy your question, others will be able to help you then.

To change this template, choose Tools | Template Manager ... ?

What template, from where ?


"The differential equations that describe dynamic interactions of power generators are similar to that of the gravitational interplay among celestial bodies, which is chaotic in nature."
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: void return type is not allowded HF SCJP