COMP 202 Lecture 10: COMP 202 - Lecture 10 - Sep 26, 2016

26 views3 pages
hwpark22 and 40159 others unlocked
COMP 202 Full Course Notes
100
COMP 202 Full Course Notes
Verified Note
100 documents

Document Summary

Methods review public static double adder (int x){ x = x + 1; return x; Double x = 5; x = adder(x); x type mismatch error, the value in adder( ) must be an int. Does the following compile? public static void main(string[] args){ int x = 6; adder(x); System. out. println(x); public static double adder(int x){ x = x + 1; return x; On the line, adder(x); the value of adder(x) isn"t stored, you would have to write x = (int) adder(x); to print out 7. (you need to cast because the method adder returns a double). Note: there are two different variables named x. The x in the adder method is not related to the x in the main method (they store different values). Boolean is another datatype (like int, double, etc). Boolean values can take on one of two values: { true, false } Boolean variables can be combined using the and (&&), or (||), and not (!) operators.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents

Related Questions