1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-08-12 09:44:24 +02:00

Merge pull request #1405 from gutsy/master

Fix some grammar, spelling and indentation
This commit is contained in:
ven
2015-10-10 21:57:47 +02:00

View File

@@ -114,7 +114,7 @@ public class LearnJava {
// but they can be initialized later. // but they can be initialized later.
final double E; final double E;
E = 2.71828; E = 2.71828;
// Strings // Strings
String fooString = "My String Is Here!"; String fooString = "My String Is Here!";
@@ -348,7 +348,7 @@ public class LearnJava {
validCodes.add("FINLAND"); validCodes.add("FINLAND");
} }
// But there's a nifty way to achive the same thing in an // But there's a nifty way to achieve the same thing in an
// easier way, by using something that is called Double Brace // easier way, by using something that is called Double Brace
// Initialization. // Initialization.
@@ -358,9 +358,9 @@ public class LearnJava {
add("FINLAND"); add("FINLAND");
}} }}
// The first brace is creating an new AnonymousInnerClass and the // The first brace is creating a new AnonymousInnerClass and the
// second one declares and instance initializer block. This block // second one declares an instance initializer block. This block
// is called with the anonymous inner class is created. // is called when the anonymous inner class is created.
// This does not only work for Collections, it works for all // This does not only work for Collections, it works for all
// non-final classes. // non-final classes.
@@ -368,7 +368,7 @@ public class LearnJava {
} // End LearnJava class } // End LearnJava class
// You can include other, non-public outer-level classes in a .java file, // You can include other, non-public outer-level classes in a .java file,
// but it is good practice. Instead split classes into separate files. // but it is good practice. Instead split classes into separate files.
@@ -389,7 +389,7 @@ class Bicycle {
// Constructors are a way of creating classes // Constructors are a way of creating classes
// This is a constructor // This is a constructor
public Bicycle() { public Bicycle() {
// You can also call another constructor: // You can also call another constructor:
// this(1, 50, 5, "Bontrager"); // this(1, 50, 5, "Bontrager");
gear = 1; gear = 1;
cadence = 50; cadence = 50;
@@ -489,6 +489,7 @@ public interface Digestible {
// We can now create a class that implements both of these interfaces. // We can now create a class that implements both of these interfaces.
public class Fruit implements Edible, Digestible { public class Fruit implements Edible, Digestible {
@Override @Override
public void eat() { public void eat() {
// ... // ...
@@ -504,6 +505,7 @@ public class Fruit implements Edible, Digestible {
// interfaces. For example: // interfaces. For example:
public class ExampleClass extends ExampleClassParent implements InterfaceOne, public class ExampleClass extends ExampleClassParent implements InterfaceOne,
InterfaceTwo { InterfaceTwo {
@Override @Override
public void InterfaceOneMethod() { public void InterfaceOneMethod() {
} }
@@ -511,6 +513,7 @@ public class ExampleClass extends ExampleClassParent implements InterfaceOne,
@Override @Override
public void InterfaceTwoMethod() { public void InterfaceTwoMethod() {
} }
} }
// Abstract Classes // Abstract Classes
@@ -522,10 +525,10 @@ public class ExampleClass extends ExampleClassParent implements InterfaceOne,
// } // }
// Marking a class as abstract means that it contains abstract methods that must // Marking a class as abstract means that it contains abstract methods that must
// be defined in a child class. Similar to interfaces, abstract classes cannot // be defined in a child class. Similar to interfaces, abstract classes cannot
// be instantiated, but instead must be extended and the abstract methods // be instantiated, but instead must be extended and the abstract methods
// defined. Different from interfaces, abstract classes can contain a mixture of // defined. Different from interfaces, abstract classes can contain a mixture of
// concrete and abstract methods. Methods in an interface cannot have a body, // concrete and abstract methods. Methods in an interface cannot have a body,
// unless the method is static, and variables are final by default, unlike an // unless the method is static, and variables are final by default, unlike an
// abstract class. Also abstract classes CAN have the "main" method. // abstract class. Also abstract classes CAN have the "main" method.
@@ -541,7 +544,7 @@ public abstract class Animal
age = 30; age = 30;
} }
// No need to initialize, however in an interface // No need to initialize, however in an interface
// a variable is implicitly final and hence has // a variable is implicitly final and hence has
// to be initialized. // to be initialized.
protected int age; protected int age;
@@ -569,7 +572,7 @@ class Dog extends Animal
// age = 30; ==> ERROR! age is private to Animal // age = 30; ==> ERROR! age is private to Animal
} }
// NOTE: You will get an error if you used the // NOTE: You will get an error if you used the
// @Override annotation here, since java doesn't allow // @Override annotation here, since java doesn't allow
// overriding of static methods. // overriding of static methods.
// What is happening here is called METHOD HIDING. // What is happening here is called METHOD HIDING.
@@ -583,7 +586,7 @@ class Dog extends Animal
} }
} }
// Final Classes // Final Classes
// Final Class declaration syntax // Final Class declaration syntax
// <access-level> final <final-class-name> { // <access-level> final <final-class-name> {
@@ -592,8 +595,8 @@ class Dog extends Animal
// } // }
// Final classes are classes that cannot be inherited from and are therefore a // Final classes are classes that cannot be inherited from and are therefore a
// final child. In a way, final classes are the opposite of abstract classes // final child. In a way, final classes are the opposite of abstract classes
// because abstract classes must be extended, but final classes cannot be // because abstract classes must be extended, but final classes cannot be
// extended. // extended.
public final class SaberToothedCat extends Animal public final class SaberToothedCat extends Animal
{ {