Skip to content

wimdetroyer/brain-q-and-a

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

Introduction

image

(source: https://xkcd.com/356/)

My brain gets a sudden urge of epistemic curiosity sometimes. A question pops up in my head, and I have to drop everything I'm doing at that point, and look up an answer immediately. Some sort of brain q & a :-)

Most of the time, after reading the answer, I immediately forget afterwards... Sometimes, they're interesting enough I want them to stick, so I add them here... Lastly, if an answer makes me ask even more questions, i'll follow-up with some follow-up questions.

Q & A

Question 1 : What is the difference between a statement a block, and an expression in Java?

An expression is any construct in java that produces a singular value.

1 == 1
    int numLetters = 0;
    Day day = Day.WEDNESDAY;
    switch (day) {
        case MONDAY, FRIDAY, SUNDAY -> numLetters = 6;
        case TUESDAY                -> numLetters = 7;
        case THURSDAY, SATURDAY     -> numLetters = 8;
        case WEDNESDAY              -> numLetters = 9;
        default -> throw new IllegalStateException("Invalid day: " + day);
    };
    System.out.println(numLetters);

A statement is a complete unit of execution_

var x = "Foo";

A block is a group of zero or more statements

{
var x = "foo";
var y =  "bar";
}

About

Brain Questions And Answers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published