You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Keywords and other things are also colored purple so make sure not to get confused.
Literal Forms of primitives = int literal (1), char literal ('c'), boolean literal (true), etc.
String literals ("hi") also exist but String is not a primitive.
* You may notice how String is not purple in our code. It's not a primitive but a class which we'll talk about later.
Examples of literals in this lesson include "Carl", 5, and 'c'.
Objects:
Objects are things that we will talk about later but for now you just need to know that they are instances of classes.
There are no concrete examples of objects in this lesson.
System.out:
System is a class that contains a variable named out.
The variable out holds an object that has many functions but the three that we care about are:
print(String x) - Let's you print simple text to the console.
In order to print a new line you should use "\n".
println(String x) - Let's you print simple text to the console and then move to the next line.
printf(String x, String y, String z, ...) - Let's you print formatted text to the console.
The ... is me saying that there can be an unlimited amount of Strings passed into the method.
We will talk about methods in more depth later so don't worry about it this too much just know how to do it.
Also keep in mind that you can pass in primitives to this method as they will be treated as Strings.
Inside your first string (x) you have to use %s or %d to denote where your other strings should be put.
%s is for Strings
%d is for numbers although %s will still work for primitive numbers since they are treated like strings.
The + Math operator can be used to combine two strings or a string and a primitive so you can emulate how printf works.