void_Keyword

Java void Keyword

The void keyword in Java denotes that a method does not have a return type. However, even though a constructor method can never have a return type, it does not have the void keyword in its declaration.

Examples

The method displayBookData() does not have a return type as shown by the use of the void keyword. Note that the constructor method Book(String, String, String) does not use the void keyword even though it too does not have a return type.

Java throws Keyword

public class Book {

private String title;
private String author;
private String publisher;

public Book(String title, String author, String publisher)
{
this.title = title;
this.author = author;
this.publisher = publisher;
}

public void displayBookData()
{
System.out.println("Title: " + title);
System.out.println("Author: " + author);
System.out.println("Publisher: " + publisher);
}
}

Java throws Keyword

全部评论

相关推荐

05-22 09:23
门头沟学院 Java
点赞 评论 收藏
分享
点赞 评论 收藏
分享
这算盘打的
程序员小白条:都这样的,都是潜规则,你自己说可以实习一年就行了,实习可以随便跑路的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务