COMP 202 Lecture 6: Void Methods

26 views3 pages
jc123 and 40170 others unlocked
COMP 202 Full Course Notes
100
COMP 202 Full Course Notes
Verified Note
100 documents

Document Summary

The method will return a random number between 0 and 1. A method is a named block of code that performs a task. Methods are inside a class, and one class can contain more than one method. We call a method in order to execute the code contained in the method. Comp 202 lecture 6 void methods. It is good practice to have either the main method as the first or the last method in the class. Methods that take no input and return no value. Methods that take inputs but return no value eg. system. out. println. Example of a method that takes no input and returns no result: void: they do not return a value. The parenthesis after the method is where you list the variables, parameters, where the method stores its argument. The method you create must be called from the main method: This void method just prints cities in which i have lived.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents