Welcome to week 2 of Java 1.
- What was shown in the videos is not idiomatic java. Write curly braces on the same line as ifs and elses. Java is open source and you look at the source code for "String" if you want to see the common style.
- Spaces vs tabs comes down to where you work and who you work with
- The only rule of spaces vs tabs is don't mix spaces + tabs in the same file. It really makes things hard to read.
- Generally web developers (such as JavaScript people) prefer spaces. Spaces look better on GitHub!
- Generally, it seems that Java developers seem to use tabs, I think this is just due to IDE defaults.
- As with many things in life, readability is ultimately subjective. Read a lot of code and form your own opinions.
- Welcome
- Recap last week:
- what is java
- what are datatypes
- how are your editors working?
- Homework Review
- review assignment one a
- review assignment one b
- review assignment two
- Reading in data.
- Using Scanner with System.in (nextInt() and nextLine())
- Boolean expressions
- 1 == 1
- 1 == 2
- var1 == var2
- string1.equals(string2)
- Integer == Integer ???
- always use .equals for objects.
- how does .equals work?
- The rest: !=, <, >, >=, <=
- Logical Operators
- && and ||
- Conditionals
- if
- if else
- if elseif else
- switch case
- nest an if in another if
- break a program early (System.exit() - exit process, or return; early - even in void)
- Scope inside of if blocks
- what is Scope
- when does scope change
- what is a block of code?
- for loops
- components of a for loop
- how does scope work?
- While loops
- How do they differ from a for loop?
- How to break early?