This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a comment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script id="jsbin-javascript"> | |
var number = 5; | |
var text = '5'; | |
console.log(number); | |
console.log(text); | |
console.log(number == text); | |
console.log(number === text); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) { | |
int a = 14; | |
if ( (a > 0) && (a < 10) ) { | |
System.out.println("a is between 0 and 10."); | |
} | |
else if (a >= 10 && a < 20) { | |
System.out.println("a is between 10 and 20, including 10."); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) { | |
// Variables | |
Scanner input = new Scanner(System.in); | |
String name; | |
// Ask and get the user's answer | |
System.out.print("Enter your name: "); | |
name = input.next(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) { | |
// Variables | |
Scanner input = new Scanner(System.in); | |
int age; | |
// Ask a question and save their answer | |
System.out.print("Enter your age: "); | |
age = input.nextInt(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) { | |
// Three "calls" to the method 'printStuff' | |
printStuff(); | |
printStuff(); | |
printStuff(); | |
} | |
// This code only runs if it's "called" | |
public static void printStuff () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EncapsulationNonExample { | |
// variables | |
public int age; | |
// default constructor | |
public EncapsulationNonExample() { | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EncapsulationExample { | |
// variables | |
private int age; | |
// default constructor | |
public EncapsulationExample() { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Testing { | |
public static void main(String[] args) { | |
Person steve = new Person(); | |
steve.info(); | |
Person jessica = new Person("Jessica", 23, true); | |
jessica.info(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Employee extends Person { | |
// default constructor | |
public Employee() { | |
} | |
// constructor with arguments | |
public Employee(String name, int age, boolean isFemale) { | |
super(name, age, isFemale); |
NewerOlder