PrintStream类型中的println(boolean)方法不适用于参数(void) [英] The method println(boolean) in the type PrintStream is not applicable for the arguments (void)

查看:2689
本文介绍了PrintStream类型中的println(boolean)方法不适用于参数(void)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试执行以下代码时出错:

I am getting an error when I try executing the following code:

package Abc;

public class Class3 {

    public void another() {
        System.out.println("Hello World");
    }

    public static void main(String[] args) {
        Class3 obj1 = new Class3();
        System.out.println(obj1.another());
    }

}

错误是:

The method println(boolean) in the type PrintStream is not applicable for the arguments (void)


推荐答案

你的另一个()函数返回类型是'void',基本上说它被定义为什么都不返回。

Your another() function return type is 'void' which essentially says it is defined to return nothing.

package Abc;

public class Class3 {
    public void another() {
       System.out.println("Hello World");
    }

   public static void main(String[] args) {
    Class3 obj1 = new Class3();
    obj1.another();
    }

}

这篇关于PrintStream类型中的println(boolean)方法不适用于参数(void)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆