CSE 110 - 3rd set of Notes
CSE 110 - 3rd set of Notes CSE 110
Popular in Prin of Programming with Java Lecture
Popular in ComputerScienence
This 4 page Class Notes was uploaded by RianMartins on Thursday October 15, 2015. The Class Notes belongs to CSE 110 at Arizona State University taught by Justin Selgrad in Fall 2015. Since its upload, it has received 64 views. For similar materials see Prin of Programming with Java Lecture in ComputerScienence at Arizona State University.
Reviews for CSE 110 - 3rd set of Notes
Report this Material
What is Karma?
Karma is the currency of StudySoup.
Date Created: 10/15/15
CSE 110 PRINCIPLES OF PROGRAMMING IN JAVA WEEKLY NOTES 3 Functions amp Methods Mathematics Java Defining Functions Defining Functions f x x 3 String substring int start int end gxyx2yxy UsingCalling the functions UsingCalling the functions f3 String a TestFunc g24 String b asubstringl4 Decision fstatement is used to make several decisions n programming in Java you can use if else and else if keywords lf statement is used to skip some statements when it is not necessary f statement starts from quotifquot keyword and then a ltexperssiongt is described within a pair of The statements are described within a block of after the condition You don39t have to use a pair of only when it has one statement in the block if ltExpressiongt if a add some statements System out println quot a is 3quot SystemoutprintlnquotDonelquot if ltExpressiongt if a 0 only one statement System out println quot a is Oquot An expression is a piece of code that can be resolved as true or false which is a boolean value eg x lt 5 true ifx is less than 5 flase otherwise Data Type The boolean is a primitive data type of true or false Declaration and Assignment lttypegt ltvariabenamegt lttypegt ltvariabenamegt lttrue or falsegt eg boolean isMale true Use true all lowercase Not True or TRUE boolean isValid false Use false all lowercase Not False or FALSE Logical Operators Logical operators are used to compare two values Equality Inequalities lt gt lt gt NotNegation AND logic ampamp OR logic I You can merge multiple expressions into one egxlt5 ygt10 x is less than 5 or y is more than 10 What is evaluated when x y 10 egxlt5ampampygt10 x is less than 5 and y is more than 10 What is evaluated when x y 10 The else block is executed only if the test expression is resolved as false if ltExpressiongt if a Systemoutprintlnquota 339 add some statements eke else Systemoutprintlnquotdonequot add some statements System out println quotnot3 quot if ltconditiongt if a add one comment System out println quotAO quot eke else addoneamnnmnt SystemoutprintlnquotnotOquot Multiple Condition lf else if else Statement is used to make more than two conditions Syntax ifltexpression1gt if a gt20 m a eseifltexpression 2gt else if a gt 15 m a l eBequotJ else if a gt 10 a 2 else a 3 Nested if Ifstatement can be used inside of other ifstatement Syntax if ltexpression1gt if ltexpression 2gt ese The ese block is always associated with the closest ifstatement De Morgan s Law De Morgan39s Law named after the logician Augustus De Morgan 18061871 can be used to simplify the Boolean expressions A ampamp B is equivalent to A ll B A II B is equivalent to A ampamp B A is equivalent to A