Science, Tech, Math › Computer Science The Void Keyword Print TommL / Vetta / Getty Images Computer Science Java Programming PHP Programming Perl Python Javascript Programming Delphi Programming C & C++ Programming Ruby Programming Visual Basic View More By Paul Leahy Paul Leahy Computer Science Expert M.A., Advanced Information Systems, University of Glasgow Paul Leahy is a computer programmer with over a decade of experience working in the IT industry, as both an in-house and vendor-based developer. Learn about our Editorial Process Updated on May 28, 2018 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. Read More A Guide to "Void" in Computer Programming By David Bolton 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. 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); } } Cite this Article Format mla apa chicago Your Citation Leahy, Paul. "The Void Keyword." ThoughtCo, Aug. 26, 2020, thoughtco.com/void-2034326. Leahy, Paul. (2020, August 26). The Void Keyword. Retrieved from https://www.thoughtco.com/void-2034326 Leahy, Paul. "The Void Keyword." ThoughtCo. https://www.thoughtco.com/void-2034326 (accessed April 19, 2024). copy citation