diff options
| -rw-r--r-- | java.html.markdown | 58 | ||||
| -rw-r--r-- | javascript.html.markdown | 4 | ||||
| -rw-r--r-- | python.html.markdown | 8 | ||||
| -rw-r--r-- | ru-ru/php-ru.html.markdown | 2 | 
4 files changed, 68 insertions, 4 deletions
diff --git a/java.html.markdown b/java.html.markdown index 4f5cde38..1813f81c 100644 --- a/java.html.markdown +++ b/java.html.markdown @@ -697,6 +697,64 @@ public abstract class Mammal()          return true;      }  } + + +// Enum Type +// +// An enum type is a special data type that enables for a variable to be a set of predefined constants. The        // variable must be equal to one of the values that have been predefined for it. +// Because they are constants, the names of an enum type's fields are in uppercase letters. +// In the Java programming language, you define an enum type by using the enum keyword. For example, you would  +// specify a days-of-the-week enum type as: + +public enum Day { +    SUNDAY, MONDAY, TUESDAY, WEDNESDAY, +    THURSDAY, FRIDAY, SATURDAY  +} + +// We can use our enum Day like that: + +public class EnumTest { +     +    // Variable Enum +    Day day; +     +    public EnumTest(Day day) { +        this.day = day; +    } +     +    public void tellItLikeItIs() { +        switch (day) { +            case MONDAY: +                System.out.println("Mondays are bad."); +                break; +                     +            case FRIDAY: +                System.out.println("Fridays are better."); +                break; +                          +            case SATURDAY:  +            case SUNDAY: +                System.out.println("Weekends are best."); +                break; +                         +            default: +                System.out.println("Midweek days are so-so."); +                break; +        } +    } +     +    public static void main(String[] args) { +        EnumTest firstDay = new EnumTest(Day.MONDAY); +        firstDay.tellItLikeItIs(); // => Mondays are bad. +        EnumTest thirdDay = new EnumTest(Day.WEDNESDAY); +        thirdDay.tellItLikeItIs(); // => Midweek days are so-so. +    } +} + +// Enum types are much more powerful than we show above.  +// The enum body can include methods and other fields. +// You can se more at https://docs.oracle.com/javase/tutorial/java/javaOO/enum.html +  ```  ## Further Reading diff --git a/javascript.html.markdown b/javascript.html.markdown index cd75b0d2..e285ca4e 100644 --- a/javascript.html.markdown +++ b/javascript.html.markdown @@ -101,6 +101,10 @@ false;  // Strings are concatenated with +  "Hello " + "world!"; // = "Hello world!" +// ... which works with more than just strings +"1, 2, " + 3; // = "1, 2, 3" +"Hello " + ["world", "!"] // = "Hello world,!" +  // and are compared with < and >  "a" < "b"; // = true diff --git a/python.html.markdown b/python.html.markdown index 753d6e8c..541bd36d 100644 --- a/python.html.markdown +++ b/python.html.markdown @@ -123,8 +123,12 @@ not False  # => True  # A string can be treated like a list of characters  "This is a string"[0]  # => 'T' -# % can be used to format strings, like this: -"%s can be %s" % ("strings", "interpolated") +#String formatting with % +#Even though the % string operator will be deprecated on Python 3.1 and removed  +#later at some time, it may still be good to know how it works. +x = 'apple' +y = 'lemon' +z = "The items in the basket are %s and %s" % (x,y)  # A newer way to format strings is the format method.  # This method is the preferred way diff --git a/ru-ru/php-ru.html.markdown b/ru-ru/php-ru.html.markdown index 5672aa90..dc254bf8 100644 --- a/ru-ru/php-ru.html.markdown +++ b/ru-ru/php-ru.html.markdown @@ -420,8 +420,6 @@ include_once 'my-file.php';  require 'my-file.php';  require_once 'my-file.php'; -// Same as include(), except require() will cause a fatal error if the -// file cannot be included.  // Действует также как и include(), но если файл не удалось подключить,  // функция выдает фатальную ошибку  | 
