diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_34/StringDemo/.classpath b/BasicJava/AnnotationDemo_Custom_App/AnnotationDemo/.classpath similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_34/StringDemo/.classpath rename to BasicJava/AnnotationDemo_Custom_App/AnnotationDemo/.classpath diff --git a/BasicJava/AnnotationDemo_Custom_App/AnnotationDemo/.project b/BasicJava/AnnotationDemo_Custom_App/AnnotationDemo/.project new file mode 100644 index 000000000..4384c5540 --- /dev/null +++ b/BasicJava/AnnotationDemo_Custom_App/AnnotationDemo/.project @@ -0,0 +1,17 @@ + + + AnnotationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_34/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/AnnotationDemo_Custom_App/AnnotationDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_34/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/AnnotationDemo_Custom_App/AnnotationDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/AnnotationDemo_Custom_App/AnnotationDemo/bin/AnnotationsDemo.class b/BasicJava/AnnotationDemo_Custom_App/AnnotationDemo/bin/AnnotationsDemo.class new file mode 100644 index 000000000..832bb4419 Binary files /dev/null and b/BasicJava/AnnotationDemo_Custom_App/AnnotationDemo/bin/AnnotationsDemo.class differ diff --git a/BasicJava/AnnotationDemo_Custom_App/AnnotationDemo/bin/MyAnnotation.class b/BasicJava/AnnotationDemo_Custom_App/AnnotationDemo/bin/MyAnnotation.class new file mode 100644 index 000000000..9a32cb21d Binary files /dev/null and b/BasicJava/AnnotationDemo_Custom_App/AnnotationDemo/bin/MyAnnotation.class differ diff --git a/BasicJava/AnnotationDemo_Custom_App/AnnotationDemo/src/AnnotationsDemo.java b/BasicJava/AnnotationDemo_Custom_App/AnnotationDemo/src/AnnotationsDemo.java new file mode 100644 index 000000000..8536e1d62 --- /dev/null +++ b/BasicJava/AnnotationDemo_Custom_App/AnnotationDemo/src/AnnotationsDemo.java @@ -0,0 +1,13 @@ +@interface MyAnnotation +{ + +} + +public class AnnotationsDemo +{ + @MyAnnotation + public static void main(String args[]) + { + System.out.println("Hi"); + } +} \ No newline at end of file diff --git a/BasicJava/AnnotationDemo_Custom_App/Output.txt b/BasicJava/AnnotationDemo_Custom_App/Output.txt new file mode 100644 index 000000000..b14df6442 --- /dev/null +++ b/BasicJava/AnnotationDemo_Custom_App/Output.txt @@ -0,0 +1 @@ +Hi diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_35/StringDemo/.classpath b/BasicJava/AnnotationDemo_Inherited_App/AnnotationDemo/.classpath similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_35/StringDemo/.classpath rename to BasicJava/AnnotationDemo_Inherited_App/AnnotationDemo/.classpath diff --git a/BasicJava/AnnotationDemo_Inherited_App/AnnotationDemo/.project b/BasicJava/AnnotationDemo_Inherited_App/AnnotationDemo/.project new file mode 100644 index 000000000..4384c5540 --- /dev/null +++ b/BasicJava/AnnotationDemo_Inherited_App/AnnotationDemo/.project @@ -0,0 +1,17 @@ + + + AnnotationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_35/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/AnnotationDemo_Inherited_App/AnnotationDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_35/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/AnnotationDemo_Inherited_App/AnnotationDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/AnnotationDemo_Inherited_App/AnnotationDemo/bin/A.class b/BasicJava/AnnotationDemo_Inherited_App/AnnotationDemo/bin/A.class new file mode 100644 index 000000000..8eee4fb60 Binary files /dev/null and b/BasicJava/AnnotationDemo_Inherited_App/AnnotationDemo/bin/A.class differ diff --git a/BasicJava/AnnotationDemo_Inherited_App/AnnotationDemo/bin/B.class b/BasicJava/AnnotationDemo_Inherited_App/AnnotationDemo/bin/B.class new file mode 100644 index 000000000..08c7e2db1 Binary files /dev/null and b/BasicJava/AnnotationDemo_Inherited_App/AnnotationDemo/bin/B.class differ diff --git a/BasicJava/AnnotationDemo_Inherited_App/AnnotationDemo/bin/InheritedAnnotationDemo.class b/BasicJava/AnnotationDemo_Inherited_App/AnnotationDemo/bin/InheritedAnnotationDemo.class new file mode 100644 index 000000000..00994764a Binary files /dev/null and b/BasicJava/AnnotationDemo_Inherited_App/AnnotationDemo/bin/InheritedAnnotationDemo.class differ diff --git a/BasicJava/AnnotationDemo_Inherited_App/AnnotationDemo/bin/MyAnnotation.class b/BasicJava/AnnotationDemo_Inherited_App/AnnotationDemo/bin/MyAnnotation.class new file mode 100644 index 000000000..1235f885a Binary files /dev/null and b/BasicJava/AnnotationDemo_Inherited_App/AnnotationDemo/bin/MyAnnotation.class differ diff --git a/BasicJava/AnnotationDemo_Inherited_App/AnnotationDemo/src/InheritedAnnotationDemo.java b/BasicJava/AnnotationDemo_Inherited_App/AnnotationDemo/src/InheritedAnnotationDemo.java new file mode 100644 index 000000000..c985f2a56 --- /dev/null +++ b/BasicJava/AnnotationDemo_Inherited_App/AnnotationDemo/src/InheritedAnnotationDemo.java @@ -0,0 +1,36 @@ +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Inherited +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface MyAnnotation + { + + } + +@MyAnnotation +class A +{ + +} + +class B extends A +{ + +} + +public class InheritedAnnotationDemo +{ + public static void main(String[] args) + { + System.out.println("Super class Annotation = "+new A().getClass().getAnnotation( + MyAnnotation.class)); + + System.out.println("Sub class Annotation = "+new B().getClass().getAnnotation( + MyAnnotation.class)); + } +} \ No newline at end of file diff --git a/BasicJava/AnnotationDemo_Inherited_App/Output.txt b/BasicJava/AnnotationDemo_Inherited_App/Output.txt new file mode 100644 index 000000000..a6dd72d14 --- /dev/null +++ b/BasicJava/AnnotationDemo_Inherited_App/Output.txt @@ -0,0 +1,2 @@ +Super class Annotation = @MyAnnotation() +Sub class Annotation = @MyAnnotation() diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_36/StringDemo/.classpath b/BasicJava/AnnotationDemo_Intro_App/AnnotationDemo/.classpath similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_36/StringDemo/.classpath rename to BasicJava/AnnotationDemo_Intro_App/AnnotationDemo/.classpath diff --git a/BasicJava/AnnotationDemo_Intro_App/AnnotationDemo/.project b/BasicJava/AnnotationDemo_Intro_App/AnnotationDemo/.project new file mode 100644 index 000000000..4384c5540 --- /dev/null +++ b/BasicJava/AnnotationDemo_Intro_App/AnnotationDemo/.project @@ -0,0 +1,17 @@ + + + AnnotationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_36/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/AnnotationDemo_Intro_App/AnnotationDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_36/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/AnnotationDemo_Intro_App/AnnotationDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/AnnotationDemo_Intro_App/AnnotationDemo/bin/AnnotationsDemo.class b/BasicJava/AnnotationDemo_Intro_App/AnnotationDemo/bin/AnnotationsDemo.class new file mode 100644 index 000000000..b3821a421 Binary files /dev/null and b/BasicJava/AnnotationDemo_Intro_App/AnnotationDemo/bin/AnnotationsDemo.class differ diff --git a/BasicJava/AnnotationDemo_Intro_App/AnnotationDemo/src/AnnotationsDemo.java b/BasicJava/AnnotationDemo_Intro_App/AnnotationDemo/src/AnnotationsDemo.java new file mode 100644 index 000000000..bdd151007 --- /dev/null +++ b/BasicJava/AnnotationDemo_Intro_App/AnnotationDemo/src/AnnotationsDemo.java @@ -0,0 +1,24 @@ +import java.util.ArrayList; + +public class AnnotationsDemo +{ + + /* + * If you remove the @SuppressWarnings("unchecked") + * annotation, it will show warning at compile time + * because we are using non-generic collection. + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + public static void main(String args[]) + { + ArrayList list = new ArrayList(); + list.add("Ram"); + list.add("Peter"); + + for (Object obj : list) + { + System.out.println(obj); + } + + } +} \ No newline at end of file diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_37/StringDemo/.classpath b/BasicJava/AnnotationDemo_Repeating_App/AnnotationDemo/.classpath similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_37/StringDemo/.classpath rename to BasicJava/AnnotationDemo_Repeating_App/AnnotationDemo/.classpath diff --git a/BasicJava/AnnotationDemo_Repeating_App/AnnotationDemo/.project b/BasicJava/AnnotationDemo_Repeating_App/AnnotationDemo/.project new file mode 100644 index 000000000..4384c5540 --- /dev/null +++ b/BasicJava/AnnotationDemo_Repeating_App/AnnotationDemo/.project @@ -0,0 +1,17 @@ + + + AnnotationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_37/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/AnnotationDemo_Repeating_App/AnnotationDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_37/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/AnnotationDemo_Repeating_App/AnnotationDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/AnnotationDemo_Repeating_App/AnnotationDemo/bin/Car.class b/BasicJava/AnnotationDemo_Repeating_App/AnnotationDemo/bin/Car.class new file mode 100644 index 000000000..fedc52efb Binary files /dev/null and b/BasicJava/AnnotationDemo_Repeating_App/AnnotationDemo/bin/Car.class differ diff --git a/BasicJava/AnnotationDemo_Repeating_App/AnnotationDemo/bin/Cars.class b/BasicJava/AnnotationDemo_Repeating_App/AnnotationDemo/bin/Cars.class new file mode 100644 index 000000000..a7e10d048 Binary files /dev/null and b/BasicJava/AnnotationDemo_Repeating_App/AnnotationDemo/bin/Cars.class differ diff --git a/BasicJava/AnnotationDemo_Repeating_App/AnnotationDemo/bin/Manufacturer.class b/BasicJava/AnnotationDemo_Repeating_App/AnnotationDemo/bin/Manufacturer.class new file mode 100644 index 000000000..8c5974a44 Binary files /dev/null and b/BasicJava/AnnotationDemo_Repeating_App/AnnotationDemo/bin/Manufacturer.class differ diff --git a/BasicJava/AnnotationDemo_Repeating_App/AnnotationDemo/bin/RepeatingAnnotations.class b/BasicJava/AnnotationDemo_Repeating_App/AnnotationDemo/bin/RepeatingAnnotations.class new file mode 100644 index 000000000..23ed7cf54 Binary files /dev/null and b/BasicJava/AnnotationDemo_Repeating_App/AnnotationDemo/bin/RepeatingAnnotations.class differ diff --git a/BasicJava/AnnotationDemo_Repeating_App/AnnotationDemo/src/Car.java b/BasicJava/AnnotationDemo_Repeating_App/AnnotationDemo/src/Car.java new file mode 100644 index 000000000..43e3da73a --- /dev/null +++ b/BasicJava/AnnotationDemo_Repeating_App/AnnotationDemo/src/Car.java @@ -0,0 +1,38 @@ +import java.lang.annotation.Repeatable; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/* + * Step 1: Declare a Repeatable Annotation Type + * + * The annotation type must be marked with the + * @Repeatable meta-annotation + */ +@Repeatable(value = Cars.class) +@interface Manufacturer + { + String name(); + }; + +/* + * Step 2: Declare the Containing Annotation Type + * + * The containing annotation type must have a value element + * with an array type. The component type of the array type + * must be the repeatable annotation type. + */ +@Retention(RetentionPolicy.RUNTIME) +@interface Cars + { + Manufacturer[] value() default + {}; + } + +@Manufacturer(name = "Mercedes Benz") +@Manufacturer(name = "Toyota") +@Manufacturer(name = "BMW") +@Manufacturer(name = "Range Rover") +public interface Car +{ + +} diff --git a/BasicJava/AnnotationDemo_Repeating_App/AnnotationDemo/src/RepeatingAnnotations.java b/BasicJava/AnnotationDemo_Repeating_App/AnnotationDemo/src/RepeatingAnnotations.java new file mode 100644 index 000000000..ccdb6fd03 --- /dev/null +++ b/BasicJava/AnnotationDemo_Repeating_App/AnnotationDemo/src/RepeatingAnnotations.java @@ -0,0 +1,39 @@ +public class RepeatingAnnotations +{ + + public static void main(String[] args) + { + + /* + * Retrieving Annotations using Reflection API + * method + */ + Manufacturer[] manufacturerArray = Car.class + .getAnnotationsByType(Manufacturer.class); + + System.out.println("Number of car manufacturers is " + + manufacturerArray.length); + + for (Manufacturer manufacturer : manufacturerArray) + { + System.out.println(manufacturer + " , name = " + + manufacturer.name()); + } + + System.out.println("\n-------Printing out Car Manufacturers--------"); + + /* + * Retrieving Annotations using Reflection API + * method + */ + Cars cars = Car.class.getAnnotation(Cars.class); + System.out.println(cars); + manufacturerArray = cars.value(); + for (Manufacturer manufacturer : manufacturerArray) + { + System.out.println(manufacturer + " , name = " + + manufacturer.name()); + } + + } +} \ No newline at end of file diff --git a/BasicJava/AnnotationDemo_Repeating_App/Output.txt b/BasicJava/AnnotationDemo_Repeating_App/Output.txt new file mode 100644 index 000000000..b25571f45 --- /dev/null +++ b/BasicJava/AnnotationDemo_Repeating_App/Output.txt @@ -0,0 +1,15 @@ +Number of car manufacturers is 4 +@Manufacturer(name=Mercedes Benz) , name = Mercedes Benz +@Manufacturer(name=Toyota) , name = Toyota +@Manufacturer(name=BMW) , name = BMW +@Manufacturer(name=Range Rover) , name = Range Rover + +-------Printing out Car Manufacturers-------- +@Cars(value=[@Manufacturer(name=Mercedes Benz), +@Manufacturer(name=Toyota), @Manufacturer(name=BMW), +@Manufacturer(name=Range Rover)]) + +@Manufacturer(name=Mercedes Benz) , name = Mercedes Benz +@Manufacturer(name=Toyota) , name = Toyota +@Manufacturer(name=BMW) , name = BMW +@Manufacturer(name=Range Rover) , name = Range Rover diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_38/StringDemo/.classpath b/BasicJava/AnnotationDemo_Repeating_Sch_App/AnnotationDemo/.classpath similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_38/StringDemo/.classpath rename to BasicJava/AnnotationDemo_Repeating_Sch_App/AnnotationDemo/.classpath diff --git a/BasicJava/AnnotationDemo_Repeating_Sch_App/AnnotationDemo/.project b/BasicJava/AnnotationDemo_Repeating_Sch_App/AnnotationDemo/.project new file mode 100644 index 000000000..4384c5540 --- /dev/null +++ b/BasicJava/AnnotationDemo_Repeating_Sch_App/AnnotationDemo/.project @@ -0,0 +1,17 @@ + + + AnnotationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_38/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/AnnotationDemo_Repeating_Sch_App/AnnotationDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_38/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/AnnotationDemo_Repeating_Sch_App/AnnotationDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/AnnotationDemo_Repeating_Sch_App/AnnotationDemo/bin/RepeatingAnnotations.class b/BasicJava/AnnotationDemo_Repeating_Sch_App/AnnotationDemo/bin/RepeatingAnnotations.class new file mode 100644 index 000000000..e3fe7dc69 Binary files /dev/null and b/BasicJava/AnnotationDemo_Repeating_Sch_App/AnnotationDemo/bin/RepeatingAnnotations.class differ diff --git a/BasicJava/AnnotationDemo_Repeating_Sch_App/AnnotationDemo/bin/Schedule.class b/BasicJava/AnnotationDemo_Repeating_Sch_App/AnnotationDemo/bin/Schedule.class new file mode 100644 index 000000000..813a0f4f9 Binary files /dev/null and b/BasicJava/AnnotationDemo_Repeating_Sch_App/AnnotationDemo/bin/Schedule.class differ diff --git a/BasicJava/AnnotationDemo_Repeating_Sch_App/AnnotationDemo/bin/Schedules.class b/BasicJava/AnnotationDemo_Repeating_Sch_App/AnnotationDemo/bin/Schedules.class new file mode 100644 index 000000000..687941c32 Binary files /dev/null and b/BasicJava/AnnotationDemo_Repeating_Sch_App/AnnotationDemo/bin/Schedules.class differ diff --git a/BasicJava/AnnotationDemo_Repeating_Sch_App/AnnotationDemo/bin/ServerRestartSchedule.class b/BasicJava/AnnotationDemo_Repeating_Sch_App/AnnotationDemo/bin/ServerRestartSchedule.class new file mode 100644 index 000000000..502e8f64c Binary files /dev/null and b/BasicJava/AnnotationDemo_Repeating_Sch_App/AnnotationDemo/bin/ServerRestartSchedule.class differ diff --git a/BasicJava/AnnotationDemo_Repeating_Sch_App/AnnotationDemo/src/RepeatingAnnotations.java b/BasicJava/AnnotationDemo_Repeating_Sch_App/AnnotationDemo/src/RepeatingAnnotations.java new file mode 100644 index 000000000..ad6f557f2 --- /dev/null +++ b/BasicJava/AnnotationDemo_Repeating_Sch_App/AnnotationDemo/src/RepeatingAnnotations.java @@ -0,0 +1,23 @@ +public class RepeatingAnnotations +{ + + public static void main(String[] args) + { + + /* + * Retrieving Annotations using Reflection API + * method + */ + Schedules schedules = ServerRestartSchedule.class + .getAnnotation(Schedules.class); + System.out.println(schedules); + Schedule[] scheduleArray = schedules.value(); + for (Schedule schedule : scheduleArray) + { + System.out.println(schedule + " , dayOfMonth = " + + schedule.dayOfMonth() + " , dayOfWeek = " + + schedule.dayOfWeek() + " , hour = " + schedule.hour()); + } + + } +} \ No newline at end of file diff --git a/BasicJava/AnnotationDemo_Repeating_Sch_App/AnnotationDemo/src/ServerRestartSchedule.java b/BasicJava/AnnotationDemo_Repeating_Sch_App/AnnotationDemo/src/ServerRestartSchedule.java new file mode 100644 index 000000000..d727837c8 --- /dev/null +++ b/BasicJava/AnnotationDemo_Repeating_Sch_App/AnnotationDemo/src/ServerRestartSchedule.java @@ -0,0 +1,51 @@ +import java.lang.annotation.Repeatable; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/* + * Step 1: Declare a Repeatable Annotation Type + * + * The annotation type must be marked with the + * + * @Repeatable meta-annotation. + * + * The value of the @Repeatable meta-annotation, in + * parentheses, is the type of the container + * annotation that the Java compiler generates to + * store repeating annotations. In this example, the + * containing annotation type is Schedules, so + * repeating @Schedule annotations is stored in an + * @Schedules annotation. + */ + +@Repeatable(Schedules.class) +@interface Schedule + { + + String dayOfMonth() default "first"; + + String dayOfWeek() default "Mon"; + + int hour() default 12; + } + +/* + * Step 2: Declare the Containing Annotation Type + * + * The containing annotation type must have a value element + * with an array type. The component type of the array type + * must be the repeatable annotation type. + */ +@Retention(RetentionPolicy.RUNTIME) +@interface Schedules + { + Schedule[] value(); + } + +@Schedule +@Schedule(dayOfMonth = "second", dayOfWeek = "Tue", hour = 17) +@Schedule(dayOfMonth = "third", dayOfWeek = "Wed", hour = 24) +public class ServerRestartSchedule +{ + +} diff --git a/BasicJava/AnnotationDemo_Repeating_Sch_App/Output.txt b/BasicJava/AnnotationDemo_Repeating_Sch_App/Output.txt new file mode 100644 index 000000000..fc5effeb5 --- /dev/null +++ b/BasicJava/AnnotationDemo_Repeating_Sch_App/Output.txt @@ -0,0 +1,12 @@ +@Schedules(value=[@Schedule(hour=12, dayOfMonth=first, dayOfWeek=Mon), +@Schedule(hour=17, dayOfMonth=second, dayOfWeek=Tue), +@Schedule(hour=24, dayOfMonth=third, dayOfWeek=Wed)]) + +@Schedule(hour=12, dayOfMonth=first, dayOfWeek=Mon) , +dayOfMonth = first , dayOfWeek = Mon , hour = 12 + +@Schedule(hour=17, dayOfMonth=second, dayOfWeek=Tue) , +dayOfMonth = second , dayOfWeek = Tue , hour = 17 + +@Schedule(hour=24, dayOfMonth=third, dayOfWeek=Wed) , +dayOfMonth = third , dayOfWeek = Wed , hour = 24 diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_39/StringDemo/.classpath b/BasicJava/AnnotationDemo_Retention_App/AnnotationDemo/.classpath similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_39/StringDemo/.classpath rename to BasicJava/AnnotationDemo_Retention_App/AnnotationDemo/.classpath diff --git a/BasicJava/AnnotationDemo_Retention_App/AnnotationDemo/.project b/BasicJava/AnnotationDemo_Retention_App/AnnotationDemo/.project new file mode 100644 index 000000000..4384c5540 --- /dev/null +++ b/BasicJava/AnnotationDemo_Retention_App/AnnotationDemo/.project @@ -0,0 +1,17 @@ + + + AnnotationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_39/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/AnnotationDemo_Retention_App/AnnotationDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_39/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/AnnotationDemo_Retention_App/AnnotationDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/AnnotationDemo_Retention_App/AnnotationDemo/bin/Message.class b/BasicJava/AnnotationDemo_Retention_App/AnnotationDemo/bin/Message.class new file mode 100644 index 000000000..408bd7ff9 Binary files /dev/null and b/BasicJava/AnnotationDemo_Retention_App/AnnotationDemo/bin/Message.class differ diff --git a/BasicJava/AnnotationDemo_Retention_App/AnnotationDemo/bin/MultiValueAnnotationDemo.class b/BasicJava/AnnotationDemo_Retention_App/AnnotationDemo/bin/MultiValueAnnotationDemo.class new file mode 100644 index 000000000..27b220712 Binary files /dev/null and b/BasicJava/AnnotationDemo_Retention_App/AnnotationDemo/bin/MultiValueAnnotationDemo.class differ diff --git a/BasicJava/AnnotationDemo_Retention_App/AnnotationDemo/bin/MyMultiValueAnnotation.class b/BasicJava/AnnotationDemo_Retention_App/AnnotationDemo/bin/MyMultiValueAnnotation.class new file mode 100644 index 000000000..bbad0ff52 Binary files /dev/null and b/BasicJava/AnnotationDemo_Retention_App/AnnotationDemo/bin/MyMultiValueAnnotation.class differ diff --git a/BasicJava/AnnotationDemo_Retention_App/AnnotationDemo/src/MultiValueAnnotationDemo.java b/BasicJava/AnnotationDemo_Retention_App/AnnotationDemo/src/MultiValueAnnotationDemo.java new file mode 100644 index 000000000..2457a92b7 --- /dev/null +++ b/BasicJava/AnnotationDemo_Retention_App/AnnotationDemo/src/MultiValueAnnotationDemo.java @@ -0,0 +1,45 @@ +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.Method; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +@interface MyMultiValueAnnotation +{ + int getValue() default 2; + + String getMessage() default "hello"; + + double getDoubleValue() default 5.5; +} + +class Message +{ + @MyMultiValueAnnotation + public void displayHi() + { + System.out.println("Hi"); + } +} + +public class MultiValueAnnotationDemo +{ + + public static void main(String[] args) throws NoSuchMethodException, + SecurityException + { + Message message = new Message(); + Method method = message.getClass().getMethod("displayHi"); + + MyMultiValueAnnotation mmva = method + .getAnnotation(MyMultiValueAnnotation.class); + + System.out.println("value is: " + mmva.getValue()); + System.out.println("message is: " + mmva.getMessage()); + System.out.println("DoubleValue is: " + mmva.getDoubleValue()); + + } + +} diff --git a/BasicJava/AnnotationDemo_Retention_App/Output.txt b/BasicJava/AnnotationDemo_Retention_App/Output.txt new file mode 100644 index 000000000..bd4580275 --- /dev/null +++ b/BasicJava/AnnotationDemo_Retention_App/Output.txt @@ -0,0 +1,3 @@ +value is: 2 +message is: hello +DoubleValue is: 5.5 diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_40/StringDemo/.classpath b/BasicJava/AnnotationDemo_Target_App/AnnotationDemo/.classpath similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_40/StringDemo/.classpath rename to BasicJava/AnnotationDemo_Target_App/AnnotationDemo/.classpath diff --git a/BasicJava/AnnotationDemo_Target_App/AnnotationDemo/.project b/BasicJava/AnnotationDemo_Target_App/AnnotationDemo/.project new file mode 100644 index 000000000..4384c5540 --- /dev/null +++ b/BasicJava/AnnotationDemo_Target_App/AnnotationDemo/.project @@ -0,0 +1,17 @@ + + + AnnotationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_40/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/AnnotationDemo_Target_App/AnnotationDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_40/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/AnnotationDemo_Target_App/AnnotationDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/AnnotationDemo_Target_App/AnnotationDemo/bin/Message.class b/BasicJava/AnnotationDemo_Target_App/AnnotationDemo/bin/Message.class new file mode 100644 index 000000000..408bd7ff9 Binary files /dev/null and b/BasicJava/AnnotationDemo_Target_App/AnnotationDemo/bin/Message.class differ diff --git a/BasicJava/AnnotationDemo_Target_App/AnnotationDemo/bin/MultiValueAnnotationDemo.class b/BasicJava/AnnotationDemo_Target_App/AnnotationDemo/bin/MultiValueAnnotationDemo.class new file mode 100644 index 000000000..27b220712 Binary files /dev/null and b/BasicJava/AnnotationDemo_Target_App/AnnotationDemo/bin/MultiValueAnnotationDemo.class differ diff --git a/BasicJava/AnnotationDemo_Target_App/AnnotationDemo/bin/MyMultiValueAnnotation.class b/BasicJava/AnnotationDemo_Target_App/AnnotationDemo/bin/MyMultiValueAnnotation.class new file mode 100644 index 000000000..bbad0ff52 Binary files /dev/null and b/BasicJava/AnnotationDemo_Target_App/AnnotationDemo/bin/MyMultiValueAnnotation.class differ diff --git a/BasicJava/AnnotationDemo_Target_App/AnnotationDemo/src/HelloWorld.java b/BasicJava/AnnotationDemo_Target_App/AnnotationDemo/src/HelloWorld.java new file mode 100644 index 000000000..adf95c4d6 --- /dev/null +++ b/BasicJava/AnnotationDemo_Target_App/AnnotationDemo/src/HelloWorld.java @@ -0,0 +1,26 @@ +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) +@interface MyAnnotation + { + int getValue() default 2; + + String getMessage() default "hello"; + + double getDoubleValue() default 5.5; + } + + +@MyAnnotation +public class HelloWorld +{ + @MyAnnotation + private int value; + + @MyAnnotation + public void displayHelloWorld() + { + System.out.println("Hello World"); + } +} diff --git a/BasicJava/AnnotationDemo_Target_App/AnnotationDemo/src/Message.java b/BasicJava/AnnotationDemo_Target_App/AnnotationDemo/src/Message.java new file mode 100644 index 000000000..b2c53805c --- /dev/null +++ b/BasicJava/AnnotationDemo_Target_App/AnnotationDemo/src/Message.java @@ -0,0 +1,22 @@ +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@Target(ElementType.METHOD) +@interface MyMultiValueAnnotation + { + int getValue() default 2; + + String getMessage() default "hello"; + + double getDoubleValue() default 5.5; + } + +public class Message +{ + @MyMultiValueAnnotation + public void displayHi() + { + System.out.println("Hi"); + } +} + diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_41/StringDemo/.classpath b/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/.classpath similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_41/StringDemo/.classpath rename to BasicJava/AnnotationDemo_Types_App/AnnotationDemo/.classpath diff --git a/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/.project b/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/.project new file mode 100644 index 000000000..4384c5540 --- /dev/null +++ b/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/.project @@ -0,0 +1,17 @@ + + + AnnotationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_41/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_41/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/AnnotationDemo_Types_App/AnnotationDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/bin/Display.class b/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/bin/Display.class new file mode 100644 index 000000000..365b1c209 Binary files /dev/null and b/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/bin/Display.class differ diff --git a/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/bin/MarkerAnnotationDemo.class b/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/bin/MarkerAnnotationDemo.class new file mode 100644 index 000000000..14b711de5 Binary files /dev/null and b/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/bin/MarkerAnnotationDemo.class differ diff --git a/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/bin/Message.class b/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/bin/Message.class new file mode 100644 index 000000000..f0769ee8c Binary files /dev/null and b/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/bin/Message.class differ diff --git a/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/bin/MultiValueAnnotationDemo.class b/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/bin/MultiValueAnnotationDemo.class new file mode 100644 index 000000000..aad944421 Binary files /dev/null and b/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/bin/MultiValueAnnotationDemo.class differ diff --git a/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/bin/MyMarkerAnnotation.class b/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/bin/MyMarkerAnnotation.class new file mode 100644 index 000000000..ea28ed3af Binary files /dev/null and b/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/bin/MyMarkerAnnotation.class differ diff --git a/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/bin/MyMultiValueAnnotation.class b/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/bin/MyMultiValueAnnotation.class new file mode 100644 index 000000000..0a0e32972 Binary files /dev/null and b/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/bin/MyMultiValueAnnotation.class differ diff --git a/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/bin/MySingleValueAnnotation.class b/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/bin/MySingleValueAnnotation.class new file mode 100644 index 000000000..b456b0bf8 Binary files /dev/null and b/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/bin/MySingleValueAnnotation.class differ diff --git a/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/bin/SingleValueAnnotationDemo.class b/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/bin/SingleValueAnnotationDemo.class new file mode 100644 index 000000000..6dd147e6b Binary files /dev/null and b/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/bin/SingleValueAnnotationDemo.class differ diff --git a/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/src/MarkerAnnotationDemo.java b/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/src/MarkerAnnotationDemo.java new file mode 100644 index 000000000..c63c9d29f --- /dev/null +++ b/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/src/MarkerAnnotationDemo.java @@ -0,0 +1,19 @@ +@interface MyMarkerAnnotation +{ + +} + +public class MarkerAnnotationDemo +{ + @MyMarkerAnnotation + public void display() + { + System.out.println("Hi"); + } + + public static void main(String args[]) + { + MarkerAnnotationDemo markerAnnotationDemo = new MarkerAnnotationDemo(); + markerAnnotationDemo.display(); + } +} \ No newline at end of file diff --git a/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/src/MultiValueAnnotationDemo.java b/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/src/MultiValueAnnotationDemo.java new file mode 100644 index 000000000..792da8b17 --- /dev/null +++ b/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/src/MultiValueAnnotationDemo.java @@ -0,0 +1,42 @@ +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.Method; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +@interface MyMultiValueAnnotation +{ + int getValue(); + + String getMessage(); +} + +class Message +{ + @MyMultiValueAnnotation(getValue = 500, getMessage = "Welcome") + public void displayHi() + { + System.out.println("Hi"); + } +} + +public class MultiValueAnnotationDemo +{ + + public static void main(String[] args) throws NoSuchMethodException, + SecurityException + { + Message message = new Message(); + Method method = message.getClass().getMethod("displayHi"); + + MyMultiValueAnnotation mmva = method + .getAnnotation(MyMultiValueAnnotation.class); + + System.out.println("value is: " + mmva.getValue()); + System.out.println("message is: " + mmva.getMessage()); + + } + +} diff --git a/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/src/SingleValueAnnotationDemo.java b/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/src/SingleValueAnnotationDemo.java new file mode 100644 index 000000000..2b995877f --- /dev/null +++ b/BasicJava/AnnotationDemo_Types_App/AnnotationDemo/src/SingleValueAnnotationDemo.java @@ -0,0 +1,39 @@ +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.Method; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +@interface MySingleValueAnnotation +{ + int getValue(); +} + +class Display +{ + @MySingleValueAnnotation(getValue = 20) + public void displayHi() + { + System.out.println("Hi"); + } +} + +public class SingleValueAnnotationDemo +{ + + public static void main(String[] args) throws NoSuchMethodException, + SecurityException + { + Display display = new Display(); + Method method = display.getClass().getMethod("displayHi"); + + MySingleValueAnnotation msva = method + .getAnnotation(MySingleValueAnnotation.class); + + System.out.println("value is: " + msva.getValue()); + + } + +} diff --git a/BasicJava/AnnotationDemo_Types_App/MarkerAnnotationDemo_Output.txt b/BasicJava/AnnotationDemo_Types_App/MarkerAnnotationDemo_Output.txt new file mode 100644 index 000000000..b14df6442 --- /dev/null +++ b/BasicJava/AnnotationDemo_Types_App/MarkerAnnotationDemo_Output.txt @@ -0,0 +1 @@ +Hi diff --git a/BasicJava/AnnotationDemo_Types_App/MultiValueAnnotationDemo_Output.txt b/BasicJava/AnnotationDemo_Types_App/MultiValueAnnotationDemo_Output.txt new file mode 100644 index 000000000..e08f1a420 --- /dev/null +++ b/BasicJava/AnnotationDemo_Types_App/MultiValueAnnotationDemo_Output.txt @@ -0,0 +1,2 @@ +value is: 500 +message is: Welcome diff --git a/BasicJava/AnnotationDemo_Types_App/SingleValueAnnotationDemo_Output.txt b/BasicJava/AnnotationDemo_Types_App/SingleValueAnnotationDemo_Output.txt new file mode 100644 index 000000000..55a8666e0 --- /dev/null +++ b/BasicJava/AnnotationDemo_Types_App/SingleValueAnnotationDemo_Output.txt @@ -0,0 +1 @@ +value is: 20 diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_42/StringDemo/.classpath b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/.classpath similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_42/StringDemo/.classpath rename to BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/.classpath diff --git a/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/.project b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/.project new file mode 100644 index 000000000..4384c5540 --- /dev/null +++ b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/.project @@ -0,0 +1,17 @@ + + + AnnotationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_42/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_42/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/bin/A.class b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/bin/A.class new file mode 100644 index 000000000..8eee4fb60 Binary files /dev/null and b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/bin/A.class differ diff --git a/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/bin/B.class b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/bin/B.class new file mode 100644 index 000000000..08c7e2db1 Binary files /dev/null and b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/bin/B.class differ diff --git a/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/bin/InheritedAnnotationDemo.class b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/bin/InheritedAnnotationDemo.class new file mode 100644 index 000000000..00994764a Binary files /dev/null and b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/bin/InheritedAnnotationDemo.class differ diff --git a/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/bin/MyAnnotation.class b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/bin/MyAnnotation.class new file mode 100644 index 000000000..1235f885a Binary files /dev/null and b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/bin/MyAnnotation.class differ diff --git a/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/MyClass.html b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/MyClass.html new file mode 100644 index 000000000..f135c8413 --- /dev/null +++ b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/MyClass.html @@ -0,0 +1,240 @@ + + + + + +MyClass + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+

Class MyClass

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/allclasses-frame.html b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/allclasses-frame.html new file mode 100644 index 000000000..471df78d0 --- /dev/null +++ b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/allclasses-frame.html @@ -0,0 +1,19 @@ + + + + + +All Classes + + + + + +

All Classes

+
+ +
+ + diff --git a/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/allclasses-noframe.html b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/allclasses-noframe.html new file mode 100644 index 000000000..a56cf202f --- /dev/null +++ b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/allclasses-noframe.html @@ -0,0 +1,19 @@ + + + + + +All Classes + + + + + +

All Classes

+
+ +
+ + diff --git a/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/class-use/MyClass.html b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/class-use/MyClass.html new file mode 100644 index 000000000..9f8d3023e --- /dev/null +++ b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/class-use/MyClass.html @@ -0,0 +1,122 @@ + + + + + +Uses of Class MyClass + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

Uses of Class
MyClass

+
+
No usage of MyClass
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/constant-values.html b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/constant-values.html new file mode 100644 index 000000000..de39807f1 --- /dev/null +++ b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/constant-values.html @@ -0,0 +1,122 @@ + + + + + +Constant Field Values + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

Constant Field Values

+

Contents

+
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/deprecated-list.html b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/deprecated-list.html new file mode 100644 index 000000000..943810dd0 --- /dev/null +++ b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/deprecated-list.html @@ -0,0 +1,122 @@ + + + + + +Deprecated List + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

Deprecated API

+

Contents

+
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/help-doc.html b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/help-doc.html new file mode 100644 index 000000000..4e428b26e --- /dev/null +++ b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/help-doc.html @@ -0,0 +1,223 @@ + + + + + +API Help + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

How This API Document Is Organized

+
This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
+
+
+ +This help file applies to API documentation generated using the standard doclet.
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/index-files/index-1.html b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/index-files/index-1.html new file mode 100644 index 000000000..f7b314f35 --- /dev/null +++ b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/index-files/index-1.html @@ -0,0 +1,129 @@ + + + + + +M-Index + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
M  + + +

M

+
+
MyClass - Class in <Unnamed>
+
 
+
MyClass() - Constructor for class MyClass
+
 
+
+M 
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/index.html b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/index.html new file mode 100644 index 000000000..cc1df8ac3 --- /dev/null +++ b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/index.html @@ -0,0 +1,72 @@ + + + + + +Generated Documentation (Untitled) + + + + + + +<noscript> +<div>JavaScript is disabled on your browser.</div> +</noscript> +<h2>Frame Alert</h2> +<p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to <a href="MyClass.html">Non-frame version</a>.</p> + + + diff --git a/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/overview-tree.html b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/overview-tree.html new file mode 100644 index 000000000..1edfa5872 --- /dev/null +++ b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/overview-tree.html @@ -0,0 +1,131 @@ + + + + + +Class Hierarchy + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

Hierarchy For All Packages

+
+
+

Class Hierarchy

+ +
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/package-frame.html b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/package-frame.html new file mode 100644 index 000000000..264c73176 --- /dev/null +++ b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/package-frame.html @@ -0,0 +1,20 @@ + + + + + +<Unnamed> + + + + + +

<Unnamed>

+
+

Classes

+ +
+ + diff --git a/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/package-list b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/package-list new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/package-list @@ -0,0 +1 @@ + diff --git a/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/package-summary.html b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/package-summary.html new file mode 100644 index 000000000..fe69ee694 --- /dev/null +++ b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/package-summary.html @@ -0,0 +1,129 @@ + + + + + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

Package <Unnamed>

+
+
+ +
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/package-tree.html b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/package-tree.html new file mode 100644 index 000000000..3452b9fbc --- /dev/null +++ b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/package-tree.html @@ -0,0 +1,131 @@ + + + + + + Class Hierarchy + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

Hierarchy For Package <Unnamed>

+
+
+

Class Hierarchy

+ +
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/package-use.html b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/package-use.html new file mode 100644 index 000000000..2f2658c77 --- /dev/null +++ b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/package-use.html @@ -0,0 +1,122 @@ + + + + + +Uses of Package + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

Uses of Package

+
+
No usage of
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/script.js b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/script.js new file mode 100644 index 000000000..b34635693 --- /dev/null +++ b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/script.js @@ -0,0 +1,30 @@ +function show(type) +{ + count = 0; + for (var key in methods) { + var row = document.getElementById(key); + if ((methods[key] & type) != 0) { + row.style.display = ''; + row.className = (count++ % 2) ? rowColor : altColor; + } + else + row.style.display = 'none'; + } + updateTabs(type); +} + +function updateTabs(type) +{ + for (var value in tabs) { + var sNode = document.getElementById(tabs[value][0]); + var spanNode = sNode.firstChild; + if (value == type) { + sNode.className = activeTableTab; + spanNode.innerHTML = tabs[value][1]; + } + else { + sNode.className = tableTab; + spanNode.innerHTML = "" + tabs[value][1] + ""; + } + } +} diff --git a/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/stylesheet.css b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/stylesheet.css new file mode 100644 index 000000000..98055b22d --- /dev/null +++ b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/doc/stylesheet.css @@ -0,0 +1,574 @@ +/* Javadoc style sheet */ +/* +Overall document style +*/ + +@import url('resources/fonts/dejavu.css'); + +body { + background-color:#ffffff; + color:#353833; + font-family:'DejaVu Sans', Arial, Helvetica, sans-serif; + font-size:14px; + margin:0; +} +a:link, a:visited { + text-decoration:none; + color:#4A6782; +} +a:hover, a:focus { + text-decoration:none; + color:#bb7a2a; +} +a:active { + text-decoration:none; + color:#4A6782; +} +a[name] { + color:#353833; +} +a[name]:hover { + text-decoration:none; + color:#353833; +} +pre { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; +} +h1 { + font-size:20px; +} +h2 { + font-size:18px; +} +h3 { + font-size:16px; + font-style:italic; +} +h4 { + font-size:13px; +} +h5 { + font-size:12px; +} +h6 { + font-size:11px; +} +ul { + list-style-type:disc; +} +code, tt { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + padding-top:4px; + margin-top:8px; + line-height:1.4em; +} +dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + padding-top:4px; +} +table tr td dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + vertical-align:top; + padding-top:4px; +} +sup { + font-size:8px; +} +/* +Document title and Copyright styles +*/ +.clear { + clear:both; + height:0px; + overflow:hidden; +} +.aboutLanguage { + float:right; + padding:0px 21px; + font-size:11px; + z-index:200; + margin-top:-9px; +} +.legalCopy { + margin-left:.5em; +} +.bar a, .bar a:link, .bar a:visited, .bar a:active { + color:#FFFFFF; + text-decoration:none; +} +.bar a:hover, .bar a:focus { + color:#bb7a2a; +} +.tab { + background-color:#0066FF; + color:#ffffff; + padding:8px; + width:5em; + font-weight:bold; +} +/* +Navigation bar styles +*/ +.bar { + background-color:#4D7A97; + color:#FFFFFF; + padding:.8em .5em .4em .8em; + height:auto;/*height:1.8em;*/ + font-size:11px; + margin:0; +} +.topNav { + background-color:#4D7A97; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.bottomNav { + margin-top:10px; + background-color:#4D7A97; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.subNav { + background-color:#dee3e9; + float:left; + width:100%; + overflow:hidden; + font-size:12px; +} +.subNav div { + clear:left; + float:left; + padding:0 0 5px 6px; + text-transform:uppercase; +} +ul.navList, ul.subNavList { + float:left; + margin:0 25px 0 0; + padding:0; +} +ul.navList li{ + list-style:none; + float:left; + padding: 5px 6px; + text-transform:uppercase; +} +ul.subNavList li{ + list-style:none; + float:left; +} +.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited { + color:#FFFFFF; + text-decoration:none; + text-transform:uppercase; +} +.topNav a:hover, .bottomNav a:hover { + text-decoration:none; + color:#bb7a2a; + text-transform:uppercase; +} +.navBarCell1Rev { + background-color:#F8981D; + color:#253441; + margin: auto 5px; +} +.skipNav { + position:absolute; + top:auto; + left:-9999px; + overflow:hidden; +} +/* +Page header and footer styles +*/ +.header, .footer { + clear:both; + margin:0 20px; + padding:5px 0 0 0; +} +.indexHeader { + margin:10px; + position:relative; +} +.indexHeader span{ + margin-right:15px; +} +.indexHeader h1 { + font-size:13px; +} +.title { + color:#2c4557; + margin:10px 0; +} +.subTitle { + margin:5px 0 0 0; +} +.header ul { + margin:0 0 15px 0; + padding:0; +} +.footer ul { + margin:20px 0 5px 0; +} +.header ul li, .footer ul li { + list-style:none; + font-size:13px; +} +/* +Heading styles +*/ +div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 { + background-color:#dee3e9; + border:1px solid #d0d9e0; + margin:0 0 6px -8px; + padding:7px 5px; +} +ul.blockList ul.blockList ul.blockList li.blockList h3 { + background-color:#dee3e9; + border:1px solid #d0d9e0; + margin:0 0 6px -8px; + padding:7px 5px; +} +ul.blockList ul.blockList li.blockList h3 { + padding:0; + margin:15px 0; +} +ul.blockList li.blockList h2 { + padding:0px 0 20px 0; +} +/* +Page layout container styles +*/ +.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer { + clear:both; + padding:10px 20px; + position:relative; +} +.indexContainer { + margin:10px; + position:relative; + font-size:12px; +} +.indexContainer h2 { + font-size:13px; + padding:0 0 3px 0; +} +.indexContainer ul { + margin:0; + padding:0; +} +.indexContainer ul li { + list-style:none; + padding-top:2px; +} +.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt { + font-size:12px; + font-weight:bold; + margin:10px 0 0 0; + color:#4E4E4E; +} +.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd { + margin:5px 0 10px 0px; + font-size:14px; + font-family:'DejaVu Sans Mono',monospace; +} +.serializedFormContainer dl.nameValue dt { + margin-left:1px; + font-size:1.1em; + display:inline; + font-weight:bold; +} +.serializedFormContainer dl.nameValue dd { + margin:0 0 0 1px; + font-size:1.1em; + display:inline; +} +/* +List styles +*/ +ul.horizontal li { + display:inline; + font-size:0.9em; +} +ul.inheritance { + margin:0; + padding:0; +} +ul.inheritance li { + display:inline; + list-style:none; +} +ul.inheritance li ul.inheritance { + margin-left:15px; + padding-left:15px; + padding-top:1px; +} +ul.blockList, ul.blockListLast { + margin:10px 0 10px 0; + padding:0; +} +ul.blockList li.blockList, ul.blockListLast li.blockList { + list-style:none; + margin-bottom:15px; + line-height:1.4; +} +ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList { + padding:0px 20px 5px 10px; + border:1px solid #ededed; + background-color:#f8f8f8; +} +ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList { + padding:0 0 5px 8px; + background-color:#ffffff; + border:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockList { + margin-left:0; + padding-left:0; + padding-bottom:15px; + border:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast { + list-style:none; + border-bottom:none; + padding-bottom:0; +} +table tr td dl, table tr td dl dt, table tr td dl dd { + margin-top:0; + margin-bottom:1px; +} +/* +Table styles +*/ +.overviewSummary, .memberSummary, .typeSummary, .useSummary, .constantsSummary, .deprecatedSummary { + width:100%; + border-left:1px solid #EEE; + border-right:1px solid #EEE; + border-bottom:1px solid #EEE; +} +.overviewSummary, .memberSummary { + padding:0px; +} +.overviewSummary caption, .memberSummary caption, .typeSummary caption, +.useSummary caption, .constantsSummary caption, .deprecatedSummary caption { + position:relative; + text-align:left; + background-repeat:no-repeat; + color:#253441; + font-weight:bold; + clear:none; + overflow:hidden; + padding:0px; + padding-top:10px; + padding-left:1px; + margin:0px; + white-space:pre; +} +.overviewSummary caption a:link, .memberSummary caption a:link, .typeSummary caption a:link, +.useSummary caption a:link, .constantsSummary caption a:link, .deprecatedSummary caption a:link, +.overviewSummary caption a:hover, .memberSummary caption a:hover, .typeSummary caption a:hover, +.useSummary caption a:hover, .constantsSummary caption a:hover, .deprecatedSummary caption a:hover, +.overviewSummary caption a:active, .memberSummary caption a:active, .typeSummary caption a:active, +.useSummary caption a:active, .constantsSummary caption a:active, .deprecatedSummary caption a:active, +.overviewSummary caption a:visited, .memberSummary caption a:visited, .typeSummary caption a:visited, +.useSummary caption a:visited, .constantsSummary caption a:visited, .deprecatedSummary caption a:visited { + color:#FFFFFF; +} +.overviewSummary caption span, .memberSummary caption span, .typeSummary caption span, +.useSummary caption span, .constantsSummary caption span, .deprecatedSummary caption span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + padding-bottom:7px; + display:inline-block; + float:left; + background-color:#F8981D; + border: none; + height:16px; +} +.memberSummary caption span.activeTableTab span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + margin-right:3px; + display:inline-block; + float:left; + background-color:#F8981D; + height:16px; +} +.memberSummary caption span.tableTab span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + margin-right:3px; + display:inline-block; + float:left; + background-color:#4D7A97; + height:16px; +} +.memberSummary caption span.tableTab, .memberSummary caption span.activeTableTab { + padding-top:0px; + padding-left:0px; + padding-right:0px; + background-image:none; + float:none; + display:inline; +} +.overviewSummary .tabEnd, .memberSummary .tabEnd, .typeSummary .tabEnd, +.useSummary .tabEnd, .constantsSummary .tabEnd, .deprecatedSummary .tabEnd { + display:none; + width:5px; + position:relative; + float:left; + background-color:#F8981D; +} +.memberSummary .activeTableTab .tabEnd { + display:none; + width:5px; + margin-right:3px; + position:relative; + float:left; + background-color:#F8981D; +} +.memberSummary .tableTab .tabEnd { + display:none; + width:5px; + margin-right:3px; + position:relative; + background-color:#4D7A97; + float:left; + +} +.overviewSummary td, .memberSummary td, .typeSummary td, +.useSummary td, .constantsSummary td, .deprecatedSummary td { + text-align:left; + padding:0px 0px 12px 10px; +} +th.colOne, th.colFirst, th.colLast, .useSummary th, .constantsSummary th, +td.colOne, td.colFirst, td.colLast, .useSummary td, .constantsSummary td{ + vertical-align:top; + padding-right:0px; + padding-top:8px; + padding-bottom:3px; +} +th.colFirst, th.colLast, th.colOne, .constantsSummary th { + background:#dee3e9; + text-align:left; + padding:8px 3px 3px 7px; +} +td.colFirst, th.colFirst { + white-space:nowrap; + font-size:13px; +} +td.colLast, th.colLast { + font-size:13px; +} +td.colOne, th.colOne { + font-size:13px; +} +.overviewSummary td.colFirst, .overviewSummary th.colFirst, +.useSummary td.colFirst, .useSummary th.colFirst, +.overviewSummary td.colOne, .overviewSummary th.colOne, +.memberSummary td.colFirst, .memberSummary th.colFirst, +.memberSummary td.colOne, .memberSummary th.colOne, +.typeSummary td.colFirst{ + width:25%; + vertical-align:top; +} +td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover { + font-weight:bold; +} +.tableSubHeadingColor { + background-color:#EEEEFF; +} +.altColor { + background-color:#FFFFFF; +} +.rowColor { + background-color:#EEEEEF; +} +/* +Content styles +*/ +.description pre { + margin-top:0; +} +.deprecatedContent { + margin:0; + padding:10px 0; +} +.docSummary { + padding:0; +} + +ul.blockList ul.blockList ul.blockList li.blockList h3 { + font-style:normal; +} + +div.block { + font-size:14px; + font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; +} + +td.colLast div { + padding-top:0px; +} + + +td.colLast a { + padding-bottom:3px; +} +/* +Formatting effect styles +*/ +.sourceLineNo { + color:green; + padding:0 30px 0 0; +} +h1.hidden { + visibility:hidden; + overflow:hidden; + font-size:10px; +} +.block { + display:block; + margin:3px 10px 2px 0px; + color:#474747; +} +.deprecatedLabel, .descfrmTypeLabel, .memberNameLabel, .memberNameLink, +.overrideSpecifyLabel, .packageHierarchyLabel, .paramLabel, .returnLabel, +.seeLabel, .simpleTagLabel, .throwsLabel, .typeNameLabel, .typeNameLink { + font-weight:bold; +} +.deprecationComment, .emphasizedPhrase, .interfaceName { + font-style:italic; +} + +div.block div.block span.deprecationComment, div.block div.block span.emphasizedPhrase, +div.block div.block span.interfaceName { + font-style:normal; +} + +div.contentContainer ul.blockList li.blockList h2{ + padding-bottom:0px; +} diff --git a/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/src/ClassPreamble.java b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/src/ClassPreamble.java new file mode 100644 index 000000000..efe16b883 --- /dev/null +++ b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/src/ClassPreamble.java @@ -0,0 +1,13 @@ +import java.lang.annotation.Documented; + +@Documented +@interface ClassPreamble +{ + String author(); + String date(); + int currentRevision() default 1; + String lastModified() default "N/A"; + String lastModifiedBy() default "N/A"; + // Note use of array + String[] reviewers(); +} diff --git a/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/src/MyClass.java b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/src/MyClass.java new file mode 100644 index 000000000..b279253d6 --- /dev/null +++ b/BasicJava/AnnotationDemo_declare_Javadoc_App/AnnotationDemo/src/MyClass.java @@ -0,0 +1,15 @@ +@ClassPreamble +( + author = "Ram", + date = "3/17/2017", + currentRevision = 2, + lastModified = "4/12/2017", + lastModifiedBy = "Peter", + // Note array notation + reviewers = {"Alice", "Bob", "Cindy"} +) + +public class MyClass +{ + // class code goes here +} diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_43/StringDemo/.classpath b/BasicJava/AnnotationDemo_deprecated_App/AnnotationDemo/.classpath similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_43/StringDemo/.classpath rename to BasicJava/AnnotationDemo_deprecated_App/AnnotationDemo/.classpath diff --git a/BasicJava/AnnotationDemo_deprecated_App/AnnotationDemo/.project b/BasicJava/AnnotationDemo_deprecated_App/AnnotationDemo/.project new file mode 100644 index 000000000..4384c5540 --- /dev/null +++ b/BasicJava/AnnotationDemo_deprecated_App/AnnotationDemo/.project @@ -0,0 +1,17 @@ + + + AnnotationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_43/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/AnnotationDemo_deprecated_App/AnnotationDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_43/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/AnnotationDemo_deprecated_App/AnnotationDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/AnnotationDemo_deprecated_App/AnnotationDemo/bin/Animal.class b/BasicJava/AnnotationDemo_deprecated_App/AnnotationDemo/bin/Animal.class new file mode 100644 index 000000000..f004e9dea Binary files /dev/null and b/BasicJava/AnnotationDemo_deprecated_App/AnnotationDemo/bin/Animal.class differ diff --git a/BasicJava/AnnotationDemo_deprecated_App/AnnotationDemo/bin/AnnotationsDemo.class b/BasicJava/AnnotationDemo_deprecated_App/AnnotationDemo/bin/AnnotationsDemo.class new file mode 100644 index 000000000..aebd723d1 Binary files /dev/null and b/BasicJava/AnnotationDemo_deprecated_App/AnnotationDemo/bin/AnnotationsDemo.class differ diff --git a/BasicJava/AnnotationDemo_deprecated_App/AnnotationDemo/src/AnnotationsDemo.java b/BasicJava/AnnotationDemo_deprecated_App/AnnotationDemo/src/AnnotationsDemo.java new file mode 100644 index 000000000..504f1f63f --- /dev/null +++ b/BasicJava/AnnotationDemo_deprecated_App/AnnotationDemo/src/AnnotationsDemo.java @@ -0,0 +1,17 @@ +class Animal +{ + @Deprecated + void eatChicken() + { + System.out.println("Eating 2 chicken legs"); + } +} + +public class AnnotationsDemo +{ + public static void main(String args[]) + { + Animal animal=new Animal(); + animal.eatChicken(); + } +} \ No newline at end of file diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_44/StringDemo/.classpath b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/.classpath similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_44/StringDemo/.classpath rename to BasicJava/AnnotationDemo_documented_App/AnnotationDemo/.classpath diff --git a/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/.project b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/.project new file mode 100644 index 000000000..4384c5540 --- /dev/null +++ b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/.project @@ -0,0 +1,17 @@ + + + AnnotationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_44/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_44/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/AnnotationDemo_documented_App/AnnotationDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/bin/A.class b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/bin/A.class new file mode 100644 index 000000000..8eee4fb60 Binary files /dev/null and b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/bin/A.class differ diff --git a/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/bin/B.class b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/bin/B.class new file mode 100644 index 000000000..08c7e2db1 Binary files /dev/null and b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/bin/B.class differ diff --git a/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/bin/InheritedAnnotationDemo.class b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/bin/InheritedAnnotationDemo.class new file mode 100644 index 000000000..00994764a Binary files /dev/null and b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/bin/InheritedAnnotationDemo.class differ diff --git a/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/bin/MyAnnotation.class b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/bin/MyAnnotation.class new file mode 100644 index 000000000..1235f885a Binary files /dev/null and b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/bin/MyAnnotation.class differ diff --git a/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/MyClass.html b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/MyClass.html new file mode 100644 index 000000000..f8e9efdd3 --- /dev/null +++ b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/MyClass.html @@ -0,0 +1,269 @@ + + + + + +MyClass + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+

Class MyClass

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/allclasses-frame.html b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/allclasses-frame.html new file mode 100644 index 000000000..2e4bc69c2 --- /dev/null +++ b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/allclasses-frame.html @@ -0,0 +1,19 @@ + + + + + +All Classes + + + + + +

All Classes

+
+ +
+ + diff --git a/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/allclasses-noframe.html b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/allclasses-noframe.html new file mode 100644 index 000000000..97f2c11d5 --- /dev/null +++ b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/allclasses-noframe.html @@ -0,0 +1,19 @@ + + + + + +All Classes + + + + + +

All Classes

+
+ +
+ + diff --git a/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/class-use/MyClass.html b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/class-use/MyClass.html new file mode 100644 index 000000000..caa44392e --- /dev/null +++ b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/class-use/MyClass.html @@ -0,0 +1,122 @@ + + + + + +Uses of Class MyClass + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

Uses of Class
MyClass

+
+
No usage of MyClass
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/constant-values.html b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/constant-values.html new file mode 100644 index 000000000..7491c5fe2 --- /dev/null +++ b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/constant-values.html @@ -0,0 +1,122 @@ + + + + + +Constant Field Values + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

Constant Field Values

+

Contents

+
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/deprecated-list.html b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/deprecated-list.html new file mode 100644 index 000000000..8cc8e1a6d --- /dev/null +++ b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/deprecated-list.html @@ -0,0 +1,122 @@ + + + + + +Deprecated List + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

Deprecated API

+

Contents

+
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/help-doc.html b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/help-doc.html new file mode 100644 index 000000000..169f97fd6 --- /dev/null +++ b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/help-doc.html @@ -0,0 +1,223 @@ + + + + + +API Help + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

How This API Document Is Organized

+
This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
+
+
+ +This help file applies to API documentation generated using the standard doclet.
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/index-files/index-1.html b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/index-files/index-1.html new file mode 100644 index 000000000..43a1dca12 --- /dev/null +++ b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/index-files/index-1.html @@ -0,0 +1,131 @@ + + + + + +M-Index + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
M  + + +

M

+
+
main(String[]) - Static method in class MyClass
+
 
+
MyClass - Class in <Unnamed>
+
 
+
MyClass() - Constructor for class MyClass
+
 
+
+M 
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/index.html b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/index.html new file mode 100644 index 000000000..a18e72e7f --- /dev/null +++ b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/index.html @@ -0,0 +1,72 @@ + + + + + +Generated Documentation (Untitled) + + + + + + +<noscript> +<div>JavaScript is disabled on your browser.</div> +</noscript> +<h2>Frame Alert</h2> +<p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to <a href="MyClass.html">Non-frame version</a>.</p> + + + diff --git a/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/overview-tree.html b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/overview-tree.html new file mode 100644 index 000000000..ff21e64b7 --- /dev/null +++ b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/overview-tree.html @@ -0,0 +1,131 @@ + + + + + +Class Hierarchy + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

Hierarchy For All Packages

+
+
+

Class Hierarchy

+ +
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/package-frame.html b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/package-frame.html new file mode 100644 index 000000000..0899144c8 --- /dev/null +++ b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/package-frame.html @@ -0,0 +1,20 @@ + + + + + +<Unnamed> + + + + + +

<Unnamed>

+
+

Classes

+ +
+ + diff --git a/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/package-list b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/package-list new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/package-list @@ -0,0 +1 @@ + diff --git a/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/package-summary.html b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/package-summary.html new file mode 100644 index 000000000..a4bc62053 --- /dev/null +++ b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/package-summary.html @@ -0,0 +1,129 @@ + + + + + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

Package <Unnamed>

+
+
+ +
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/package-tree.html b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/package-tree.html new file mode 100644 index 000000000..0831194f5 --- /dev/null +++ b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/package-tree.html @@ -0,0 +1,131 @@ + + + + + + Class Hierarchy + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

Hierarchy For Package <Unnamed>

+
+
+

Class Hierarchy

+ +
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/package-use.html b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/package-use.html new file mode 100644 index 000000000..f6a2e8432 --- /dev/null +++ b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/package-use.html @@ -0,0 +1,122 @@ + + + + + +Uses of Package + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

Uses of Package

+
+
No usage of
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/script.js b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/script.js new file mode 100644 index 000000000..b34635693 --- /dev/null +++ b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/script.js @@ -0,0 +1,30 @@ +function show(type) +{ + count = 0; + for (var key in methods) { + var row = document.getElementById(key); + if ((methods[key] & type) != 0) { + row.style.display = ''; + row.className = (count++ % 2) ? rowColor : altColor; + } + else + row.style.display = 'none'; + } + updateTabs(type); +} + +function updateTabs(type) +{ + for (var value in tabs) { + var sNode = document.getElementById(tabs[value][0]); + var spanNode = sNode.firstChild; + if (value == type) { + sNode.className = activeTableTab; + spanNode.innerHTML = tabs[value][1]; + } + else { + sNode.className = tableTab; + spanNode.innerHTML = "" + tabs[value][1] + ""; + } + } +} diff --git a/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/stylesheet.css b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/stylesheet.css new file mode 100644 index 000000000..98055b22d --- /dev/null +++ b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/doc/stylesheet.css @@ -0,0 +1,574 @@ +/* Javadoc style sheet */ +/* +Overall document style +*/ + +@import url('resources/fonts/dejavu.css'); + +body { + background-color:#ffffff; + color:#353833; + font-family:'DejaVu Sans', Arial, Helvetica, sans-serif; + font-size:14px; + margin:0; +} +a:link, a:visited { + text-decoration:none; + color:#4A6782; +} +a:hover, a:focus { + text-decoration:none; + color:#bb7a2a; +} +a:active { + text-decoration:none; + color:#4A6782; +} +a[name] { + color:#353833; +} +a[name]:hover { + text-decoration:none; + color:#353833; +} +pre { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; +} +h1 { + font-size:20px; +} +h2 { + font-size:18px; +} +h3 { + font-size:16px; + font-style:italic; +} +h4 { + font-size:13px; +} +h5 { + font-size:12px; +} +h6 { + font-size:11px; +} +ul { + list-style-type:disc; +} +code, tt { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + padding-top:4px; + margin-top:8px; + line-height:1.4em; +} +dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + padding-top:4px; +} +table tr td dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + vertical-align:top; + padding-top:4px; +} +sup { + font-size:8px; +} +/* +Document title and Copyright styles +*/ +.clear { + clear:both; + height:0px; + overflow:hidden; +} +.aboutLanguage { + float:right; + padding:0px 21px; + font-size:11px; + z-index:200; + margin-top:-9px; +} +.legalCopy { + margin-left:.5em; +} +.bar a, .bar a:link, .bar a:visited, .bar a:active { + color:#FFFFFF; + text-decoration:none; +} +.bar a:hover, .bar a:focus { + color:#bb7a2a; +} +.tab { + background-color:#0066FF; + color:#ffffff; + padding:8px; + width:5em; + font-weight:bold; +} +/* +Navigation bar styles +*/ +.bar { + background-color:#4D7A97; + color:#FFFFFF; + padding:.8em .5em .4em .8em; + height:auto;/*height:1.8em;*/ + font-size:11px; + margin:0; +} +.topNav { + background-color:#4D7A97; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.bottomNav { + margin-top:10px; + background-color:#4D7A97; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.subNav { + background-color:#dee3e9; + float:left; + width:100%; + overflow:hidden; + font-size:12px; +} +.subNav div { + clear:left; + float:left; + padding:0 0 5px 6px; + text-transform:uppercase; +} +ul.navList, ul.subNavList { + float:left; + margin:0 25px 0 0; + padding:0; +} +ul.navList li{ + list-style:none; + float:left; + padding: 5px 6px; + text-transform:uppercase; +} +ul.subNavList li{ + list-style:none; + float:left; +} +.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited { + color:#FFFFFF; + text-decoration:none; + text-transform:uppercase; +} +.topNav a:hover, .bottomNav a:hover { + text-decoration:none; + color:#bb7a2a; + text-transform:uppercase; +} +.navBarCell1Rev { + background-color:#F8981D; + color:#253441; + margin: auto 5px; +} +.skipNav { + position:absolute; + top:auto; + left:-9999px; + overflow:hidden; +} +/* +Page header and footer styles +*/ +.header, .footer { + clear:both; + margin:0 20px; + padding:5px 0 0 0; +} +.indexHeader { + margin:10px; + position:relative; +} +.indexHeader span{ + margin-right:15px; +} +.indexHeader h1 { + font-size:13px; +} +.title { + color:#2c4557; + margin:10px 0; +} +.subTitle { + margin:5px 0 0 0; +} +.header ul { + margin:0 0 15px 0; + padding:0; +} +.footer ul { + margin:20px 0 5px 0; +} +.header ul li, .footer ul li { + list-style:none; + font-size:13px; +} +/* +Heading styles +*/ +div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 { + background-color:#dee3e9; + border:1px solid #d0d9e0; + margin:0 0 6px -8px; + padding:7px 5px; +} +ul.blockList ul.blockList ul.blockList li.blockList h3 { + background-color:#dee3e9; + border:1px solid #d0d9e0; + margin:0 0 6px -8px; + padding:7px 5px; +} +ul.blockList ul.blockList li.blockList h3 { + padding:0; + margin:15px 0; +} +ul.blockList li.blockList h2 { + padding:0px 0 20px 0; +} +/* +Page layout container styles +*/ +.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer { + clear:both; + padding:10px 20px; + position:relative; +} +.indexContainer { + margin:10px; + position:relative; + font-size:12px; +} +.indexContainer h2 { + font-size:13px; + padding:0 0 3px 0; +} +.indexContainer ul { + margin:0; + padding:0; +} +.indexContainer ul li { + list-style:none; + padding-top:2px; +} +.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt { + font-size:12px; + font-weight:bold; + margin:10px 0 0 0; + color:#4E4E4E; +} +.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd { + margin:5px 0 10px 0px; + font-size:14px; + font-family:'DejaVu Sans Mono',monospace; +} +.serializedFormContainer dl.nameValue dt { + margin-left:1px; + font-size:1.1em; + display:inline; + font-weight:bold; +} +.serializedFormContainer dl.nameValue dd { + margin:0 0 0 1px; + font-size:1.1em; + display:inline; +} +/* +List styles +*/ +ul.horizontal li { + display:inline; + font-size:0.9em; +} +ul.inheritance { + margin:0; + padding:0; +} +ul.inheritance li { + display:inline; + list-style:none; +} +ul.inheritance li ul.inheritance { + margin-left:15px; + padding-left:15px; + padding-top:1px; +} +ul.blockList, ul.blockListLast { + margin:10px 0 10px 0; + padding:0; +} +ul.blockList li.blockList, ul.blockListLast li.blockList { + list-style:none; + margin-bottom:15px; + line-height:1.4; +} +ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList { + padding:0px 20px 5px 10px; + border:1px solid #ededed; + background-color:#f8f8f8; +} +ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList { + padding:0 0 5px 8px; + background-color:#ffffff; + border:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockList { + margin-left:0; + padding-left:0; + padding-bottom:15px; + border:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast { + list-style:none; + border-bottom:none; + padding-bottom:0; +} +table tr td dl, table tr td dl dt, table tr td dl dd { + margin-top:0; + margin-bottom:1px; +} +/* +Table styles +*/ +.overviewSummary, .memberSummary, .typeSummary, .useSummary, .constantsSummary, .deprecatedSummary { + width:100%; + border-left:1px solid #EEE; + border-right:1px solid #EEE; + border-bottom:1px solid #EEE; +} +.overviewSummary, .memberSummary { + padding:0px; +} +.overviewSummary caption, .memberSummary caption, .typeSummary caption, +.useSummary caption, .constantsSummary caption, .deprecatedSummary caption { + position:relative; + text-align:left; + background-repeat:no-repeat; + color:#253441; + font-weight:bold; + clear:none; + overflow:hidden; + padding:0px; + padding-top:10px; + padding-left:1px; + margin:0px; + white-space:pre; +} +.overviewSummary caption a:link, .memberSummary caption a:link, .typeSummary caption a:link, +.useSummary caption a:link, .constantsSummary caption a:link, .deprecatedSummary caption a:link, +.overviewSummary caption a:hover, .memberSummary caption a:hover, .typeSummary caption a:hover, +.useSummary caption a:hover, .constantsSummary caption a:hover, .deprecatedSummary caption a:hover, +.overviewSummary caption a:active, .memberSummary caption a:active, .typeSummary caption a:active, +.useSummary caption a:active, .constantsSummary caption a:active, .deprecatedSummary caption a:active, +.overviewSummary caption a:visited, .memberSummary caption a:visited, .typeSummary caption a:visited, +.useSummary caption a:visited, .constantsSummary caption a:visited, .deprecatedSummary caption a:visited { + color:#FFFFFF; +} +.overviewSummary caption span, .memberSummary caption span, .typeSummary caption span, +.useSummary caption span, .constantsSummary caption span, .deprecatedSummary caption span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + padding-bottom:7px; + display:inline-block; + float:left; + background-color:#F8981D; + border: none; + height:16px; +} +.memberSummary caption span.activeTableTab span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + margin-right:3px; + display:inline-block; + float:left; + background-color:#F8981D; + height:16px; +} +.memberSummary caption span.tableTab span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + margin-right:3px; + display:inline-block; + float:left; + background-color:#4D7A97; + height:16px; +} +.memberSummary caption span.tableTab, .memberSummary caption span.activeTableTab { + padding-top:0px; + padding-left:0px; + padding-right:0px; + background-image:none; + float:none; + display:inline; +} +.overviewSummary .tabEnd, .memberSummary .tabEnd, .typeSummary .tabEnd, +.useSummary .tabEnd, .constantsSummary .tabEnd, .deprecatedSummary .tabEnd { + display:none; + width:5px; + position:relative; + float:left; + background-color:#F8981D; +} +.memberSummary .activeTableTab .tabEnd { + display:none; + width:5px; + margin-right:3px; + position:relative; + float:left; + background-color:#F8981D; +} +.memberSummary .tableTab .tabEnd { + display:none; + width:5px; + margin-right:3px; + position:relative; + background-color:#4D7A97; + float:left; + +} +.overviewSummary td, .memberSummary td, .typeSummary td, +.useSummary td, .constantsSummary td, .deprecatedSummary td { + text-align:left; + padding:0px 0px 12px 10px; +} +th.colOne, th.colFirst, th.colLast, .useSummary th, .constantsSummary th, +td.colOne, td.colFirst, td.colLast, .useSummary td, .constantsSummary td{ + vertical-align:top; + padding-right:0px; + padding-top:8px; + padding-bottom:3px; +} +th.colFirst, th.colLast, th.colOne, .constantsSummary th { + background:#dee3e9; + text-align:left; + padding:8px 3px 3px 7px; +} +td.colFirst, th.colFirst { + white-space:nowrap; + font-size:13px; +} +td.colLast, th.colLast { + font-size:13px; +} +td.colOne, th.colOne { + font-size:13px; +} +.overviewSummary td.colFirst, .overviewSummary th.colFirst, +.useSummary td.colFirst, .useSummary th.colFirst, +.overviewSummary td.colOne, .overviewSummary th.colOne, +.memberSummary td.colFirst, .memberSummary th.colFirst, +.memberSummary td.colOne, .memberSummary th.colOne, +.typeSummary td.colFirst{ + width:25%; + vertical-align:top; +} +td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover { + font-weight:bold; +} +.tableSubHeadingColor { + background-color:#EEEEFF; +} +.altColor { + background-color:#FFFFFF; +} +.rowColor { + background-color:#EEEEEF; +} +/* +Content styles +*/ +.description pre { + margin-top:0; +} +.deprecatedContent { + margin:0; + padding:10px 0; +} +.docSummary { + padding:0; +} + +ul.blockList ul.blockList ul.blockList li.blockList h3 { + font-style:normal; +} + +div.block { + font-size:14px; + font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; +} + +td.colLast div { + padding-top:0px; +} + + +td.colLast a { + padding-bottom:3px; +} +/* +Formatting effect styles +*/ +.sourceLineNo { + color:green; + padding:0 30px 0 0; +} +h1.hidden { + visibility:hidden; + overflow:hidden; + font-size:10px; +} +.block { + display:block; + margin:3px 10px 2px 0px; + color:#474747; +} +.deprecatedLabel, .descfrmTypeLabel, .memberNameLabel, .memberNameLink, +.overrideSpecifyLabel, .packageHierarchyLabel, .paramLabel, .returnLabel, +.seeLabel, .simpleTagLabel, .throwsLabel, .typeNameLabel, .typeNameLink { + font-weight:bold; +} +.deprecationComment, .emphasizedPhrase, .interfaceName { + font-style:italic; +} + +div.block div.block span.deprecationComment, div.block div.block span.emphasizedPhrase, +div.block div.block span.interfaceName { + font-style:normal; +} + +div.contentContainer ul.blockList li.blockList h2{ + padding-bottom:0px; +} diff --git a/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/src/MyClass.java b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/src/MyClass.java new file mode 100644 index 000000000..c53047063 --- /dev/null +++ b/BasicJava/AnnotationDemo_documented_App/AnnotationDemo/src/MyClass.java @@ -0,0 +1,16 @@ +import java.lang.annotation.Documented; + +@Documented +@interface MyAnnotation + { + + } + +@MyAnnotation +public class MyClass +{ + public static void main(String[] args) + { + //javadoc MyClass.java + } +} \ No newline at end of file diff --git a/Later/String/Manipulating Characters in a String/String_18/StringDemo/.classpath b/BasicJava/AnnotationDemo_mv_default_App/AnnotationDemo/.classpath similarity index 100% rename from Later/String/Manipulating Characters in a String/String_18/StringDemo/.classpath rename to BasicJava/AnnotationDemo_mv_default_App/AnnotationDemo/.classpath diff --git a/BasicJava/AnnotationDemo_mv_default_App/AnnotationDemo/.project b/BasicJava/AnnotationDemo_mv_default_App/AnnotationDemo/.project new file mode 100644 index 000000000..4384c5540 --- /dev/null +++ b/BasicJava/AnnotationDemo_mv_default_App/AnnotationDemo/.project @@ -0,0 +1,17 @@ + + + AnnotationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/Manipulating Characters in a String/String_18/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/AnnotationDemo_mv_default_App/AnnotationDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/Manipulating Characters in a String/String_18/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/AnnotationDemo_mv_default_App/AnnotationDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/AnnotationDemo_mv_default_App/AnnotationDemo/bin/Message.class b/BasicJava/AnnotationDemo_mv_default_App/AnnotationDemo/bin/Message.class new file mode 100644 index 000000000..408bd7ff9 Binary files /dev/null and b/BasicJava/AnnotationDemo_mv_default_App/AnnotationDemo/bin/Message.class differ diff --git a/BasicJava/AnnotationDemo_mv_default_App/AnnotationDemo/bin/MultiValueAnnotationDemo.class b/BasicJava/AnnotationDemo_mv_default_App/AnnotationDemo/bin/MultiValueAnnotationDemo.class new file mode 100644 index 000000000..27b220712 Binary files /dev/null and b/BasicJava/AnnotationDemo_mv_default_App/AnnotationDemo/bin/MultiValueAnnotationDemo.class differ diff --git a/BasicJava/AnnotationDemo_mv_default_App/AnnotationDemo/bin/MyMultiValueAnnotation.class b/BasicJava/AnnotationDemo_mv_default_App/AnnotationDemo/bin/MyMultiValueAnnotation.class new file mode 100644 index 000000000..bbad0ff52 Binary files /dev/null and b/BasicJava/AnnotationDemo_mv_default_App/AnnotationDemo/bin/MyMultiValueAnnotation.class differ diff --git a/BasicJava/AnnotationDemo_mv_default_App/AnnotationDemo/src/MultiValueAnnotationDemo.java b/BasicJava/AnnotationDemo_mv_default_App/AnnotationDemo/src/MultiValueAnnotationDemo.java new file mode 100644 index 000000000..2457a92b7 --- /dev/null +++ b/BasicJava/AnnotationDemo_mv_default_App/AnnotationDemo/src/MultiValueAnnotationDemo.java @@ -0,0 +1,45 @@ +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.Method; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +@interface MyMultiValueAnnotation +{ + int getValue() default 2; + + String getMessage() default "hello"; + + double getDoubleValue() default 5.5; +} + +class Message +{ + @MyMultiValueAnnotation + public void displayHi() + { + System.out.println("Hi"); + } +} + +public class MultiValueAnnotationDemo +{ + + public static void main(String[] args) throws NoSuchMethodException, + SecurityException + { + Message message = new Message(); + Method method = message.getClass().getMethod("displayHi"); + + MyMultiValueAnnotation mmva = method + .getAnnotation(MyMultiValueAnnotation.class); + + System.out.println("value is: " + mmva.getValue()); + System.out.println("message is: " + mmva.getMessage()); + System.out.println("DoubleValue is: " + mmva.getDoubleValue()); + + } + +} diff --git a/BasicJava/AnnotationDemo_mv_default_App/Output.txt b/BasicJava/AnnotationDemo_mv_default_App/Output.txt new file mode 100644 index 000000000..bd4580275 --- /dev/null +++ b/BasicJava/AnnotationDemo_mv_default_App/Output.txt @@ -0,0 +1,3 @@ +value is: 2 +message is: hello +DoubleValue is: 5.5 diff --git a/Later/String/Manipulating Characters in a String/String_19/StringDemo/.classpath b/BasicJava/AnnotationDemo_override_App/AnnotationDemo/.classpath similarity index 100% rename from Later/String/Manipulating Characters in a String/String_19/StringDemo/.classpath rename to BasicJava/AnnotationDemo_override_App/AnnotationDemo/.classpath diff --git a/BasicJava/AnnotationDemo_override_App/AnnotationDemo/.project b/BasicJava/AnnotationDemo_override_App/AnnotationDemo/.project new file mode 100644 index 000000000..4384c5540 --- /dev/null +++ b/BasicJava/AnnotationDemo_override_App/AnnotationDemo/.project @@ -0,0 +1,17 @@ + + + AnnotationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/Manipulating Characters in a String/String_19/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/AnnotationDemo_override_App/AnnotationDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/Manipulating Characters in a String/String_19/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/AnnotationDemo_override_App/AnnotationDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/AnnotationDemo_override_App/AnnotationDemo/bin/Animal.class b/BasicJava/AnnotationDemo_override_App/AnnotationDemo/bin/Animal.class new file mode 100644 index 000000000..254f5f62e Binary files /dev/null and b/BasicJava/AnnotationDemo_override_App/AnnotationDemo/bin/Animal.class differ diff --git a/BasicJava/AnnotationDemo_override_App/AnnotationDemo/bin/AnnotationsDemo.class b/BasicJava/AnnotationDemo_override_App/AnnotationDemo/bin/AnnotationsDemo.class new file mode 100644 index 000000000..54cb186c8 Binary files /dev/null and b/BasicJava/AnnotationDemo_override_App/AnnotationDemo/bin/AnnotationsDemo.class differ diff --git a/BasicJava/AnnotationDemo_override_App/AnnotationDemo/bin/Dog.class b/BasicJava/AnnotationDemo_override_App/AnnotationDemo/bin/Dog.class new file mode 100644 index 000000000..0c9c7d8ad Binary files /dev/null and b/BasicJava/AnnotationDemo_override_App/AnnotationDemo/bin/Dog.class differ diff --git a/BasicJava/AnnotationDemo_override_App/AnnotationDemo/src/AnnotationsDemo.java b/BasicJava/AnnotationDemo_override_App/AnnotationDemo/src/AnnotationsDemo.java new file mode 100644 index 000000000..4823cef60 --- /dev/null +++ b/BasicJava/AnnotationDemo_override_App/AnnotationDemo/src/AnnotationsDemo.java @@ -0,0 +1,25 @@ +class Animal +{ + void eatChicken() + { + System.out.println("Eating 2 chicken legs"); + } +} + +class Dog extends Animal +{ + @Override + void eatchicken() + { + System.out.println("Eating 5 chicken legs"); + } +} + +public class AnnotationsDemo +{ + public static void main(String args[]) + { + Animal animal=new Dog(); + animal.eatChicken(); + } +} \ No newline at end of file diff --git a/BasicJava/AnnotationDemo_override_App/Output.txt b/BasicJava/AnnotationDemo_override_App/Output.txt new file mode 100644 index 000000000..3348c005e --- /dev/null +++ b/BasicJava/AnnotationDemo_override_App/Output.txt @@ -0,0 +1,3 @@ +Compile time error: + +The method eatchicken() of type Dog must override or implement a supertype method. diff --git a/Later/String/Manipulating Characters in a String/String_20/StringDemo/.classpath b/BasicJava/AutoBoxing_Demo_List_App/BoxingDemo/.classpath similarity index 100% rename from Later/String/Manipulating Characters in a String/String_20/StringDemo/.classpath rename to BasicJava/AutoBoxing_Demo_List_App/BoxingDemo/.classpath diff --git a/BasicJava/AutoBoxing_Demo_List_App/BoxingDemo/.project b/BasicJava/AutoBoxing_Demo_List_App/BoxingDemo/.project new file mode 100644 index 000000000..c91619eea --- /dev/null +++ b/BasicJava/AutoBoxing_Demo_List_App/BoxingDemo/.project @@ -0,0 +1,17 @@ + + + BoxingDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/Manipulating Characters in a String/String_20/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/AutoBoxing_Demo_List_App/BoxingDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/Manipulating Characters in a String/String_20/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/AutoBoxing_Demo_List_App/BoxingDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/AutoBoxing_Demo_List_App/BoxingDemo/bin/AutoBoxingDemo.class b/BasicJava/AutoBoxing_Demo_List_App/BoxingDemo/bin/AutoBoxingDemo.class new file mode 100644 index 000000000..9a21375c5 Binary files /dev/null and b/BasicJava/AutoBoxing_Demo_List_App/BoxingDemo/bin/AutoBoxingDemo.class differ diff --git a/BasicJava/AutoBoxing_Demo_List_App/BoxingDemo/src/AutoBoxingDemo.java b/BasicJava/AutoBoxing_Demo_List_App/BoxingDemo/src/AutoBoxingDemo.java new file mode 100644 index 000000000..44dc7a352 --- /dev/null +++ b/BasicJava/AutoBoxing_Demo_List_App/BoxingDemo/src/AutoBoxingDemo.java @@ -0,0 +1,19 @@ +import java.util.ArrayList; +import java.util.List; + +public class AutoBoxingDemo +{ + + public static void main(String[] args) + { + List li = new ArrayList<>(); + + for (int i = 1; i < 20; i += 2) + { + li.add(i); + } + System.out.println(li); + System.out.println(li.get(0).getClass()); + } + +} diff --git a/BasicJava/AutoBoxing_Demo_List_App/Output.txt b/BasicJava/AutoBoxing_Demo_List_App/Output.txt new file mode 100644 index 000000000..a7cbcac0e --- /dev/null +++ b/BasicJava/AutoBoxing_Demo_List_App/Output.txt @@ -0,0 +1,2 @@ +[1, 3, 5, 7, 9, 11, 13, 15, 17, 19] +class java.lang.Integer diff --git a/BasicJava/AutoBoxing_UnBoxingDemo_App/AutoBoxingDemo_Output.txt b/BasicJava/AutoBoxing_UnBoxingDemo_App/AutoBoxingDemo_Output.txt new file mode 100644 index 000000000..e3c854d52 --- /dev/null +++ b/BasicJava/AutoBoxing_UnBoxingDemo_App/AutoBoxingDemo_Output.txt @@ -0,0 +1,2 @@ +50 +50 diff --git a/Later/String/Manipulating Characters in a String/String_21/StringDemo/.classpath b/BasicJava/AutoBoxing_UnBoxingDemo_App/BoxingDemo/.classpath similarity index 100% rename from Later/String/Manipulating Characters in a String/String_21/StringDemo/.classpath rename to BasicJava/AutoBoxing_UnBoxingDemo_App/BoxingDemo/.classpath diff --git a/BasicJava/AutoBoxing_UnBoxingDemo_App/BoxingDemo/.project b/BasicJava/AutoBoxing_UnBoxingDemo_App/BoxingDemo/.project new file mode 100644 index 000000000..c91619eea --- /dev/null +++ b/BasicJava/AutoBoxing_UnBoxingDemo_App/BoxingDemo/.project @@ -0,0 +1,17 @@ + + + BoxingDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/Manipulating Characters in a String/String_21/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/AutoBoxing_UnBoxingDemo_App/BoxingDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/Manipulating Characters in a String/String_21/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/AutoBoxing_UnBoxingDemo_App/BoxingDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/AutoBoxing_UnBoxingDemo_App/BoxingDemo/bin/AutoBoxingDemo.class b/BasicJava/AutoBoxing_UnBoxingDemo_App/BoxingDemo/bin/AutoBoxingDemo.class new file mode 100644 index 000000000..2cb65d81f Binary files /dev/null and b/BasicJava/AutoBoxing_UnBoxingDemo_App/BoxingDemo/bin/AutoBoxingDemo.class differ diff --git a/BasicJava/AutoBoxing_UnBoxingDemo_App/BoxingDemo/bin/UnboxingDemo.class b/BasicJava/AutoBoxing_UnBoxingDemo_App/BoxingDemo/bin/UnboxingDemo.class new file mode 100644 index 000000000..aeb233229 Binary files /dev/null and b/BasicJava/AutoBoxing_UnBoxingDemo_App/BoxingDemo/bin/UnboxingDemo.class differ diff --git a/BasicJava/AutoBoxing_UnBoxingDemo_App/BoxingDemo/src/AutoBoxingDemo.java b/BasicJava/AutoBoxing_UnBoxingDemo_App/BoxingDemo/src/AutoBoxingDemo.java new file mode 100644 index 000000000..d67e307a4 --- /dev/null +++ b/BasicJava/AutoBoxing_UnBoxingDemo_App/BoxingDemo/src/AutoBoxingDemo.java @@ -0,0 +1,18 @@ +public class AutoBoxingDemo +{ + + public static void main(String[] args) + { + int intValue = 50; + Integer integerObj = intValue;// Boxing + System.out.println(integerObj); + + display(intValue); //Boxing + } + + public static void display(Integer integerObj) + { + System.out.println(integerObj); + } + +} diff --git a/BasicJava/AutoBoxing_UnBoxingDemo_App/BoxingDemo/src/UnboxingDemo.java b/BasicJava/AutoBoxing_UnBoxingDemo_App/BoxingDemo/src/UnboxingDemo.java new file mode 100644 index 000000000..b5927702f --- /dev/null +++ b/BasicJava/AutoBoxing_UnBoxingDemo_App/BoxingDemo/src/UnboxingDemo.java @@ -0,0 +1,17 @@ +public class UnboxingDemo +{ + + public static void main(String[] args) + { + Integer integerObj = new Integer(100); + int intValue = integerObj; // UnBoxing + System.out.println(intValue); + + display(integerObj);//UnBoxing + } + + public static void display(int intValue) + { + System.out.println(intValue); + } +} \ No newline at end of file diff --git a/BasicJava/AutoBoxing_UnBoxingDemo_App/UnboxingDemo_Output.txt b/BasicJava/AutoBoxing_UnBoxingDemo_App/UnboxingDemo_Output.txt new file mode 100644 index 000000000..e58e9764b --- /dev/null +++ b/BasicJava/AutoBoxing_UnBoxingDemo_App/UnboxingDemo_Output.txt @@ -0,0 +1,2 @@ +100 +100 diff --git a/Later/String/Manipulating Characters in a String/String_22/StringDemo/.classpath b/BasicJava/ClockDemo_intro/ClockDemo/.classpath similarity index 100% rename from Later/String/Manipulating Characters in a String/String_22/StringDemo/.classpath rename to BasicJava/ClockDemo_intro/ClockDemo/.classpath diff --git a/BasicJava/ClockDemo_intro/ClockDemo/.project b/BasicJava/ClockDemo_intro/ClockDemo/.project new file mode 100644 index 000000000..6d8c49e0b --- /dev/null +++ b/BasicJava/ClockDemo_intro/ClockDemo/.project @@ -0,0 +1,17 @@ + + + ClockDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/Manipulating Characters in a String/String_22/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ClockDemo_intro/ClockDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/Manipulating Characters in a String/String_22/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/ClockDemo_intro/ClockDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/ClockDemo_intro/ClockDemo/bin/ClockDemo1.class b/BasicJava/ClockDemo_intro/ClockDemo/bin/ClockDemo1.class new file mode 100644 index 000000000..91e4ada93 Binary files /dev/null and b/BasicJava/ClockDemo_intro/ClockDemo/bin/ClockDemo1.class differ diff --git a/BasicJava/ClockDemo_intro/ClockDemo/bin/ClockDemo2.class b/BasicJava/ClockDemo_intro/ClockDemo/bin/ClockDemo2.class new file mode 100644 index 000000000..dae7ac173 Binary files /dev/null and b/BasicJava/ClockDemo_intro/ClockDemo/bin/ClockDemo2.class differ diff --git a/BasicJava/ClockDemo_intro/ClockDemo/bin/ClockDemo3.class b/BasicJava/ClockDemo_intro/ClockDemo/bin/ClockDemo3.class new file mode 100644 index 000000000..84ccbe814 Binary files /dev/null and b/BasicJava/ClockDemo_intro/ClockDemo/bin/ClockDemo3.class differ diff --git a/BasicJava/ClockDemo_intro/ClockDemo/src/ClockDemo1.java b/BasicJava/ClockDemo_intro/ClockDemo/src/ClockDemo1.java new file mode 100644 index 000000000..904ea1b5a --- /dev/null +++ b/BasicJava/ClockDemo_intro/ClockDemo/src/ClockDemo1.java @@ -0,0 +1,27 @@ +import java.time.Clock; +import java.time.ZoneId; + +public class ClockDemo1 +{ + + public static void main(String[] args) + { + /* + * Returns: + * + * a clock that uses the best available system clock in the + * default zone, not null + */ + Clock clock = Clock.systemDefaultZone(); + System.out.println("clock = "+clock); + + /* + * Returns: + * + * the time-zone being used to interpret instants, not null + */ + ZoneId zoneId = clock.getZone(); + System.out.println("zoneId = "+zoneId); + } + +} diff --git a/BasicJava/ClockDemo_intro/ClockDemo/src/ClockDemo2.java b/BasicJava/ClockDemo_intro/ClockDemo/src/ClockDemo2.java new file mode 100644 index 000000000..b5f8b985c --- /dev/null +++ b/BasicJava/ClockDemo_intro/ClockDemo/src/ClockDemo2.java @@ -0,0 +1,26 @@ +import java.time.Clock; +import java.time.Instant; + +public class ClockDemo2 +{ + + public static void main(String[] args) + { + /* + * Returns: + * + * a clock that uses the best available system clock in the + * UTC zone, not null + */ + Clock clock = Clock.systemUTC(); + System.out.println("clock = "+clock); + /* + * Returns: + * + * the current instant from this clock, not null + */ + Instant instant = clock.instant(); + System.out.println("instant = "+instant); + } + +} diff --git a/BasicJava/ClockDemo_intro/ClockDemo/src/ClockDemo3.java b/BasicJava/ClockDemo_intro/ClockDemo/src/ClockDemo3.java new file mode 100644 index 000000000..1585c2628 --- /dev/null +++ b/BasicJava/ClockDemo_intro/ClockDemo/src/ClockDemo3.java @@ -0,0 +1,28 @@ +import java.time.Clock; +import java.time.ZoneId; + +public class ClockDemo3 +{ + + public static void main(String[] args) + { + + ZoneId zoneId = ZoneId.systemDefault(); + System.out.println("zoneId = " + zoneId); + + /* + * Parameters: + * + * zone - the time-zone to use to convert the instant to + * date-time, not null + * + * Returns: + * + * a clock that uses the best available system clock in the + * specified zone, not null + */ + Clock clock = Clock.system(zoneId); + System.out.println("Clock = " + clock); + } + +} diff --git a/BasicJava/ClockDemo_intro/ClockDemo1_Output.txt b/BasicJava/ClockDemo_intro/ClockDemo1_Output.txt new file mode 100644 index 000000000..368bdb554 --- /dev/null +++ b/BasicJava/ClockDemo_intro/ClockDemo1_Output.txt @@ -0,0 +1,2 @@ +clock = SystemClock[Asia/Calcutta] +zoneId = Asia/Calcutta diff --git a/BasicJava/ClockDemo_intro/ClockDemo2_Output.txt b/BasicJava/ClockDemo_intro/ClockDemo2_Output.txt new file mode 100644 index 000000000..d389b5b64 --- /dev/null +++ b/BasicJava/ClockDemo_intro/ClockDemo2_Output.txt @@ -0,0 +1,2 @@ +clock = SystemClock[Z] +instant = 2018-02-12T04:17:39.294Z diff --git a/BasicJava/ClockDemo_intro/ClockDemo3_Output.txt b/BasicJava/ClockDemo_intro/ClockDemo3_Output.txt new file mode 100644 index 000000000..ee9585684 --- /dev/null +++ b/BasicJava/ClockDemo_intro/ClockDemo3_Output.txt @@ -0,0 +1,2 @@ +zoneId = Asia/Calcutta +Clock = SystemClock[Asia/Calcutta] diff --git a/Later/String/Manipulating Characters in a String/String_23/StringDemo/.classpath b/BasicJava/ClockDemo_millis/ClockDemo/.classpath similarity index 100% rename from Later/String/Manipulating Characters in a String/String_23/StringDemo/.classpath rename to BasicJava/ClockDemo_millis/ClockDemo/.classpath diff --git a/BasicJava/ClockDemo_millis/ClockDemo/.project b/BasicJava/ClockDemo_millis/ClockDemo/.project new file mode 100644 index 000000000..6d8c49e0b --- /dev/null +++ b/BasicJava/ClockDemo_millis/ClockDemo/.project @@ -0,0 +1,17 @@ + + + ClockDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/Manipulating Characters in a String/String_23/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ClockDemo_millis/ClockDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/Manipulating Characters in a String/String_23/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/ClockDemo_millis/ClockDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/ClockDemo_millis/ClockDemo/bin/ClockDemo.class b/BasicJava/ClockDemo_millis/ClockDemo/bin/ClockDemo.class new file mode 100644 index 000000000..5a55d0dec Binary files /dev/null and b/BasicJava/ClockDemo_millis/ClockDemo/bin/ClockDemo.class differ diff --git a/BasicJava/ClockDemo_millis/ClockDemo/src/ClockDemo.java b/BasicJava/ClockDemo_millis/ClockDemo/src/ClockDemo.java new file mode 100644 index 000000000..68b448f32 --- /dev/null +++ b/BasicJava/ClockDemo_millis/ClockDemo/src/ClockDemo.java @@ -0,0 +1,21 @@ +import java.time.Clock; + +public class ClockDemo +{ + + public static void main(String[] args) + { + Clock clock = Clock.systemDefaultZone(); + System.out.println("clock = " + clock); + + /* + * Returns: + * + * the current millisecond instant from this clock, measured + * from the Java epoch of 1970-01-01T00:00Z (UTC), not null + */ + long millis = clock.millis(); + System.out.println("Clock millis = " + millis); + } + +} diff --git a/BasicJava/ClockDemo_millis/Output.txt b/BasicJava/ClockDemo_millis/Output.txt new file mode 100644 index 000000000..b3ad929bd --- /dev/null +++ b/BasicJava/ClockDemo_millis/Output.txt @@ -0,0 +1,2 @@ +clock = SystemClock[Asia/Calcutta] +Clock millis = 1518409712509 diff --git a/Later/String/Manipulating Characters in a String/String_24/StringDemo/.classpath b/BasicJava/ClockDemo_offset_duration/ClockDemo/.classpath similarity index 100% rename from Later/String/Manipulating Characters in a String/String_24/StringDemo/.classpath rename to BasicJava/ClockDemo_offset_duration/ClockDemo/.classpath diff --git a/BasicJava/ClockDemo_offset_duration/ClockDemo/.project b/BasicJava/ClockDemo_offset_duration/ClockDemo/.project new file mode 100644 index 000000000..6d8c49e0b --- /dev/null +++ b/BasicJava/ClockDemo_offset_duration/ClockDemo/.project @@ -0,0 +1,17 @@ + + + ClockDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/Manipulating Characters in a String/String_24/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ClockDemo_offset_duration/ClockDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/Manipulating Characters in a String/String_24/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/ClockDemo_offset_duration/ClockDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/ClockDemo_offset_duration/ClockDemo/bin/ClockDemo.class b/BasicJava/ClockDemo_offset_duration/ClockDemo/bin/ClockDemo.class new file mode 100644 index 000000000..ba3e8e31c Binary files /dev/null and b/BasicJava/ClockDemo_offset_duration/ClockDemo/bin/ClockDemo.class differ diff --git a/BasicJava/ClockDemo_offset_duration/ClockDemo/src/ClockDemo.java b/BasicJava/ClockDemo_offset_duration/ClockDemo/src/ClockDemo.java new file mode 100644 index 000000000..6c966c38e --- /dev/null +++ b/BasicJava/ClockDemo_offset_duration/ClockDemo/src/ClockDemo.java @@ -0,0 +1,33 @@ +import java.time.Clock; +import java.time.Duration; + +public class ClockDemo +{ + + public static void main(String[] args) + { + Clock baseClock = Clock.systemUTC(); + System.out.println("instant of baseClock = " + baseClock.instant()); + + Duration duration = Duration.ofHours(6); + System.out.println("duration = " + duration); + + /* + * Parameters: + * + * baseClock - the base clock to add the duration to, not null + * offset + * + * Duration - the duration to add, not null + * + * Returns: + * + * a clock based on the base clock with the duration added, + * not null + */ + + Clock clock = Clock.offset(baseClock, duration); + System.out.println("instant of clock = " + clock.instant()); + } + +} diff --git a/BasicJava/ClockDemo_offset_duration/Output.txt b/BasicJava/ClockDemo_offset_duration/Output.txt new file mode 100644 index 000000000..9a506af99 --- /dev/null +++ b/BasicJava/ClockDemo_offset_duration/Output.txt @@ -0,0 +1,3 @@ +instant of baseClock = 2018-02-13T03:22:38.254Z +duration = PT6H +instant of clock = 2018-02-13T09:23:36.572Z diff --git a/Later/String/Manipulating Characters in a String/String_25/StringDemo/.classpath b/BasicJava/ClockDemo_tick_duration/ClockDemo/.classpath similarity index 100% rename from Later/String/Manipulating Characters in a String/String_25/StringDemo/.classpath rename to BasicJava/ClockDemo_tick_duration/ClockDemo/.classpath diff --git a/BasicJava/ClockDemo_tick_duration/ClockDemo/.project b/BasicJava/ClockDemo_tick_duration/ClockDemo/.project new file mode 100644 index 000000000..6d8c49e0b --- /dev/null +++ b/BasicJava/ClockDemo_tick_duration/ClockDemo/.project @@ -0,0 +1,17 @@ + + + ClockDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/Manipulating Characters in a String/String_25/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ClockDemo_tick_duration/ClockDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/Manipulating Characters in a String/String_25/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/ClockDemo_tick_duration/ClockDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/ClockDemo_tick_duration/ClockDemo/bin/ClockDemo.class b/BasicJava/ClockDemo_tick_duration/ClockDemo/bin/ClockDemo.class new file mode 100644 index 000000000..ba5af67d0 Binary files /dev/null and b/BasicJava/ClockDemo_tick_duration/ClockDemo/bin/ClockDemo.class differ diff --git a/BasicJava/ClockDemo_tick_duration/ClockDemo/src/ClockDemo.java b/BasicJava/ClockDemo_tick_duration/ClockDemo/src/ClockDemo.java new file mode 100644 index 000000000..a2b0cbd3e --- /dev/null +++ b/BasicJava/ClockDemo_tick_duration/ClockDemo/src/ClockDemo.java @@ -0,0 +1,35 @@ +import java.time.Clock; +import java.time.Duration; + +public class ClockDemo +{ + + public static void main(String[] args) + { + Clock baseClock = Clock.systemUTC(); + System.out.println("instant of baseClock = " + baseClock.instant()); + + Duration tickDuration = Duration.ofDays(300); + System.out.println("tickDuration = " + tickDuration); + + /* + * Parameters: + * + * baseClock - the base clock to base the ticking clock on, + * not null + * + * tickDuration - the duration of each visible tick, not + * negative, not null + * + * Returns: + * + * a clock that ticks in whole units of the duration, + * not null + */ + + Clock clock = Clock.tick(baseClock, tickDuration); + + System.out.println("instant of clock = " + clock.instant()); + } + +} diff --git a/BasicJava/ClockDemo_tick_duration/Output.txt b/BasicJava/ClockDemo_tick_duration/Output.txt new file mode 100644 index 000000000..cacd5fa0f --- /dev/null +++ b/BasicJava/ClockDemo_tick_duration/Output.txt @@ -0,0 +1,3 @@ +instant of baseClock = 2018-02-13T03:41:00.886Z +tickDuration = PT7200H +instant of clock = 2017-08-22T00:00:00Z diff --git a/Later/String/Manipulating Characters in a String/String_26/StringDemo/.classpath b/BasicJava/ClockDemo_tickminutes/ClockDemo/.classpath similarity index 100% rename from Later/String/Manipulating Characters in a String/String_26/StringDemo/.classpath rename to BasicJava/ClockDemo_tickminutes/ClockDemo/.classpath diff --git a/BasicJava/ClockDemo_tickminutes/ClockDemo/.project b/BasicJava/ClockDemo_tickminutes/ClockDemo/.project new file mode 100644 index 000000000..6d8c49e0b --- /dev/null +++ b/BasicJava/ClockDemo_tickminutes/ClockDemo/.project @@ -0,0 +1,17 @@ + + + ClockDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/Manipulating Characters in a String/String_26/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ClockDemo_tickminutes/ClockDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/Manipulating Characters in a String/String_26/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/ClockDemo_tickminutes/ClockDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/ClockDemo_tickminutes/ClockDemo/bin/ClockDemo.class b/BasicJava/ClockDemo_tickminutes/ClockDemo/bin/ClockDemo.class new file mode 100644 index 000000000..358578803 Binary files /dev/null and b/BasicJava/ClockDemo_tickminutes/ClockDemo/bin/ClockDemo.class differ diff --git a/BasicJava/ClockDemo_tickminutes/ClockDemo/src/ClockDemo.java b/BasicJava/ClockDemo_tickminutes/ClockDemo/src/ClockDemo.java new file mode 100644 index 000000000..4e84d2901 --- /dev/null +++ b/BasicJava/ClockDemo_tickminutes/ClockDemo/src/ClockDemo.java @@ -0,0 +1,27 @@ +import java.time.Clock; +import java.time.ZoneId; + +public class ClockDemo +{ + + public static void main(String[] args) + { + Clock clock1 = Clock.systemDefaultZone(); + System.out.println("clock1 = " + clock1.instant()); + + /* + * Parameters: + * + * zone - the time-zone to use to convert the instant to + * date-time, not null + * + * Returns: + * + * a clock that ticks in whole minutes using the + * specified zone, not null + */ + Clock clock2 = Clock.tickMinutes(ZoneId.systemDefault()); + System.out.println("clock2 = " + clock2.instant()); + } + +} diff --git a/BasicJava/ClockDemo_tickminutes/Output.txt b/BasicJava/ClockDemo_tickminutes/Output.txt new file mode 100644 index 000000000..e5f76748f --- /dev/null +++ b/BasicJava/ClockDemo_tickminutes/Output.txt @@ -0,0 +1,2 @@ +clock1 = 2018-02-13T04:01:38.294Z +clock2 = 2018-02-13T04:01:00Z diff --git a/Later/String/Manipulating Characters in a String/String_27/StringDemo/.classpath b/BasicJava/ClockDemo_tickseconds/ClockDemo/.classpath similarity index 100% rename from Later/String/Manipulating Characters in a String/String_27/StringDemo/.classpath rename to BasicJava/ClockDemo_tickseconds/ClockDemo/.classpath diff --git a/BasicJava/ClockDemo_tickseconds/ClockDemo/.project b/BasicJava/ClockDemo_tickseconds/ClockDemo/.project new file mode 100644 index 000000000..6d8c49e0b --- /dev/null +++ b/BasicJava/ClockDemo_tickseconds/ClockDemo/.project @@ -0,0 +1,17 @@ + + + ClockDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/Manipulating Characters in a String/String_27/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ClockDemo_tickseconds/ClockDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/Manipulating Characters in a String/String_27/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/ClockDemo_tickseconds/ClockDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/ClockDemo_tickseconds/ClockDemo/bin/ClockDemo.class b/BasicJava/ClockDemo_tickseconds/ClockDemo/bin/ClockDemo.class new file mode 100644 index 000000000..b64cddb7a Binary files /dev/null and b/BasicJava/ClockDemo_tickseconds/ClockDemo/bin/ClockDemo.class differ diff --git a/BasicJava/ClockDemo_tickseconds/ClockDemo/src/ClockDemo.java b/BasicJava/ClockDemo_tickseconds/ClockDemo/src/ClockDemo.java new file mode 100644 index 000000000..486b3f959 --- /dev/null +++ b/BasicJava/ClockDemo_tickseconds/ClockDemo/src/ClockDemo.java @@ -0,0 +1,27 @@ +import java.time.Clock; +import java.time.ZoneId; + +public class ClockDemo +{ + + public static void main(String[] args) + { + Clock clock1 = Clock.systemDefaultZone(); + System.out.println("clock1 = " + clock1.instant()); + + /* + * Parameters: + * + * zone - the time-zone to use to convert the instant to + * date-time, not null + * + * Returns: + * + * a clock that ticks in whole seconds using the specified + * zone, not null + */ + Clock clock2 = Clock.tickSeconds(ZoneId.systemDefault()); + System.out.println("clock2 = " + clock2.instant()); + } + +} diff --git a/BasicJava/ClockDemo_tickseconds/Output.txt b/BasicJava/ClockDemo_tickseconds/Output.txt new file mode 100644 index 000000000..8b081f302 --- /dev/null +++ b/BasicJava/ClockDemo_tickseconds/Output.txt @@ -0,0 +1,2 @@ +clock1 = 2018-02-13T04:12:24.569Z +clock2 = 2018-02-13T04:12:40Z diff --git a/Later/String/Manipulating Characters in a String/String_28/StringDemo/.classpath b/BasicJava/ClockDemo_withzone/ClockDemo/.classpath similarity index 100% rename from Later/String/Manipulating Characters in a String/String_28/StringDemo/.classpath rename to BasicJava/ClockDemo_withzone/ClockDemo/.classpath diff --git a/BasicJava/ClockDemo_withzone/ClockDemo/.project b/BasicJava/ClockDemo_withzone/ClockDemo/.project new file mode 100644 index 000000000..6d8c49e0b --- /dev/null +++ b/BasicJava/ClockDemo_withzone/ClockDemo/.project @@ -0,0 +1,17 @@ + + + ClockDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/Manipulating Characters in a String/String_28/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ClockDemo_withzone/ClockDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/Manipulating Characters in a String/String_28/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/ClockDemo_withzone/ClockDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/ClockDemo_withzone/ClockDemo/bin/ClockDemo.class b/BasicJava/ClockDemo_withzone/ClockDemo/bin/ClockDemo.class new file mode 100644 index 000000000..efaf6b50c Binary files /dev/null and b/BasicJava/ClockDemo_withzone/ClockDemo/bin/ClockDemo.class differ diff --git a/BasicJava/ClockDemo_withzone/ClockDemo/src/ClockDemo.java b/BasicJava/ClockDemo_withzone/ClockDemo/src/ClockDemo.java new file mode 100644 index 000000000..a867d1f84 --- /dev/null +++ b/BasicJava/ClockDemo_withzone/ClockDemo/src/ClockDemo.java @@ -0,0 +1,26 @@ +import java.time.Clock; +import java.time.ZoneId; + +public class ClockDemo +{ + + public static void main(String[] args) + { + Clock clock1 = Clock.systemDefaultZone(); + System.out.println("clock1 = " + clock1.instant()); + + /* + * Parameters: + * + * zone - the time-zone to change to, not null + * + * Returns: + * + * a clock based on this clock with the specified time-zone, + * not null + */ + Clock clock2 = clock1.withZone(ZoneId.systemDefault()); + System.out.println("clock2 = " + clock2.instant()); + } + +} diff --git a/BasicJava/ClockDemo_withzone/Output.txt b/BasicJava/ClockDemo_withzone/Output.txt new file mode 100644 index 000000000..a69ba6bae --- /dev/null +++ b/BasicJava/ClockDemo_withzone/Output.txt @@ -0,0 +1,2 @@ +clock1 = 2018-02-13T04:24:13.638Z +clock2 = 2018-02-13T04:24:32.123Z diff --git a/Later/String/Manipulating Characters in a String/String_29/StringDemo/.classpath b/BasicJava/CommandLineArgsDemo_App/CommandLineArgsDemo/.classpath similarity index 100% rename from Later/String/Manipulating Characters in a String/String_29/StringDemo/.classpath rename to BasicJava/CommandLineArgsDemo_App/CommandLineArgsDemo/.classpath diff --git a/BasicJava/CommandLineArgsDemo_App/CommandLineArgsDemo/.project b/BasicJava/CommandLineArgsDemo_App/CommandLineArgsDemo/.project new file mode 100644 index 000000000..38c1c7007 --- /dev/null +++ b/BasicJava/CommandLineArgsDemo_App/CommandLineArgsDemo/.project @@ -0,0 +1,17 @@ + + + CommandLineArgsDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/Manipulating Characters in a String/String_29/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/CommandLineArgsDemo_App/CommandLineArgsDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/Manipulating Characters in a String/String_29/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/CommandLineArgsDemo_App/CommandLineArgsDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/CommandLineArgsDemo_App/CommandLineArgsDemo/bin/Echo.class b/BasicJava/CommandLineArgsDemo_App/CommandLineArgsDemo/bin/Echo.class new file mode 100644 index 000000000..e9718925c Binary files /dev/null and b/BasicJava/CommandLineArgsDemo_App/CommandLineArgsDemo/bin/Echo.class differ diff --git a/BasicJava/CommandLineArgsDemo_App/CommandLineArgsDemo/src/Echo.java b/BasicJava/CommandLineArgsDemo_App/CommandLineArgsDemo/src/Echo.java new file mode 100644 index 000000000..c1a9f457e --- /dev/null +++ b/BasicJava/CommandLineArgsDemo_App/CommandLineArgsDemo/src/Echo.java @@ -0,0 +1,10 @@ +public class Echo +{ + public static void main(String[] args) + { + for (String s : args) + { + System.out.println(s); + } + } +} \ No newline at end of file diff --git a/BasicJava/CommandLineArgsDemo_App/Output.txt b/BasicJava/CommandLineArgsDemo_App/Output.txt new file mode 100644 index 000000000..f48cc3066 --- /dev/null +++ b/BasicJava/CommandLineArgsDemo_App/Output.txt @@ -0,0 +1,3 @@ +Welcome +to +India diff --git a/BasicJava/CommandLineArgsDemo_App/commadline.jpg b/BasicJava/CommandLineArgsDemo_App/commadline.jpg new file mode 100644 index 000000000..ac1a65ac4 Binary files /dev/null and b/BasicJava/CommandLineArgsDemo_App/commadline.jpg differ diff --git a/Later/String/Manipulating Characters in a String/String_30/StringDemo/.classpath b/BasicJava/CommandLineArgsDemo_int_App/CommandLineArgsDemo/.classpath similarity index 100% rename from Later/String/Manipulating Characters in a String/String_30/StringDemo/.classpath rename to BasicJava/CommandLineArgsDemo_int_App/CommandLineArgsDemo/.classpath diff --git a/BasicJava/CommandLineArgsDemo_int_App/CommandLineArgsDemo/.project b/BasicJava/CommandLineArgsDemo_int_App/CommandLineArgsDemo/.project new file mode 100644 index 000000000..38c1c7007 --- /dev/null +++ b/BasicJava/CommandLineArgsDemo_int_App/CommandLineArgsDemo/.project @@ -0,0 +1,17 @@ + + + CommandLineArgsDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/Manipulating Characters in a String/String_30/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/CommandLineArgsDemo_int_App/CommandLineArgsDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/Manipulating Characters in a String/String_30/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/CommandLineArgsDemo_int_App/CommandLineArgsDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/CommandLineArgsDemo_int_App/CommandLineArgsDemo/bin/Echo.class b/BasicJava/CommandLineArgsDemo_int_App/CommandLineArgsDemo/bin/Echo.class new file mode 100644 index 000000000..14e475800 Binary files /dev/null and b/BasicJava/CommandLineArgsDemo_int_App/CommandLineArgsDemo/bin/Echo.class differ diff --git a/BasicJava/CommandLineArgsDemo_int_App/CommandLineArgsDemo/src/Echo.java b/BasicJava/CommandLineArgsDemo_int_App/CommandLineArgsDemo/src/Echo.java new file mode 100644 index 000000000..c07629670 --- /dev/null +++ b/BasicJava/CommandLineArgsDemo_int_App/CommandLineArgsDemo/src/Echo.java @@ -0,0 +1,24 @@ +public class Echo +{ + public static void main(String[] args) + { + int value; + try + { + /* + * Converts a command-line argument to an int. + * + * All of the Number classes — Integer, Float, + * Double, and so on — have parseXXX methods + * that convert a String representing a number + * to an object of their type. + */ + value = Integer.parseInt(args[0]); + System.out.println(value); + } + catch (NumberFormatException e) + { + System.err.println("Argument " + args[0] + " must be an integer."); + } + } +} \ No newline at end of file diff --git a/BasicJava/CommandLineArgsDemo_int_App/Output.txt b/BasicJava/CommandLineArgsDemo_int_App/Output.txt new file mode 100644 index 000000000..52bd8e43a --- /dev/null +++ b/BasicJava/CommandLineArgsDemo_int_App/Output.txt @@ -0,0 +1 @@ +120 diff --git a/Later/String/Manipulating Characters in a String/String_31/StringDemo/.classpath b/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo/.classpath similarity index 100% rename from Later/String/Manipulating Characters in a String/String_31/StringDemo/.classpath rename to BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo/.classpath diff --git a/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo/.project b/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo/.project new file mode 100644 index 000000000..eaee21695 --- /dev/null +++ b/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo/.project @@ -0,0 +1,17 @@ + + + DateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/Manipulating Characters in a String/String_31/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/Manipulating Characters in a String/String_31/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo/bin/DateTimeDemo1.class b/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo/bin/DateTimeDemo1.class new file mode 100644 index 000000000..30fca6339 Binary files /dev/null and b/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo/bin/DateTimeDemo1.class differ diff --git a/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo/bin/DateTimeDemo2.class b/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo/bin/DateTimeDemo2.class new file mode 100644 index 000000000..a6ffebb96 Binary files /dev/null and b/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo/bin/DateTimeDemo2.class differ diff --git a/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo/bin/DateTimeDemo3.class b/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo/bin/DateTimeDemo3.class new file mode 100644 index 000000000..c563eb885 Binary files /dev/null and b/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo/bin/DateTimeDemo3.class differ diff --git a/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo/bin/DateTimeDemo4.class b/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo/bin/DateTimeDemo4.class new file mode 100644 index 000000000..79a536d6a Binary files /dev/null and b/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo/bin/DateTimeDemo4.class differ diff --git a/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo/src/DateTimeDemo1.java b/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo/src/DateTimeDemo1.java new file mode 100644 index 000000000..3beb9ed82 --- /dev/null +++ b/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo/src/DateTimeDemo1.java @@ -0,0 +1,37 @@ +import java.time.Clock; + +public class DateTimeDemo1 +{ + + public static void main(String[] args) + { + /* + * Returns:the current date using the system clock and default + * time-zone, not null + */ + System.out.println(java.time.LocalDate.now()); + + /* + * Returns:the current time using the system clock and default + * time-zone, not null + */ + System.out.println(java.time.LocalTime.now()); + + /* + * Returns:the current date-time using the system clock and + * default time-zone, not null + */ + System.out.println(java.time.LocalDateTime.now()); + + /* + * systemUTC(): Returns:a clock that uses the best available + * system clock in the UTC zone, not null. + * + * instant(): Returns:the current instant from this clock, not + * null. + */ + Clock clock = java.time.Clock.systemUTC(); + System.out.println(clock.instant()); + } + +} diff --git a/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo/src/DateTimeDemo2.java b/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo/src/DateTimeDemo2.java new file mode 100644 index 000000000..f4fc1e670 --- /dev/null +++ b/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo/src/DateTimeDemo2.java @@ -0,0 +1,21 @@ + +public class DateTimeDemo2 +{ + + public static void main(String[] args) + { + /* + * 1 way + */ + java.util.Date date1 = new java.util.Date(); + System.out.println(date1); + + /* + * 2nd way + */ + long millis = System.currentTimeMillis(); + java.util.Date date2 = new java.util.Date(millis); + System.out.println(date2); + } + +} diff --git a/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo/src/DateTimeDemo3.java b/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo/src/DateTimeDemo3.java new file mode 100644 index 000000000..1c153832a --- /dev/null +++ b/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo/src/DateTimeDemo3.java @@ -0,0 +1,12 @@ + +public class DateTimeDemo3 +{ + + public static void main(String[] args) + { + long millis = System.currentTimeMillis(); + java.sql.Date date = new java.sql.Date(millis); + System.out.println(date); + } + +} diff --git a/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo/src/DateTimeDemo4.java b/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo/src/DateTimeDemo4.java new file mode 100644 index 000000000..77658425f --- /dev/null +++ b/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo/src/DateTimeDemo4.java @@ -0,0 +1,19 @@ +import java.util.Date; + +public class DateTimeDemo4 +{ + + public static void main(String[] args) + { + + java.util.Calendar cal = java.util.Calendar.getInstance(); + /* + * It is recommended to use Calendar class for getting current + * date and time in classical Date API. Since Java 8, you can + * use LocalDate, LocalTime or LocalDateTime classes. + */ + Date date = cal.getTime(); + System.out.println(date); + } + +} diff --git a/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo1_Output.txt b/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo1_Output.txt new file mode 100644 index 000000000..c5a5f470b --- /dev/null +++ b/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo1_Output.txt @@ -0,0 +1,4 @@ +2018-01-02 +08:20:52.973 +2018-01-02T08:20:52.973 +2018-01-02T02:50:52.974Z diff --git a/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo2_Output.txt b/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo2_Output.txt new file mode 100644 index 000000000..fcd50edc5 --- /dev/null +++ b/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo2_Output.txt @@ -0,0 +1,2 @@ +Tue Jan 02 08:21:02 IST 2018 +Tue Jan 02 08:21:02 IST 2018 diff --git a/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo3_Output.txt b/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo3_Output.txt new file mode 100644 index 000000000..674e22bc2 --- /dev/null +++ b/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo3_Output.txt @@ -0,0 +1 @@ +2018-01-02 diff --git a/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo4_Output.txt b/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo4_Output.txt new file mode 100644 index 000000000..a8a1b51c3 --- /dev/null +++ b/BasicJava/DateTimeDemo_currentdatetime/DateTimeDemo4_Output.txt @@ -0,0 +1 @@ +Tue Jan 02 08:21:24 IST 2018 diff --git a/Later/String/Manipulating Characters in a String/String_32/StringDemo/.classpath b/BasicJava/EnumDemo_Car_Cons_method_App/EnumDemo/.classpath similarity index 100% rename from Later/String/Manipulating Characters in a String/String_32/StringDemo/.classpath rename to BasicJava/EnumDemo_Car_Cons_method_App/EnumDemo/.classpath diff --git a/BasicJava/EnumDemo_Car_Cons_method_App/EnumDemo/.project b/BasicJava/EnumDemo_Car_Cons_method_App/EnumDemo/.project new file mode 100644 index 000000000..821a962c7 --- /dev/null +++ b/BasicJava/EnumDemo_Car_Cons_method_App/EnumDemo/.project @@ -0,0 +1,17 @@ + + + EnumDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/Manipulating Characters in a String/String_32/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/EnumDemo_Car_Cons_method_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/Manipulating Characters in a String/String_32/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/EnumDemo_Car_Cons_method_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/EnumDemo_Car_Cons_method_App/EnumDemo/bin/Car.class b/BasicJava/EnumDemo_Car_Cons_method_App/EnumDemo/bin/Car.class new file mode 100644 index 000000000..eb60510e7 Binary files /dev/null and b/BasicJava/EnumDemo_Car_Cons_method_App/EnumDemo/bin/Car.class differ diff --git a/BasicJava/EnumDemo_Car_Cons_method_App/EnumDemo/bin/EnumDemo.class b/BasicJava/EnumDemo_Car_Cons_method_App/EnumDemo/bin/EnumDemo.class new file mode 100644 index 000000000..ba6fccdbb Binary files /dev/null and b/BasicJava/EnumDemo_Car_Cons_method_App/EnumDemo/bin/EnumDemo.class differ diff --git a/BasicJava/EnumDemo_Car_Cons_method_App/EnumDemo/src/EnumDemo.java b/BasicJava/EnumDemo_Car_Cons_method_App/EnumDemo/src/EnumDemo.java new file mode 100644 index 000000000..fe8550da5 --- /dev/null +++ b/BasicJava/EnumDemo_Car_Cons_method_App/EnumDemo/src/EnumDemo.java @@ -0,0 +1,34 @@ +enum Car +{ + TATA(2), + AUDI(60), + FIAT(20), + HONDA(15); + + private int price; + + Car(int price) + { + this.price = price; + } + + int getPrice() + { + return price; + } +} + +public class EnumDemo +{ + public static void main(String args[]) + { + Car[] carArray = Car.values(); + System.out.println("All car prices:"); + for (Car car : carArray) + { + System.out.println(car + " costs " + car.getPrice() + + " thousand dollars."); + } + + } +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_Car_Cons_method_App/Output.txt b/BasicJava/EnumDemo_Car_Cons_method_App/Output.txt new file mode 100644 index 000000000..2774a318c --- /dev/null +++ b/BasicJava/EnumDemo_Car_Cons_method_App/Output.txt @@ -0,0 +1,5 @@ +All car prices: +TATA costs 2 thousand dollars. +AUDI costs 60 thousand dollars. +FIAT costs 20 thousand dollars. +HONDA costs 15 thousand dollars. diff --git a/Later/String/Manipulating Characters in a String/String_33/StringDemo/.classpath b/BasicJava/EnumDemo_Car_switch_App/EnumDemo/.classpath similarity index 100% rename from Later/String/Manipulating Characters in a String/String_33/StringDemo/.classpath rename to BasicJava/EnumDemo_Car_switch_App/EnumDemo/.classpath diff --git a/BasicJava/EnumDemo_Car_switch_App/EnumDemo/.project b/BasicJava/EnumDemo_Car_switch_App/EnumDemo/.project new file mode 100644 index 000000000..821a962c7 --- /dev/null +++ b/BasicJava/EnumDemo_Car_switch_App/EnumDemo/.project @@ -0,0 +1,17 @@ + + + EnumDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/Manipulating Characters in a String/String_33/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/EnumDemo_Car_switch_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/Manipulating Characters in a String/String_33/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/EnumDemo_Car_switch_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/EnumDemo_Car_switch_App/EnumDemo/bin/Car.class b/BasicJava/EnumDemo_Car_switch_App/EnumDemo/bin/Car.class new file mode 100644 index 000000000..ce541d7e1 Binary files /dev/null and b/BasicJava/EnumDemo_Car_switch_App/EnumDemo/bin/Car.class differ diff --git a/BasicJava/EnumDemo_Car_switch_App/EnumDemo/bin/EnumDemo.class b/BasicJava/EnumDemo_Car_switch_App/EnumDemo/bin/EnumDemo.class new file mode 100644 index 000000000..a98595e76 Binary files /dev/null and b/BasicJava/EnumDemo_Car_switch_App/EnumDemo/bin/EnumDemo.class differ diff --git a/BasicJava/EnumDemo_Car_switch_App/EnumDemo/src/EnumDemo.java b/BasicJava/EnumDemo_Car_switch_App/EnumDemo/src/EnumDemo.java new file mode 100644 index 000000000..d9d7401c8 --- /dev/null +++ b/BasicJava/EnumDemo_Car_switch_App/EnumDemo/src/EnumDemo.java @@ -0,0 +1,35 @@ +/* + * How to use enum & switch statement? + */ +enum Car +{ + TATA, AUDI, FIAT, HONDA +} + +public class EnumDemo +{ + public static void main(String args[]) + { + Car car; + car = Car.AUDI; + switch (car) + { + case TATA: + System.out.println("You choose tata!"); + break; + case AUDI: + System.out.println("You choose audi!"); + break; + case FIAT: + System.out.println("You choose fiat!"); + break; + case HONDA: + System.out.println("You choose honda!"); + break; + default: + System.out.println("I don't know your car."); + break; + } + + } +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_Car_switch_App/Output.txt b/BasicJava/EnumDemo_Car_switch_App/Output.txt new file mode 100644 index 000000000..635f3d937 --- /dev/null +++ b/BasicJava/EnumDemo_Car_switch_App/Output.txt @@ -0,0 +1 @@ +You choose audi! diff --git a/Later/String/misc/String Concatenation in Java_62/StringDemo/.classpath b/BasicJava/EnumDemo_Company_App/EnumDemo/.classpath similarity index 100% rename from Later/String/misc/String Concatenation in Java_62/StringDemo/.classpath rename to BasicJava/EnumDemo_Company_App/EnumDemo/.classpath diff --git a/BasicJava/EnumDemo_Company_App/EnumDemo/.project b/BasicJava/EnumDemo_Company_App/EnumDemo/.project new file mode 100644 index 000000000..821a962c7 --- /dev/null +++ b/BasicJava/EnumDemo_Company_App/EnumDemo/.project @@ -0,0 +1,17 @@ + + + EnumDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/misc/String Concatenation in Java_62/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/EnumDemo_Company_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/misc/String Concatenation in Java_62/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/EnumDemo_Company_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/EnumDemo_Company_App/EnumDemo/bin/Company.class b/BasicJava/EnumDemo_Company_App/EnumDemo/bin/Company.class new file mode 100644 index 000000000..2106efa0a Binary files /dev/null and b/BasicJava/EnumDemo_Company_App/EnumDemo/bin/Company.class differ diff --git a/BasicJava/EnumDemo_Company_App/EnumDemo/bin/EnumDemo.class b/BasicJava/EnumDemo_Company_App/EnumDemo/bin/EnumDemo.class new file mode 100644 index 000000000..b13cfddb7 Binary files /dev/null and b/BasicJava/EnumDemo_Company_App/EnumDemo/bin/EnumDemo.class differ diff --git a/BasicJava/EnumDemo_Company_App/EnumDemo/bin/MultiNationalCompany.class b/BasicJava/EnumDemo_Company_App/EnumDemo/bin/MultiNationalCompany.class new file mode 100644 index 000000000..4188963a8 Binary files /dev/null and b/BasicJava/EnumDemo_Company_App/EnumDemo/bin/MultiNationalCompany.class differ diff --git a/BasicJava/EnumDemo_Company_App/EnumDemo/src/EnumDemo.java b/BasicJava/EnumDemo_Company_App/EnumDemo/src/EnumDemo.java new file mode 100644 index 000000000..b6e29495a --- /dev/null +++ b/BasicJava/EnumDemo_Company_App/EnumDemo/src/EnumDemo.java @@ -0,0 +1,12 @@ +public class EnumDemo +{ + public static void main(String[] args) + { + MultiNationalCompany paypal = new MultiNationalCompany(Company.PAYPAL); + paypal.getCompanyDetails(); + MultiNationalCompany google = new MultiNationalCompany(Company.GOOGLE); + google.getCompanyDetails(); + MultiNationalCompany yahoo = new MultiNationalCompany(Company.YAHOO); + yahoo.getCompanyDetails(); + } +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_Company_App/EnumDemo/src/MultiNationalCompany.java b/BasicJava/EnumDemo_Company_App/EnumDemo/src/MultiNationalCompany.java new file mode 100644 index 000000000..ec4b6e9d3 --- /dev/null +++ b/BasicJava/EnumDemo_Company_App/EnumDemo/src/MultiNationalCompany.java @@ -0,0 +1,33 @@ +enum Company +{ + PAYPAL, GOOGLE, YAHOO +} + +public class MultiNationalCompany +{ + + private Company companyName; + + public MultiNationalCompany(Company companyName) + { + this.companyName = companyName; + } + + public void getCompanyDetails() + { + switch (companyName) + { + case PAYPAL: + System.out.println("Simplest way to manage Money."); + break; + + case GOOGLE: + System.out.println("Google - biggest search giant.. "); + break; + + case YAHOO: + System.out.println("1st Web 2.0 Company."); + break; + } + } +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_Company_App/Output.txt b/BasicJava/EnumDemo_Company_App/Output.txt new file mode 100644 index 000000000..f4e286b32 --- /dev/null +++ b/BasicJava/EnumDemo_Company_App/Output.txt @@ -0,0 +1,3 @@ +Simplest way to manage Money. +Google - biggest search giant.. +1st Web 2.0 Company. diff --git a/Later/String/misc/String-Comparison_61/String_61/StringDemo/.classpath b/BasicJava/EnumDemo_Company_cons_method_App/EnumDemo/.classpath similarity index 100% rename from Later/String/misc/String-Comparison_61/String_61/StringDemo/.classpath rename to BasicJava/EnumDemo_Company_cons_method_App/EnumDemo/.classpath diff --git a/BasicJava/EnumDemo_Company_cons_method_App/EnumDemo/.project b/BasicJava/EnumDemo_Company_cons_method_App/EnumDemo/.project new file mode 100644 index 000000000..821a962c7 --- /dev/null +++ b/BasicJava/EnumDemo_Company_cons_method_App/EnumDemo/.project @@ -0,0 +1,17 @@ + + + EnumDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/misc/String-Comparison_61/String_61/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/EnumDemo_Company_cons_method_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/misc/String-Comparison_61/String_61/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/EnumDemo_Company_cons_method_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/EnumDemo_Company_cons_method_App/EnumDemo/bin/Company.class b/BasicJava/EnumDemo_Company_cons_method_App/EnumDemo/bin/Company.class new file mode 100644 index 000000000..fac004b8d Binary files /dev/null and b/BasicJava/EnumDemo_Company_cons_method_App/EnumDemo/bin/Company.class differ diff --git a/BasicJava/EnumDemo_Company_cons_method_App/EnumDemo/bin/EnumDemo.class b/BasicJava/EnumDemo_Company_cons_method_App/EnumDemo/bin/EnumDemo.class new file mode 100644 index 000000000..14da6b9b5 Binary files /dev/null and b/BasicJava/EnumDemo_Company_cons_method_App/EnumDemo/bin/EnumDemo.class differ diff --git a/BasicJava/EnumDemo_Company_cons_method_App/EnumDemo/src/Company.java b/BasicJava/EnumDemo_Company_cons_method_App/EnumDemo/src/Company.java new file mode 100644 index 000000000..6c6368471 --- /dev/null +++ b/BasicJava/EnumDemo_Company_cons_method_App/EnumDemo/src/Company.java @@ -0,0 +1,17 @@ +enum Company +{ + PAYPAL(101), GOOGLE(201), YAHOO(301); + + private int companyCode; + + private Company(int companyCode) + { + this.companyCode = companyCode; + } + + public int getCompanyCode() + { + return companyCode; + } + +} diff --git a/BasicJava/EnumDemo_Company_cons_method_App/EnumDemo/src/EnumDemo.java b/BasicJava/EnumDemo_Company_cons_method_App/EnumDemo/src/EnumDemo.java new file mode 100644 index 000000000..852916a5b --- /dev/null +++ b/BasicJava/EnumDemo_Company_cons_method_App/EnumDemo/src/EnumDemo.java @@ -0,0 +1,12 @@ +public class EnumDemo +{ + public static void main(String[] args) + { + Company[] companyArray= Company.values(); + for (Company cName : companyArray) + { + System.out.println("Company Code: " + cName.getCompanyCode() + + " - Company Name: " + cName); + } + } +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_Company_cons_method_App/Output.txt b/BasicJava/EnumDemo_Company_cons_method_App/Output.txt new file mode 100644 index 000000000..bb0766be1 --- /dev/null +++ b/BasicJava/EnumDemo_Company_cons_method_App/Output.txt @@ -0,0 +1,3 @@ +Company Code: 101 - Company Name: PAYPAL +Company Code: 201 - Company Name: GOOGLE +Company Code: 301 - Company Name: YAHOO diff --git a/Later/String/misc/String_45/StringDemo/.classpath b/BasicJava/EnumDemo_Convert_to_Enum_App/EnumDemo/.classpath similarity index 100% rename from Later/String/misc/String_45/StringDemo/.classpath rename to BasicJava/EnumDemo_Convert_to_Enum_App/EnumDemo/.classpath diff --git a/BasicJava/EnumDemo_Convert_to_Enum_App/EnumDemo/.project b/BasicJava/EnumDemo_Convert_to_Enum_App/EnumDemo/.project new file mode 100644 index 000000000..821a962c7 --- /dev/null +++ b/BasicJava/EnumDemo_Convert_to_Enum_App/EnumDemo/.project @@ -0,0 +1,17 @@ + + + EnumDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/misc/String_45/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/EnumDemo_Convert_to_Enum_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/misc/String_45/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/EnumDemo_Convert_to_Enum_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/EnumDemo_Convert_to_Enum_App/EnumDemo/bin/EnumDemo.class b/BasicJava/EnumDemo_Convert_to_Enum_App/EnumDemo/bin/EnumDemo.class new file mode 100644 index 000000000..0905d2939 Binary files /dev/null and b/BasicJava/EnumDemo_Convert_to_Enum_App/EnumDemo/bin/EnumDemo.class differ diff --git a/BasicJava/EnumDemo_Convert_to_Enum_App/EnumDemo/bin/Operation.class b/BasicJava/EnumDemo_Convert_to_Enum_App/EnumDemo/bin/Operation.class new file mode 100644 index 000000000..88f4e65ae Binary files /dev/null and b/BasicJava/EnumDemo_Convert_to_Enum_App/EnumDemo/bin/Operation.class differ diff --git a/BasicJava/EnumDemo_Convert_to_Enum_App/EnumDemo/src/EnumDemo.java b/BasicJava/EnumDemo_Convert_to_Enum_App/EnumDemo/src/EnumDemo.java new file mode 100644 index 000000000..04ac9f099 --- /dev/null +++ b/BasicJava/EnumDemo_Convert_to_Enum_App/EnumDemo/src/EnumDemo.java @@ -0,0 +1,13 @@ +public class EnumDemo +{ + public static void main(String[] args) + { + /* + * Convert a String to Enum object. + */ + Operation operation = Operation.valueOf("plus".toUpperCase()); + System.out.println(operation); + + System.out.println(operation.calculate(10, 20)); + } +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_Convert_to_Enum_App/EnumDemo/src/Operation.java b/BasicJava/EnumDemo_Convert_to_Enum_App/EnumDemo/src/Operation.java new file mode 100644 index 000000000..4c0634214 --- /dev/null +++ b/BasicJava/EnumDemo_Convert_to_Enum_App/EnumDemo/src/Operation.java @@ -0,0 +1,22 @@ +public enum Operation +{ + PLUS, MINUS, MULTIPLY, DIVIDE; + + long calculate(long x, long y) + { + switch (this) + { + case PLUS: + return x + y; + case MINUS: + return x - y; + case MULTIPLY: + return x * y; + case DIVIDE: + return x / y; + default: + throw new AssertionError("Unknown operations " + this); + } + } + +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_Convert_to_Enum_App/Output.txt b/BasicJava/EnumDemo_Convert_to_Enum_App/Output.txt new file mode 100644 index 000000000..2eabae485 --- /dev/null +++ b/BasicJava/EnumDemo_Convert_to_Enum_App/Output.txt @@ -0,0 +1,2 @@ +PLUS +30 diff --git a/Later/String/misc/String_46/StringDemo/.classpath b/BasicJava/EnumDemo_Intro_App/EnumDemo/.classpath similarity index 100% rename from Later/String/misc/String_46/StringDemo/.classpath rename to BasicJava/EnumDemo_Intro_App/EnumDemo/.classpath diff --git a/BasicJava/EnumDemo_Intro_App/EnumDemo/.project b/BasicJava/EnumDemo_Intro_App/EnumDemo/.project new file mode 100644 index 000000000..821a962c7 --- /dev/null +++ b/BasicJava/EnumDemo_Intro_App/EnumDemo/.project @@ -0,0 +1,17 @@ + + + EnumDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/misc/String_46/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/EnumDemo_Intro_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/misc/String_46/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/EnumDemo_Intro_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/EnumDemo_Intro_App/EnumDemo/bin/EnumDemo1$Day.class b/BasicJava/EnumDemo_Intro_App/EnumDemo/bin/EnumDemo1$Day.class new file mode 100644 index 000000000..984f053f5 Binary files /dev/null and b/BasicJava/EnumDemo_Intro_App/EnumDemo/bin/EnumDemo1$Day.class differ diff --git a/BasicJava/EnumDemo_Intro_App/EnumDemo/bin/EnumDemo1.class b/BasicJava/EnumDemo_Intro_App/EnumDemo/bin/EnumDemo1.class new file mode 100644 index 000000000..1de0a6616 Binary files /dev/null and b/BasicJava/EnumDemo_Intro_App/EnumDemo/bin/EnumDemo1.class differ diff --git a/BasicJava/EnumDemo_Intro_App/EnumDemo/bin/EnumDemo2$Direction.class b/BasicJava/EnumDemo_Intro_App/EnumDemo/bin/EnumDemo2$Direction.class new file mode 100644 index 000000000..a08765f8c Binary files /dev/null and b/BasicJava/EnumDemo_Intro_App/EnumDemo/bin/EnumDemo2$Direction.class differ diff --git a/BasicJava/EnumDemo_Intro_App/EnumDemo/bin/EnumDemo2.class b/BasicJava/EnumDemo_Intro_App/EnumDemo/bin/EnumDemo2.class new file mode 100644 index 000000000..08dc14c3d Binary files /dev/null and b/BasicJava/EnumDemo_Intro_App/EnumDemo/bin/EnumDemo2.class differ diff --git a/BasicJava/EnumDemo_Intro_App/EnumDemo/bin/EnumDemo3$Season.class b/BasicJava/EnumDemo_Intro_App/EnumDemo/bin/EnumDemo3$Season.class new file mode 100644 index 000000000..96ea2431f Binary files /dev/null and b/BasicJava/EnumDemo_Intro_App/EnumDemo/bin/EnumDemo3$Season.class differ diff --git a/BasicJava/EnumDemo_Intro_App/EnumDemo/bin/EnumDemo3.class b/BasicJava/EnumDemo_Intro_App/EnumDemo/bin/EnumDemo3.class new file mode 100644 index 000000000..c226cd3ce Binary files /dev/null and b/BasicJava/EnumDemo_Intro_App/EnumDemo/bin/EnumDemo3.class differ diff --git a/BasicJava/EnumDemo_Intro_App/EnumDemo/src/EnumDemo1.java b/BasicJava/EnumDemo_Intro_App/EnumDemo/src/EnumDemo1.java new file mode 100644 index 000000000..c2fc29605 --- /dev/null +++ b/BasicJava/EnumDemo_Intro_App/EnumDemo/src/EnumDemo1.java @@ -0,0 +1,23 @@ +public class EnumDemo1 +{ + public enum Day + { + SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY + } + + public static void main(String[] args) + { + /* + * The java compiler internally adds the values() + * method when it creates an enum. The values() + * method returns an array containing all the values + * of the enum. + */ + Day[] daysArray = Day.values(); + for (Day day : daysArray) + { + System.out.println(day); + } + + } +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_Intro_App/EnumDemo/src/EnumDemo2.java b/BasicJava/EnumDemo_Intro_App/EnumDemo/src/EnumDemo2.java new file mode 100644 index 000000000..d9f444b5d --- /dev/null +++ b/BasicJava/EnumDemo_Intro_App/EnumDemo/src/EnumDemo2.java @@ -0,0 +1,23 @@ +public class EnumDemo2 +{ + public enum Direction + { + NORTH, SOUTH, EAST, WEST + } + + public static void main(String[] args) + { + /* + * The java compiler internally adds the values() + * method when it creates an enum. The values() + * method returns an array containing all the values + * of the enum. + */ + Direction[] directionsArray = Direction.values(); + for (Direction direction : directionsArray) + { + System.out.println(direction); + } + + } +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_Intro_App/EnumDemo/src/EnumDemo3.java b/BasicJava/EnumDemo_Intro_App/EnumDemo/src/EnumDemo3.java new file mode 100644 index 000000000..f80f24320 --- /dev/null +++ b/BasicJava/EnumDemo_Intro_App/EnumDemo/src/EnumDemo3.java @@ -0,0 +1,23 @@ +public class EnumDemo3 +{ + public enum Season + { + WINTER, SPRING, SUMMER, FALL + } + + public static void main(String[] args) + { + /* + * The java compiler internally adds the values() + * method when it creates an enum. The values() + * method returns an array containing all the values + * of the enum. + */ + Season[] seasonArray = Season.values(); + for (Season season : seasonArray) + { + System.out.println(season); + } + + } +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_Intro_App/EnumDemo1_Output.txt b/BasicJava/EnumDemo_Intro_App/EnumDemo1_Output.txt new file mode 100644 index 000000000..21d4b5adc --- /dev/null +++ b/BasicJava/EnumDemo_Intro_App/EnumDemo1_Output.txt @@ -0,0 +1,7 @@ +SUNDAY +MONDAY +TUESDAY +WEDNESDAY +THURSDAY +FRIDAY +SATURDAY diff --git a/BasicJava/EnumDemo_Intro_App/EnumDemo2_Output.txt b/BasicJava/EnumDemo_Intro_App/EnumDemo2_Output.txt new file mode 100644 index 000000000..70ccdf1f5 --- /dev/null +++ b/BasicJava/EnumDemo_Intro_App/EnumDemo2_Output.txt @@ -0,0 +1,4 @@ +NORTH +SOUTH +EAST +WEST diff --git a/BasicJava/EnumDemo_Intro_App/EnumDemo3_Output.txt b/BasicJava/EnumDemo_Intro_App/EnumDemo3_Output.txt new file mode 100644 index 000000000..6d9ed60ae --- /dev/null +++ b/BasicJava/EnumDemo_Intro_App/EnumDemo3_Output.txt @@ -0,0 +1,4 @@ +WINTER +SPRING +SUMMER +FALL diff --git a/Later/String/misc/String_47/StringDemo/.classpath b/BasicJava/EnumDemo_Level_App/EnumDemo/.classpath similarity index 100% rename from Later/String/misc/String_47/StringDemo/.classpath rename to BasicJava/EnumDemo_Level_App/EnumDemo/.classpath diff --git a/BasicJava/EnumDemo_Level_App/EnumDemo/.project b/BasicJava/EnumDemo_Level_App/EnumDemo/.project new file mode 100644 index 000000000..821a962c7 --- /dev/null +++ b/BasicJava/EnumDemo_Level_App/EnumDemo/.project @@ -0,0 +1,17 @@ + + + EnumDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/misc/String_47/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/EnumDemo_Level_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/misc/String_47/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/EnumDemo_Level_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/EnumDemo_Level_App/EnumDemo/bin/EnumDemo.class b/BasicJava/EnumDemo_Level_App/EnumDemo/bin/EnumDemo.class new file mode 100644 index 000000000..3c37252c8 Binary files /dev/null and b/BasicJava/EnumDemo_Level_App/EnumDemo/bin/EnumDemo.class differ diff --git a/BasicJava/EnumDemo_Level_App/EnumDemo/bin/Level.class b/BasicJava/EnumDemo_Level_App/EnumDemo/bin/Level.class new file mode 100644 index 000000000..a1b34a7a5 Binary files /dev/null and b/BasicJava/EnumDemo_Level_App/EnumDemo/bin/Level.class differ diff --git a/BasicJava/EnumDemo_Level_App/EnumDemo/src/EnumDemo.java b/BasicJava/EnumDemo_Level_App/EnumDemo/src/EnumDemo.java new file mode 100644 index 000000000..d7a6e613a --- /dev/null +++ b/BasicJava/EnumDemo_Level_App/EnumDemo/src/EnumDemo.java @@ -0,0 +1,9 @@ +public class EnumDemo +{ + + public static void main(String[] args) + { + Level level = Level.HIGH; + System.out.println(level); + } +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_Level_App/EnumDemo/src/Level.java b/BasicJava/EnumDemo_Level_App/EnumDemo/src/Level.java new file mode 100644 index 000000000..e9ddc911c --- /dev/null +++ b/BasicJava/EnumDemo_Level_App/EnumDemo/src/Level.java @@ -0,0 +1,4 @@ +public enum Level +{ + HIGH, MEDIUM, LOW +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_Level_App/Output.txt b/BasicJava/EnumDemo_Level_App/Output.txt new file mode 100644 index 000000000..14a30e495 --- /dev/null +++ b/BasicJava/EnumDemo_Level_App/Output.txt @@ -0,0 +1 @@ +HIGH diff --git a/Later/String/misc/String_48/StringDemo/.classpath b/BasicJava/EnumDemo_Level_values_App/EnumDemo/.classpath similarity index 100% rename from Later/String/misc/String_48/StringDemo/.classpath rename to BasicJava/EnumDemo_Level_values_App/EnumDemo/.classpath diff --git a/BasicJava/EnumDemo_Level_values_App/EnumDemo/.project b/BasicJava/EnumDemo_Level_values_App/EnumDemo/.project new file mode 100644 index 000000000..821a962c7 --- /dev/null +++ b/BasicJava/EnumDemo_Level_values_App/EnumDemo/.project @@ -0,0 +1,17 @@ + + + EnumDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/misc/String_48/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/EnumDemo_Level_values_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/misc/String_48/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/EnumDemo_Level_values_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/EnumDemo_Level_values_App/EnumDemo/bin/EnumDemo.class b/BasicJava/EnumDemo_Level_values_App/EnumDemo/bin/EnumDemo.class new file mode 100644 index 000000000..c784ce458 Binary files /dev/null and b/BasicJava/EnumDemo_Level_values_App/EnumDemo/bin/EnumDemo.class differ diff --git a/BasicJava/EnumDemo_Level_values_App/EnumDemo/bin/Level.class b/BasicJava/EnumDemo_Level_values_App/EnumDemo/bin/Level.class new file mode 100644 index 000000000..a1b34a7a5 Binary files /dev/null and b/BasicJava/EnumDemo_Level_values_App/EnumDemo/bin/Level.class differ diff --git a/BasicJava/EnumDemo_Level_values_App/EnumDemo/src/EnumDemo.java b/BasicJava/EnumDemo_Level_values_App/EnumDemo/src/EnumDemo.java new file mode 100644 index 000000000..a9d1edb66 --- /dev/null +++ b/BasicJava/EnumDemo_Level_values_App/EnumDemo/src/EnumDemo.java @@ -0,0 +1,27 @@ +public class EnumDemo +{ + + public static void main(String[] args) + { + /* + * We can obtain an array of all the possible values + * of a Java enum type by calling its static + * values() method. + * + * All enum types get a static values() method + * automatically by the Java compiler. + * + * Notice the output how the names of the constants + * themselves are printed out. This is one area + * where Java enums are different than static final + * constants. + */ + + Level[] levelArray = Level.values(); + + for (Level level : levelArray) + { + System.out.println(level); + } + } +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_Level_values_App/EnumDemo/src/Level.java b/BasicJava/EnumDemo_Level_values_App/EnumDemo/src/Level.java new file mode 100644 index 000000000..e9ddc911c --- /dev/null +++ b/BasicJava/EnumDemo_Level_values_App/EnumDemo/src/Level.java @@ -0,0 +1,4 @@ +public enum Level +{ + HIGH, MEDIUM, LOW +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_Level_values_App/Output.txt b/BasicJava/EnumDemo_Level_values_App/Output.txt new file mode 100644 index 000000000..e199ac81a --- /dev/null +++ b/BasicJava/EnumDemo_Level_values_App/Output.txt @@ -0,0 +1,3 @@ +HIGH +MEDIUM +LOW diff --git a/Later/String/misc/String_49/StringDemo/.classpath b/BasicJava/EnumDemo_Operation_App/EnumDemo/.classpath similarity index 100% rename from Later/String/misc/String_49/StringDemo/.classpath rename to BasicJava/EnumDemo_Operation_App/EnumDemo/.classpath diff --git a/BasicJava/EnumDemo_Operation_App/EnumDemo/.project b/BasicJava/EnumDemo_Operation_App/EnumDemo/.project new file mode 100644 index 000000000..821a962c7 --- /dev/null +++ b/BasicJava/EnumDemo_Operation_App/EnumDemo/.project @@ -0,0 +1,17 @@ + + + EnumDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/misc/String_49/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/EnumDemo_Operation_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/misc/String_49/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/EnumDemo_Operation_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/EnumDemo_Operation_App/EnumDemo/bin/EnumDemo.class b/BasicJava/EnumDemo_Operation_App/EnumDemo/bin/EnumDemo.class new file mode 100644 index 000000000..5af64e7ea Binary files /dev/null and b/BasicJava/EnumDemo_Operation_App/EnumDemo/bin/EnumDemo.class differ diff --git a/BasicJava/EnumDemo_Operation_App/EnumDemo/bin/Operation.class b/BasicJava/EnumDemo_Operation_App/EnumDemo/bin/Operation.class new file mode 100644 index 000000000..88f4e65ae Binary files /dev/null and b/BasicJava/EnumDemo_Operation_App/EnumDemo/bin/Operation.class differ diff --git a/BasicJava/EnumDemo_Operation_App/EnumDemo/src/EnumDemo.java b/BasicJava/EnumDemo_Operation_App/EnumDemo/src/EnumDemo.java new file mode 100644 index 000000000..95f13ed49 --- /dev/null +++ b/BasicJava/EnumDemo_Operation_App/EnumDemo/src/EnumDemo.java @@ -0,0 +1,11 @@ +public class EnumDemo +{ + public static void main(String[] args) + { + long result = Operation.MULTIPLY.calculate(4, 2); + System.out.println("Multiply Result = "+result); + + result = Operation.PLUS.calculate(4, 2); + System.out.println("Plus Result = "+result); + } +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_Operation_App/EnumDemo/src/Operation.java b/BasicJava/EnumDemo_Operation_App/EnumDemo/src/Operation.java new file mode 100644 index 000000000..4c0634214 --- /dev/null +++ b/BasicJava/EnumDemo_Operation_App/EnumDemo/src/Operation.java @@ -0,0 +1,22 @@ +public enum Operation +{ + PLUS, MINUS, MULTIPLY, DIVIDE; + + long calculate(long x, long y) + { + switch (this) + { + case PLUS: + return x + y; + case MINUS: + return x - y; + case MULTIPLY: + return x * y; + case DIVIDE: + return x / y; + default: + throw new AssertionError("Unknown operations " + this); + } + } + +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_Operation_App/Output.txt b/BasicJava/EnumDemo_Operation_App/Output.txt new file mode 100644 index 000000000..4aaeed26e --- /dev/null +++ b/BasicJava/EnumDemo_Operation_App/Output.txt @@ -0,0 +1,2 @@ +Multiply Result = 8 +Plus Result = 6 diff --git a/Later/String/misc/String_50/StringDemo/.classpath b/BasicJava/EnumDemo_Operation_all_Values_App/EnumDemo/.classpath similarity index 100% rename from Later/String/misc/String_50/StringDemo/.classpath rename to BasicJava/EnumDemo_Operation_all_Values_App/EnumDemo/.classpath diff --git a/BasicJava/EnumDemo_Operation_all_Values_App/EnumDemo/.project b/BasicJava/EnumDemo_Operation_all_Values_App/EnumDemo/.project new file mode 100644 index 000000000..821a962c7 --- /dev/null +++ b/BasicJava/EnumDemo_Operation_all_Values_App/EnumDemo/.project @@ -0,0 +1,17 @@ + + + EnumDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/misc/String_50/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/EnumDemo_Operation_all_Values_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/misc/String_50/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/EnumDemo_Operation_all_Values_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/EnumDemo_Operation_all_Values_App/EnumDemo/bin/EnumDemo.class b/BasicJava/EnumDemo_Operation_all_Values_App/EnumDemo/bin/EnumDemo.class new file mode 100644 index 000000000..b3aa579e0 Binary files /dev/null and b/BasicJava/EnumDemo_Operation_all_Values_App/EnumDemo/bin/EnumDemo.class differ diff --git a/BasicJava/EnumDemo_Operation_all_Values_App/EnumDemo/bin/Operation.class b/BasicJava/EnumDemo_Operation_all_Values_App/EnumDemo/bin/Operation.class new file mode 100644 index 000000000..b077f7034 Binary files /dev/null and b/BasicJava/EnumDemo_Operation_all_Values_App/EnumDemo/bin/Operation.class differ diff --git a/BasicJava/EnumDemo_Operation_all_Values_App/EnumDemo/src/EnumDemo.java b/BasicJava/EnumDemo_Operation_all_Values_App/EnumDemo/src/EnumDemo.java new file mode 100644 index 000000000..238b2d594 --- /dev/null +++ b/BasicJava/EnumDemo_Operation_all_Values_App/EnumDemo/src/EnumDemo.java @@ -0,0 +1,22 @@ +enum Operation +{ + PLUS, MINUS, MULTIPLY, DIVIDE; + +} + +public class EnumDemo +{ + public static void main(String[] args) + { + + Operation[] operationArray = Operation.values(); + + /* + * To loop a Enum object. + */ + for (Operation operation : operationArray) + { + System.out.println(operation); + } + } +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_Operation_all_Values_App/Output.txt b/BasicJava/EnumDemo_Operation_all_Values_App/Output.txt new file mode 100644 index 000000000..4a7e84218 --- /dev/null +++ b/BasicJava/EnumDemo_Operation_all_Values_App/Output.txt @@ -0,0 +1,4 @@ +PLUS +MINUS +MULTIPLY +DIVIDE diff --git a/Later/String/misc/String_51/StringDemo/.classpath b/BasicJava/EnumDemo_Siteinfo_switch_App/EnumDemo/.classpath similarity index 100% rename from Later/String/misc/String_51/StringDemo/.classpath rename to BasicJava/EnumDemo_Siteinfo_switch_App/EnumDemo/.classpath diff --git a/BasicJava/EnumDemo_Siteinfo_switch_App/EnumDemo/.project b/BasicJava/EnumDemo_Siteinfo_switch_App/EnumDemo/.project new file mode 100644 index 000000000..821a962c7 --- /dev/null +++ b/BasicJava/EnumDemo_Siteinfo_switch_App/EnumDemo/.project @@ -0,0 +1,17 @@ + + + EnumDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/misc/String_51/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/EnumDemo_Siteinfo_switch_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/misc/String_51/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/EnumDemo_Siteinfo_switch_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/EnumDemo_Siteinfo_switch_App/EnumDemo/bin/EnumDemo.class b/BasicJava/EnumDemo_Siteinfo_switch_App/EnumDemo/bin/EnumDemo.class new file mode 100644 index 000000000..e8fb16eef Binary files /dev/null and b/BasicJava/EnumDemo_Siteinfo_switch_App/EnumDemo/bin/EnumDemo.class differ diff --git a/BasicJava/EnumDemo_Siteinfo_switch_App/EnumDemo/bin/SiteInfo.class b/BasicJava/EnumDemo_Siteinfo_switch_App/EnumDemo/bin/SiteInfo.class new file mode 100644 index 000000000..cf87249e3 Binary files /dev/null and b/BasicJava/EnumDemo_Siteinfo_switch_App/EnumDemo/bin/SiteInfo.class differ diff --git a/BasicJava/EnumDemo_Siteinfo_switch_App/EnumDemo/src/EnumDemo.java b/BasicJava/EnumDemo_Siteinfo_switch_App/EnumDemo/src/EnumDemo.java new file mode 100644 index 000000000..38b4ec63a --- /dev/null +++ b/BasicJava/EnumDemo_Siteinfo_switch_App/EnumDemo/src/EnumDemo.java @@ -0,0 +1,26 @@ +public class EnumDemo +{ + public static void main(String[] args) + { + getSiteInfo(SiteInfo.PAYTM); + } + + private static void getSiteInfo(SiteInfo siteInfo) + { + + switch (siteInfo) + { + case AMAZON: + System.out.println("URL : " + siteInfo.getUrl()); + break; + case PAYTM: + System.out.println("URL : " + siteInfo.getUrl()); + break; + case SNAPDEAL: + System.out.println("URL : " + siteInfo.getUrl()); + break; + default: + System.out.println("Not a valid site.. " ); + } + } +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_Siteinfo_switch_App/EnumDemo/src/SiteInfo.java b/BasicJava/EnumDemo_Siteinfo_switch_App/EnumDemo/src/SiteInfo.java new file mode 100644 index 000000000..0fc425ea1 --- /dev/null +++ b/BasicJava/EnumDemo_Siteinfo_switch_App/EnumDemo/src/SiteInfo.java @@ -0,0 +1,18 @@ +public enum SiteInfo +{ + AMAZON("https://www.amazon.in/"), + PAYTM("https://www.paytm.com"), + SNAPDEAL("https://www.snapdeal.com/"); + + private String url; + + SiteInfo(String url) + { + this.url = url; + } + + public String getUrl() + { + return url; + } +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_Siteinfo_switch_App/Output.txt b/BasicJava/EnumDemo_Siteinfo_switch_App/Output.txt new file mode 100644 index 000000000..03c32d8e3 --- /dev/null +++ b/BasicJava/EnumDemo_Siteinfo_switch_App/Output.txt @@ -0,0 +1 @@ +URL : https://www.paytm.com diff --git a/Later/String/misc/String_52/StringDemo/.classpath b/BasicJava/EnumDemo_access_App/EnumDemo/.classpath similarity index 100% rename from Later/String/misc/String_52/StringDemo/.classpath rename to BasicJava/EnumDemo_access_App/EnumDemo/.classpath diff --git a/BasicJava/EnumDemo_access_App/EnumDemo/.project b/BasicJava/EnumDemo_access_App/EnumDemo/.project new file mode 100644 index 000000000..821a962c7 --- /dev/null +++ b/BasicJava/EnumDemo_access_App/EnumDemo/.project @@ -0,0 +1,17 @@ + + + EnumDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/misc/String_52/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/EnumDemo_access_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/misc/String_52/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/EnumDemo_access_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/EnumDemo_access_App/EnumDemo/bin/EnumDemo$Day.class b/BasicJava/EnumDemo_access_App/EnumDemo/bin/EnumDemo$Day.class new file mode 100644 index 000000000..738362107 Binary files /dev/null and b/BasicJava/EnumDemo_access_App/EnumDemo/bin/EnumDemo$Day.class differ diff --git a/BasicJava/EnumDemo_access_App/EnumDemo/bin/EnumDemo.class b/BasicJava/EnumDemo_access_App/EnumDemo/bin/EnumDemo.class new file mode 100644 index 000000000..c11847365 Binary files /dev/null and b/BasicJava/EnumDemo_access_App/EnumDemo/bin/EnumDemo.class differ diff --git a/BasicJava/EnumDemo_access_App/EnumDemo/src/EnumDemo.java b/BasicJava/EnumDemo_access_App/EnumDemo/src/EnumDemo.java new file mode 100644 index 000000000..84dc8a021 --- /dev/null +++ b/BasicJava/EnumDemo_access_App/EnumDemo/src/EnumDemo.java @@ -0,0 +1,14 @@ +public class EnumDemo +{ + + public enum Day + { + SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY + } + + public static void main(String[] args) + { + System.out.println(Day.SUNDAY); + System.out.println(Day.MONDAY); + } +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_access_App/Output.txt b/BasicJava/EnumDemo_access_App/Output.txt new file mode 100644 index 000000000..fe1e08dba --- /dev/null +++ b/BasicJava/EnumDemo_access_App/Output.txt @@ -0,0 +1,2 @@ +SUNDAY +MONDAY diff --git a/Later/String/misc/String_53/StringDemo/.classpath b/BasicJava/EnumDemo_cons_App/EnumDemo/.classpath similarity index 100% rename from Later/String/misc/String_53/StringDemo/.classpath rename to BasicJava/EnumDemo_cons_App/EnumDemo/.classpath diff --git a/BasicJava/EnumDemo_cons_App/EnumDemo/.project b/BasicJava/EnumDemo_cons_App/EnumDemo/.project new file mode 100644 index 000000000..821a962c7 --- /dev/null +++ b/BasicJava/EnumDemo_cons_App/EnumDemo/.project @@ -0,0 +1,17 @@ + + + EnumDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/misc/String_53/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/EnumDemo_cons_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/misc/String_53/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/EnumDemo_cons_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/EnumDemo_cons_App/EnumDemo/bin/EnumDemo$Day.class b/BasicJava/EnumDemo_cons_App/EnumDemo/bin/EnumDemo$Day.class new file mode 100644 index 000000000..7fb1a59cd Binary files /dev/null and b/BasicJava/EnumDemo_cons_App/EnumDemo/bin/EnumDemo$Day.class differ diff --git a/BasicJava/EnumDemo_cons_App/EnumDemo/bin/EnumDemo$Days.class b/BasicJava/EnumDemo_cons_App/EnumDemo/bin/EnumDemo$Days.class new file mode 100644 index 000000000..6a1652a2d Binary files /dev/null and b/BasicJava/EnumDemo_cons_App/EnumDemo/bin/EnumDemo$Days.class differ diff --git a/BasicJava/EnumDemo_cons_App/EnumDemo/bin/EnumDemo.class b/BasicJava/EnumDemo_cons_App/EnumDemo/bin/EnumDemo.class new file mode 100644 index 000000000..e47cf0613 Binary files /dev/null and b/BasicJava/EnumDemo_cons_App/EnumDemo/bin/EnumDemo.class differ diff --git a/BasicJava/EnumDemo_cons_App/EnumDemo/src/EnumDemo.java b/BasicJava/EnumDemo_cons_App/EnumDemo/src/EnumDemo.java new file mode 100644 index 000000000..913aee764 --- /dev/null +++ b/BasicJava/EnumDemo_cons_App/EnumDemo/src/EnumDemo.java @@ -0,0 +1,38 @@ +public class EnumDemo +{ + + private enum Day + { + MONDAY(1), TUESDAY(2), WEDNESDAY(3), THURSDAY(4), FRIDAY(5), SATURDAY(6), + SUNDAY(7); + + private int whichDay; + + /* + * Constructor of enum type is private. If you don't + * declare private compiler internally creates + * private constructor. + */ + private Day(int whichDay) + { + this.whichDay = whichDay; + } + + } + + public static void main(String[] args) + { + /* + * The java compiler internally adds the values() + * method when it creates an enum. The values() + * method returns an array containing all the values + * of the enum. + */ + Day[] daysArray = Day.values(); + for (Day day : daysArray) + { + System.out.println(day + " is which day? " + day.whichDay); + } + + } +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_cons_App/Output.txt b/BasicJava/EnumDemo_cons_App/Output.txt new file mode 100644 index 000000000..2dad3768d --- /dev/null +++ b/BasicJava/EnumDemo_cons_App/Output.txt @@ -0,0 +1,7 @@ +MONDAY is which day? 1 +TUESDAY is which day? 2 +WEDNESDAY is which day? 3 +THURSDAY is which day? 4 +FRIDAY is which day? 5 +SATURDAY is which day? 6 +SUNDAY is which day? 7 diff --git a/Later/String/misc/String_54/StringDemo/.classpath b/BasicJava/EnumDemo_define_App/EnumDemo/.classpath similarity index 100% rename from Later/String/misc/String_54/StringDemo/.classpath rename to BasicJava/EnumDemo_define_App/EnumDemo/.classpath diff --git a/BasicJava/EnumDemo_define_App/EnumDemo/.project b/BasicJava/EnumDemo_define_App/EnumDemo/.project new file mode 100644 index 000000000..821a962c7 --- /dev/null +++ b/BasicJava/EnumDemo_define_App/EnumDemo/.project @@ -0,0 +1,17 @@ + + + EnumDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/misc/String_54/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/EnumDemo_define_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/misc/String_54/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/EnumDemo_define_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/EnumDemo_define_App/EnumDemo/bin/Day.class b/BasicJava/EnumDemo_define_App/EnumDemo/bin/Day.class new file mode 100644 index 000000000..a18606fed Binary files /dev/null and b/BasicJava/EnumDemo_define_App/EnumDemo/bin/Day.class differ diff --git a/BasicJava/EnumDemo_define_App/EnumDemo/bin/Days.class b/BasicJava/EnumDemo_define_App/EnumDemo/bin/Days.class new file mode 100644 index 000000000..08778d2dd Binary files /dev/null and b/BasicJava/EnumDemo_define_App/EnumDemo/bin/Days.class differ diff --git a/BasicJava/EnumDemo_define_App/EnumDemo/bin/EnumInsideDemo$Day.class b/BasicJava/EnumDemo_define_App/EnumDemo/bin/EnumInsideDemo$Day.class new file mode 100644 index 000000000..93b71e599 Binary files /dev/null and b/BasicJava/EnumDemo_define_App/EnumDemo/bin/EnumInsideDemo$Day.class differ diff --git a/BasicJava/EnumDemo_define_App/EnumDemo/bin/EnumInsideDemo$Days.class b/BasicJava/EnumDemo_define_App/EnumDemo/bin/EnumInsideDemo$Days.class new file mode 100644 index 000000000..1fa7369ed Binary files /dev/null and b/BasicJava/EnumDemo_define_App/EnumDemo/bin/EnumInsideDemo$Days.class differ diff --git a/BasicJava/EnumDemo_define_App/EnumDemo/bin/EnumInsideDemo.class b/BasicJava/EnumDemo_define_App/EnumDemo/bin/EnumInsideDemo.class new file mode 100644 index 000000000..4b0514368 Binary files /dev/null and b/BasicJava/EnumDemo_define_App/EnumDemo/bin/EnumInsideDemo.class differ diff --git a/BasicJava/EnumDemo_define_App/EnumDemo/bin/EnumOutsideDemo.class b/BasicJava/EnumDemo_define_App/EnumDemo/bin/EnumOutsideDemo.class new file mode 100644 index 000000000..3fb8157bf Binary files /dev/null and b/BasicJava/EnumDemo_define_App/EnumDemo/bin/EnumOutsideDemo.class differ diff --git a/BasicJava/EnumDemo_define_App/EnumDemo/src/EnumInsideDemo.java b/BasicJava/EnumDemo_define_App/EnumDemo/src/EnumInsideDemo.java new file mode 100644 index 000000000..ff24723e7 --- /dev/null +++ b/BasicJava/EnumDemo_define_App/EnumDemo/src/EnumInsideDemo.java @@ -0,0 +1,26 @@ +public class EnumInsideDemo +{ + /* + * Enum is Defined inside of the class. + */ + private enum Day + { + SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY + } + + public static void main(String[] args) + { + /* + * The java compiler internally adds the values() + * method when it creates an enum. The values() + * method returns an array containing all the values + * of the enum. + */ + Day[] daysArray = Day.values(); + for (Day day : daysArray) + { + System.out.println(day); + } + + } +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_define_App/EnumDemo/src/EnumOutsideDemo.java b/BasicJava/EnumDemo_define_App/EnumDemo/src/EnumOutsideDemo.java new file mode 100644 index 000000000..2bd5156e6 --- /dev/null +++ b/BasicJava/EnumDemo_define_App/EnumDemo/src/EnumOutsideDemo.java @@ -0,0 +1,27 @@ +/* + * Enum is Defined outside of the class. + */ +enum Day +{ + SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY +} + +public class EnumOutsideDemo +{ + + public static void main(String[] args) + { + /* + * The java compiler internally adds the values() + * method when it creates an enum. The values() + * method returns an array containing all the values + * of the enum. + */ + Day[] daysArray = Day.values(); + for (Day day : daysArray) + { + System.out.println(day); + } + + } +} diff --git a/BasicJava/EnumDemo_define_App/EnumInsideDemo_Output.txt b/BasicJava/EnumDemo_define_App/EnumInsideDemo_Output.txt new file mode 100644 index 000000000..21d4b5adc --- /dev/null +++ b/BasicJava/EnumDemo_define_App/EnumInsideDemo_Output.txt @@ -0,0 +1,7 @@ +SUNDAY +MONDAY +TUESDAY +WEDNESDAY +THURSDAY +FRIDAY +SATURDAY diff --git a/BasicJava/EnumDemo_define_App/EnumOutsideDemo_Output.txt b/BasicJava/EnumDemo_define_App/EnumOutsideDemo_Output.txt new file mode 100644 index 000000000..21d4b5adc --- /dev/null +++ b/BasicJava/EnumDemo_define_App/EnumOutsideDemo_Output.txt @@ -0,0 +1,7 @@ +SUNDAY +MONDAY +TUESDAY +WEDNESDAY +THURSDAY +FRIDAY +SATURDAY diff --git a/Later/String/misc/String_55/StringDemo/.classpath b/BasicJava/EnumDemo_equal_to_op_App/EnumDemo/.classpath similarity index 100% rename from Later/String/misc/String_55/StringDemo/.classpath rename to BasicJava/EnumDemo_equal_to_op_App/EnumDemo/.classpath diff --git a/BasicJava/EnumDemo_equal_to_op_App/EnumDemo/.project b/BasicJava/EnumDemo_equal_to_op_App/EnumDemo/.project new file mode 100644 index 000000000..821a962c7 --- /dev/null +++ b/BasicJava/EnumDemo_equal_to_op_App/EnumDemo/.project @@ -0,0 +1,17 @@ + + + EnumDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/misc/String_55/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/EnumDemo_equal_to_op_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/misc/String_55/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/EnumDemo_equal_to_op_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/EnumDemo_equal_to_op_App/EnumDemo/bin/EnumDemo.class b/BasicJava/EnumDemo_equal_to_op_App/EnumDemo/bin/EnumDemo.class new file mode 100644 index 000000000..5b7158678 Binary files /dev/null and b/BasicJava/EnumDemo_equal_to_op_App/EnumDemo/bin/EnumDemo.class differ diff --git a/BasicJava/EnumDemo_equal_to_op_App/EnumDemo/bin/SiteInfo.class b/BasicJava/EnumDemo_equal_to_op_App/EnumDemo/bin/SiteInfo.class new file mode 100644 index 000000000..cf87249e3 Binary files /dev/null and b/BasicJava/EnumDemo_equal_to_op_App/EnumDemo/bin/SiteInfo.class differ diff --git a/BasicJava/EnumDemo_equal_to_op_App/EnumDemo/src/EnumDemo.java b/BasicJava/EnumDemo_equal_to_op_App/EnumDemo/src/EnumDemo.java new file mode 100644 index 000000000..dd831a894 --- /dev/null +++ b/BasicJava/EnumDemo_equal_to_op_App/EnumDemo/src/EnumDemo.java @@ -0,0 +1,31 @@ +public class EnumDemo +{ + public static void main(String[] args) + { + getSiteInfo(SiteInfo.SNAPDEAL); + } + + private static void getSiteInfo(SiteInfo siteInfo) + { + + /* + * We can compare the Enum values using == operator. + */ + if (siteInfo == SiteInfo.AMAZON) + { + System.out.println("URL : " + siteInfo.getUrl()); + } + else if (siteInfo == SiteInfo.PAYTM) + { + System.out.println("URL : " + siteInfo.getUrl()); + } + else if (siteInfo == SiteInfo.SNAPDEAL) + { + System.out.println("URL : " + siteInfo.getUrl()); + } + else + { + System.out.println("Not a valid site..."); + } + } +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_equal_to_op_App/EnumDemo/src/SiteInfo.java b/BasicJava/EnumDemo_equal_to_op_App/EnumDemo/src/SiteInfo.java new file mode 100644 index 000000000..0fc425ea1 --- /dev/null +++ b/BasicJava/EnumDemo_equal_to_op_App/EnumDemo/src/SiteInfo.java @@ -0,0 +1,18 @@ +public enum SiteInfo +{ + AMAZON("https://www.amazon.in/"), + PAYTM("https://www.paytm.com"), + SNAPDEAL("https://www.snapdeal.com/"); + + private String url; + + SiteInfo(String url) + { + this.url = url; + } + + public String getUrl() + { + return url; + } +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_equal_to_op_App/Output.txt b/BasicJava/EnumDemo_equal_to_op_App/Output.txt new file mode 100644 index 000000000..c298c01fa --- /dev/null +++ b/BasicJava/EnumDemo_equal_to_op_App/Output.txt @@ -0,0 +1 @@ +URL : https://www.snapdeal.com/ diff --git a/Later/String/misc/String_56/StringDemo/.classpath b/BasicJava/EnumDemo_if_App/EnumDemo/.classpath similarity index 100% rename from Later/String/misc/String_56/StringDemo/.classpath rename to BasicJava/EnumDemo_if_App/EnumDemo/.classpath diff --git a/BasicJava/EnumDemo_if_App/EnumDemo/.project b/BasicJava/EnumDemo_if_App/EnumDemo/.project new file mode 100644 index 000000000..821a962c7 --- /dev/null +++ b/BasicJava/EnumDemo_if_App/EnumDemo/.project @@ -0,0 +1,17 @@ + + + EnumDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/misc/String_56/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/EnumDemo_if_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/misc/String_56/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/EnumDemo_if_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/EnumDemo_if_App/EnumDemo/bin/EnumDemo.class b/BasicJava/EnumDemo_if_App/EnumDemo/bin/EnumDemo.class new file mode 100644 index 000000000..3b0379f52 Binary files /dev/null and b/BasicJava/EnumDemo_if_App/EnumDemo/bin/EnumDemo.class differ diff --git a/BasicJava/EnumDemo_if_App/EnumDemo/bin/Level.class b/BasicJava/EnumDemo_if_App/EnumDemo/bin/Level.class new file mode 100644 index 000000000..a1b34a7a5 Binary files /dev/null and b/BasicJava/EnumDemo_if_App/EnumDemo/bin/Level.class differ diff --git a/BasicJava/EnumDemo_if_App/EnumDemo/src/EnumDemo.java b/BasicJava/EnumDemo_if_App/EnumDemo/src/EnumDemo.java new file mode 100644 index 000000000..b996fae37 --- /dev/null +++ b/BasicJava/EnumDemo_if_App/EnumDemo/src/EnumDemo.java @@ -0,0 +1,21 @@ +public class EnumDemo +{ + + public static void main(String[] args) + { + Level level = Level.MEDIUM; + + if (level == Level.HIGH) + { + System.out.println("This is high voltage"); + } + else if (level == Level.MEDIUM) + { + System.out.println("This is meidum voltage"); + } + else if (level == Level.LOW) + { + System.out.println("This is low voltage"); + } + } +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_if_App/EnumDemo/src/Level.java b/BasicJava/EnumDemo_if_App/EnumDemo/src/Level.java new file mode 100644 index 000000000..e9ddc911c --- /dev/null +++ b/BasicJava/EnumDemo_if_App/EnumDemo/src/Level.java @@ -0,0 +1,4 @@ +public enum Level +{ + HIGH, MEDIUM, LOW +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_if_App/Output.txt b/BasicJava/EnumDemo_if_App/Output.txt new file mode 100644 index 000000000..93dae50d6 --- /dev/null +++ b/BasicJava/EnumDemo_if_App/Output.txt @@ -0,0 +1 @@ +This is meidum voltage diff --git a/Later/String/misc/String_57/StringDemo/.classpath b/BasicJava/EnumDemo_level_Cons_method_App/EnumDemo/.classpath similarity index 100% rename from Later/String/misc/String_57/StringDemo/.classpath rename to BasicJava/EnumDemo_level_Cons_method_App/EnumDemo/.classpath diff --git a/BasicJava/EnumDemo_level_Cons_method_App/EnumDemo/.project b/BasicJava/EnumDemo_level_Cons_method_App/EnumDemo/.project new file mode 100644 index 000000000..821a962c7 --- /dev/null +++ b/BasicJava/EnumDemo_level_Cons_method_App/EnumDemo/.project @@ -0,0 +1,17 @@ + + + EnumDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/misc/String_57/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/EnumDemo_level_Cons_method_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/misc/String_57/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/EnumDemo_level_Cons_method_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/EnumDemo_level_Cons_method_App/EnumDemo/bin/EnumDemo.class b/BasicJava/EnumDemo_level_Cons_method_App/EnumDemo/bin/EnumDemo.class new file mode 100644 index 000000000..2c850da54 Binary files /dev/null and b/BasicJava/EnumDemo_level_Cons_method_App/EnumDemo/bin/EnumDemo.class differ diff --git a/BasicJava/EnumDemo_level_Cons_method_App/EnumDemo/bin/Level.class b/BasicJava/EnumDemo_level_Cons_method_App/EnumDemo/bin/Level.class new file mode 100644 index 000000000..3908852f9 Binary files /dev/null and b/BasicJava/EnumDemo_level_Cons_method_App/EnumDemo/bin/Level.class differ diff --git a/BasicJava/EnumDemo_level_Cons_method_App/EnumDemo/src/EnumDemo.java b/BasicJava/EnumDemo_level_Cons_method_App/EnumDemo/src/EnumDemo.java new file mode 100644 index 000000000..39756e4f7 --- /dev/null +++ b/BasicJava/EnumDemo_level_Cons_method_App/EnumDemo/src/EnumDemo.java @@ -0,0 +1,13 @@ +public class EnumDemo +{ + + public static void main(String[] args) + { + + Level[] levelArray = Level.values(); + for (Level level : levelArray) + { + System.out.println(level + " = " + level.getLevelCode()); + } + } +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_level_Cons_method_App/EnumDemo/src/Level.java b/BasicJava/EnumDemo_level_Cons_method_App/EnumDemo/src/Level.java new file mode 100644 index 000000000..55c69ff2a --- /dev/null +++ b/BasicJava/EnumDemo_level_Cons_method_App/EnumDemo/src/Level.java @@ -0,0 +1,18 @@ +public enum Level +{ + HIGH(3), // calls constructor with value 3 + MEDIUM(2), // calls constructor with value 2 + LOW(1);// calls constructor with value 1 + + private final int levelCode; + + private Level(int levelCode) + { + this.levelCode = levelCode; + } + + public int getLevelCode() + { + return this.levelCode; + } +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_level_Cons_method_App/Output.txt b/BasicJava/EnumDemo_level_Cons_method_App/Output.txt new file mode 100644 index 000000000..1957836e6 --- /dev/null +++ b/BasicJava/EnumDemo_level_Cons_method_App/Output.txt @@ -0,0 +1,3 @@ +HIGH = 3 +MEDIUM = 2 +LOW = 1 diff --git a/Later/String/misc/String_58/StringDemo/.classpath b/BasicJava/EnumDemo_level_switch_App/EnumDemo/.classpath similarity index 100% rename from Later/String/misc/String_58/StringDemo/.classpath rename to BasicJava/EnumDemo_level_switch_App/EnumDemo/.classpath diff --git a/BasicJava/EnumDemo_level_switch_App/EnumDemo/.project b/BasicJava/EnumDemo_level_switch_App/EnumDemo/.project new file mode 100644 index 000000000..821a962c7 --- /dev/null +++ b/BasicJava/EnumDemo_level_switch_App/EnumDemo/.project @@ -0,0 +1,17 @@ + + + EnumDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/misc/String_58/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/EnumDemo_level_switch_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/misc/String_58/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/EnumDemo_level_switch_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/EnumDemo_level_switch_App/EnumDemo/bin/EnumDemo.class b/BasicJava/EnumDemo_level_switch_App/EnumDemo/bin/EnumDemo.class new file mode 100644 index 000000000..8e69387d4 Binary files /dev/null and b/BasicJava/EnumDemo_level_switch_App/EnumDemo/bin/EnumDemo.class differ diff --git a/BasicJava/EnumDemo_level_switch_App/EnumDemo/bin/Level.class b/BasicJava/EnumDemo_level_switch_App/EnumDemo/bin/Level.class new file mode 100644 index 000000000..a1b34a7a5 Binary files /dev/null and b/BasicJava/EnumDemo_level_switch_App/EnumDemo/bin/Level.class differ diff --git a/BasicJava/EnumDemo_level_switch_App/EnumDemo/src/EnumDemo.java b/BasicJava/EnumDemo_level_switch_App/EnumDemo/src/EnumDemo.java new file mode 100644 index 000000000..ab478cc3e --- /dev/null +++ b/BasicJava/EnumDemo_level_switch_App/EnumDemo/src/EnumDemo.java @@ -0,0 +1,25 @@ +public class EnumDemo +{ + + public static void main(String[] args) + { + Level level = Level.MEDIUM; + + /* + * We can use enums in switch statements like this. + */ + switch (level) + { + case HIGH: + System.out.println("This is high voltage"); + break; + case MEDIUM: + System.out.println("This is meidum voltage"); + break; + case LOW: + System.out.println("This is low voltage"); + break; + } + + } +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_level_switch_App/EnumDemo/src/Level.java b/BasicJava/EnumDemo_level_switch_App/EnumDemo/src/Level.java new file mode 100644 index 000000000..e9ddc911c --- /dev/null +++ b/BasicJava/EnumDemo_level_switch_App/EnumDemo/src/Level.java @@ -0,0 +1,4 @@ +public enum Level +{ + HIGH, MEDIUM, LOW +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_level_switch_App/Output.txt b/BasicJava/EnumDemo_level_switch_App/Output.txt new file mode 100644 index 000000000..93dae50d6 --- /dev/null +++ b/BasicJava/EnumDemo_level_switch_App/Output.txt @@ -0,0 +1 @@ +This is meidum voltage diff --git a/Later/String/misc/String_59/StringDemo/.classpath b/BasicJava/EnumDemo_method_App/EnumDemo/.classpath similarity index 100% rename from Later/String/misc/String_59/StringDemo/.classpath rename to BasicJava/EnumDemo_method_App/EnumDemo/.classpath diff --git a/BasicJava/EnumDemo_method_App/EnumDemo/.project b/BasicJava/EnumDemo_method_App/EnumDemo/.project new file mode 100644 index 000000000..821a962c7 --- /dev/null +++ b/BasicJava/EnumDemo_method_App/EnumDemo/.project @@ -0,0 +1,17 @@ + + + EnumDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/misc/String_59/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/EnumDemo_method_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/misc/String_59/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/EnumDemo_method_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/EnumDemo_method_App/EnumDemo/bin/EnumDemo.class b/BasicJava/EnumDemo_method_App/EnumDemo/bin/EnumDemo.class new file mode 100644 index 000000000..6f336ec78 Binary files /dev/null and b/BasicJava/EnumDemo_method_App/EnumDemo/bin/EnumDemo.class differ diff --git a/BasicJava/EnumDemo_method_App/EnumDemo/bin/Season.class b/BasicJava/EnumDemo_method_App/EnumDemo/bin/Season.class new file mode 100644 index 000000000..8fc42d481 Binary files /dev/null and b/BasicJava/EnumDemo_method_App/EnumDemo/bin/Season.class differ diff --git a/BasicJava/EnumDemo_method_App/EnumDemo/src/EnumDemo.java b/BasicJava/EnumDemo_method_App/EnumDemo/src/EnumDemo.java new file mode 100644 index 000000000..c6aaee9ec --- /dev/null +++ b/BasicJava/EnumDemo_method_App/EnumDemo/src/EnumDemo.java @@ -0,0 +1,21 @@ +public class EnumDemo +{ + + public static void main(String[] args) + { + /* + * The java compiler internally adds the values() + * method when it creates an enum. The values() + * method returns an array containing all the values + * of the enum. + */ + Season[] seasonArray = Season.values(); + + for (Season season : seasonArray) + { + System.out.println(season + ", SeasonNumber = " + + season.getSeasonNumber()); + } + + } +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_method_App/EnumDemo/src/Season.java b/BasicJava/EnumDemo_method_App/EnumDemo/src/Season.java new file mode 100644 index 000000000..0ec7eae7c --- /dev/null +++ b/BasicJava/EnumDemo_method_App/EnumDemo/src/Season.java @@ -0,0 +1,16 @@ +public enum Season +{ + WINTER(5), SPRING(10), SUMMER(15), FALL(20); + + private int seasonNumber; + + private Season(int seasonNumber) + { + this.seasonNumber = seasonNumber; + } + + public int getSeasonNumber() + { + return seasonNumber; + } +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_method_App/Output.txt b/BasicJava/EnumDemo_method_App/Output.txt new file mode 100644 index 000000000..15e0cc6b8 --- /dev/null +++ b/BasicJava/EnumDemo_method_App/Output.txt @@ -0,0 +1,4 @@ +WINTER, SeasonNumber = 5 +SPRING, SeasonNumber = 10 +SUMMER, SeasonNumber = 15 +FALL, SeasonNumber = 20 diff --git a/Later/String/misc/String_60/StringDemo/.classpath b/BasicJava/EnumDemo_mobile_Cons_method_App/EnumDemo/.classpath similarity index 100% rename from Later/String/misc/String_60/StringDemo/.classpath rename to BasicJava/EnumDemo_mobile_Cons_method_App/EnumDemo/.classpath diff --git a/BasicJava/EnumDemo_mobile_Cons_method_App/EnumDemo/.project b/BasicJava/EnumDemo_mobile_Cons_method_App/EnumDemo/.project new file mode 100644 index 000000000..821a962c7 --- /dev/null +++ b/BasicJava/EnumDemo_mobile_Cons_method_App/EnumDemo/.project @@ -0,0 +1,17 @@ + + + EnumDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/String/misc/String_60/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/EnumDemo_mobile_Cons_method_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/String/misc/String_60/StringDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/EnumDemo_mobile_Cons_method_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/EnumDemo_mobile_Cons_method_App/EnumDemo/bin/EnumDemo.class b/BasicJava/EnumDemo_mobile_Cons_method_App/EnumDemo/bin/EnumDemo.class new file mode 100644 index 000000000..e5cc7445c Binary files /dev/null and b/BasicJava/EnumDemo_mobile_Cons_method_App/EnumDemo/bin/EnumDemo.class differ diff --git a/BasicJava/EnumDemo_mobile_Cons_method_App/EnumDemo/bin/Mobile.class b/BasicJava/EnumDemo_mobile_Cons_method_App/EnumDemo/bin/Mobile.class new file mode 100644 index 000000000..cab7d01a0 Binary files /dev/null and b/BasicJava/EnumDemo_mobile_Cons_method_App/EnumDemo/bin/Mobile.class differ diff --git a/BasicJava/EnumDemo_mobile_Cons_method_App/EnumDemo/src/EnumDemo.java b/BasicJava/EnumDemo_mobile_Cons_method_App/EnumDemo/src/EnumDemo.java new file mode 100644 index 000000000..5015da715 --- /dev/null +++ b/BasicJava/EnumDemo_mobile_Cons_method_App/EnumDemo/src/EnumDemo.java @@ -0,0 +1,27 @@ +public class EnumDemo +{ + public static void main(String args[]) + { + System.out.println("Mobile Phone List:"); + System.out.println("-------------------"); + + Mobile[] mobileArray = Mobile.values(); + + for (Mobile mobile : mobileArray) + { + System.out.println(mobile + " costs " + mobile.getPrice() + + " dollars"); + } + System.out.println("-------------------"); + + Mobile mobile = Mobile.Motorola; + /* + * Returns the name of this enum constant, exactly + * as declared in its enum declaration. + */ + + String mobileName = mobile.name(); + System.out.println("\nMobileName = " + mobileName); + + } +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_mobile_Cons_method_App/EnumDemo/src/Mobile.java b/BasicJava/EnumDemo_mobile_Cons_method_App/EnumDemo/src/Mobile.java new file mode 100644 index 000000000..098582e0c --- /dev/null +++ b/BasicJava/EnumDemo_mobile_Cons_method_App/EnumDemo/src/Mobile.java @@ -0,0 +1,18 @@ +enum Mobile +{ + Samsung(500), + Nokia(300), + Motorola(400); + + int price; + + Mobile(int price) + { + this.price = price; + } + + int getPrice() + { + return price; + } +} diff --git a/BasicJava/EnumDemo_mobile_Cons_method_App/Output.txt b/BasicJava/EnumDemo_mobile_Cons_method_App/Output.txt new file mode 100644 index 000000000..655b9a17e --- /dev/null +++ b/BasicJava/EnumDemo_mobile_Cons_method_App/Output.txt @@ -0,0 +1,8 @@ +Mobile Phone List: +------------------- +Samsung costs 500 dollars +Nokia costs 300 dollars +Motorola costs 400 dollars +------------------- + +MobileName = Motorola diff --git a/Later/StringBuffer/StringBuffer_1/StringBufferDemo/.classpath b/BasicJava/EnumDemo_mobile_ordinal_App/EnumDemo/.classpath similarity index 100% rename from Later/StringBuffer/StringBuffer_1/StringBufferDemo/.classpath rename to BasicJava/EnumDemo_mobile_ordinal_App/EnumDemo/.classpath diff --git a/BasicJava/EnumDemo_mobile_ordinal_App/EnumDemo/.project b/BasicJava/EnumDemo_mobile_ordinal_App/EnumDemo/.project new file mode 100644 index 000000000..821a962c7 --- /dev/null +++ b/BasicJava/EnumDemo_mobile_ordinal_App/EnumDemo/.project @@ -0,0 +1,17 @@ + + + EnumDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/StringBuffer/StringBuffer_1/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/EnumDemo_mobile_ordinal_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/StringBuffer/StringBuffer_1/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/EnumDemo_mobile_ordinal_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/EnumDemo_mobile_ordinal_App/EnumDemo/bin/EnumDemo.class b/BasicJava/EnumDemo_mobile_ordinal_App/EnumDemo/bin/EnumDemo.class new file mode 100644 index 000000000..c6b79d3fa Binary files /dev/null and b/BasicJava/EnumDemo_mobile_ordinal_App/EnumDemo/bin/EnumDemo.class differ diff --git a/BasicJava/EnumDemo_mobile_ordinal_App/EnumDemo/bin/Mobile.class b/BasicJava/EnumDemo_mobile_ordinal_App/EnumDemo/bin/Mobile.class new file mode 100644 index 000000000..22d831ba5 Binary files /dev/null and b/BasicJava/EnumDemo_mobile_ordinal_App/EnumDemo/bin/Mobile.class differ diff --git a/BasicJava/EnumDemo_mobile_ordinal_App/EnumDemo/src/EnumDemo.java b/BasicJava/EnumDemo_mobile_ordinal_App/EnumDemo/src/EnumDemo.java new file mode 100644 index 000000000..73d38a5b4 --- /dev/null +++ b/BasicJava/EnumDemo_mobile_ordinal_App/EnumDemo/src/EnumDemo.java @@ -0,0 +1,22 @@ +enum Mobile +{ + Samsung, Nokia, Motorola; +} + +public class EnumDemo +{ + public static void main(String args[]) + { + Mobile mobile = Mobile.Nokia; + + /* + * Returns the ordinal of this enumeration constant + * (its position in its enum declaration, where the + * initial constant is assigned an ordinal of zero). + */ + + int ordinal = mobile.ordinal(); + System.out.println("The ordinal is = " + ordinal); + + } +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_mobile_ordinal_App/Output.txt b/BasicJava/EnumDemo_mobile_ordinal_App/Output.txt new file mode 100644 index 000000000..5803acdd7 --- /dev/null +++ b/BasicJava/EnumDemo_mobile_ordinal_App/Output.txt @@ -0,0 +1 @@ +The ordinal is = 1 diff --git a/Later/StringBuffer/StringBuffer_2/StringBufferDemo/.classpath b/BasicJava/EnumDemo_siteinfo_App/EnumDemo/.classpath similarity index 100% rename from Later/StringBuffer/StringBuffer_2/StringBufferDemo/.classpath rename to BasicJava/EnumDemo_siteinfo_App/EnumDemo/.classpath diff --git a/BasicJava/EnumDemo_siteinfo_App/EnumDemo/.project b/BasicJava/EnumDemo_siteinfo_App/EnumDemo/.project new file mode 100644 index 000000000..821a962c7 --- /dev/null +++ b/BasicJava/EnumDemo_siteinfo_App/EnumDemo/.project @@ -0,0 +1,17 @@ + + + EnumDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/StringBuffer/StringBuffer_2/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/EnumDemo_siteinfo_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/StringBuffer/StringBuffer_2/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/EnumDemo_siteinfo_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/EnumDemo_siteinfo_App/EnumDemo/bin/EnumDemo.class b/BasicJava/EnumDemo_siteinfo_App/EnumDemo/bin/EnumDemo.class new file mode 100644 index 000000000..e0fa47a7d Binary files /dev/null and b/BasicJava/EnumDemo_siteinfo_App/EnumDemo/bin/EnumDemo.class differ diff --git a/BasicJava/EnumDemo_siteinfo_App/EnumDemo/bin/SiteInfo.class b/BasicJava/EnumDemo_siteinfo_App/EnumDemo/bin/SiteInfo.class new file mode 100644 index 000000000..6277e47ba Binary files /dev/null and b/BasicJava/EnumDemo_siteinfo_App/EnumDemo/bin/SiteInfo.class differ diff --git a/BasicJava/EnumDemo_siteinfo_App/EnumDemo/src/EnumDemo.java b/BasicJava/EnumDemo_siteinfo_App/EnumDemo/src/EnumDemo.java new file mode 100644 index 000000000..62f423183 --- /dev/null +++ b/BasicJava/EnumDemo_siteinfo_App/EnumDemo/src/EnumDemo.java @@ -0,0 +1,26 @@ +enum SiteInfo +{ + AMAZON("https://www.amazon.in/"), + PAYTM("https://www.paytm.com"), + SNAPDEAL("https://www.snapdeal.com/"); + + private String url; + + private SiteInfo(String url) + { + this.url = url; + } + + public String getUrl() + { + return url; + } +} + +public class EnumDemo +{ + public static void main(String[] args) + { + System.out.println(SiteInfo.PAYTM.getUrl()); + } +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_siteinfo_App/Output.txt b/BasicJava/EnumDemo_siteinfo_App/Output.txt new file mode 100644 index 000000000..fc5f08ccb --- /dev/null +++ b/BasicJava/EnumDemo_siteinfo_App/Output.txt @@ -0,0 +1 @@ +https://www.paytm.com diff --git a/Later/StringBuffer/StringBuffer_3/StringBufferDemo/.classpath b/BasicJava/EnumDemo_switch_App/EnumDemo/.classpath similarity index 100% rename from Later/StringBuffer/StringBuffer_3/StringBufferDemo/.classpath rename to BasicJava/EnumDemo_switch_App/EnumDemo/.classpath diff --git a/BasicJava/EnumDemo_switch_App/EnumDemo/.project b/BasicJava/EnumDemo_switch_App/EnumDemo/.project new file mode 100644 index 000000000..821a962c7 --- /dev/null +++ b/BasicJava/EnumDemo_switch_App/EnumDemo/.project @@ -0,0 +1,17 @@ + + + EnumDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/StringBuffer/StringBuffer_3/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/EnumDemo_switch_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/StringBuffer/StringBuffer_3/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/EnumDemo_switch_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/EnumDemo_switch_App/EnumDemo/bin/EnumDemo$Day.class b/BasicJava/EnumDemo_switch_App/EnumDemo/bin/EnumDemo$Day.class new file mode 100644 index 000000000..9911004bb Binary files /dev/null and b/BasicJava/EnumDemo_switch_App/EnumDemo/bin/EnumDemo$Day.class differ diff --git a/BasicJava/EnumDemo_switch_App/EnumDemo/bin/EnumDemo.class b/BasicJava/EnumDemo_switch_App/EnumDemo/bin/EnumDemo.class new file mode 100644 index 000000000..3c0c028bd Binary files /dev/null and b/BasicJava/EnumDemo_switch_App/EnumDemo/bin/EnumDemo.class differ diff --git a/BasicJava/EnumDemo_switch_App/EnumDemo/src/EnumDemo.java b/BasicJava/EnumDemo_switch_App/EnumDemo/src/EnumDemo.java new file mode 100644 index 000000000..c573be1f6 --- /dev/null +++ b/BasicJava/EnumDemo_switch_App/EnumDemo/src/EnumDemo.java @@ -0,0 +1,31 @@ +public class EnumDemo +{ + public enum Day + { + SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY + } + + public static void main(String[] args) + { + Day day = Day.TUESDAY; + + /* + * We can apply enum on switch statement + */ + switch (day) + { + case SUNDAY: + System.out.println("sunday"); + break; + case MONDAY: + System.out.println("monday"); + break; + case TUESDAY: + System.out.println("Tuesday"); + break; + + default: + System.out.println("other day"); + } + } +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_switch_App/Output.txt b/BasicJava/EnumDemo_switch_App/Output.txt new file mode 100644 index 000000000..ca5687197 --- /dev/null +++ b/BasicJava/EnumDemo_switch_App/Output.txt @@ -0,0 +1 @@ +Tuesday diff --git a/Later/StringBuffer/StringBuffer_4/StringBufferDemo/.classpath b/BasicJava/EnumDemo_userstatus_access_App/EnumDemo/.classpath similarity index 100% rename from Later/StringBuffer/StringBuffer_4/StringBufferDemo/.classpath rename to BasicJava/EnumDemo_userstatus_access_App/EnumDemo/.classpath diff --git a/BasicJava/EnumDemo_userstatus_access_App/EnumDemo/.project b/BasicJava/EnumDemo_userstatus_access_App/EnumDemo/.project new file mode 100644 index 000000000..821a962c7 --- /dev/null +++ b/BasicJava/EnumDemo_userstatus_access_App/EnumDemo/.project @@ -0,0 +1,17 @@ + + + EnumDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/StringBuffer/StringBuffer_4/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/EnumDemo_userstatus_access_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/StringBuffer/StringBuffer_4/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/EnumDemo_userstatus_access_App/EnumDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/EnumDemo_userstatus_access_App/EnumDemo/bin/EnumDemo.class b/BasicJava/EnumDemo_userstatus_access_App/EnumDemo/bin/EnumDemo.class new file mode 100644 index 000000000..afe12dfb2 Binary files /dev/null and b/BasicJava/EnumDemo_userstatus_access_App/EnumDemo/bin/EnumDemo.class differ diff --git a/BasicJava/EnumDemo_userstatus_access_App/EnumDemo/bin/UserStatus.class b/BasicJava/EnumDemo_userstatus_access_App/EnumDemo/bin/UserStatus.class new file mode 100644 index 000000000..d153b6ba5 Binary files /dev/null and b/BasicJava/EnumDemo_userstatus_access_App/EnumDemo/bin/UserStatus.class differ diff --git a/BasicJava/EnumDemo_userstatus_access_App/EnumDemo/src/EnumDemo.java b/BasicJava/EnumDemo_userstatus_access_App/EnumDemo/src/EnumDemo.java new file mode 100644 index 000000000..bf86d34fb --- /dev/null +++ b/BasicJava/EnumDemo_userstatus_access_App/EnumDemo/src/EnumDemo.java @@ -0,0 +1,13 @@ +enum UserStatus +{ + PENDING, ACTIVE, INACTIVE, DELETED; +} + +public class EnumDemo +{ + public static void main(String[] args) + { + //ACTIVE + System.out.println(UserStatus.ACTIVE); + } +} \ No newline at end of file diff --git a/BasicJava/EnumDemo_userstatus_access_App/Output.txt b/BasicJava/EnumDemo_userstatus_access_App/Output.txt new file mode 100644 index 000000000..36a1bcc44 --- /dev/null +++ b/BasicJava/EnumDemo_userstatus_access_App/Output.txt @@ -0,0 +1 @@ +ACTIVE diff --git a/Later/StringBuffer/StringBuffer_5/StringBufferDemo/.classpath b/BasicJava/EnvVarDemo_App/EnvVarDemo/.classpath similarity index 100% rename from Later/StringBuffer/StringBuffer_5/StringBufferDemo/.classpath rename to BasicJava/EnvVarDemo_App/EnvVarDemo/.classpath diff --git a/BasicJava/EnvVarDemo_App/EnvVarDemo/.project b/BasicJava/EnvVarDemo_App/EnvVarDemo/.project new file mode 100644 index 000000000..2ef88a4de --- /dev/null +++ b/BasicJava/EnvVarDemo_App/EnvVarDemo/.project @@ -0,0 +1,17 @@ + + + EnvVarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/StringBuffer/StringBuffer_5/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/EnvVarDemo_App/EnvVarDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/StringBuffer/StringBuffer_5/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/EnvVarDemo_App/EnvVarDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/EnvVarDemo_App/EnvVarDemo/bin/EnvMap.class b/BasicJava/EnvVarDemo_App/EnvVarDemo/bin/EnvMap.class new file mode 100644 index 000000000..40c2cc23e Binary files /dev/null and b/BasicJava/EnvVarDemo_App/EnvVarDemo/bin/EnvMap.class differ diff --git a/BasicJava/EnvVarDemo_App/EnvVarDemo/src/EnvMap.java b/BasicJava/EnvVarDemo_App/EnvVarDemo/src/EnvMap.java new file mode 100644 index 000000000..6527d9ddf --- /dev/null +++ b/BasicJava/EnvVarDemo_App/EnvVarDemo/src/EnvMap.java @@ -0,0 +1,22 @@ +import java.util.Map; + +public class EnvMap +{ + public static void main(String[] args) + { + /* + * Returns an unmodifiable string map view of the + * current system environment. + */ + Map env = System.getenv(); + for (String envName : env.keySet()) + { + /* + * Gets the value of the specified environment + * variable. + */ + String envValue = env.get(envName); + System.out.format("%s=%s%n", envName, envValue); + } + } +} \ No newline at end of file diff --git a/BasicJava/EnvVarDemo_App/Output.txt b/BasicJava/EnvVarDemo_App/Output.txt new file mode 100644 index 000000000..9253fd2ca --- /dev/null +++ b/BasicJava/EnvVarDemo_App/Output.txt @@ -0,0 +1,42 @@ +LOCALAPPDATA=C:\Users\Ramesh\AppData\Local +PROCESSOR_LEVEL=6 +FP_NO_HOST_CHECK=NO +USERDOMAIN=Ramesh-PC +LOGONSERVER=\\RAMESH-PC +JAVA_HOME=C:\Java\jdk1.8.0_111 +PROMPT=$P$G +SESSIONNAME=Console +ALLUSERSPROFILE=C:\ProgramData +PROCESSOR_ARCHITECTURE=AMD64 +PSModulePath=C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ +SystemDrive=C: +=ExitCode=00000000 +=C:=C:\ +APPDATA=C:\Users\Ramesh\AppData\Roaming +USERNAME=Ramesh +ProgramFiles(x86)=C:\Program Files (x86) +CommonProgramFiles=C:\Program Files\Common Files +Path=C:/Java/jre1.8.0_111/bin/server;C:/Java/jre1.8.0_111/bin;C:/Java/jre1.8.0_111/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\Lenovo\Bluetooth Software\;C:\Program Files\Lenovo\Bluetooth Software\syswow64;C:\Program Files\OpenVPN\bin;C:\Java\jdk1.8.0_111\bin;C:\Program Files\TortoiseGit\bin;C:\Program Files\Git\cmd;C:\Program Files\TortoiseHg\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;D:\eclipse; +PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC +OS=Windows_NT +COMPUTERNAME=RAMESH-PC +PROCESSOR_REVISION=2a07 +CommonProgramW6432=C:\Program Files\Common Files +ComSpec=C:\Windows\system32\cmd.exe +ProgramData=C:\ProgramData +ProgramW6432=C:\Program Files +=D:=D:\eclipse +HOMEPATH=\Users\Ramesh +SystemRoot=C:\Windows +TEMP=C:\Users\Ramesh\AppData\Local\Temp +HOMEDRIVE=C: +PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 42 Stepping 7, GenuineIntel +USERPROFILE=C:\Users\Ramesh +TMP=C:\Users\Ramesh\AppData\Local\Temp +CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files +ProgramFiles=C:\Program Files +PUBLIC=C:\Users\Public +NUMBER_OF_PROCESSORS=4 +windir=C:\Windows +AMDAPPSDKROOT=C:\Program Files (x86)\AMD APP\ +=::=::\ diff --git a/BasicJava/ExceptionDemo_CNFE_NCDFE_App/B_Output.txt b/BasicJava/ExceptionDemo_CNFE_NCDFE_App/B_Output.txt new file mode 100644 index 000000000..01fbc8569 --- /dev/null +++ b/BasicJava/ExceptionDemo_CNFE_NCDFE_App/B_Output.txt @@ -0,0 +1,8 @@ +Exception in thread "main" java.lang.NoClassDefFoundError: A + at B.main(B.java:11) +Caused by: java.lang.ClassNotFoundException: A + at java.net.URLClassLoader.findClass(URLClassLoader.java:381) + at java.lang.ClassLoader.loadClass(ClassLoader.java:424) + at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) + at java.lang.ClassLoader.loadClass(ClassLoader.java:357) + ... 1 more diff --git a/BasicJava/ExceptionDemo_CNFE_NCDFE_App/ClassNotFoundExceptionDemo_Output.txt b/BasicJava/ExceptionDemo_CNFE_NCDFE_App/ClassNotFoundExceptionDemo_Output.txt new file mode 100644 index 000000000..7340adb20 --- /dev/null +++ b/BasicJava/ExceptionDemo_CNFE_NCDFE_App/ClassNotFoundExceptionDemo_Output.txt @@ -0,0 +1,8 @@ +java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver + at java.net.URLClassLoader.findClass(URLClassLoader.java:381) + at java.lang.ClassLoader.loadClass(ClassLoader.java:424) + at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) + at java.lang.ClassLoader.loadClass(ClassLoader.java:357) + at java.lang.Class.forName0(Native Method) + at java.lang.Class.forName(Class.java:264) + at ClassNotFoundExceptionDemo.main(ClassNotFoundExceptionDemo.java:9) diff --git a/Later/StringBuffer/StringBuffer_6/StringBufferDemo/.classpath b/BasicJava/ExceptionDemo_CNFE_NCDFE_App/ExceptionDemo/.classpath similarity index 100% rename from Later/StringBuffer/StringBuffer_6/StringBufferDemo/.classpath rename to BasicJava/ExceptionDemo_CNFE_NCDFE_App/ExceptionDemo/.classpath diff --git a/BasicJava/ExceptionDemo_CNFE_NCDFE_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_CNFE_NCDFE_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_CNFE_NCDFE_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/StringBuffer/StringBuffer_6/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_CNFE_NCDFE_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from Later/StringBuffer/StringBuffer_6/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs rename to BasicJava/ExceptionDemo_CNFE_NCDFE_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs diff --git a/BasicJava/ExceptionDemo_CNFE_NCDFE_App/ExceptionDemo/bin/A.class b/BasicJava/ExceptionDemo_CNFE_NCDFE_App/ExceptionDemo/bin/A.class new file mode 100644 index 000000000..424e939ab Binary files /dev/null and b/BasicJava/ExceptionDemo_CNFE_NCDFE_App/ExceptionDemo/bin/A.class differ diff --git a/BasicJava/ExceptionDemo_CNFE_NCDFE_App/ExceptionDemo/bin/B.class b/BasicJava/ExceptionDemo_CNFE_NCDFE_App/ExceptionDemo/bin/B.class new file mode 100644 index 000000000..1ea5eee4d Binary files /dev/null and b/BasicJava/ExceptionDemo_CNFE_NCDFE_App/ExceptionDemo/bin/B.class differ diff --git a/BasicJava/ExceptionDemo_CNFE_NCDFE_App/ExceptionDemo/bin/ClassNotFoundExceptionDemo.class b/BasicJava/ExceptionDemo_CNFE_NCDFE_App/ExceptionDemo/bin/ClassNotFoundExceptionDemo.class new file mode 100644 index 000000000..0b35b1041 Binary files /dev/null and b/BasicJava/ExceptionDemo_CNFE_NCDFE_App/ExceptionDemo/bin/ClassNotFoundExceptionDemo.class differ diff --git a/BasicJava/ExceptionDemo_CNFE_NCDFE_App/ExceptionDemo/src/B.java b/BasicJava/ExceptionDemo_CNFE_NCDFE_App/ExceptionDemo/src/B.java new file mode 100644 index 000000000..cae9bc3cf --- /dev/null +++ b/BasicJava/ExceptionDemo_CNFE_NCDFE_App/ExceptionDemo/src/B.java @@ -0,0 +1,14 @@ +class A +{ + +} + +public class B +{ + + public static void main(String[] args) + { + A a=new A(); + } + +} diff --git a/BasicJava/ExceptionDemo_CNFE_NCDFE_App/ExceptionDemo/src/ClassNotFoundExceptionDemo.java b/BasicJava/ExceptionDemo_CNFE_NCDFE_App/ExceptionDemo/src/ClassNotFoundExceptionDemo.java new file mode 100644 index 000000000..aae664552 --- /dev/null +++ b/BasicJava/ExceptionDemo_CNFE_NCDFE_App/ExceptionDemo/src/ClassNotFoundExceptionDemo.java @@ -0,0 +1,18 @@ +public class ClassNotFoundExceptionDemo +{ + + public static void main(String[] args) + { + + try + { + Class.forName("oracle.jdbc.driver.OracleDriver"); + } + catch (ClassNotFoundException e) + { + e.printStackTrace(); + } + + } + +} diff --git a/BasicJava/ExceptionDemo_Catch_block_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_Catch_block_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_Catch_block_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_Catch_block_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_Catch_block_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_Catch_block_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_Catch_block_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_Catch_block_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_Catch_block_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_Catch_block_App/ExceptionDemo/bin/ExceptionDemo1.class b/BasicJava/ExceptionDemo_Catch_block_App/ExceptionDemo/bin/ExceptionDemo1.class new file mode 100644 index 000000000..25ebc5449 Binary files /dev/null and b/BasicJava/ExceptionDemo_Catch_block_App/ExceptionDemo/bin/ExceptionDemo1.class differ diff --git a/BasicJava/ExceptionDemo_Catch_block_App/ExceptionDemo/bin/ExceptionDemo2.class b/BasicJava/ExceptionDemo_Catch_block_App/ExceptionDemo/bin/ExceptionDemo2.class new file mode 100644 index 000000000..623860beb Binary files /dev/null and b/BasicJava/ExceptionDemo_Catch_block_App/ExceptionDemo/bin/ExceptionDemo2.class differ diff --git a/BasicJava/ExceptionDemo_Catch_block_App/ExceptionDemo/src/ExceptionDemo1.java b/BasicJava/ExceptionDemo_Catch_block_App/ExceptionDemo/src/ExceptionDemo1.java new file mode 100644 index 000000000..0cdd9a6fe --- /dev/null +++ b/BasicJava/ExceptionDemo_Catch_block_App/ExceptionDemo/src/ExceptionDemo1.java @@ -0,0 +1,15 @@ +public class ExceptionDemo1 +{ + public static void main(String[] args) + { + String firstName = null; + + // May throw an Exception + System.out.println(firstName.length()); + + String lastName = "Peter"; + String fullName = firstName + lastName; + System.out.println("fullName = " + fullName); + } + +} diff --git a/BasicJava/ExceptionDemo_Catch_block_App/ExceptionDemo/src/ExceptionDemo2.java b/BasicJava/ExceptionDemo_Catch_block_App/ExceptionDemo/src/ExceptionDemo2.java new file mode 100644 index 000000000..13ba19330 --- /dev/null +++ b/BasicJava/ExceptionDemo_Catch_block_App/ExceptionDemo/src/ExceptionDemo2.java @@ -0,0 +1,22 @@ +public class ExceptionDemo2 +{ + public static void main(String[] args) + { + String firstName = null; + + try + { + // May throw an Exception + System.out.println(firstName.length()); + } + catch(NullPointerException nullPointerException) + { + System.out.println("String is null"); + } + + String lastName = "Peter"; + String fullName = firstName+lastName; + System.out.println("fullName = "+fullName); + } + +} diff --git a/BasicJava/ExceptionDemo_Catch_block_App/ExceptionDemo1_Output.txt b/BasicJava/ExceptionDemo_Catch_block_App/ExceptionDemo1_Output.txt new file mode 100644 index 000000000..be0f84bc5 --- /dev/null +++ b/BasicJava/ExceptionDemo_Catch_block_App/ExceptionDemo1_Output.txt @@ -0,0 +1,2 @@ +Exception in thread "main" java.lang.NullPointerException + at ExceptionDemo1.main(ExceptionDemo1.java:8) diff --git a/BasicJava/ExceptionDemo_Catch_block_App/ExceptionDemo2_Output.txt b/BasicJava/ExceptionDemo_Catch_block_App/ExceptionDemo2_Output.txt new file mode 100644 index 000000000..cf74f70d7 --- /dev/null +++ b/BasicJava/ExceptionDemo_Catch_block_App/ExceptionDemo2_Output.txt @@ -0,0 +1,2 @@ +String is null +fullName = nullPeter diff --git a/BasicJava/ExceptionDemo_Catch_handles_multi_exe_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_Catch_handles_multi_exe_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_Catch_handles_multi_exe_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_Catch_handles_multi_exe_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_Catch_handles_multi_exe_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_Catch_handles_multi_exe_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_Catch_handles_multi_exe_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_Catch_handles_multi_exe_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_Catch_handles_multi_exe_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_Catch_handles_multi_exe_App/ExceptionDemo/bin/CatchBlockDemo.class b/BasicJava/ExceptionDemo_Catch_handles_multi_exe_App/ExceptionDemo/bin/CatchBlockDemo.class new file mode 100644 index 000000000..db7161505 Binary files /dev/null and b/BasicJava/ExceptionDemo_Catch_handles_multi_exe_App/ExceptionDemo/bin/CatchBlockDemo.class differ diff --git a/BasicJava/ExceptionDemo_Catch_handles_multi_exe_App/ExceptionDemo/src/CatchBlockDemo.java b/BasicJava/ExceptionDemo_Catch_handles_multi_exe_App/ExceptionDemo/src/CatchBlockDemo.java new file mode 100644 index 000000000..bca5bf719 --- /dev/null +++ b/BasicJava/ExceptionDemo_Catch_handles_multi_exe_App/ExceptionDemo/src/CatchBlockDemo.java @@ -0,0 +1,27 @@ +public class CatchBlockDemo +{ + + public static void main(String[] args) + { + + try + { + String str = null; + + // This line will throw NullPointerException + System.out.println(str.length()); + + // This line will throw ArithmeticException + int a = 5 / 0; + + } + + catch (ArithmeticException | NullPointerException exe) + { + exe.printStackTrace(); + } + + System.out.println("Normal flow---"); + + } +} diff --git a/BasicJava/ExceptionDemo_Catch_handles_multi_exe_App/Output.txt b/BasicJava/ExceptionDemo_Catch_handles_multi_exe_App/Output.txt new file mode 100644 index 000000000..02239f26f --- /dev/null +++ b/BasicJava/ExceptionDemo_Catch_handles_multi_exe_App/Output.txt @@ -0,0 +1,3 @@ +java.lang.NullPointerException + at CatchBlockDemo.main(CatchBlockDemo.java:12) +Normal flow--- diff --git a/BasicJava/ExceptionDemo_CheckedException_App/CheckedExceptionDemo1_Output.txt b/BasicJava/ExceptionDemo_CheckedException_App/CheckedExceptionDemo1_Output.txt new file mode 100644 index 000000000..b9339b9f4 --- /dev/null +++ b/BasicJava/ExceptionDemo_CheckedException_App/CheckedExceptionDemo1_Output.txt @@ -0,0 +1,6 @@ +Exception in thread "main" java.lang.Error: Unresolved compilation problems: + Unhandled exception type FileNotFoundException + Unhandled exception type IOException + Unhandled exception type IOException + + at CheckedExceptionDemo1.main(CheckedExceptionDemo1.java:21) diff --git a/BasicJava/ExceptionDemo_CheckedException_App/CheckedExceptionDemo2_Output.txt b/BasicJava/ExceptionDemo_CheckedException_App/CheckedExceptionDemo2_Output.txt new file mode 100644 index 000000000..5ab2f8a43 --- /dev/null +++ b/BasicJava/ExceptionDemo_CheckedException_App/CheckedExceptionDemo2_Output.txt @@ -0,0 +1 @@ +Hello \ No newline at end of file diff --git a/BasicJava/ExceptionDemo_CheckedException_App/CheckedExceptionDemo3_Output.txt b/BasicJava/ExceptionDemo_CheckedException_App/CheckedExceptionDemo3_Output.txt new file mode 100644 index 000000000..5950533c1 --- /dev/null +++ b/BasicJava/ExceptionDemo_CheckedException_App/CheckedExceptionDemo3_Output.txt @@ -0,0 +1,2 @@ +Hello +Inside finally block diff --git a/BasicJava/ExceptionDemo_CheckedException_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_CheckedException_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_CheckedException_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_CheckedException_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_CheckedException_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_CheckedException_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_CheckedException_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_CheckedException_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_CheckedException_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_CheckedException_App/ExceptionDemo/bin/CheckedExceptionDemo1.class b/BasicJava/ExceptionDemo_CheckedException_App/ExceptionDemo/bin/CheckedExceptionDemo1.class new file mode 100644 index 000000000..1007cd4d0 Binary files /dev/null and b/BasicJava/ExceptionDemo_CheckedException_App/ExceptionDemo/bin/CheckedExceptionDemo1.class differ diff --git a/BasicJava/ExceptionDemo_CheckedException_App/ExceptionDemo/bin/CheckedExceptionDemo2.class b/BasicJava/ExceptionDemo_CheckedException_App/ExceptionDemo/bin/CheckedExceptionDemo2.class new file mode 100644 index 000000000..d1dd54b2e Binary files /dev/null and b/BasicJava/ExceptionDemo_CheckedException_App/ExceptionDemo/bin/CheckedExceptionDemo2.class differ diff --git a/BasicJava/ExceptionDemo_CheckedException_App/ExceptionDemo/bin/CheckedExceptionDemo3.class b/BasicJava/ExceptionDemo_CheckedException_App/ExceptionDemo/bin/CheckedExceptionDemo3.class new file mode 100644 index 000000000..cdf0fc1ed Binary files /dev/null and b/BasicJava/ExceptionDemo_CheckedException_App/ExceptionDemo/bin/CheckedExceptionDemo3.class differ diff --git a/BasicJava/ExceptionDemo_CheckedException_App/ExceptionDemo/myfile.txt b/BasicJava/ExceptionDemo_CheckedException_App/ExceptionDemo/myfile.txt new file mode 100644 index 000000000..5ab2f8a43 --- /dev/null +++ b/BasicJava/ExceptionDemo_CheckedException_App/ExceptionDemo/myfile.txt @@ -0,0 +1 @@ +Hello \ No newline at end of file diff --git a/BasicJava/ExceptionDemo_CheckedException_App/ExceptionDemo/src/CheckedExceptionDemo1.java b/BasicJava/ExceptionDemo_CheckedException_App/ExceptionDemo/src/CheckedExceptionDemo1.java new file mode 100644 index 000000000..e33148445 --- /dev/null +++ b/BasicJava/ExceptionDemo_CheckedException_App/ExceptionDemo/src/CheckedExceptionDemo1.java @@ -0,0 +1,40 @@ +import java.io.FileInputStream; + +/* + * Checked exceptions gets checked during compile time. + * Since we didn’t handled/declared the exceptions, our + * program gave the compilation error. + */ + +public class CheckedExceptionDemo1 +{ + + public static void main(String[] args) + { + FileInputStream fis = null; + + /* + * This constructor FileInputStream(File filename) + * throws FileNotFoundException which is a checked + * exception + */ + fis = new FileInputStream("./myfile.txt"); + int i; + + /* + * Method read() of FileInputStream class also + * throws a checked exception: IOException + */ + while ((i = fis.read()) != -1) + { + System.out.print((char) i); + } + + /* + * The method close() closes the file input stream + * It throws IOException + */ + fis.close(); + } + +} diff --git a/BasicJava/ExceptionDemo_CheckedException_App/ExceptionDemo/src/CheckedExceptionDemo2.java b/BasicJava/ExceptionDemo_CheckedException_App/ExceptionDemo/src/CheckedExceptionDemo2.java new file mode 100644 index 000000000..6780fe3cb --- /dev/null +++ b/BasicJava/ExceptionDemo_CheckedException_App/ExceptionDemo/src/CheckedExceptionDemo2.java @@ -0,0 +1,40 @@ +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; + +public class CheckedExceptionDemo2 +{ + + // Declare the exception using throws keyword. + + public static void main(String[] args) + throws FileNotFoundException, IOException + { + FileInputStream fis = null; + + /* + * This constructor FileInputStream(File filename) + * throws FileNotFoundException which is a checked + * exception + */ + fis = new FileInputStream("./myfile.txt"); + int i; + + /* + * Method read() of FileInputStream class also + * throws a checked exception: IOException + */ + while ((i = fis.read()) != -1) + { + System.out.print((char) i); + } + + /* + * The method close() closes the file input stream + * It throws IOException + */ + fis.close(); + + } + +} diff --git a/BasicJava/ExceptionDemo_CheckedException_App/ExceptionDemo/src/CheckedExceptionDemo3.java b/BasicJava/ExceptionDemo_CheckedException_App/ExceptionDemo/src/CheckedExceptionDemo3.java new file mode 100644 index 000000000..1dfbb24d6 --- /dev/null +++ b/BasicJava/ExceptionDemo_CheckedException_App/ExceptionDemo/src/CheckedExceptionDemo3.java @@ -0,0 +1,65 @@ +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; + +public class CheckedExceptionDemo3 +{ + + public static void main(String[] args) + { + + FileInputStream fis = null; + + // Handle them using try-catch blocks. + try + { + + /* + * This constructor FileInputStream(File + * filename) throws FileNotFoundException which + * is a checked exception + */ + fis = new FileInputStream("./myfile.txt"); + int i; + + /* + * Method read() of FileInputStream class also + * throws a checked exception: IOException + */ + while ((i = fis.read()) != -1) + { + System.out.print((char) i); + } + + } + catch (FileNotFoundException fileNotFoundException) + { + System.out.println("The specified file is not " + + "present at the given path"); + } + catch (IOException ioException) + { + System.out.println("I/O error occurred: " + ioException); + } + finally + { + try + { + System.out.println(" \nInside finally block"); + /* + * The method close() closes the file input + * stream It throws IOException + */ + if (fis != null) + { + fis.close(); + } + } + catch (IOException e) + { + e.printStackTrace(); + } + } + + } +} diff --git a/BasicJava/ExceptionDemo_CustomException_V1_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_CustomException_V1_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_CustomException_V1_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_CustomException_V1_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_CustomException_V1_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_CustomException_V1_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_CustomException_V1_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_CustomException_V1_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_CustomException_V1_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_CustomException_V1_App/ExceptionDemo/bin/CustomExceptionDemo.class b/BasicJava/ExceptionDemo_CustomException_V1_App/ExceptionDemo/bin/CustomExceptionDemo.class new file mode 100644 index 000000000..15dab658c Binary files /dev/null and b/BasicJava/ExceptionDemo_CustomException_V1_App/ExceptionDemo/bin/CustomExceptionDemo.class differ diff --git a/BasicJava/ExceptionDemo_CustomException_V1_App/ExceptionDemo/bin/InvalidAgeException.class b/BasicJava/ExceptionDemo_CustomException_V1_App/ExceptionDemo/bin/InvalidAgeException.class new file mode 100644 index 000000000..da8e0f0e2 Binary files /dev/null and b/BasicJava/ExceptionDemo_CustomException_V1_App/ExceptionDemo/bin/InvalidAgeException.class differ diff --git a/BasicJava/ExceptionDemo_CustomException_V1_App/ExceptionDemo/src/CustomExceptionDemo.java b/BasicJava/ExceptionDemo_CustomException_V1_App/ExceptionDemo/src/CustomExceptionDemo.java new file mode 100644 index 000000000..fad90a84e --- /dev/null +++ b/BasicJava/ExceptionDemo_CustomException_V1_App/ExceptionDemo/src/CustomExceptionDemo.java @@ -0,0 +1,31 @@ +public class CustomExceptionDemo +{ + + public static void main(String[] args) + { + try + { + CustomExceptionDemo customExceptionDemo = new CustomExceptionDemo(); + customExceptionDemo.validate(15); + } + catch (InvalidAgeException invalidAgeException) + { + invalidAgeException.printStackTrace(); + System.out.println("message = "+invalidAgeException.getMessage()); + } + + } + + public void validate(int age) throws InvalidAgeException + { + if (age < 25) + { + throw new InvalidAgeException("Not a valid age to apply for Govt. jobs"); + } + else + { + System.out.println("Valid age to apply for Govt. jobs"); + } + + } +} diff --git a/BasicJava/ExceptionDemo_CustomException_V1_App/ExceptionDemo/src/InvalidAgeException.java b/BasicJava/ExceptionDemo_CustomException_V1_App/ExceptionDemo/src/InvalidAgeException.java new file mode 100644 index 000000000..3da8d65de --- /dev/null +++ b/BasicJava/ExceptionDemo_CustomException_V1_App/ExceptionDemo/src/InvalidAgeException.java @@ -0,0 +1,9 @@ +public class InvalidAgeException extends Exception +{ + + public InvalidAgeException(String message) + { + super(message); + } + +} diff --git a/BasicJava/ExceptionDemo_CustomException_V1_App/Output.txt b/BasicJava/ExceptionDemo_CustomException_V1_App/Output.txt new file mode 100644 index 000000000..46016528a --- /dev/null +++ b/BasicJava/ExceptionDemo_CustomException_V1_App/Output.txt @@ -0,0 +1,4 @@ +InvalidAgeException: Not a valid age to apply for Govt. jobs + at CustomExceptionDemo.validate(CustomExceptionDemo.java:23) + at CustomExceptionDemo.main(CustomExceptionDemo.java:9) +message = Not a valid age to apply for Govt. jobs diff --git a/BasicJava/ExceptionDemo_CustomException_V2_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_CustomException_V2_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_CustomException_V2_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_CustomException_V2_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_CustomException_V2_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_CustomException_V2_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_CustomException_V2_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_CustomException_V2_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_CustomException_V2_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_CustomException_V2_App/ExceptionDemo/bin/CustomExceptionDemo.class b/BasicJava/ExceptionDemo_CustomException_V2_App/ExceptionDemo/bin/CustomExceptionDemo.class new file mode 100644 index 000000000..2cf1ae369 Binary files /dev/null and b/BasicJava/ExceptionDemo_CustomException_V2_App/ExceptionDemo/bin/CustomExceptionDemo.class differ diff --git a/BasicJava/ExceptionDemo_CustomException_V2_App/ExceptionDemo/bin/InsufficientBalanceException.class b/BasicJava/ExceptionDemo_CustomException_V2_App/ExceptionDemo/bin/InsufficientBalanceException.class new file mode 100644 index 000000000..3c69e085c Binary files /dev/null and b/BasicJava/ExceptionDemo_CustomException_V2_App/ExceptionDemo/bin/InsufficientBalanceException.class differ diff --git a/BasicJava/ExceptionDemo_CustomException_V2_App/ExceptionDemo/src/CustomExceptionDemo.java b/BasicJava/ExceptionDemo_CustomException_V2_App/ExceptionDemo/src/CustomExceptionDemo.java new file mode 100644 index 000000000..ff04cb4e1 --- /dev/null +++ b/BasicJava/ExceptionDemo_CustomException_V2_App/ExceptionDemo/src/CustomExceptionDemo.java @@ -0,0 +1,34 @@ +public class CustomExceptionDemo +{ + + public static void main(String[] args) + { + try + { + CustomExceptionDemo customExceptionDemo = new CustomExceptionDemo(); + customExceptionDemo.withdrawMoney(20000); + } + catch (InsufficientBalanceException insufficientBalanceException) + { + insufficientBalanceException.printStackTrace(); + System.out.println("message = " + + insufficientBalanceException.getMessage()); + } + + } + + public void withdrawMoney(int amount) + throws InsufficientBalanceException + { + if (amount > 10000) + { + throw new InsufficientBalanceException( + "Your account does not have enough money to withdraw."); + } + else + { + System.out.println("Successfully withdrawn."); + } + + } +} diff --git a/BasicJava/ExceptionDemo_CustomException_V2_App/ExceptionDemo/src/InsufficientBalanceException.java b/BasicJava/ExceptionDemo_CustomException_V2_App/ExceptionDemo/src/InsufficientBalanceException.java new file mode 100644 index 000000000..fa415d4cc --- /dev/null +++ b/BasicJava/ExceptionDemo_CustomException_V2_App/ExceptionDemo/src/InsufficientBalanceException.java @@ -0,0 +1,9 @@ +class InsufficientBalanceException extends Exception +{ + + public InsufficientBalanceException(String message) + { + super(message); + } + +} diff --git a/BasicJava/ExceptionDemo_CustomException_V2_App/Output.txt b/BasicJava/ExceptionDemo_CustomException_V2_App/Output.txt new file mode 100644 index 000000000..2b8e7c6c2 --- /dev/null +++ b/BasicJava/ExceptionDemo_CustomException_V2_App/Output.txt @@ -0,0 +1,4 @@ +InsufficientBalanceException: Your account does not have enough money to withdraw. + at CustomExceptionDemo.withdrawMoney(CustomExceptionDemo.java:25) + at CustomExceptionDemo.main(CustomExceptionDemo.java:9) +message = Your account does not have enough money to withdraw. diff --git a/BasicJava/ExceptionDemo_Custom_AutoClosable_impl_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_Custom_AutoClosable_impl_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_Custom_AutoClosable_impl_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_Custom_AutoClosable_impl_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_Custom_AutoClosable_impl_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_Custom_AutoClosable_impl_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_Custom_AutoClosable_impl_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_Custom_AutoClosable_impl_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_Custom_AutoClosable_impl_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_Custom_AutoClosable_impl_App/ExceptionDemo/bin/MyBufferedReader.class b/BasicJava/ExceptionDemo_Custom_AutoClosable_impl_App/ExceptionDemo/bin/MyBufferedReader.class new file mode 100644 index 000000000..ea5822baa Binary files /dev/null and b/BasicJava/ExceptionDemo_Custom_AutoClosable_impl_App/ExceptionDemo/bin/MyBufferedReader.class differ diff --git a/BasicJava/ExceptionDemo_Custom_AutoClosable_impl_App/ExceptionDemo/bin/TryWithResourcesDemo.class b/BasicJava/ExceptionDemo_Custom_AutoClosable_impl_App/ExceptionDemo/bin/TryWithResourcesDemo.class new file mode 100644 index 000000000..c3da3d013 Binary files /dev/null and b/BasicJava/ExceptionDemo_Custom_AutoClosable_impl_App/ExceptionDemo/bin/TryWithResourcesDemo.class differ diff --git a/BasicJava/ExceptionDemo_Custom_AutoClosable_impl_App/ExceptionDemo/myfile.txt b/BasicJava/ExceptionDemo_Custom_AutoClosable_impl_App/ExceptionDemo/myfile.txt new file mode 100644 index 000000000..f975aa079 --- /dev/null +++ b/BasicJava/ExceptionDemo_Custom_AutoClosable_impl_App/ExceptionDemo/myfile.txt @@ -0,0 +1,3 @@ +Peter +David +Julia \ No newline at end of file diff --git a/BasicJava/ExceptionDemo_Custom_AutoClosable_impl_App/ExceptionDemo/src/MyBufferedReader.java b/BasicJava/ExceptionDemo_Custom_AutoClosable_impl_App/ExceptionDemo/src/MyBufferedReader.java new file mode 100644 index 000000000..7f336887a --- /dev/null +++ b/BasicJava/ExceptionDemo_Custom_AutoClosable_impl_App/ExceptionDemo/src/MyBufferedReader.java @@ -0,0 +1,15 @@ +public class MyBufferedReader implements AutoCloseable +{ + + public void read() + { + System.out.println("read method is called..."); + } + + @Override + public void close() throws Exception + { + System.out.println("close method is called..."); + } + +} diff --git a/BasicJava/ExceptionDemo_Custom_AutoClosable_impl_App/ExceptionDemo/src/TryWithResourcesDemo.java b/BasicJava/ExceptionDemo_Custom_AutoClosable_impl_App/ExceptionDemo/src/TryWithResourcesDemo.java new file mode 100644 index 000000000..6ea1918fe --- /dev/null +++ b/BasicJava/ExceptionDemo_Custom_AutoClosable_impl_App/ExceptionDemo/src/TryWithResourcesDemo.java @@ -0,0 +1,13 @@ + +public class TryWithResourcesDemo +{ + + public static void main(String[] args) throws Exception + { + try (MyBufferedReader myBufferedReader = new MyBufferedReader()) + { + myBufferedReader.read(); + } + } + +} diff --git a/BasicJava/ExceptionDemo_Custom_AutoClosable_impl_App/Output.txt b/BasicJava/ExceptionDemo_Custom_AutoClosable_impl_App/Output.txt new file mode 100644 index 000000000..b1bcfb4b9 --- /dev/null +++ b/BasicJava/ExceptionDemo_Custom_AutoClosable_impl_App/Output.txt @@ -0,0 +1,2 @@ +read method is called... +close method is called... diff --git a/BasicJava/ExceptionDemo_Exception_Propagation_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_Exception_Propagation_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_Exception_Propagation_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_Exception_Propagation_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_Exception_Propagation_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_Exception_Propagation_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_Exception_Propagation_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_Exception_Propagation_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_Exception_Propagation_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_Exception_Propagation_App/ExceptionDemo/bin/ExceptionPropagationDemo.class b/BasicJava/ExceptionDemo_Exception_Propagation_App/ExceptionDemo/bin/ExceptionPropagationDemo.class new file mode 100644 index 000000000..848b2391a Binary files /dev/null and b/BasicJava/ExceptionDemo_Exception_Propagation_App/ExceptionDemo/bin/ExceptionPropagationDemo.class differ diff --git a/BasicJava/ExceptionDemo_Exception_Propagation_App/ExceptionDemo/src/ExceptionPropagationDemo.java b/BasicJava/ExceptionDemo_Exception_Propagation_App/ExceptionDemo/src/ExceptionPropagationDemo.java new file mode 100644 index 000000000..2cd08b655 --- /dev/null +++ b/BasicJava/ExceptionDemo_Exception_Propagation_App/ExceptionDemo/src/ExceptionPropagationDemo.java @@ -0,0 +1,38 @@ +public class ExceptionPropagationDemo +{ + + public static void main(String[] args) + { + ExceptionPropagationDemo exceptionPropagationDemo = new ExceptionPropagationDemo(); + try + { + exceptionPropagationDemo.method1(); + } + catch(Exception exe) + { + exe.printStackTrace(); + System.out.println("Exception is handled in main method."); + } + System.out.println("Normal flow..."); + } + + public void method1() + { + System.out.println("method1() is called."); + method2(); + } + + public void method2() + { + System.out.println("method2() is called."); + method3(); + } + + public void method3() + { + System.out.println("method3() is called."); + String str = null; + System.out.println(str.length()); + } + +} diff --git a/BasicJava/ExceptionDemo_Exception_Propagation_App/Output.txt b/BasicJava/ExceptionDemo_Exception_Propagation_App/Output.txt new file mode 100644 index 000000000..056b56425 --- /dev/null +++ b/BasicJava/ExceptionDemo_Exception_Propagation_App/Output.txt @@ -0,0 +1,9 @@ +method1() is called. +method2() is called. +method3() is called. +java.lang.NullPointerException + at ExceptionPropagationDemo.method3(ExceptionPropagationDemo.java:35) + at ExceptionPropagationDemo.method2(ExceptionPropagationDemo.java:28) + at ExceptionPropagationDemo.method1(ExceptionPropagationDemo.java:22) + at ExceptionPropagationDemo.main(ExceptionPropagationDemo.java:9) +Exception is handled in main method. diff --git a/BasicJava/ExceptionDemo_Exception_handling_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_Exception_handling_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_Exception_handling_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_Exception_handling_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_Exception_handling_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_Exception_handling_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_Exception_handling_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_Exception_handling_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_Exception_handling_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_Exception_handling_App/ExceptionDemo/bin/ExceptionHandlingDemo1.class b/BasicJava/ExceptionDemo_Exception_handling_App/ExceptionDemo/bin/ExceptionHandlingDemo1.class new file mode 100644 index 000000000..fce62648d Binary files /dev/null and b/BasicJava/ExceptionDemo_Exception_handling_App/ExceptionDemo/bin/ExceptionHandlingDemo1.class differ diff --git a/BasicJava/ExceptionDemo_Exception_handling_App/ExceptionDemo/bin/ExceptionHandlingDemo2.class b/BasicJava/ExceptionDemo_Exception_handling_App/ExceptionDemo/bin/ExceptionHandlingDemo2.class new file mode 100644 index 000000000..8e83c1174 Binary files /dev/null and b/BasicJava/ExceptionDemo_Exception_handling_App/ExceptionDemo/bin/ExceptionHandlingDemo2.class differ diff --git a/BasicJava/ExceptionDemo_Exception_handling_App/ExceptionDemo/src/ExceptionHandlingDemo1.java b/BasicJava/ExceptionDemo_Exception_handling_App/ExceptionDemo/src/ExceptionHandlingDemo1.java new file mode 100644 index 000000000..5a64b9232 --- /dev/null +++ b/BasicJava/ExceptionDemo_Exception_handling_App/ExceptionDemo/src/ExceptionHandlingDemo1.java @@ -0,0 +1,26 @@ +/* + * With out exception handling + */ +public class ExceptionHandlingDemo1 +{ + + public static void main(String[] args) + { + int intValue = 50; + System.out.println("intValue = " + intValue); + + double doubleValue = 45.9; + System.out.println("doubleValue = " + doubleValue); + + String str = null; + System.out.println("str = " + str.toString()); + + float floatValue = 10.f; + System.out.println("floatValue = " + floatValue); + + long longValue = 45000; + System.out.println("longValue = " + longValue); + + } + +} diff --git a/BasicJava/ExceptionDemo_Exception_handling_App/ExceptionDemo/src/ExceptionHandlingDemo2.java b/BasicJava/ExceptionDemo_Exception_handling_App/ExceptionDemo/src/ExceptionHandlingDemo2.java new file mode 100644 index 000000000..686745881 --- /dev/null +++ b/BasicJava/ExceptionDemo_Exception_handling_App/ExceptionDemo/src/ExceptionHandlingDemo2.java @@ -0,0 +1,34 @@ +/* + * With exception handling. + */ +public class ExceptionHandlingDemo2 +{ + + public static void main(String[] args) + { + int intValue = 50; + System.out.println("intValue = " + intValue); + + double doubleValue = 45.9; + System.out.println("doubleValue = " + doubleValue); + + try + { + String str = null; + System.out.println("str = " + str.toString()); + } + catch(Exception exe) + { + System.out.println("String value is null"); + } + + + float floatValue = 10.f; + System.out.println("floatValue = " + floatValue); + + long longValue = 45000; + System.out.println("longValue = " + longValue); + + } + +} diff --git a/BasicJava/ExceptionDemo_Exception_handling_App/ExceptionHandlingDemo1_Output.txt b/BasicJava/ExceptionDemo_Exception_handling_App/ExceptionHandlingDemo1_Output.txt new file mode 100644 index 000000000..a21b0cd80 --- /dev/null +++ b/BasicJava/ExceptionDemo_Exception_handling_App/ExceptionHandlingDemo1_Output.txt @@ -0,0 +1,4 @@ +intValue = 50 +doubleValue = 45.9 +Exception in thread "main" java.lang.NullPointerException + at ExceptionHandlingDemo1.main(ExceptionHandlingDemo1.java:16) diff --git a/BasicJava/ExceptionDemo_Exception_handling_App/ExceptionHandlingDemo2_Output.txt b/BasicJava/ExceptionDemo_Exception_handling_App/ExceptionHandlingDemo2_Output.txt new file mode 100644 index 000000000..a8175277f --- /dev/null +++ b/BasicJava/ExceptionDemo_Exception_handling_App/ExceptionHandlingDemo2_Output.txt @@ -0,0 +1,5 @@ +intValue = 50 +doubleValue = 45.9 +String value is null +floatValue = 10.0 +longValue = 45000 diff --git a/BasicJava/ExceptionDemo_Exception_in_detail_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_Exception_in_detail_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_Exception_in_detail_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_Exception_in_detail_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_Exception_in_detail_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_Exception_in_detail_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_Exception_in_detail_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_Exception_in_detail_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_Exception_in_detail_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_Exception_in_detail_App/ExceptionDemo/bin/ExceptionPropagationDemo1.class b/BasicJava/ExceptionDemo_Exception_in_detail_App/ExceptionDemo/bin/ExceptionPropagationDemo1.class new file mode 100644 index 000000000..cb45f82ee Binary files /dev/null and b/BasicJava/ExceptionDemo_Exception_in_detail_App/ExceptionDemo/bin/ExceptionPropagationDemo1.class differ diff --git a/BasicJava/ExceptionDemo_Exception_in_detail_App/ExceptionDemo/bin/ExceptionPropagationDemo2.class b/BasicJava/ExceptionDemo_Exception_in_detail_App/ExceptionDemo/bin/ExceptionPropagationDemo2.class new file mode 100644 index 000000000..7e23b2cfe Binary files /dev/null and b/BasicJava/ExceptionDemo_Exception_in_detail_App/ExceptionDemo/bin/ExceptionPropagationDemo2.class differ diff --git a/BasicJava/ExceptionDemo_Exception_in_detail_App/ExceptionDemo/src/ExceptionPropagationDemo1.java b/BasicJava/ExceptionDemo_Exception_in_detail_App/ExceptionDemo/src/ExceptionPropagationDemo1.java new file mode 100644 index 000000000..d4fa02501 --- /dev/null +++ b/BasicJava/ExceptionDemo_Exception_in_detail_App/ExceptionDemo/src/ExceptionPropagationDemo1.java @@ -0,0 +1,40 @@ +public class ExceptionPropagationDemo1 +{ + + public static void main(String[] args) + { + ExceptionPropagationDemo1 exceptionPropagationDemo1 = new ExceptionPropagationDemo1(); + exceptionPropagationDemo1.method1(); + System.out.println("Normal flow."); + } + + public void method1() + { + System.out.println("method1() is called."); + try + { + method2(); + } + catch(NullPointerException nullPointerException) + { + nullPointerException.printStackTrace(); + System.out.println("Exception handled in method1()."); + } + System.out.println("method1 completed."); + + } + + public void method2() + { + System.out.println("method2() is called."); + method3(); + } + + public void method3() + { + System.out.println("method3() is called."); + String str = null; + System.out.println(str.length()); + } + +} diff --git a/BasicJava/ExceptionDemo_Exception_in_detail_App/ExceptionDemo/src/ExceptionPropagationDemo2.java b/BasicJava/ExceptionDemo_Exception_in_detail_App/ExceptionDemo/src/ExceptionPropagationDemo2.java new file mode 100644 index 000000000..3df700781 --- /dev/null +++ b/BasicJava/ExceptionDemo_Exception_in_detail_App/ExceptionDemo/src/ExceptionPropagationDemo2.java @@ -0,0 +1,31 @@ +public class ExceptionPropagationDemo2 +{ + + public static void main(String[] args) + { + ExceptionPropagationDemo2 exceptionPropagationDemo2 = new ExceptionPropagationDemo2(); + exceptionPropagationDemo2.method1(); + System.out.println("Normal flow."); + } + + public void method1() + { + System.out.println("method1() is called."); + method2(); + System.out.println("method1 completed."); + } + + public void method2() + { + System.out.println("method2() is called."); + method3(); + } + + public void method3() + { + System.out.println("method3() is called."); + String str = null; + System.out.println(str.length()); + } + +} diff --git a/BasicJava/ExceptionDemo_Exception_in_detail_App/ExceptionPropagationDemo1_Output.txt b/BasicJava/ExceptionDemo_Exception_in_detail_App/ExceptionPropagationDemo1_Output.txt new file mode 100644 index 000000000..354fe2732 --- /dev/null +++ b/BasicJava/ExceptionDemo_Exception_in_detail_App/ExceptionPropagationDemo1_Output.txt @@ -0,0 +1,11 @@ +method1() is called. +method2() is called. +method3() is called. +java.lang.NullPointerException + at ExceptionPropagationDemo1.method3(ExceptionPropagationDemo1.java:37) + at ExceptionPropagationDemo1.method2(ExceptionPropagationDemo1.java:30) + at ExceptionPropagationDemo1.method1(ExceptionPropagationDemo1.java:16) + at ExceptionPropagationDemo1.main(ExceptionPropagationDemo1.java:7) +Exception handled in method1(). +method1 completed. +Normal flow. diff --git a/BasicJava/ExceptionDemo_Exception_in_detail_App/ExceptionPropagationDemo2_Output.txt b/BasicJava/ExceptionDemo_Exception_in_detail_App/ExceptionPropagationDemo2_Output.txt new file mode 100644 index 000000000..2ab4c1dec --- /dev/null +++ b/BasicJava/ExceptionDemo_Exception_in_detail_App/ExceptionPropagationDemo2_Output.txt @@ -0,0 +1,8 @@ +method1() is called. +method2() is called. +method3() is called. +Exception in thread "main" java.lang.NullPointerException + at ExceptionPropagationDemo2.method3(ExceptionPropagationDemo2.java:28) + at ExceptionPropagationDemo2.method2(ExceptionPropagationDemo2.java:21) + at ExceptionPropagationDemo2.method1(ExceptionPropagationDemo2.java:14) + at ExceptionPropagationDemo2.main(ExceptionPropagationDemo2.java:7) diff --git a/BasicJava/ExceptionDemo_Nested_try_example_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_Nested_try_example_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_Nested_try_example_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_Nested_try_example_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_Nested_try_example_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_Nested_try_example_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_Nested_try_example_App/ExceptionDemo/bin/NestedTryBlockDemo.class b/BasicJava/ExceptionDemo_Nested_try_example_App/ExceptionDemo/bin/NestedTryBlockDemo.class new file mode 100644 index 000000000..17db6cd21 Binary files /dev/null and b/BasicJava/ExceptionDemo_Nested_try_example_App/ExceptionDemo/bin/NestedTryBlockDemo.class differ diff --git a/BasicJava/ExceptionDemo_Nested_try_example_App/ExceptionDemo/src/NestedTryBlockDemo.java b/BasicJava/ExceptionDemo_Nested_try_example_App/ExceptionDemo/src/NestedTryBlockDemo.java new file mode 100644 index 000000000..aa8ab0c89 --- /dev/null +++ b/BasicJava/ExceptionDemo_Nested_try_example_App/ExceptionDemo/src/NestedTryBlockDemo.java @@ -0,0 +1,29 @@ +public class NestedTryBlockDemo +{ + public static void main(String args[]) + { + try + { + try + { + int a[] = new int[5]; + a[15] = 4; + + int b = 30 / 0; + System.out.println("b = " + b); + } + catch (ArithmeticException arithmeticException) + { + arithmeticException.printStackTrace(); + } + + System.out.println("Other statements"); + } + catch (Exception exception) + { + exception.printStackTrace(); + } + + System.out.println("normal flow.."); + } +} diff --git a/BasicJava/ExceptionDemo_Nested_try_example_App/Output.txt b/BasicJava/ExceptionDemo_Nested_try_example_App/Output.txt new file mode 100644 index 000000000..149eefa8e --- /dev/null +++ b/BasicJava/ExceptionDemo_Nested_try_example_App/Output.txt @@ -0,0 +1,3 @@ +java.lang.ArrayIndexOutOfBoundsException: 15 + at NestedTryBlockDemo.main(NestedTryBlockDemo.java:10) +normal flow.. diff --git a/BasicJava/ExceptionDemo_OutOfMemoryError_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_OutOfMemoryError_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_OutOfMemoryError_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_OutOfMemoryError_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_OutOfMemoryError_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_OutOfMemoryError_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_OutOfMemoryError_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_OutOfMemoryError_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_OutOfMemoryError_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_OutOfMemoryError_App/ExceptionDemo/bin/OutOfMemoryErrorDemo.class b/BasicJava/ExceptionDemo_OutOfMemoryError_App/ExceptionDemo/bin/OutOfMemoryErrorDemo.class new file mode 100644 index 000000000..bfe04c080 Binary files /dev/null and b/BasicJava/ExceptionDemo_OutOfMemoryError_App/ExceptionDemo/bin/OutOfMemoryErrorDemo.class differ diff --git a/BasicJava/ExceptionDemo_OutOfMemoryError_App/ExceptionDemo/src/OutOfMemoryErrorDemo.java b/BasicJava/ExceptionDemo_OutOfMemoryError_App/ExceptionDemo/src/OutOfMemoryErrorDemo.java new file mode 100644 index 000000000..c84b5289f --- /dev/null +++ b/BasicJava/ExceptionDemo_OutOfMemoryError_App/ExceptionDemo/src/OutOfMemoryErrorDemo.java @@ -0,0 +1,17 @@ +import java.util.LinkedList; + +public class OutOfMemoryErrorDemo +{ + + public static void main(String[] args) + { + String str = "Peter"; + LinkedList linkedList = new LinkedList(); + while(true) + { + str=str+" Welcome to India"; + linkedList.add(str); + } + } + +} diff --git a/BasicJava/ExceptionDemo_OutOfMemoryError_App/Output.txt b/BasicJava/ExceptionDemo_OutOfMemoryError_App/Output.txt new file mode 100644 index 000000000..dad5f74f3 --- /dev/null +++ b/BasicJava/ExceptionDemo_OutOfMemoryError_App/Output.txt @@ -0,0 +1,7 @@ +Exception in thread "main" java.lang.OutOfMemoryError: Java heap space + at java.util.Arrays.copyOf(Unknown Source) + at java.lang.AbstractStringBuilder.expandCapacity(Unknown Source) + at java.lang.AbstractStringBuilder.ensureCapacityInternal(Unknown Source) + at java.lang.AbstractStringBuilder.append(Unknown Source) + at java.lang.StringBuilder.append(Unknown Source) + at OutOfMemoryErrorDemo.main(OutOfMemoryErrorDemo.java:12) diff --git a/BasicJava/ExceptionDemo_OutOfMemoryError_VMLimit_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_OutOfMemoryError_VMLimit_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_OutOfMemoryError_VMLimit_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_OutOfMemoryError_VMLimit_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_OutOfMemoryError_VMLimit_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_OutOfMemoryError_VMLimit_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_OutOfMemoryError_VMLimit_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_OutOfMemoryError_VMLimit_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_OutOfMemoryError_VMLimit_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_OutOfMemoryError_VMLimit_App/ExceptionDemo/bin/OutOfMemoryErrorDemo.class b/BasicJava/ExceptionDemo_OutOfMemoryError_VMLimit_App/ExceptionDemo/bin/OutOfMemoryErrorDemo.class new file mode 100644 index 000000000..6313f8241 Binary files /dev/null and b/BasicJava/ExceptionDemo_OutOfMemoryError_VMLimit_App/ExceptionDemo/bin/OutOfMemoryErrorDemo.class differ diff --git a/BasicJava/ExceptionDemo_OutOfMemoryError_VMLimit_App/ExceptionDemo/src/OutOfMemoryErrorDemo.java b/BasicJava/ExceptionDemo_OutOfMemoryError_VMLimit_App/ExceptionDemo/src/OutOfMemoryErrorDemo.java new file mode 100644 index 000000000..d1f5218c1 --- /dev/null +++ b/BasicJava/ExceptionDemo_OutOfMemoryError_VMLimit_App/ExceptionDemo/src/OutOfMemoryErrorDemo.java @@ -0,0 +1,15 @@ + +public class OutOfMemoryErrorDemo +{ + + public static void main(String[] args) + { + int[] matrix = new int[Integer.MAX_VALUE]; + + for(int i = 0; i < matrix.length; ++i) + { + matrix[i] = i+1; + } + } + +} diff --git a/BasicJava/ExceptionDemo_OutOfMemoryError_VMLimit_App/Output.txt b/BasicJava/ExceptionDemo_OutOfMemoryError_VMLimit_App/Output.txt new file mode 100644 index 000000000..bad155d28 --- /dev/null +++ b/BasicJava/ExceptionDemo_OutOfMemoryError_VMLimit_App/Output.txt @@ -0,0 +1,2 @@ +Exception in thread "main" java.lang.OutOfMemoryError: Requested array size exceeds VM limit + at OutOfMemoryErrorDemo.main(OutOfMemoryErrorDemo.java:7) diff --git a/BasicJava/ExceptionDemo_OutOfMemoryError_heapspace_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_OutOfMemoryError_heapspace_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_OutOfMemoryError_heapspace_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_OutOfMemoryError_heapspace_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_OutOfMemoryError_heapspace_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_OutOfMemoryError_heapspace_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_OutOfMemoryError_heapspace_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_OutOfMemoryError_heapspace_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_OutOfMemoryError_heapspace_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_OutOfMemoryError_heapspace_App/ExceptionDemo/bin/OutOfMemoryErrorDemo.class b/BasicJava/ExceptionDemo_OutOfMemoryError_heapspace_App/ExceptionDemo/bin/OutOfMemoryErrorDemo.class new file mode 100644 index 000000000..2550ea97a Binary files /dev/null and b/BasicJava/ExceptionDemo_OutOfMemoryError_heapspace_App/ExceptionDemo/bin/OutOfMemoryErrorDemo.class differ diff --git a/BasicJava/ExceptionDemo_OutOfMemoryError_heapspace_App/ExceptionDemo/src/OutOfMemoryErrorDemo.java b/BasicJava/ExceptionDemo_OutOfMemoryError_heapspace_App/ExceptionDemo/src/OutOfMemoryErrorDemo.java new file mode 100644 index 000000000..ca7833253 --- /dev/null +++ b/BasicJava/ExceptionDemo_OutOfMemoryError_heapspace_App/ExceptionDemo/src/OutOfMemoryErrorDemo.java @@ -0,0 +1,22 @@ +import java.util.HashMap; +import java.util.Map; +import java.util.Random; + +public class OutOfMemoryErrorDemo +{ + + public static void main(String[] args) + { + Random random = new Random(); + Map map = new HashMap(); + String str = "Hello"; + + while (true) + { + int randomValue = random.nextInt(); + str=str+"Peter"; + map.put(randomValue, str); + } + } + +} diff --git a/BasicJava/ExceptionDemo_OutOfMemoryError_heapspace_App/Output.txt b/BasicJava/ExceptionDemo_OutOfMemoryError_heapspace_App/Output.txt new file mode 100644 index 000000000..d3cd957c3 --- /dev/null +++ b/BasicJava/ExceptionDemo_OutOfMemoryError_heapspace_App/Output.txt @@ -0,0 +1,5 @@ +Exception in thread "main" java.lang.OutOfMemoryError: Java heap space + at java.util.Arrays.copyOfRange(Unknown Source) + at java.lang.String.(Unknown Source) + at java.lang.StringBuilder.toString(Unknown Source) + at OutOfMemoryErrorDemo.main(OutOfMemoryErrorDemo.java:17) diff --git a/BasicJava/ExceptionDemo_Rethrow_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_Rethrow_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_Rethrow_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_Rethrow_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_Rethrow_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_Rethrow_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_Rethrow_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_Rethrow_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_Rethrow_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_Rethrow_App/ExceptionDemo/bin/ReThrowDemo.class b/BasicJava/ExceptionDemo_Rethrow_App/ExceptionDemo/bin/ReThrowDemo.class new file mode 100644 index 000000000..87f71789f Binary files /dev/null and b/BasicJava/ExceptionDemo_Rethrow_App/ExceptionDemo/bin/ReThrowDemo.class differ diff --git a/BasicJava/ExceptionDemo_Rethrow_App/ExceptionDemo/myfile.txt b/BasicJava/ExceptionDemo_Rethrow_App/ExceptionDemo/myfile.txt new file mode 100644 index 000000000..f975aa079 --- /dev/null +++ b/BasicJava/ExceptionDemo_Rethrow_App/ExceptionDemo/myfile.txt @@ -0,0 +1,3 @@ +Peter +David +Julia \ No newline at end of file diff --git a/BasicJava/ExceptionDemo_Rethrow_App/ExceptionDemo/src/ReThrowDemo.java b/BasicJava/ExceptionDemo_Rethrow_App/ExceptionDemo/src/ReThrowDemo.java new file mode 100644 index 000000000..b4a707480 --- /dev/null +++ b/BasicJava/ExceptionDemo_Rethrow_App/ExceptionDemo/src/ReThrowDemo.java @@ -0,0 +1,68 @@ +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import java.util.Scanner; + +public class ReThrowDemo +{ + public static void main(String[] args) + { + + try + { + new ReThrowDemo().getFileInfo(); + } + catch (IOException e) + { + System.out.println("Exception handled."); + } + + System.out.println("normal flow..."); + + } + + private void getFileInfo() throws IOException + { + + Scanner scanner = new Scanner(System.in); + System.out.print("Enter the fileName : "); + String fileName = scanner.nextLine(); + scanner.close(); + + /* + * Wrap a BufferedReader around FileReader. + */ + BufferedReader bufferedReader; + try + { + bufferedReader = new BufferedReader(new FileReader( + fileName)); + + /* + * Use the readLine method of the BufferedReader + * to read one line at a time. the readLine + * method returns null when there is nothing + * else to read. + */ + String line = null; + + while ((line = bufferedReader.readLine()) != null) + { + System.out.println(line); + } + + // Close the BufferedReader when we're done. + bufferedReader.close(); + } + catch (IOException e) + { + System.out.println("Rethrowing the IOException"); + /* + * We can rethrow an exception by throwing same + * exception in catch block + */ + throw e; + } + } + +} \ No newline at end of file diff --git a/BasicJava/ExceptionDemo_Rethrow_App/Output.txt b/BasicJava/ExceptionDemo_Rethrow_App/Output.txt new file mode 100644 index 000000000..566fe071b --- /dev/null +++ b/BasicJava/ExceptionDemo_Rethrow_App/Output.txt @@ -0,0 +1,4 @@ +Enter the fileName : hi.txt +Rethrowing the IOException +Exception handled. +normal flow... diff --git a/BasicJava/ExceptionDemo_Runtime_Exception_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_Runtime_Exception_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_Runtime_Exception_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_Runtime_Exception_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_Runtime_Exception_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_Runtime_Exception_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_Runtime_Exception_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_Runtime_Exception_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_Runtime_Exception_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_Runtime_Exception_App/ExceptionDemo/bin/RuntimeExceptionDemo.class b/BasicJava/ExceptionDemo_Runtime_Exception_App/ExceptionDemo/bin/RuntimeExceptionDemo.class new file mode 100644 index 000000000..1ffb9567b Binary files /dev/null and b/BasicJava/ExceptionDemo_Runtime_Exception_App/ExceptionDemo/bin/RuntimeExceptionDemo.class differ diff --git a/BasicJava/ExceptionDemo_Runtime_Exception_App/ExceptionDemo/src/RuntimeExceptionDemo.java b/BasicJava/ExceptionDemo_Runtime_Exception_App/ExceptionDemo/src/RuntimeExceptionDemo.java new file mode 100644 index 000000000..2c92296b8 --- /dev/null +++ b/BasicJava/ExceptionDemo_Runtime_Exception_App/ExceptionDemo/src/RuntimeExceptionDemo.java @@ -0,0 +1,12 @@ +public class RuntimeExceptionDemo +{ + public static void main(String[] args) + { + int a = 10; + int b = 0; + + // Divide by zero, will lead to exception + int result = a / b; + } + +} diff --git a/BasicJava/ExceptionDemo_Runtime_Exception_App/Output.txt b/BasicJava/ExceptionDemo_Runtime_Exception_App/Output.txt new file mode 100644 index 000000000..28065e752 --- /dev/null +++ b/BasicJava/ExceptionDemo_Runtime_Exception_App/Output.txt @@ -0,0 +1,2 @@ +Exception in thread "main" java.lang.ArithmeticException: / by zero + at RuntimeExceptionDemo.main(RuntimeExceptionDemo.java:9) diff --git a/BasicJava/ExceptionDemo_Specify_Exceptions_Thrown_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_Specify_Exceptions_Thrown_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_Specify_Exceptions_Thrown_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_Specify_Exceptions_Thrown_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_Specify_Exceptions_Thrown_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_Specify_Exceptions_Thrown_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_Specify_Exceptions_Thrown_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_Specify_Exceptions_Thrown_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_Specify_Exceptions_Thrown_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_Specify_Exceptions_Thrown_App/ExceptionDemo/bin/ThorwsDemo.class b/BasicJava/ExceptionDemo_Specify_Exceptions_Thrown_App/ExceptionDemo/bin/ThorwsDemo.class new file mode 100644 index 000000000..f0d9e47b8 Binary files /dev/null and b/BasicJava/ExceptionDemo_Specify_Exceptions_Thrown_App/ExceptionDemo/bin/ThorwsDemo.class differ diff --git a/BasicJava/ExceptionDemo_Specify_Exceptions_Thrown_App/ExceptionDemo/src/ThorwsDemo.java b/BasicJava/ExceptionDemo_Specify_Exceptions_Thrown_App/ExceptionDemo/src/ThorwsDemo.java new file mode 100644 index 000000000..07c2cd879 --- /dev/null +++ b/BasicJava/ExceptionDemo_Specify_Exceptions_Thrown_App/ExceptionDemo/src/ThorwsDemo.java @@ -0,0 +1,35 @@ +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; + +public class ThorwsDemo +{ + + public static void main(String[] args) + { + ThorwsDemo throwsDemo = new ThorwsDemo(); + + try + { + String firstLine = throwsDemo + .readFirstLineFromFile("myfile.txt"); + System.out.println("firstLine = " + firstLine); + } + catch (IOException e) + { + e.printStackTrace(); + } + + } + + public String readFirstLineFromFile(String path) + throws IOException + + { + BufferedReader br = new BufferedReader(new FileReader(path)); + String line = br.readLine(); + br.close(); + return line; + } + +} diff --git a/BasicJava/ExceptionDemo_Specify_Exceptions_Thrown_App/Output.txt b/BasicJava/ExceptionDemo_Specify_Exceptions_Thrown_App/Output.txt new file mode 100644 index 000000000..0ecbad31f --- /dev/null +++ b/BasicJava/ExceptionDemo_Specify_Exceptions_Thrown_App/Output.txt @@ -0,0 +1,8 @@ +java.io.FileNotFoundException: myfile.txt (The system cannot find the file specified) + at java.io.FileInputStream.open0(Native Method) + at java.io.FileInputStream.open(FileInputStream.java:195) + at java.io.FileInputStream.(FileInputStream.java:138) + at java.io.FileInputStream.(FileInputStream.java:93) + at java.io.FileReader.(FileReader.java:58) + at ThorwsDemo.readFirstLineFromFile(ThorwsDemo.java:29) + at ThorwsDemo.main(ThorwsDemo.java:15) diff --git a/BasicJava/ExceptionDemo_The_catch_blocks_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_The_catch_blocks_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_The_catch_blocks_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_The_catch_blocks_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_The_catch_blocks_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_The_catch_blocks_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_The_catch_blocks_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_The_catch_blocks_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_The_catch_blocks_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_The_catch_blocks_App/ExceptionDemo/bin/CatchBlockDemo.class b/BasicJava/ExceptionDemo_The_catch_blocks_App/ExceptionDemo/bin/CatchBlockDemo.class new file mode 100644 index 000000000..671a9fcae Binary files /dev/null and b/BasicJava/ExceptionDemo_The_catch_blocks_App/ExceptionDemo/bin/CatchBlockDemo.class differ diff --git a/BasicJava/ExceptionDemo_The_catch_blocks_App/ExceptionDemo/src/CatchBlockDemo.java b/BasicJava/ExceptionDemo_The_catch_blocks_App/ExceptionDemo/src/CatchBlockDemo.java new file mode 100644 index 000000000..7dc705333 --- /dev/null +++ b/BasicJava/ExceptionDemo_The_catch_blocks_App/ExceptionDemo/src/CatchBlockDemo.java @@ -0,0 +1,33 @@ +public class CatchBlockDemo +{ + + public static void main(String[] args) + { + + try + { + String str = null; + + // This line will throw NullPointerException + System.out.println(str.length()); + + // This line will throw ArithmeticException + int a = 5 / 0; + + } + + catch (ArithmeticException arithmeticException) + { + arithmeticException.printStackTrace(); + } + + catch (NullPointerException nullPointerException) + { + nullPointerException.printStackTrace(); + + } + + System.out.println("Normal flow---"); + + } +} diff --git a/BasicJava/ExceptionDemo_The_catch_blocks_App/Output.txt b/BasicJava/ExceptionDemo_The_catch_blocks_App/Output.txt new file mode 100644 index 000000000..02239f26f --- /dev/null +++ b/BasicJava/ExceptionDemo_The_catch_blocks_App/Output.txt @@ -0,0 +1,3 @@ +java.lang.NullPointerException + at CatchBlockDemo.main(CatchBlockDemo.java:12) +Normal flow--- diff --git a/BasicJava/ExceptionDemo_The_finally_Block_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_The_finally_Block_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_The_finally_Block_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_The_finally_Block_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_The_finally_Block_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_The_finally_Block_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_The_finally_Block_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_The_finally_Block_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_The_finally_Block_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_The_finally_Block_App/ExceptionDemo/bin/FinallyBlockDemo.class b/BasicJava/ExceptionDemo_The_finally_Block_App/ExceptionDemo/bin/FinallyBlockDemo.class new file mode 100644 index 000000000..bd38a94f3 Binary files /dev/null and b/BasicJava/ExceptionDemo_The_finally_Block_App/ExceptionDemo/bin/FinallyBlockDemo.class differ diff --git a/BasicJava/ExceptionDemo_The_finally_Block_App/ExceptionDemo/src/FinallyBlockDemo.java b/BasicJava/ExceptionDemo_The_finally_Block_App/ExceptionDemo/src/FinallyBlockDemo.java new file mode 100644 index 000000000..e75ac0b01 --- /dev/null +++ b/BasicJava/ExceptionDemo_The_finally_Block_App/ExceptionDemo/src/FinallyBlockDemo.java @@ -0,0 +1,30 @@ +public class FinallyBlockDemo +{ + + public static void main(String[] args) + { + + try + { + String str = null; + + // This line will throw NullPointerException + System.out.println(str.length()); + + // This line will throw ArithmeticException + int a = 5 / 0; + + } + + catch (ArithmeticException | NullPointerException exe) + { + exe.printStackTrace(); + } + finally + { + System.out.println("finally block is called."); + //clean up code. + } + + } +} diff --git a/BasicJava/ExceptionDemo_The_finally_Block_App/Output.txt b/BasicJava/ExceptionDemo_The_finally_Block_App/Output.txt new file mode 100644 index 000000000..4396c1222 --- /dev/null +++ b/BasicJava/ExceptionDemo_The_finally_Block_App/Output.txt @@ -0,0 +1,3 @@ +java.lang.NullPointerException + at FinallyBlockDemo.main(FinallyBlockDemo.java:12) +finally block is called. diff --git a/BasicJava/ExceptionDemo_The_try_block_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_The_try_block_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_The_try_block_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_The_try_block_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_The_try_block_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_The_try_block_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_The_try_block_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_The_try_block_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_The_try_block_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_The_try_block_App/ExceptionDemo/bin/TryBlockDemo1.class b/BasicJava/ExceptionDemo_The_try_block_App/ExceptionDemo/bin/TryBlockDemo1.class new file mode 100644 index 000000000..dbe07238c Binary files /dev/null and b/BasicJava/ExceptionDemo_The_try_block_App/ExceptionDemo/bin/TryBlockDemo1.class differ diff --git a/BasicJava/ExceptionDemo_The_try_block_App/ExceptionDemo/bin/TryBlockDemo2.class b/BasicJava/ExceptionDemo_The_try_block_App/ExceptionDemo/bin/TryBlockDemo2.class new file mode 100644 index 000000000..c3dc5b6ff Binary files /dev/null and b/BasicJava/ExceptionDemo_The_try_block_App/ExceptionDemo/bin/TryBlockDemo2.class differ diff --git a/BasicJava/ExceptionDemo_The_try_block_App/ExceptionDemo/src/TryBlockDemo1.java b/BasicJava/ExceptionDemo_The_try_block_App/ExceptionDemo/src/TryBlockDemo1.java new file mode 100644 index 000000000..055d173b2 --- /dev/null +++ b/BasicJava/ExceptionDemo_The_try_block_App/ExceptionDemo/src/TryBlockDemo1.java @@ -0,0 +1,37 @@ + +public class TryBlockDemo1 +{ + + public static void main(String[] args) + { + + try + { + String str = null; + + // This line will throw NullPointerException + System.out.println(str.length()); + } + + catch (NullPointerException nullPointerException) + { + nullPointerException.printStackTrace(); + } + + try + { + + // This line will throw ArithmeticException + int a = 5/0; + + } + + catch (ArithmeticException arithmeticException) + { + arithmeticException.printStackTrace(); + } + + System.out.println("Normal flow---"); + + } +} diff --git a/BasicJava/ExceptionDemo_The_try_block_App/ExceptionDemo/src/TryBlockDemo2.java b/BasicJava/ExceptionDemo_The_try_block_App/ExceptionDemo/src/TryBlockDemo2.java new file mode 100644 index 000000000..168be7e4b --- /dev/null +++ b/BasicJava/ExceptionDemo_The_try_block_App/ExceptionDemo/src/TryBlockDemo2.java @@ -0,0 +1,33 @@ +public class TryBlockDemo2 +{ + + public static void main(String[] args) + { + + try + { + String str = null; + + // This line will throw NullPointerException + System.out.println(str.length()); + + // This line will throw ArithmeticException + int a = 5 / 0; + + } + + catch (ArithmeticException arithmeticException) + { + arithmeticException.printStackTrace(); + } + + catch (NullPointerException nullPointerException) + { + nullPointerException.printStackTrace(); + + } + + System.out.println("Normal flow---"); + + } +} diff --git a/BasicJava/ExceptionDemo_The_try_block_App/TryBlockDemo1_Output.txt b/BasicJava/ExceptionDemo_The_try_block_App/TryBlockDemo1_Output.txt new file mode 100644 index 000000000..cdd04a908 --- /dev/null +++ b/BasicJava/ExceptionDemo_The_try_block_App/TryBlockDemo1_Output.txt @@ -0,0 +1,5 @@ +java.lang.NullPointerException + at TryBlockDemo1.main(TryBlockDemo1.java:13) +java.lang.ArithmeticException: / by zero + at TryBlockDemo1.main(TryBlockDemo1.java:25) +Normal flow--- diff --git a/BasicJava/ExceptionDemo_The_try_block_App/TryBlockDemo2_Output.txt b/BasicJava/ExceptionDemo_The_try_block_App/TryBlockDemo2_Output.txt new file mode 100644 index 000000000..cbbaa46c0 --- /dev/null +++ b/BasicJava/ExceptionDemo_The_try_block_App/TryBlockDemo2_Output.txt @@ -0,0 +1,3 @@ +java.lang.NullPointerException + at TryBlockDemo2.main(TryBlockDemo2.java:12) +Normal flow--- diff --git a/BasicJava/ExceptionDemo_The_try_with_Resources_statement_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_The_try_with_Resources_statement_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_The_try_with_Resources_statement_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_The_try_with_Resources_statement_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_The_try_with_Resources_statement_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_The_try_with_Resources_statement_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_The_try_with_Resources_statement_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_The_try_with_Resources_statement_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_The_try_with_Resources_statement_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_The_try_with_Resources_statement_App/ExceptionDemo/bin/FinallyDemo.class b/BasicJava/ExceptionDemo_The_try_with_Resources_statement_App/ExceptionDemo/bin/FinallyDemo.class new file mode 100644 index 000000000..ec76449d1 Binary files /dev/null and b/BasicJava/ExceptionDemo_The_try_with_Resources_statement_App/ExceptionDemo/bin/FinallyDemo.class differ diff --git a/BasicJava/ExceptionDemo_The_try_with_Resources_statement_App/ExceptionDemo/bin/TryWithResourcesDemo.class b/BasicJava/ExceptionDemo_The_try_with_Resources_statement_App/ExceptionDemo/bin/TryWithResourcesDemo.class new file mode 100644 index 000000000..815fef5db Binary files /dev/null and b/BasicJava/ExceptionDemo_The_try_with_Resources_statement_App/ExceptionDemo/bin/TryWithResourcesDemo.class differ diff --git a/BasicJava/ExceptionDemo_The_try_with_Resources_statement_App/ExceptionDemo/myfile.txt b/BasicJava/ExceptionDemo_The_try_with_Resources_statement_App/ExceptionDemo/myfile.txt new file mode 100644 index 000000000..f975aa079 --- /dev/null +++ b/BasicJava/ExceptionDemo_The_try_with_Resources_statement_App/ExceptionDemo/myfile.txt @@ -0,0 +1,3 @@ +Peter +David +Julia \ No newline at end of file diff --git a/BasicJava/ExceptionDemo_The_try_with_Resources_statement_App/ExceptionDemo/src/FinallyDemo.java b/BasicJava/ExceptionDemo_The_try_with_Resources_statement_App/ExceptionDemo/src/FinallyDemo.java new file mode 100644 index 000000000..96376214a --- /dev/null +++ b/BasicJava/ExceptionDemo_The_try_with_Resources_statement_App/ExceptionDemo/src/FinallyDemo.java @@ -0,0 +1,32 @@ +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; + +public class FinallyDemo +{ + + public static void main(String[] args) throws IOException + { + FinallyDemo finallyDemo = new FinallyDemo(); + String firstLine = finallyDemo.readFirstLineFromFile("myfile.txt"); + System.out.println("firstLine = "+firstLine); + + } + + public String readFirstLineFromFile(String path) + throws IOException + { + BufferedReader br = new BufferedReader(new FileReader(path)); + try + { + return br.readLine(); + } + finally + { + if (br != null) + { + br.close(); + } + } + } +} diff --git a/BasicJava/ExceptionDemo_The_try_with_Resources_statement_App/ExceptionDemo/src/TryWithResourcesDemo.java b/BasicJava/ExceptionDemo_The_try_with_Resources_statement_App/ExceptionDemo/src/TryWithResourcesDemo.java new file mode 100644 index 000000000..3dc2c6498 --- /dev/null +++ b/BasicJava/ExceptionDemo_The_try_with_Resources_statement_App/ExceptionDemo/src/TryWithResourcesDemo.java @@ -0,0 +1,26 @@ +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; + +public class TryWithResourcesDemo +{ + + public static void main(String[] args) throws Exception + { + TryWithResourcesDemo tryWithResourcesDemo = new TryWithResourcesDemo(); + String firstLine = tryWithResourcesDemo.readFirstLineFromFile("myfile.txt"); + System.out.println("firstLine = "+firstLine); + + } + + public String readFirstLineFromFile(String path) + throws IOException + { + try (BufferedReader br = new BufferedReader(new FileReader( + path))) + { + return br.readLine(); + } + } + +} diff --git a/BasicJava/ExceptionDemo_The_try_with_Resources_statement_App/FinallyDemo_Output.txt b/BasicJava/ExceptionDemo_The_try_with_Resources_statement_App/FinallyDemo_Output.txt new file mode 100644 index 000000000..b677543de --- /dev/null +++ b/BasicJava/ExceptionDemo_The_try_with_Resources_statement_App/FinallyDemo_Output.txt @@ -0,0 +1 @@ +firstLine = Peter diff --git a/BasicJava/ExceptionDemo_The_try_with_Resources_statement_App/TryWithResourcesDemo_Output.txt b/BasicJava/ExceptionDemo_The_try_with_Resources_statement_App/TryWithResourcesDemo_Output.txt new file mode 100644 index 000000000..b677543de --- /dev/null +++ b/BasicJava/ExceptionDemo_The_try_with_Resources_statement_App/TryWithResourcesDemo_Output.txt @@ -0,0 +1 @@ +firstLine = Peter diff --git a/BasicJava/ExceptionDemo_UnCheckedException_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_UnCheckedException_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_UnCheckedException_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_UnCheckedException_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_UnCheckedException_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_UnCheckedException_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_UnCheckedException_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_UnCheckedException_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_UnCheckedException_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_UnCheckedException_App/ExceptionDemo/bin/UnCheckedExceptionDemo1.class b/BasicJava/ExceptionDemo_UnCheckedException_App/ExceptionDemo/bin/UnCheckedExceptionDemo1.class new file mode 100644 index 000000000..a7ab27a13 Binary files /dev/null and b/BasicJava/ExceptionDemo_UnCheckedException_App/ExceptionDemo/bin/UnCheckedExceptionDemo1.class differ diff --git a/BasicJava/ExceptionDemo_UnCheckedException_App/ExceptionDemo/bin/UnCheckedExceptionDemo2.class b/BasicJava/ExceptionDemo_UnCheckedException_App/ExceptionDemo/bin/UnCheckedExceptionDemo2.class new file mode 100644 index 000000000..6521195bf Binary files /dev/null and b/BasicJava/ExceptionDemo_UnCheckedException_App/ExceptionDemo/bin/UnCheckedExceptionDemo2.class differ diff --git a/BasicJava/ExceptionDemo_UnCheckedException_App/ExceptionDemo/src/UnCheckedExceptionDemo1.java b/BasicJava/ExceptionDemo_UnCheckedException_App/ExceptionDemo/src/UnCheckedExceptionDemo1.java new file mode 100644 index 000000000..078e0b1b6 --- /dev/null +++ b/BasicJava/ExceptionDemo_UnCheckedException_App/ExceptionDemo/src/UnCheckedExceptionDemo1.java @@ -0,0 +1,23 @@ +/* + * If you compile this code, it would compile + * successfully however when you will run it, it would + * throw ArithmeticException. That clearly shows that + * unchecked exceptions are not checked at compile-time, + * they are being checked at runtime. + */ + +public class UnCheckedExceptionDemo1 +{ + public static void main(String[] args) + { + int number1 = 10; + int number2 = 0; + /* + * Since I'm dividing an integer with 0 it should + * throw ArithmeticException + */ + int result = number1 / number2; + System.out.println(result); + } + +} diff --git a/BasicJava/ExceptionDemo_UnCheckedException_App/ExceptionDemo/src/UnCheckedExceptionDemo2.java b/BasicJava/ExceptionDemo_UnCheckedException_App/ExceptionDemo/src/UnCheckedExceptionDemo2.java new file mode 100644 index 000000000..938aaf17e --- /dev/null +++ b/BasicJava/ExceptionDemo_UnCheckedException_App/ExceptionDemo/src/UnCheckedExceptionDemo2.java @@ -0,0 +1,32 @@ +import java.util.Scanner; + +public class UnCheckedExceptionDemo2 +{ + public static void main(String[] args) + { + + Scanner scanner = new Scanner(System.in); + + System.out.print("Enter number1:\t"); + int number1 = scanner.nextInt(); + + System.out.print("Enter number2:\t"); + int number2 = scanner.nextInt(); + + scanner.close(); + + try + { + int result = number1 / number2; + System.out.println(result); + } + catch (ArithmeticException arithmeticException) + { + System.out + .println("Cannot divide an interger with zero." + + "So please enter number2 value greater then zero."); + } + + } + +} diff --git a/BasicJava/ExceptionDemo_UnCheckedException_App/UnCheckedExceptionDemo1_Output.txt b/BasicJava/ExceptionDemo_UnCheckedException_App/UnCheckedExceptionDemo1_Output.txt new file mode 100644 index 000000000..38e002ffa --- /dev/null +++ b/BasicJava/ExceptionDemo_UnCheckedException_App/UnCheckedExceptionDemo1_Output.txt @@ -0,0 +1,2 @@ +Exception in thread "main" java.lang.ArithmeticException: / by zero + at UnCheckedExceptionDemo1.main(UnCheckedExceptionDemo1.java:19) diff --git a/BasicJava/ExceptionDemo_UnCheckedException_App/UnCheckedExceptionDemo2_Output.txt b/BasicJava/ExceptionDemo_UnCheckedException_App/UnCheckedExceptionDemo2_Output.txt new file mode 100644 index 000000000..32bf0d2ae --- /dev/null +++ b/BasicJava/ExceptionDemo_UnCheckedException_App/UnCheckedExceptionDemo2_Output.txt @@ -0,0 +1,3 @@ +Enter number1: 15 +Enter number2: 0 +Cannot divide an interger with zero.So please enter number2 value greater then zero. diff --git a/BasicJava/ExceptionDemo_UncheckedExcecption_AIOBEXE_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_UncheckedExcecption_AIOBEXE_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_UncheckedExcecption_AIOBEXE_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_UncheckedExcecption_AIOBEXE_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_UncheckedExcecption_AIOBEXE_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_UncheckedExcecption_AIOBEXE_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_UncheckedExcecption_AIOBEXE_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_UncheckedExcecption_AIOBEXE_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_UncheckedExcecption_AIOBEXE_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_UncheckedExcecption_AIOBEXE_App/ExceptionDemo/bin/UnCheckedExceptionDemo1.class b/BasicJava/ExceptionDemo_UncheckedExcecption_AIOBEXE_App/ExceptionDemo/bin/UnCheckedExceptionDemo1.class new file mode 100644 index 000000000..0fe314f03 Binary files /dev/null and b/BasicJava/ExceptionDemo_UncheckedExcecption_AIOBEXE_App/ExceptionDemo/bin/UnCheckedExceptionDemo1.class differ diff --git a/BasicJava/ExceptionDemo_UncheckedExcecption_AIOBEXE_App/ExceptionDemo/bin/UnCheckedExceptionDemo2.class b/BasicJava/ExceptionDemo_UncheckedExcecption_AIOBEXE_App/ExceptionDemo/bin/UnCheckedExceptionDemo2.class new file mode 100644 index 000000000..f37788818 Binary files /dev/null and b/BasicJava/ExceptionDemo_UncheckedExcecption_AIOBEXE_App/ExceptionDemo/bin/UnCheckedExceptionDemo2.class differ diff --git a/BasicJava/ExceptionDemo_UncheckedExcecption_AIOBEXE_App/ExceptionDemo/src/UnCheckedExceptionDemo1.java b/BasicJava/ExceptionDemo_UncheckedExcecption_AIOBEXE_App/ExceptionDemo/src/UnCheckedExceptionDemo1.java new file mode 100644 index 000000000..20f4d2b52 --- /dev/null +++ b/BasicJava/ExceptionDemo_UncheckedExcecption_AIOBEXE_App/ExceptionDemo/src/UnCheckedExceptionDemo1.java @@ -0,0 +1,24 @@ +/* + * If you compile this code, it would compile + * successfully however when you will run it, it would + * throw ArrayIndexOutOfBoundsException. That clearly shows that + * unchecked exceptions are not checked at compile-time, + * they are being checked at runtime. + */ + +public class UnCheckedExceptionDemo1 +{ + public static void main(String[] args) + { + int intArray[] = { 1, 2, 3 }; + + /* + * intArray has only 3 elements but I'm trying to + * display the value of 6th element. It should throw + * ArrayIndexOutOfBoundsException + */ + System.out.println(intArray[5]); + System.out.println("Normal flow..."); + } + +} diff --git a/BasicJava/ExceptionDemo_UncheckedExcecption_AIOBEXE_App/ExceptionDemo/src/UnCheckedExceptionDemo2.java b/BasicJava/ExceptionDemo_UncheckedExcecption_AIOBEXE_App/ExceptionDemo/src/UnCheckedExceptionDemo2.java new file mode 100644 index 000000000..145445d16 --- /dev/null +++ b/BasicJava/ExceptionDemo_UncheckedExcecption_AIOBEXE_App/ExceptionDemo/src/UnCheckedExceptionDemo2.java @@ -0,0 +1,31 @@ +import java.util.Scanner; + +public class UnCheckedExceptionDemo2 +{ + public static void main(String[] args) + { + + Scanner scanner = new Scanner(System.in); + + System.out.print("Enter the index: "); + int index = scanner.nextInt(); + + scanner.close(); + + try + { + int intArray[] = + { 155, 345, 999 }; + System.out.println(intArray[index]); + } + catch (ArrayIndexOutOfBoundsException arrayIndexOutOfBoundsException) + { + System.out.println("Enter the index value less " + + "than or equal to 2,\nbecause " + + "size of the array is 3"); + } + System.out.println("Normal flow..."); + + } + +} diff --git a/BasicJava/ExceptionDemo_UncheckedExcecption_AIOBEXE_App/UnCheckedExceptionDemo1_Output.txt b/BasicJava/ExceptionDemo_UncheckedExcecption_AIOBEXE_App/UnCheckedExceptionDemo1_Output.txt new file mode 100644 index 000000000..b67305ca0 --- /dev/null +++ b/BasicJava/ExceptionDemo_UncheckedExcecption_AIOBEXE_App/UnCheckedExceptionDemo1_Output.txt @@ -0,0 +1,2 @@ +Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5 + at UnCheckedExceptionDemo1.main(UnCheckedExceptionDemo1.java:20) diff --git a/BasicJava/ExceptionDemo_UncheckedExcecption_AIOBEXE_App/UnCheckedExceptionDemo2_Output.txt b/BasicJava/ExceptionDemo_UncheckedExcecption_AIOBEXE_App/UnCheckedExceptionDemo2_Output.txt new file mode 100644 index 000000000..831305a70 --- /dev/null +++ b/BasicJava/ExceptionDemo_UncheckedExcecption_AIOBEXE_App/UnCheckedExceptionDemo2_Output.txt @@ -0,0 +1,4 @@ +Enter the index: 10 +Enter the index value less than or equal to 2, +because size of the array is 3 +Normal flow... diff --git a/BasicJava/ExceptionDemo_UncheckedException_NPE_NFE_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_UncheckedException_NPE_NFE_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_UncheckedException_NPE_NFE_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_UncheckedException_NPE_NFE_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_UncheckedException_NPE_NFE_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_UncheckedException_NPE_NFE_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_UncheckedException_NPE_NFE_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_UncheckedException_NPE_NFE_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_UncheckedException_NPE_NFE_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_UncheckedException_NPE_NFE_App/ExceptionDemo/bin/UnCheckedExceptionDemo1.class b/BasicJava/ExceptionDemo_UncheckedException_NPE_NFE_App/ExceptionDemo/bin/UnCheckedExceptionDemo1.class new file mode 100644 index 000000000..b791442aa Binary files /dev/null and b/BasicJava/ExceptionDemo_UncheckedException_NPE_NFE_App/ExceptionDemo/bin/UnCheckedExceptionDemo1.class differ diff --git a/BasicJava/ExceptionDemo_UncheckedException_NPE_NFE_App/ExceptionDemo/bin/UnCheckedExceptionDemo2.class b/BasicJava/ExceptionDemo_UncheckedException_NPE_NFE_App/ExceptionDemo/bin/UnCheckedExceptionDemo2.class new file mode 100644 index 000000000..e9b97e2fb Binary files /dev/null and b/BasicJava/ExceptionDemo_UncheckedException_NPE_NFE_App/ExceptionDemo/bin/UnCheckedExceptionDemo2.class differ diff --git a/BasicJava/ExceptionDemo_UncheckedException_NPE_NFE_App/ExceptionDemo/src/UnCheckedExceptionDemo1.java b/BasicJava/ExceptionDemo_UncheckedException_NPE_NFE_App/ExceptionDemo/src/UnCheckedExceptionDemo1.java new file mode 100644 index 000000000..d46f6d406 --- /dev/null +++ b/BasicJava/ExceptionDemo_UncheckedException_NPE_NFE_App/ExceptionDemo/src/UnCheckedExceptionDemo1.java @@ -0,0 +1,22 @@ +/* + * If you compile this code, it would compile + * successfully however when you will run it, it would + * throw NullPointerException. That clearly shows that + * unchecked exceptions are not checked at compile-time, + * they are being checked at runtime. + */ + +public class UnCheckedExceptionDemo1 +{ + public static void main(String[] args) + { + String str = null; + /* + * str is null, so it should throw + * NullPointerException + */ + System.out.println(str.isEmpty()); + System.out.println("Normal flow..."); + } + +} diff --git a/BasicJava/ExceptionDemo_UncheckedException_NPE_NFE_App/ExceptionDemo/src/UnCheckedExceptionDemo2.java b/BasicJava/ExceptionDemo_UncheckedException_NPE_NFE_App/ExceptionDemo/src/UnCheckedExceptionDemo2.java new file mode 100644 index 000000000..ffcc29bf0 --- /dev/null +++ b/BasicJava/ExceptionDemo_UncheckedException_NPE_NFE_App/ExceptionDemo/src/UnCheckedExceptionDemo2.java @@ -0,0 +1,23 @@ +/* + * If you compile this code, it would compile + * successfully however when you will run it, it would + * throw NumberFormatException. That clearly shows that + * unchecked exceptions are not checked at compile-time, + * they are being checked at runtime. + */ + +public class UnCheckedExceptionDemo2 +{ + public static void main(String[] args) + { + String str = "abc"; + /* + * str is "abc", so it should throw + * NumberFormatException + */ + int i=Integer.parseInt(str); + System.out.println(i); + System.out.println("Normal flow..."); + } + +} diff --git a/BasicJava/ExceptionDemo_UncheckedException_NPE_NFE_App/UnCheckedExceptionDemo1_Output.txt b/BasicJava/ExceptionDemo_UncheckedException_NPE_NFE_App/UnCheckedExceptionDemo1_Output.txt new file mode 100644 index 000000000..16d3229c3 --- /dev/null +++ b/BasicJava/ExceptionDemo_UncheckedException_NPE_NFE_App/UnCheckedExceptionDemo1_Output.txt @@ -0,0 +1,2 @@ +Exception in thread "main" java.lang.NullPointerException + at UnCheckedExceptionDemo1.main(UnCheckedExceptionDemo1.java:18) diff --git a/BasicJava/ExceptionDemo_UncheckedException_NPE_NFE_App/UnCheckedExceptionDemo2_Output.txt b/BasicJava/ExceptionDemo_UncheckedException_NPE_NFE_App/UnCheckedExceptionDemo2_Output.txt new file mode 100644 index 000000000..db7bae18a --- /dev/null +++ b/BasicJava/ExceptionDemo_UncheckedException_NPE_NFE_App/UnCheckedExceptionDemo2_Output.txt @@ -0,0 +1,5 @@ +Exception in thread "main" java.lang.NumberFormatException: For input string: "abc" + at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) + at java.lang.Integer.parseInt(Integer.java:580) + at java.lang.Integer.parseInt(Integer.java:615) + at UnCheckedExceptionDemo2.main(UnCheckedExceptionDemo2.java:18) diff --git a/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo/bin/ExceptionDemo1.class b/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo/bin/ExceptionDemo1.class new file mode 100644 index 000000000..ce51c258c Binary files /dev/null and b/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo/bin/ExceptionDemo1.class differ diff --git a/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo/bin/ExceptionDemo2.class b/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo/bin/ExceptionDemo2.class new file mode 100644 index 000000000..490d43691 Binary files /dev/null and b/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo/bin/ExceptionDemo2.class differ diff --git a/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo/bin/ExceptionDemo3.class b/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo/bin/ExceptionDemo3.class new file mode 100644 index 000000000..d9994f05c Binary files /dev/null and b/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo/bin/ExceptionDemo3.class differ diff --git a/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo/src/ExceptionDemo1.java b/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo/src/ExceptionDemo1.java new file mode 100644 index 000000000..ce7f9601b --- /dev/null +++ b/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo/src/ExceptionDemo1.java @@ -0,0 +1,28 @@ +public class ExceptionDemo1 +{ + public static void main(String[] args) + { + + String firstName = null; + + try + { + // It will throw NullPointerException + System.out.println(firstName.length()); + } + catch (NullPointerException nullPointerException) + { + System.out.println("String value is null."); + } + catch (Exception exception) + { + exception.printStackTrace(); + } + + String lastName = "Peter"; + String fullName = firstName + lastName; + System.out.println("fullName = " + fullName); + + } + +} diff --git a/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo/src/ExceptionDemo2.java b/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo/src/ExceptionDemo2.java new file mode 100644 index 000000000..6becae5b4 --- /dev/null +++ b/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo/src/ExceptionDemo2.java @@ -0,0 +1,21 @@ +public class ExceptionDemo2 +{ + public static void main(String[] args) + { + String firstName = null; + + try + { + // It will throw NullPointerException + System.out.println(firstName.length()); + } + catch (Exception exception) + { + exception.printStackTrace(); + } + + String lastName = "Peter"; + String fullName = firstName + lastName; + System.out.println("fullName = " + fullName); + } +} diff --git a/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo/src/ExceptionDemo3.java b/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo/src/ExceptionDemo3.java new file mode 100644 index 000000000..b97d4cf0a --- /dev/null +++ b/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo/src/ExceptionDemo3.java @@ -0,0 +1,29 @@ +public class ExceptionDemo3 +{ + public static void main(String[] args) + { + + String firstName = null; + + try + { + // It will throw NullPointerException + System.out.println(firstName.length()); + } + + catch (Exception exception) + { + exception.printStackTrace(); + } + + catch (NullPointerException nullPointerException) + { + System.out.println("String value is null."); + } + + String lastName = "Peter"; + String fullName = firstName + lastName; + System.out.println("fullName = " + fullName); + + } +} diff --git a/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo1_Output.txt b/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo1_Output.txt new file mode 100644 index 000000000..6d6f21d73 --- /dev/null +++ b/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo1_Output.txt @@ -0,0 +1,2 @@ +String value is null. +fullName = nullPeter diff --git a/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo2_Output.txt b/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo2_Output.txt new file mode 100644 index 000000000..19b923800 --- /dev/null +++ b/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo2_Output.txt @@ -0,0 +1,3 @@ +java.lang.NullPointerException + at ExceptionDemo2.main(ExceptionDemo2.java:10) +fullName = nullPeter diff --git a/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo3_Output.txt b/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo3_Output.txt new file mode 100644 index 000000000..2542359dc --- /dev/null +++ b/BasicJava/ExceptionDemo_Unreachable_catch_App/ExceptionDemo3_Output.txt @@ -0,0 +1,4 @@ +Exception in thread "main" java.lang.Error: Unresolved compilation problem: + Unreachable catch block for NullPointerException. It is already handled by the catch block for Exception + + at ExceptionDemo3.main(ExceptionDemo3.java:19) diff --git a/BasicJava/ExceptionDemo_What_is_an_Exception_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_What_is_an_Exception_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_What_is_an_Exception_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_What_is_an_Exception_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_What_is_an_Exception_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_What_is_an_Exception_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_What_is_an_Exception_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_What_is_an_Exception_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_What_is_an_Exception_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_What_is_an_Exception_App/ExceptionDemo/bin/ExceptionDemo.class b/BasicJava/ExceptionDemo_What_is_an_Exception_App/ExceptionDemo/bin/ExceptionDemo.class new file mode 100644 index 000000000..a782e2a83 Binary files /dev/null and b/BasicJava/ExceptionDemo_What_is_an_Exception_App/ExceptionDemo/bin/ExceptionDemo.class differ diff --git a/BasicJava/ExceptionDemo_What_is_an_Exception_App/ExceptionDemo/src/ExceptionDemo.java b/BasicJava/ExceptionDemo_What_is_an_Exception_App/ExceptionDemo/src/ExceptionDemo.java new file mode 100644 index 000000000..66728859e --- /dev/null +++ b/BasicJava/ExceptionDemo_What_is_an_Exception_App/ExceptionDemo/src/ExceptionDemo.java @@ -0,0 +1,24 @@ + +public class ExceptionDemo +{ + + public static void main(String[] args) + { + int intValue = 50; + System.out.println("intValue = " + intValue); + + double doubleValue = 45.9; + System.out.println("doubleValue = " + doubleValue); + + String str = null; + System.out.println("str = " + str.toString()); + + float floatValue = 10.f; + System.out.println("floatValue = " + floatValue); + + long longValue = 45000; + System.out.println("longValue = " + longValue); + + } + +} diff --git a/BasicJava/ExceptionDemo_What_is_an_Exception_App/Output.txt b/BasicJava/ExceptionDemo_What_is_an_Exception_App/Output.txt new file mode 100644 index 000000000..e15c0e021 --- /dev/null +++ b/BasicJava/ExceptionDemo_What_is_an_Exception_App/Output.txt @@ -0,0 +1,4 @@ +intValue = 50 +doubleValue = 45.9 +Exception in thread "main" java.lang.NullPointerException + at ExceptionDemo.main(ExceptionDemo.java:14) diff --git a/BasicJava/ExceptionDemo_chained_exceptions_App/ChainedExceptionDemo1_Output.txt b/BasicJava/ExceptionDemo_chained_exceptions_App/ChainedExceptionDemo1_Output.txt new file mode 100644 index 000000000..7723ac625 --- /dev/null +++ b/BasicJava/ExceptionDemo_chained_exceptions_App/ChainedExceptionDemo1_Output.txt @@ -0,0 +1,2 @@ +Cause = java.lang.ArithmeticException: / by zero +Message = / by zero diff --git a/BasicJava/ExceptionDemo_chained_exceptions_App/ChainedExceptionDemo2_Output.txt b/BasicJava/ExceptionDemo_chained_exceptions_App/ChainedExceptionDemo2_Output.txt new file mode 100644 index 000000000..7723ac625 --- /dev/null +++ b/BasicJava/ExceptionDemo_chained_exceptions_App/ChainedExceptionDemo2_Output.txt @@ -0,0 +1,2 @@ +Cause = java.lang.ArithmeticException: / by zero +Message = / by zero diff --git a/BasicJava/ExceptionDemo_chained_exceptions_App/ChainedExceptionDemo3_Output.txt b/BasicJava/ExceptionDemo_chained_exceptions_App/ChainedExceptionDemo3_Output.txt new file mode 100644 index 000000000..016091b43 --- /dev/null +++ b/BasicJava/ExceptionDemo_chained_exceptions_App/ChainedExceptionDemo3_Output.txt @@ -0,0 +1,2 @@ +Cause = java.lang.ArithmeticException: / by zero +Message = java.lang.ArithmeticException: / by zero diff --git a/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/bin/ChainedExceptionDemo1.class b/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/bin/ChainedExceptionDemo1.class new file mode 100644 index 000000000..1cefebf45 Binary files /dev/null and b/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/bin/ChainedExceptionDemo1.class differ diff --git a/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/bin/ChainedExceptionDemo2.class b/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/bin/ChainedExceptionDemo2.class new file mode 100644 index 000000000..424fd9049 Binary files /dev/null and b/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/bin/ChainedExceptionDemo2.class differ diff --git a/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/bin/ChainedExceptionDemo3.class b/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/bin/ChainedExceptionDemo3.class new file mode 100644 index 000000000..4498ae90c Binary files /dev/null and b/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/bin/ChainedExceptionDemo3.class differ diff --git a/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/bin/MyException.class b/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/bin/MyException.class new file mode 100644 index 000000000..b20c642eb Binary files /dev/null and b/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/bin/MyException.class differ diff --git a/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/src/ChainedExceptionDemo1.java b/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/src/ChainedExceptionDemo1.java new file mode 100644 index 000000000..004c94daf --- /dev/null +++ b/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/src/ChainedExceptionDemo1.java @@ -0,0 +1,37 @@ +public class ChainedExceptionDemo1 +{ + + public static void main(String[] args) + { + try + { + getValue(); + } + catch (MyException myException) + { + System.out.println("Cause = " + myException.getCause()); + System.out.println("Message = " + + myException.getMessage()); + } + } + + public static int getValue() throws MyException + { + int a = 0; + try + { + a = 10 / 0; + } + catch (ArithmeticException arithmeticException) + { + MyException myException = new MyException( + arithmeticException.getMessage(), + arithmeticException); + + throw myException; + } + + return a; + } + +} diff --git a/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/src/ChainedExceptionDemo2.java b/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/src/ChainedExceptionDemo2.java new file mode 100644 index 000000000..f3ace2ebb --- /dev/null +++ b/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/src/ChainedExceptionDemo2.java @@ -0,0 +1,38 @@ +public class ChainedExceptionDemo2 +{ + + public static void main(String[] args) + { + try + { + getValue(); + } + catch (MyException myException) + { + System.out.println("Cause = " + myException.getCause()); + System.out.println("Message = " + + myException.getMessage()); + } + } + + public static int getValue() throws MyException + { + int a = 0; + try + { + a = 10 / 0; + } + catch (ArithmeticException arithmeticException) + { + MyException myException = new MyException( + arithmeticException.getMessage()); + + myException.initCause(arithmeticException); + + throw myException; + } + + return a; + } + +} diff --git a/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/src/ChainedExceptionDemo3.java b/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/src/ChainedExceptionDemo3.java new file mode 100644 index 000000000..14bd610e4 --- /dev/null +++ b/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/src/ChainedExceptionDemo3.java @@ -0,0 +1,36 @@ +public class ChainedExceptionDemo3 +{ + + public static void main(String[] args) + { + try + { + getValue(); + } + catch (MyException myException) + { + System.out.println("Cause = " + myException.getCause()); + System.out.println("Message = " + + myException.getMessage()); + } + } + + public static int getValue() throws MyException + { + int a = 0; + try + { + a = 10 / 0; + } + catch (ArithmeticException arithmeticException) + { + MyException myException = new MyException( + arithmeticException); + + throw myException; + } + + return a; + } + +} diff --git a/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/src/MyException.java b/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/src/MyException.java new file mode 100644 index 000000000..8308bef12 --- /dev/null +++ b/BasicJava/ExceptionDemo_chained_exceptions_App/ExceptionDemo/src/MyException.java @@ -0,0 +1,19 @@ +public class MyException extends Exception +{ + + public MyException(String message) + { + super(message); + } + + public MyException(Throwable throwable) + { + super(throwable); + } + + public MyException(String message, Throwable throwable) + { + super(message, throwable); + } + +} diff --git a/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/bin/FinalDemo1.class b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/bin/FinalDemo1.class new file mode 100644 index 000000000..445992110 Binary files /dev/null and b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/bin/FinalDemo1.class differ diff --git a/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/bin/FinalDemo2.class b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/bin/FinalDemo2.class new file mode 100644 index 000000000..857a4693d Binary files /dev/null and b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/bin/FinalDemo2.class differ diff --git a/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/bin/FinalDemo3.class b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/bin/FinalDemo3.class new file mode 100644 index 000000000..dc24ea585 Binary files /dev/null and b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/bin/FinalDemo3.class differ diff --git a/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/bin/FinalizeDemo.class b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/bin/FinalizeDemo.class new file mode 100644 index 000000000..196c986c3 Binary files /dev/null and b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/bin/FinalizeDemo.class differ diff --git a/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/bin/FinallyDemo.class b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/bin/FinallyDemo.class new file mode 100644 index 000000000..e895b241a Binary files /dev/null and b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/bin/FinallyDemo.class differ diff --git a/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/bin/SubClass.class b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/bin/SubClass.class new file mode 100644 index 000000000..ccdb28380 Binary files /dev/null and b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/bin/SubClass.class differ diff --git a/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/bin/SubClass1.class b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/bin/SubClass1.class new file mode 100644 index 000000000..8c7acd396 Binary files /dev/null and b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/bin/SubClass1.class differ diff --git a/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/bin/SuperClass.class b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/bin/SuperClass.class new file mode 100644 index 000000000..43f525990 Binary files /dev/null and b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/bin/SuperClass.class differ diff --git a/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/bin/SuperClass1.class b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/bin/SuperClass1.class new file mode 100644 index 000000000..3b3ac4426 Binary files /dev/null and b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/bin/SuperClass1.class differ diff --git a/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/src/FinalDemo1.java b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/src/FinalDemo1.java new file mode 100644 index 000000000..e61e25be8 --- /dev/null +++ b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/src/FinalDemo1.java @@ -0,0 +1,14 @@ +public class FinalDemo1 +{ + public static void main(String[] args) + { + /* + * If the final keyword is attached to a variable + * then the variable becomes constant i.e. its value + * cannot be changed in the program. + */ + final int intValue = 1000; + intValue = 500;// Compile Time Error + } + +} \ No newline at end of file diff --git a/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/src/FinalDemo2.java b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/src/FinalDemo2.java new file mode 100644 index 000000000..ad90509f2 --- /dev/null +++ b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/src/FinalDemo2.java @@ -0,0 +1,25 @@ +class SuperClass +{ + final void methodOfSuperClass() + { + System.out.println("final Method"); + } +} + +class SubClass extends SuperClass +{ + void methodOfSuperClass() + { + //Compile time error, final method can not be overridden. + } +} + +public class FinalDemo2 +{ + public static void main(String[] args) + { + SuperClass superClass = new SubClass(); + superClass.methodOfSuperClass(); + } + +} \ No newline at end of file diff --git a/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/src/FinalDemo3.java b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/src/FinalDemo3.java new file mode 100644 index 000000000..dc789b151 --- /dev/null +++ b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/src/FinalDemo3.java @@ -0,0 +1,27 @@ +/* + * If a class is marked as final then this class + * cannot be inherited by any other class. + */ + +final class SuperClass1 +{ + void methodOfSuperClass() + { + System.out.println("final class"); + } +} + +class SubClass1 extends SuperClass1 +{ + +} + +public class FinalDemo3 +{ + public static void main(String[] args) + { + SuperClass1 superClass1 = new SubClass1(); + superClass1.methodOfSuperClass(); + } + +} \ No newline at end of file diff --git a/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/src/FinalizeDemo.java b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/src/FinalizeDemo.java new file mode 100644 index 000000000..aaaa7d27c --- /dev/null +++ b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/src/FinalizeDemo.java @@ -0,0 +1,30 @@ +public class FinalizeDemo +{ + + private String name = null; + + public FinalizeDemo(String name) + { + super(); + this.name = name; + } + + public static void main(String[] args) + throws InterruptedException + { + FinalizeDemo FinalizeDemo1 = new FinalizeDemo("FinalizeDemo1"); + FinalizeDemo1 = null; + FinalizeDemo FinalizeDemo2 = new FinalizeDemo("FinalizeDemo2"); + FinalizeDemo1 = null; + FinalizeDemo2 = null; + System.gc(); + Thread.sleep(100); + } + + public void finalize() + { + System.out.println(this.name + + " Object finalize method is called"); + } + +} diff --git a/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/src/FinallyDemo.java b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/src/FinallyDemo.java new file mode 100644 index 000000000..fb6653def --- /dev/null +++ b/BasicJava/ExceptionDemo_final_finally_finalize_App/ExceptionDemo/src/FinallyDemo.java @@ -0,0 +1,21 @@ +public class FinallyDemo +{ + + public static void main(String[] args) + { + try + { + String str = "Peter"; + System.out.println("str = "+str); + } + catch (Exception exe) + { + exe.printStackTrace(); + } + finally + { + System.out.println("finally block is executed"); + } + } + +} diff --git a/BasicJava/ExceptionDemo_final_finally_finalize_App/FinalDemo1_Output.txt b/BasicJava/ExceptionDemo_final_finally_finalize_App/FinalDemo1_Output.txt new file mode 100644 index 000000000..6fad9b7c4 --- /dev/null +++ b/BasicJava/ExceptionDemo_final_finally_finalize_App/FinalDemo1_Output.txt @@ -0,0 +1,4 @@ +Exception in thread "main" java.lang.Error: Unresolved compilation problem: + The final local variable intValue cannot be assigned. It must be blank and not using a compound assignment + + at FinalDemo1.main(FinalDemo1.java:11) diff --git a/BasicJava/ExceptionDemo_final_finally_finalize_App/FinalDemo2_Output.txt b/BasicJava/ExceptionDemo_final_finally_finalize_App/FinalDemo2_Output.txt new file mode 100644 index 000000000..4035fdd6e --- /dev/null +++ b/BasicJava/ExceptionDemo_final_finally_finalize_App/FinalDemo2_Output.txt @@ -0,0 +1,20 @@ +Exception in thread "main" java.lang.VerifyError: class SubClass overrides final method methodOfSuperClass.()V + at java.lang.ClassLoader.defineClass1(Native Method) + at java.lang.ClassLoader.defineClass(ClassLoader.java:760) + at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) + at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) + at java.net.URLClassLoader.access$100(URLClassLoader.java:73) + at java.net.URLClassLoader$1.run(URLClassLoader.java:368) + at java.net.URLClassLoader$1.run(URLClassLoader.java:362) + at java.security.AccessController.doPrivileged(Native Method) + at java.net.URLClassLoader.findClass(URLClassLoader.java:361) + at java.lang.ClassLoader.loadClass(ClassLoader.java:424) + at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) + at java.lang.ClassLoader.loadClass(ClassLoader.java:357) + at java.lang.Class.getDeclaredMethods0(Native Method) + at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) + at java.lang.Class.privateGetMethodRecursive(Class.java:3048) + at java.lang.Class.getMethod0(Class.java:3018) + at java.lang.Class.getMethod(Class.java:1784) + at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544) + at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526) diff --git a/BasicJava/ExceptionDemo_final_finally_finalize_App/FinalDemo3_Output.txt b/BasicJava/ExceptionDemo_final_finally_finalize_App/FinalDemo3_Output.txt new file mode 100644 index 000000000..5b19e1304 --- /dev/null +++ b/BasicJava/ExceptionDemo_final_finally_finalize_App/FinalDemo3_Output.txt @@ -0,0 +1,4 @@ +Exception in thread "main" java.lang.Error: Unresolved compilation problem: + Type mismatch: cannot convert from SubClass1 to SuperClass1 + + at FinalDemo3.main(FinalDemo3.java:23) diff --git a/BasicJava/ExceptionDemo_final_finally_finalize_App/FinalizeDemo_Output.txt b/BasicJava/ExceptionDemo_final_finally_finalize_App/FinalizeDemo_Output.txt new file mode 100644 index 000000000..b7b9f74dc --- /dev/null +++ b/BasicJava/ExceptionDemo_final_finally_finalize_App/FinalizeDemo_Output.txt @@ -0,0 +1,2 @@ +FinalizeDemo2 Object finalize method is called +FinalizeDemo1 Object finalize method is called diff --git a/BasicJava/ExceptionDemo_final_finally_finalize_App/FinallyDemo_Output.txt b/BasicJava/ExceptionDemo_final_finally_finalize_App/FinallyDemo_Output.txt new file mode 100644 index 000000000..5f060b83e --- /dev/null +++ b/BasicJava/ExceptionDemo_final_finally_finalize_App/FinallyDemo_Output.txt @@ -0,0 +1,2 @@ +str = Peter +finally block is executed diff --git a/BasicJava/ExceptionDemo_finally_block_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_finally_block_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_finally_block_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_finally_block_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_finally_block_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_finally_block_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_finally_block_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_finally_block_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_finally_block_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_finally_block_App/ExceptionDemo/bin/FinallyDemo1.class b/BasicJava/ExceptionDemo_finally_block_App/ExceptionDemo/bin/FinallyDemo1.class new file mode 100644 index 000000000..a58588056 Binary files /dev/null and b/BasicJava/ExceptionDemo_finally_block_App/ExceptionDemo/bin/FinallyDemo1.class differ diff --git a/BasicJava/ExceptionDemo_finally_block_App/ExceptionDemo/bin/FinallyDemo2.class b/BasicJava/ExceptionDemo_finally_block_App/ExceptionDemo/bin/FinallyDemo2.class new file mode 100644 index 000000000..3acdfa5ae Binary files /dev/null and b/BasicJava/ExceptionDemo_finally_block_App/ExceptionDemo/bin/FinallyDemo2.class differ diff --git a/BasicJava/ExceptionDemo_finally_block_App/ExceptionDemo/bin/FinallyDemo3.class b/BasicJava/ExceptionDemo_finally_block_App/ExceptionDemo/bin/FinallyDemo3.class new file mode 100644 index 000000000..2d68d6e4a Binary files /dev/null and b/BasicJava/ExceptionDemo_finally_block_App/ExceptionDemo/bin/FinallyDemo3.class differ diff --git a/BasicJava/ExceptionDemo_finally_block_App/ExceptionDemo/src/FinallyDemo1.java b/BasicJava/ExceptionDemo_finally_block_App/ExceptionDemo/src/FinallyDemo1.java new file mode 100644 index 000000000..b67a80ec2 --- /dev/null +++ b/BasicJava/ExceptionDemo_finally_block_App/ExceptionDemo/src/FinallyDemo1.java @@ -0,0 +1,24 @@ +/* + * finally block will be executed, + * Even if exception not occur. + */ + +public class FinallyDemo1 +{ + public static void main(String args[]) + { + try + { + int b = 30 / 5; + System.out.println("b = " + b); + } + catch (ArithmeticException arithmeticException) + { + arithmeticException.printStackTrace(); + } + finally + { + System.out.println("finally block is always executed."); + } + } +} diff --git a/BasicJava/ExceptionDemo_finally_block_App/ExceptionDemo/src/FinallyDemo2.java b/BasicJava/ExceptionDemo_finally_block_App/ExceptionDemo/src/FinallyDemo2.java new file mode 100644 index 000000000..dd0c0592f --- /dev/null +++ b/BasicJava/ExceptionDemo_finally_block_App/ExceptionDemo/src/FinallyDemo2.java @@ -0,0 +1,24 @@ +/* + * finally block will be executed, even exception + * occurs and it is not handled, + */ + +public class FinallyDemo2 +{ + public static void main(String args[]) + { + try + { + int b = 30 / 0; + System.out.println("b = " + b); + } + catch (IndexOutOfBoundsException indexOutOfBoundsException) + { + indexOutOfBoundsException.printStackTrace(); + } + finally + { + System.out.println("finally block is always executed."); + } + } +} diff --git a/BasicJava/ExceptionDemo_finally_block_App/ExceptionDemo/src/FinallyDemo3.java b/BasicJava/ExceptionDemo_finally_block_App/ExceptionDemo/src/FinallyDemo3.java new file mode 100644 index 000000000..1a27be512 --- /dev/null +++ b/BasicJava/ExceptionDemo_finally_block_App/ExceptionDemo/src/FinallyDemo3.java @@ -0,0 +1,24 @@ +/* + * finally block will be executed, + * Even if exception occurs and handled. + */ + +public class FinallyDemo3 +{ + public static void main(String args[]) + { + try + { + int b = 30 / 0; + System.out.println("b = " + b); + } + catch (ArithmeticException arithmeticException) + { + System.out.println("Divide by zero is not possible."); + } + finally + { + System.out.println("finally block is always executed."); + } + } +} diff --git a/BasicJava/ExceptionDemo_finally_block_App/FinallyDemo1_Output.txt b/BasicJava/ExceptionDemo_finally_block_App/FinallyDemo1_Output.txt new file mode 100644 index 000000000..8662cdaef --- /dev/null +++ b/BasicJava/ExceptionDemo_finally_block_App/FinallyDemo1_Output.txt @@ -0,0 +1,2 @@ +b = 6 +finally block is always executed. diff --git a/BasicJava/ExceptionDemo_finally_block_App/FinallyDemo2_Output.txt b/BasicJava/ExceptionDemo_finally_block_App/FinallyDemo2_Output.txt new file mode 100644 index 000000000..785132f24 --- /dev/null +++ b/BasicJava/ExceptionDemo_finally_block_App/FinallyDemo2_Output.txt @@ -0,0 +1,3 @@ +finally block is always executed. +Exception in thread "main" java.lang.ArithmeticException: / by zero + at FinallyDemo2.main(FinallyDemo2.java:12) diff --git a/BasicJava/ExceptionDemo_finally_block_App/FinallyDemo3_Output.txt b/BasicJava/ExceptionDemo_finally_block_App/FinallyDemo3_Output.txt new file mode 100644 index 000000000..12926b015 --- /dev/null +++ b/BasicJava/ExceptionDemo_finally_block_App/FinallyDemo3_Output.txt @@ -0,0 +1,2 @@ +Divide by zero is not possible. +finally block is always executed. diff --git a/BasicJava/ExceptionDemo_finally_exit_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_finally_exit_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_finally_exit_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_finally_exit_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_finally_exit_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_finally_exit_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_finally_exit_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_finally_exit_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_finally_exit_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_finally_exit_App/ExceptionDemo/bin/FinallyDemo.class b/BasicJava/ExceptionDemo_finally_exit_App/ExceptionDemo/bin/FinallyDemo.class new file mode 100644 index 000000000..fd62278fc Binary files /dev/null and b/BasicJava/ExceptionDemo_finally_exit_App/ExceptionDemo/bin/FinallyDemo.class differ diff --git a/BasicJava/ExceptionDemo_finally_exit_App/ExceptionDemo/src/FinallyDemo.java b/BasicJava/ExceptionDemo_finally_exit_App/ExceptionDemo/src/FinallyDemo.java new file mode 100644 index 000000000..1a5914aa7 --- /dev/null +++ b/BasicJava/ExceptionDemo_finally_exit_App/ExceptionDemo/src/FinallyDemo.java @@ -0,0 +1,31 @@ +public class FinallyDemo +{ + + public static void main(String[] args) + { + FinallyDemo finallyDemo = new FinallyDemo(); + finallyDemo.displayName("Peter"); + } + + public void displayName(String name) + { + try + { + System.out.println("Before exit,Name = " + name); + /* + * Terminates the currently running Java Virtual + * Machine. The argument serves as a status + * code; by convention, a nonzero status code + * indicates abnormal termination. + */ + System.exit(1); + System.out.println("After exit,Name = " + name); + } + finally + { + System.out.println("finally block is executed"); + } + + } + +} diff --git a/BasicJava/ExceptionDemo_finally_exit_App/Output.txt b/BasicJava/ExceptionDemo_finally_exit_App/Output.txt new file mode 100644 index 000000000..fb516aaa8 --- /dev/null +++ b/BasicJava/ExceptionDemo_finally_exit_App/Output.txt @@ -0,0 +1 @@ +Before exit,Name = Peter diff --git a/BasicJava/ExceptionDemo_finally_override_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_finally_override_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_finally_override_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_finally_override_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_finally_override_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_finally_override_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_finally_override_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_finally_override_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_finally_override_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_finally_override_App/ExceptionDemo/bin/FinallyDemo.class b/BasicJava/ExceptionDemo_finally_override_App/ExceptionDemo/bin/FinallyDemo.class new file mode 100644 index 000000000..c5592af44 Binary files /dev/null and b/BasicJava/ExceptionDemo_finally_override_App/ExceptionDemo/bin/FinallyDemo.class differ diff --git a/BasicJava/ExceptionDemo_finally_override_App/ExceptionDemo/src/FinallyDemo.java b/BasicJava/ExceptionDemo_finally_override_App/ExceptionDemo/src/FinallyDemo.java new file mode 100644 index 000000000..94618a926 --- /dev/null +++ b/BasicJava/ExceptionDemo_finally_override_App/ExceptionDemo/src/FinallyDemo.java @@ -0,0 +1,27 @@ +public class FinallyDemo +{ + + public static void main(String[] args) + { + FinallyDemo finallyDemo = new FinallyDemo(); + int returnValue = finallyDemo.calculateSum(2,4); + System.out.println("returnValue = " + returnValue); + } + + public int calculateSum(int a, int b) + { + try + { + int sum = a + b; + System.out.println(sum); + return sum; + } + finally + { + System.out.println("finally block is executed"); + return 100; + } + + } + +} diff --git a/BasicJava/ExceptionDemo_finally_override_App/Output.txt b/BasicJava/ExceptionDemo_finally_override_App/Output.txt new file mode 100644 index 000000000..b9e7e8158 --- /dev/null +++ b/BasicJava/ExceptionDemo_finally_override_App/Output.txt @@ -0,0 +1,3 @@ +6 +finally block is executed +returnValue = 100 diff --git a/BasicJava/ExceptionDemo_finally_return_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_finally_return_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_finally_return_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_finally_return_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_finally_return_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_finally_return_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_finally_return_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_finally_return_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_finally_return_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_finally_return_App/ExceptionDemo/bin/FinallyDemo.class b/BasicJava/ExceptionDemo_finally_return_App/ExceptionDemo/bin/FinallyDemo.class new file mode 100644 index 000000000..eb92b3cb2 Binary files /dev/null and b/BasicJava/ExceptionDemo_finally_return_App/ExceptionDemo/bin/FinallyDemo.class differ diff --git a/BasicJava/ExceptionDemo_finally_return_App/ExceptionDemo/src/FinallyDemo.java b/BasicJava/ExceptionDemo_finally_return_App/ExceptionDemo/src/FinallyDemo.java new file mode 100644 index 000000000..daa30d0bb --- /dev/null +++ b/BasicJava/ExceptionDemo_finally_return_App/ExceptionDemo/src/FinallyDemo.java @@ -0,0 +1,33 @@ +public class FinallyDemo +{ + + public static void main(String[] args) + { + FinallyDemo finallyDemo = new FinallyDemo(); + boolean returnValue = finallyDemo.isHeOld(55); + System.out.println("returnValue = "+returnValue); + } + + public boolean isHeOld(int age) + { + try + { + if (age > 50) + { + System.out.println("yes he is old "); + return true; + } + } + catch (Exception exe) + { + exe.printStackTrace(); + } + finally + { + System.out.println("finally block is executed"); + } + + return false; + } + +} diff --git a/BasicJava/ExceptionDemo_finally_return_App/Output.txt b/BasicJava/ExceptionDemo_finally_return_App/Output.txt new file mode 100644 index 000000000..b5347d405 --- /dev/null +++ b/BasicJava/ExceptionDemo_finally_return_App/Output.txt @@ -0,0 +1,3 @@ +yes he is old +finally block is executed +returnValue = true diff --git a/BasicJava/ExceptionDemo_finally_with_only_try_return_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_finally_with_only_try_return_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_finally_with_only_try_return_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_finally_with_only_try_return_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_finally_with_only_try_return_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_finally_with_only_try_return_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_finally_with_only_try_return_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_finally_with_only_try_return_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_finally_with_only_try_return_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_finally_with_only_try_return_App/ExceptionDemo/bin/FinallyDemo.class b/BasicJava/ExceptionDemo_finally_with_only_try_return_App/ExceptionDemo/bin/FinallyDemo.class new file mode 100644 index 000000000..1713a466a Binary files /dev/null and b/BasicJava/ExceptionDemo_finally_with_only_try_return_App/ExceptionDemo/bin/FinallyDemo.class differ diff --git a/BasicJava/ExceptionDemo_finally_with_only_try_return_App/ExceptionDemo/src/FinallyDemo.java b/BasicJava/ExceptionDemo_finally_with_only_try_return_App/ExceptionDemo/src/FinallyDemo.java new file mode 100644 index 000000000..4c174603c --- /dev/null +++ b/BasicJava/ExceptionDemo_finally_with_only_try_return_App/ExceptionDemo/src/FinallyDemo.java @@ -0,0 +1,29 @@ +public class FinallyDemo +{ + + public static void main(String[] args) + { + FinallyDemo finallyDemo = new FinallyDemo(); + boolean returnValue = finallyDemo.isHeOld(55); + System.out.println("returnValue = "+returnValue); + } + + public boolean isHeOld(int age) + { + try + { + if (age > 50) + { + System.out.println("yes he is old "); + return true; + } + } + finally + { + System.out.println("finally block is executed"); + } + + return false; + } + +} diff --git a/BasicJava/ExceptionDemo_finally_with_only_try_return_App/Output.txt b/BasicJava/ExceptionDemo_finally_with_only_try_return_App/Output.txt new file mode 100644 index 000000000..b5347d405 --- /dev/null +++ b/BasicJava/ExceptionDemo_finally_with_only_try_return_App/Output.txt @@ -0,0 +1,3 @@ +yes he is old +finally block is executed +returnValue = true diff --git a/BasicJava/ExceptionDemo_finallyblock_BufferedReader_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_finallyblock_BufferedReader_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_finallyblock_BufferedReader_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_finallyblock_BufferedReader_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_finallyblock_BufferedReader_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_finallyblock_BufferedReader_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_finallyblock_BufferedReader_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_finallyblock_BufferedReader_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_finallyblock_BufferedReader_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_finallyblock_BufferedReader_App/ExceptionDemo/bin/FinallyDemo.class b/BasicJava/ExceptionDemo_finallyblock_BufferedReader_App/ExceptionDemo/bin/FinallyDemo.class new file mode 100644 index 000000000..4a30d2061 Binary files /dev/null and b/BasicJava/ExceptionDemo_finallyblock_BufferedReader_App/ExceptionDemo/bin/FinallyDemo.class differ diff --git a/BasicJava/ExceptionDemo_finallyblock_BufferedReader_App/ExceptionDemo/myfile.txt b/BasicJava/ExceptionDemo_finallyblock_BufferedReader_App/ExceptionDemo/myfile.txt new file mode 100644 index 000000000..f975aa079 --- /dev/null +++ b/BasicJava/ExceptionDemo_finallyblock_BufferedReader_App/ExceptionDemo/myfile.txt @@ -0,0 +1,3 @@ +Peter +David +Julia \ No newline at end of file diff --git a/BasicJava/ExceptionDemo_finallyblock_BufferedReader_App/ExceptionDemo/src/FinallyDemo.java b/BasicJava/ExceptionDemo_finallyblock_BufferedReader_App/ExceptionDemo/src/FinallyDemo.java new file mode 100644 index 000000000..eaee1039a --- /dev/null +++ b/BasicJava/ExceptionDemo_finallyblock_BufferedReader_App/ExceptionDemo/src/FinallyDemo.java @@ -0,0 +1,71 @@ +import java.io.BufferedReader; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.util.Scanner; + +public class FinallyDemo +{ + public static void main(String[] args) + { + + BufferedReader bufferedReader = null; + + try + { + + Scanner scanner = new Scanner(System.in); + System.out.print("Enter the fileName : "); + String fileName = scanner.nextLine(); + scanner.close(); + + /* + * Wrap a BufferedReader around FileReader. + */ + bufferedReader = new BufferedReader(new FileReader( + fileName)); + + /* + * Use the readLine method of the BufferedReader + * to read one line at a time. the readLine + * method returns null when there is nothing + * else to read. + */ + String line = null; + + while ((line = bufferedReader.readLine()) != null) + { + System.out.println(line); + } + + } + catch (FileNotFoundException fileNotFoundException) + { + fileNotFoundException.printStackTrace(); + } + catch (IOException ioException) + { + ioException.printStackTrace(); + } + finally + { + + System.out.print("Inside finally block...."); + if (bufferedReader != null) + { + // Close the BufferedReader when we're done. + try + { + System.out + .println(",close the BufferedReader...."); + bufferedReader.close(); + } + catch (IOException ioException) + { + ioException.printStackTrace(); + } + } + } + + } +} \ No newline at end of file diff --git a/BasicJava/ExceptionDemo_finallyblock_BufferedReader_App/Output.txt b/BasicJava/ExceptionDemo_finallyblock_BufferedReader_App/Output.txt new file mode 100644 index 000000000..36bb051ac --- /dev/null +++ b/BasicJava/ExceptionDemo_finallyblock_BufferedReader_App/Output.txt @@ -0,0 +1,17 @@ +Enter the fileName : myfile.txt +Peter +David +Julia +Inside finally block....,close the BufferedReader.... + +----------------------------------------------- + +Enter the fileName : hi.txt +java.io.FileNotFoundException: hi.txt (The system cannot find the file specified) + at java.io.FileInputStream.open0(Native Method) + at java.io.FileInputStream.open(FileInputStream.java:195) + at java.io.FileInputStream.(FileInputStream.java:138) + at java.io.FileInputStream.(FileInputStream.java:93) + at java.io.FileReader.(FileReader.java:58) + at FinallyDemo.main(FinallyDemo.java:26) +Inside finally block.... \ No newline at end of file diff --git a/BasicJava/ExceptionDemo_multiple_catch-blocks_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_multiple_catch-blocks_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_multiple_catch-blocks_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_multiple_catch-blocks_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_multiple_catch-blocks_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_multiple_catch-blocks_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_multiple_catch-blocks_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_multiple_catch-blocks_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_multiple_catch-blocks_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_multiple_catch-blocks_App/ExceptionDemo/bin/ExceptionDemo1.class b/BasicJava/ExceptionDemo_multiple_catch-blocks_App/ExceptionDemo/bin/ExceptionDemo1.class new file mode 100644 index 000000000..3dc0e4b9f Binary files /dev/null and b/BasicJava/ExceptionDemo_multiple_catch-blocks_App/ExceptionDemo/bin/ExceptionDemo1.class differ diff --git a/BasicJava/ExceptionDemo_multiple_catch-blocks_App/ExceptionDemo/bin/ExceptionDemo2.class b/BasicJava/ExceptionDemo_multiple_catch-blocks_App/ExceptionDemo/bin/ExceptionDemo2.class new file mode 100644 index 000000000..2c9427fe7 Binary files /dev/null and b/BasicJava/ExceptionDemo_multiple_catch-blocks_App/ExceptionDemo/bin/ExceptionDemo2.class differ diff --git a/BasicJava/ExceptionDemo_multiple_catch-blocks_App/ExceptionDemo/src/ExceptionDemo1.java b/BasicJava/ExceptionDemo_multiple_catch-blocks_App/ExceptionDemo/src/ExceptionDemo1.java new file mode 100644 index 000000000..fe38fb215 --- /dev/null +++ b/BasicJava/ExceptionDemo_multiple_catch-blocks_App/ExceptionDemo/src/ExceptionDemo1.java @@ -0,0 +1,24 @@ +import java.util.ArrayList; +import java.util.Scanner; + +public class ExceptionDemo1 +{ + public static void main(String[] args) + { + Scanner scanner = new Scanner(System.in); + System.out.print("Enter the index : "); + int index = scanner.nextInt(); + scanner.close(); + + ArrayList list = new ArrayList(); + list.add("Dave"); + list.add(null); + System.out.println("list = " + list); + + String str = list.get(index); + System.out.println("str = " + str); + System.out.println("length = " + str.length()); + System.out.println("Normal flow.."); + } + +} diff --git a/BasicJava/ExceptionDemo_multiple_catch-blocks_App/ExceptionDemo/src/ExceptionDemo2.java b/BasicJava/ExceptionDemo_multiple_catch-blocks_App/ExceptionDemo/src/ExceptionDemo2.java new file mode 100644 index 000000000..9d20f09b0 --- /dev/null +++ b/BasicJava/ExceptionDemo_multiple_catch-blocks_App/ExceptionDemo/src/ExceptionDemo2.java @@ -0,0 +1,38 @@ +import java.util.ArrayList; +import java.util.Scanner; + +public class ExceptionDemo2 +{ + public static void main(String[] args) + { + Scanner scanner = new Scanner(System.in); + System.out.print("Enter the index : "); + int index = scanner.nextInt(); + scanner.close(); + + ArrayList list = new ArrayList(); + list.add("Dave"); + list.add(null); + System.out.println("list = "+list); + + try + { + String str = list.get(index); + System.out.println("str = " + str); + System.out.println("length = " + str.length()); + } + catch (IndexOutOfBoundsException indexOutOfBoundsException) + { + System.out.println("Enter the index value " + + "less than or equal to 1."); + } + catch (NullPointerException nullPointerException) + { + System.out.println("String value is null,so " + + "cannot calculate the length."); + } + + System.out.println("Normal flow.."); + + } +} diff --git a/BasicJava/ExceptionDemo_multiple_catch-blocks_App/ExceptionDemo1_Output.txt b/BasicJava/ExceptionDemo_multiple_catch-blocks_App/ExceptionDemo1_Output.txt new file mode 100644 index 000000000..b54eaf5ba --- /dev/null +++ b/BasicJava/ExceptionDemo_multiple_catch-blocks_App/ExceptionDemo1_Output.txt @@ -0,0 +1,14 @@ +Enter the index : 8 +list = [Dave, null]Exception in thread "main" + java.lang.IndexOutOfBoundsException: Index: 8, Size: 2 + at java.util.ArrayList.rangeCheck(ArrayList.java:653) + at java.util.ArrayList.get(ArrayList.java:429) + at ExceptionDemo1.main(ExceptionDemo1.java:18) + +------------------------------------------------------------ + +Enter the index : 1 +list = [Dave, null] +str = null +Exception in thread "main" java.lang.NullPointerException + at ExceptionDemo1.main(ExceptionDemo1.java:20) diff --git a/BasicJava/ExceptionDemo_multiple_catch-blocks_App/ExceptionDemo2_Output.txt b/BasicJava/ExceptionDemo_multiple_catch-blocks_App/ExceptionDemo2_Output.txt new file mode 100644 index 000000000..268ba9bb6 --- /dev/null +++ b/BasicJava/ExceptionDemo_multiple_catch-blocks_App/ExceptionDemo2_Output.txt @@ -0,0 +1,12 @@ +Enter the index : 8 +list = [Dave, null] +Enter the index value less than or equal to 1. +Normal flow.. + +---------------------------------------------- + +Enter the index : 1 +list = [Dave, null] +str = null +String value is null,so cannot calculate the length. +Normal flow.. diff --git a/BasicJava/ExceptionDemo_nested_try_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_nested_try_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_nested_try_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_nested_try_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_nested_try_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_nested_try_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_nested_try_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_nested_try_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_nested_try_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_nested_try_App/ExceptionDemo/bin/NestedTryBlockDemo.class b/BasicJava/ExceptionDemo_nested_try_App/ExceptionDemo/bin/NestedTryBlockDemo.class new file mode 100644 index 000000000..6a2e9f7fe Binary files /dev/null and b/BasicJava/ExceptionDemo_nested_try_App/ExceptionDemo/bin/NestedTryBlockDemo.class differ diff --git a/BasicJava/ExceptionDemo_nested_try_App/ExceptionDemo/src/NestedTryBlockDemo.java b/BasicJava/ExceptionDemo_nested_try_App/ExceptionDemo/src/NestedTryBlockDemo.java new file mode 100644 index 000000000..c55b85166 --- /dev/null +++ b/BasicJava/ExceptionDemo_nested_try_App/ExceptionDemo/src/NestedTryBlockDemo.java @@ -0,0 +1,29 @@ +public class NestedTryBlockDemo +{ + public static void main(String args[]) + { + try + { + try + { + int b = 30 / 0; + System.out.println("b = " + b); + } + catch (ArithmeticException arithmeticException) + { + arithmeticException.printStackTrace(); + } + + int a[] = new int[5]; + a[15] = 4; + + System.out.println("Other statements"); + } + catch (Exception exception) + { + exception.printStackTrace(); + } + + System.out.println("normal flow.."); + } +} diff --git a/BasicJava/ExceptionDemo_nested_try_App/Output.txt b/BasicJava/ExceptionDemo_nested_try_App/Output.txt new file mode 100644 index 000000000..2186a4e68 --- /dev/null +++ b/BasicJava/ExceptionDemo_nested_try_App/Output.txt @@ -0,0 +1,5 @@ +java.lang.ArithmeticException: / by zero + at NestedTryBlockDemo.main(NestedTryBlockDemo.java:9) +java.lang.ArrayIndexOutOfBoundsException: 15 + at NestedTryBlockDemo.main(NestedTryBlockDemo.java:18) +normal flow.. diff --git a/BasicJava/ExceptionDemo_stacktrace_info_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_stacktrace_info_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_stacktrace_info_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_stacktrace_info_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_stacktrace_info_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_stacktrace_info_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_stacktrace_info_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_stacktrace_info_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_stacktrace_info_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_stacktrace_info_App/ExceptionDemo/bin/StackTraceDemo.class b/BasicJava/ExceptionDemo_stacktrace_info_App/ExceptionDemo/bin/StackTraceDemo.class new file mode 100644 index 000000000..a41d19f51 Binary files /dev/null and b/BasicJava/ExceptionDemo_stacktrace_info_App/ExceptionDemo/bin/StackTraceDemo.class differ diff --git a/BasicJava/ExceptionDemo_stacktrace_info_App/ExceptionDemo/src/StackTraceDemo.java b/BasicJava/ExceptionDemo_stacktrace_info_App/ExceptionDemo/src/StackTraceDemo.java new file mode 100644 index 000000000..8aba386eb --- /dev/null +++ b/BasicJava/ExceptionDemo_stacktrace_info_App/ExceptionDemo/src/StackTraceDemo.java @@ -0,0 +1,31 @@ +public class StackTraceDemo +{ + + public static void main(String[] args) + { + + try + { + getValue(); + } + catch (Exception cause) + { + StackTraceElement stackTraceElements[] = cause.getStackTrace(); + for (int i = 0, n = stackTraceElements.length; i < n; i++) + { + System.err.println(stackTraceElements[i].getFileName() + ":" + + stackTraceElements[i].getLineNumber() + ">> " + + stackTraceElements[i].getMethodName() + "()"); + } + } + + } + + public static int getValue() + { + int a = 0; + a = 10 / 0; + return a; + } + +} diff --git a/BasicJava/ExceptionDemo_stacktrace_info_App/Output.txt b/BasicJava/ExceptionDemo_stacktrace_info_App/Output.txt new file mode 100644 index 000000000..3c77a71fc --- /dev/null +++ b/BasicJava/ExceptionDemo_stacktrace_info_App/Output.txt @@ -0,0 +1,2 @@ +StackTraceDemo.java:27>> getValue() +StackTraceDemo.java:9>> main() diff --git a/BasicJava/ExceptionDemo_the_try_with_resources_two_zip_writter_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_the_try_with_resources_two_zip_writter_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_the_try_with_resources_two_zip_writter_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_the_try_with_resources_two_zip_writter_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_the_try_with_resources_two_zip_writter_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_the_try_with_resources_two_zip_writter_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_the_try_with_resources_two_zip_writter_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_the_try_with_resources_two_zip_writter_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_the_try_with_resources_two_zip_writter_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_the_try_with_resources_two_zip_writter_App/ExceptionDemo/bin/TryWithResourcesDemo.class b/BasicJava/ExceptionDemo_the_try_with_resources_two_zip_writter_App/ExceptionDemo/bin/TryWithResourcesDemo.class new file mode 100644 index 000000000..e2134f686 Binary files /dev/null and b/BasicJava/ExceptionDemo_the_try_with_resources_two_zip_writter_App/ExceptionDemo/bin/TryWithResourcesDemo.class differ diff --git a/BasicJava/ExceptionDemo_the_try_with_resources_two_zip_writter_App/ExceptionDemo/files.zip b/BasicJava/ExceptionDemo_the_try_with_resources_two_zip_writter_App/ExceptionDemo/files.zip new file mode 100644 index 000000000..c6d56ec13 Binary files /dev/null and b/BasicJava/ExceptionDemo_the_try_with_resources_two_zip_writter_App/ExceptionDemo/files.zip differ diff --git a/BasicJava/ExceptionDemo_the_try_with_resources_two_zip_writter_App/ExceptionDemo/myfile.txt b/BasicJava/ExceptionDemo_the_try_with_resources_two_zip_writter_App/ExceptionDemo/myfile.txt new file mode 100644 index 000000000..116a23add --- /dev/null +++ b/BasicJava/ExceptionDemo_the_try_with_resources_two_zip_writter_App/ExceptionDemo/myfile.txt @@ -0,0 +1,3 @@ +files/ +files/a.txt +files/b.txt diff --git a/BasicJava/ExceptionDemo_the_try_with_resources_two_zip_writter_App/ExceptionDemo/src/TryWithResourcesDemo.java b/BasicJava/ExceptionDemo_the_try_with_resources_two_zip_writter_App/ExceptionDemo/src/TryWithResourcesDemo.java new file mode 100644 index 000000000..1ebdfeff2 --- /dev/null +++ b/BasicJava/ExceptionDemo_the_try_with_resources_two_zip_writter_App/ExceptionDemo/src/TryWithResourcesDemo.java @@ -0,0 +1,51 @@ +public class TryWithResourcesDemo +{ + + public static void main(String[] args) throws Exception + { + TryWithResourcesDemo tryWithResourcesDemo = new TryWithResourcesDemo(); + tryWithResourcesDemo.writeToFileZipFileContents("files.zip", + "myfile.txt"); + System.out + .println("Open zip file and create output file is done."); + + } + + /* + * Retrieves the names of the files packaged in the zip + * file zipFileName and creates a text file that + * contains the names of these files. + */ + + public void writeToFileZipFileContents(String zipFileName, + String outputFileName) throws java.io.IOException + { + + java.nio.charset.Charset charset = java.nio.charset.StandardCharsets.US_ASCII; + java.nio.file.Path outputFilePath = java.nio.file.Paths + .get(outputFileName); + + // Open zip file and create output file with + // try-with-resources statement + + try (java.util.zip.ZipFile zipFile = new java.util.zip.ZipFile( + zipFileName); + java.io.BufferedWriter bufferedWriter = java.nio.file.Files + .newBufferedWriter(outputFilePath, charset)) + { + + // Enumerate each entry + for (java.util.Enumeration entries = zipFile.entries(); entries + .hasMoreElements();) + { + // Get the entry name and write it to the + // output file + String newLine = System.getProperty("line.separator"); + String zipEntryName = ((java.util.zip.ZipEntry) entries + .nextElement()).getName() + newLine; + bufferedWriter.write(zipEntryName, 0, + zipEntryName.length()); + } + } + } +} diff --git a/BasicJava/ExceptionDemo_the_try_with_resources_two_zip_writter_App/Output.txt b/BasicJava/ExceptionDemo_the_try_with_resources_two_zip_writter_App/Output.txt new file mode 100644 index 000000000..e1e85be69 --- /dev/null +++ b/BasicJava/ExceptionDemo_the_try_with_resources_two_zip_writter_App/Output.txt @@ -0,0 +1 @@ +Open zip file and create output file is done. diff --git a/BasicJava/ExceptionDemo_three_kinds_of_Exception_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_three_kinds_of_Exception_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_three_kinds_of_Exception_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_three_kinds_of_Exception_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_three_kinds_of_Exception_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_three_kinds_of_Exception_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_three_kinds_of_Exception_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_three_kinds_of_Exception_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_three_kinds_of_Exception_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_three_kinds_of_Exception_App/ExceptionDemo/bin/ExceptionDemo.class b/BasicJava/ExceptionDemo_three_kinds_of_Exception_App/ExceptionDemo/bin/ExceptionDemo.class new file mode 100644 index 000000000..5f7be86c6 Binary files /dev/null and b/BasicJava/ExceptionDemo_three_kinds_of_Exception_App/ExceptionDemo/bin/ExceptionDemo.class differ diff --git a/BasicJava/ExceptionDemo_three_kinds_of_Exception_App/ExceptionDemo/bin/OutOfMemoryDemo.class b/BasicJava/ExceptionDemo_three_kinds_of_Exception_App/ExceptionDemo/bin/OutOfMemoryDemo.class new file mode 100644 index 000000000..67f015487 Binary files /dev/null and b/BasicJava/ExceptionDemo_three_kinds_of_Exception_App/ExceptionDemo/bin/OutOfMemoryDemo.class differ diff --git a/BasicJava/ExceptionDemo_three_kinds_of_Exception_App/ExceptionDemo/src/ExceptionDemo.java b/BasicJava/ExceptionDemo_three_kinds_of_Exception_App/ExceptionDemo/src/ExceptionDemo.java new file mode 100644 index 000000000..00ff083e4 --- /dev/null +++ b/BasicJava/ExceptionDemo_three_kinds_of_Exception_App/ExceptionDemo/src/ExceptionDemo.java @@ -0,0 +1,77 @@ +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.util.Scanner; + +public class ExceptionDemo +{ + + public static void main(String[] args) + { + String fileName = null; + Scanner scanner = new Scanner(System.in); + + System.out.print("Enter the fileName:"); + String value = scanner.next(); + if (value.length() > 5) + { + fileName = value; + } + + scanner.close(); + + FileReader fileReader = null; + + // Handle them using try-catch blocks. + try + { + + /* + * This constructor FileReader(File filename) + * throws FileNotFoundException which is a + * checked exception + */ + fileReader = new FileReader(fileName); + int i; + + /* + * Method read() of FileReader class also throws + * a checked exception: IOException + */ + while ((i = fileReader.read()) != -1) + { + System.out.print((char) i); + } + + } + catch (FileNotFoundException fileNotFoundException) + { + System.out.println("The specified file is not " + + "present at the given path."); + } + catch (IOException ioException) + { + System.out.println("I/O error occurred: " + ioException); + } + finally + { + try + { + System.out.println(" \nInside finally block"); + /* + * The method close() closes the + * fileReader,It throws IOException + */ + if (fileReader != null) + { + fileReader.close(); + } + } + catch (IOException e) + { + e.printStackTrace(); + } + } + + } +} diff --git a/BasicJava/ExceptionDemo_three_kinds_of_Exception_App/ExceptionDemo/src/OutOfMemoryDemo.java b/BasicJava/ExceptionDemo_three_kinds_of_Exception_App/ExceptionDemo/src/OutOfMemoryDemo.java new file mode 100644 index 000000000..c5590818a --- /dev/null +++ b/BasicJava/ExceptionDemo_three_kinds_of_Exception_App/ExceptionDemo/src/OutOfMemoryDemo.java @@ -0,0 +1,20 @@ +import java.util.HashMap; +import java.util.LinkedHashMap; + + +public class OutOfMemoryDemo +{ + + public static void main(String[] args) + { + String str = "Hello"; + HashMap map = new LinkedHashMap(); + while(true) + { + str = str+"Welcome to india"; + map.put(str, str); + } + + } + +} diff --git a/BasicJava/ExceptionDemo_three_kinds_of_Exception_App/ExceptionDemo_Output.txt b/BasicJava/ExceptionDemo_three_kinds_of_Exception_App/ExceptionDemo_Output.txt new file mode 100644 index 000000000..53a12f1e9 --- /dev/null +++ b/BasicJava/ExceptionDemo_three_kinds_of_Exception_App/ExceptionDemo_Output.txt @@ -0,0 +1,15 @@ +Enter the fileName:hello.txt +The specified file is not present at the given path. + +Inside finally block + +---------------------------------------------- + +Enter the fileName:a.txt + +Inside finally block +Exception in thread "main" java.lang.NullPointerException + at java.io.FileInputStream.(FileInputStream.java:130) + at java.io.FileInputStream.(FileInputStream.java:93) + at java.io.FileReader.(FileReader.java:58) + at ExceptionDemo.main(ExceptionDemo.java:34) diff --git a/BasicJava/ExceptionDemo_three_kinds_of_Exception_App/OutOfMemoryDemo_Output.txt b/BasicJava/ExceptionDemo_three_kinds_of_Exception_App/OutOfMemoryDemo_Output.txt new file mode 100644 index 000000000..e8b086c3a --- /dev/null +++ b/BasicJava/ExceptionDemo_three_kinds_of_Exception_App/OutOfMemoryDemo_Output.txt @@ -0,0 +1,5 @@ +Exception in thread "main" java.lang.OutOfMemoryError: Java heap space + at java.util.Arrays.copyOfRange(Unknown Source) + at java.lang.String.(Unknown Source) + at java.lang.StringBuilder.toString(Unknown Source) + at OutOfMemoryDemo.main(OutOfMemoryDemo.java:14) diff --git a/BasicJava/ExceptionDemo_throw_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_throw_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_throw_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_throw_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_throw_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_throw_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_throw_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_throw_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_throw_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_throw_App/ExceptionDemo/bin/ThrowDemo.class b/BasicJava/ExceptionDemo_throw_App/ExceptionDemo/bin/ThrowDemo.class new file mode 100644 index 000000000..ee152a66a Binary files /dev/null and b/BasicJava/ExceptionDemo_throw_App/ExceptionDemo/bin/ThrowDemo.class differ diff --git a/BasicJava/ExceptionDemo_throw_App/ExceptionDemo/bin/ThrowHandlingDemo.class b/BasicJava/ExceptionDemo_throw_App/ExceptionDemo/bin/ThrowHandlingDemo.class new file mode 100644 index 000000000..6ab202324 Binary files /dev/null and b/BasicJava/ExceptionDemo_throw_App/ExceptionDemo/bin/ThrowHandlingDemo.class differ diff --git a/BasicJava/ExceptionDemo_throw_App/ExceptionDemo/src/ThrowDemo.java b/BasicJava/ExceptionDemo_throw_App/ExceptionDemo/src/ThrowDemo.java new file mode 100644 index 000000000..8e7b75c69 --- /dev/null +++ b/BasicJava/ExceptionDemo_throw_App/ExceptionDemo/src/ThrowDemo.java @@ -0,0 +1,22 @@ + +public class ThrowDemo +{ + public static void main(String[] args) + { + ThrowDemo throwDemo = new ThrowDemo(); + throwDemo.validateAge(15); + System.out.println("Validated.."); + } + + public void validateAge(int age) + { + if (age < 25) + { + throw new ArithmeticException("Not eligible to apply for Govt Jobs"); + } + else + { + System.out.println("Eligible to apply for Govt Jobs"); + } + } +} \ No newline at end of file diff --git a/BasicJava/ExceptionDemo_throw_App/ExceptionDemo/src/ThrowHandlingDemo.java b/BasicJava/ExceptionDemo_throw_App/ExceptionDemo/src/ThrowHandlingDemo.java new file mode 100644 index 000000000..46f4e338c --- /dev/null +++ b/BasicJava/ExceptionDemo_throw_App/ExceptionDemo/src/ThrowHandlingDemo.java @@ -0,0 +1,33 @@ +public class ThrowHandlingDemo +{ + + public static void main(String[] args) + { + ThrowHandlingDemo throwHandlingDemo = new ThrowHandlingDemo(); + + try + { + throwHandlingDemo.validateAge(15); + } + catch(ArithmeticException arithmeticException) + { + System.out.println(arithmeticException.getMessage()); + } + + System.out.println("Validated.."); + + } + + public void validateAge(int age) + { + if (age < 25) + { + throw new ArithmeticException("Not eligible to apply for Govt Jobs"); + } + else + { + System.out.println("Eligible to apply for Govt Jobs."); + } + } + +} diff --git a/BasicJava/ExceptionDemo_throw_App/ThrowDemo_Output.txt b/BasicJava/ExceptionDemo_throw_App/ThrowDemo_Output.txt new file mode 100644 index 000000000..d4229a5f8 --- /dev/null +++ b/BasicJava/ExceptionDemo_throw_App/ThrowDemo_Output.txt @@ -0,0 +1,3 @@ +Exception in thread "main" java.lang.ArithmeticException: Not eligible to apply for Govt Jobs + at ThrowDemo.validateAge(ThrowDemo.java:15) + at ThrowDemo.main(ThrowDemo.java:7) diff --git a/BasicJava/ExceptionDemo_throw_App/ThrowHandlingDemo_Output.txt b/BasicJava/ExceptionDemo_throw_App/ThrowHandlingDemo_Output.txt new file mode 100644 index 000000000..7e71ef2de --- /dev/null +++ b/BasicJava/ExceptionDemo_throw_App/ThrowHandlingDemo_Output.txt @@ -0,0 +1,2 @@ +Not eligible to apply for Govt Jobs +Validated.. diff --git a/BasicJava/ExceptionDemo_throw_exception_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_throw_exception_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_throw_exception_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_throw_exception_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_throw_exception_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_throw_exception_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_throw_exception_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_throw_exception_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_throw_exception_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_throw_exception_App/ExceptionDemo/bin/ThrowDemo.class b/BasicJava/ExceptionDemo_throw_exception_App/ExceptionDemo/bin/ThrowDemo.class new file mode 100644 index 000000000..638483c4e Binary files /dev/null and b/BasicJava/ExceptionDemo_throw_exception_App/ExceptionDemo/bin/ThrowDemo.class differ diff --git a/BasicJava/ExceptionDemo_throw_exception_App/ExceptionDemo/myfile.txt b/BasicJava/ExceptionDemo_throw_exception_App/ExceptionDemo/myfile.txt new file mode 100644 index 000000000..a4f6ac69e --- /dev/null +++ b/BasicJava/ExceptionDemo_throw_exception_App/ExceptionDemo/myfile.txt @@ -0,0 +1,3 @@ +Peter +David +John diff --git a/BasicJava/ExceptionDemo_throw_exception_App/ExceptionDemo/src/ThrowDemo.java b/BasicJava/ExceptionDemo_throw_exception_App/ExceptionDemo/src/ThrowDemo.java new file mode 100644 index 000000000..8c87a98f2 --- /dev/null +++ b/BasicJava/ExceptionDemo_throw_exception_App/ExceptionDemo/src/ThrowDemo.java @@ -0,0 +1,18 @@ +public class ThrowDemo +{ + + public static void main(String[] args) + { + getNumber("aaa"); + } + + public static int getNumber(String value) + { + if (!value.matches("[0-9]+")) + { + throw new ArithmeticException(); + } + return Integer.parseInt(value); + } + +} diff --git a/BasicJava/ExceptionDemo_throw_exception_App/Output.txt b/BasicJava/ExceptionDemo_throw_exception_App/Output.txt new file mode 100644 index 000000000..e66768a25 --- /dev/null +++ b/BasicJava/ExceptionDemo_throw_exception_App/Output.txt @@ -0,0 +1,3 @@ +Exception in thread "main" java.lang.ArithmeticException + at ThrowDemo.getNumber(ThrowDemo.java:13) + at ThrowDemo.main(ThrowDemo.java:6) diff --git a/BasicJava/ExceptionDemo_throws_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_throws_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_throws_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_throws_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_throws_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_throws_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_throws_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_throws_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_throws_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_throws_App/ExceptionDemo/bin/ThrowsDemo1.class b/BasicJava/ExceptionDemo_throws_App/ExceptionDemo/bin/ThrowsDemo1.class new file mode 100644 index 000000000..176eac293 Binary files /dev/null and b/BasicJava/ExceptionDemo_throws_App/ExceptionDemo/bin/ThrowsDemo1.class differ diff --git a/BasicJava/ExceptionDemo_throws_App/ExceptionDemo/bin/ThrowsDemo2.class b/BasicJava/ExceptionDemo_throws_App/ExceptionDemo/bin/ThrowsDemo2.class new file mode 100644 index 000000000..667d08f8a Binary files /dev/null and b/BasicJava/ExceptionDemo_throws_App/ExceptionDemo/bin/ThrowsDemo2.class differ diff --git a/BasicJava/ExceptionDemo_throws_App/ExceptionDemo/bin/ThrowsDemo3.class b/BasicJava/ExceptionDemo_throws_App/ExceptionDemo/bin/ThrowsDemo3.class new file mode 100644 index 000000000..ac56044ab Binary files /dev/null and b/BasicJava/ExceptionDemo_throws_App/ExceptionDemo/bin/ThrowsDemo3.class differ diff --git a/BasicJava/ExceptionDemo_throws_App/ExceptionDemo/myfile.txt b/BasicJava/ExceptionDemo_throws_App/ExceptionDemo/myfile.txt new file mode 100644 index 000000000..f975aa079 --- /dev/null +++ b/BasicJava/ExceptionDemo_throws_App/ExceptionDemo/myfile.txt @@ -0,0 +1,3 @@ +Peter +David +Julia \ No newline at end of file diff --git a/BasicJava/ExceptionDemo_throws_App/ExceptionDemo/src/ThrowsDemo1.java b/BasicJava/ExceptionDemo_throws_App/ExceptionDemo/src/ThrowsDemo1.java new file mode 100644 index 000000000..9aaefd5c8 --- /dev/null +++ b/BasicJava/ExceptionDemo_throws_App/ExceptionDemo/src/ThrowsDemo1.java @@ -0,0 +1,54 @@ +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import java.util.Scanner; + +public class ThrowsDemo1 +{ + public static void main(String[] args) + { + + try + { + new ThrowsDemo1().getFileInfo(); + } + catch (IOException e) + { + System.out.println("Exception handled."); + } + + System.out.println("normal flow..."); + + } + + private void getFileInfo() throws IOException + { + + Scanner scanner = new Scanner(System.in); + System.out.print("Enter the fileName : "); + String fileName = scanner.nextLine(); + scanner.close(); + + /* + * Wrap a BufferedReader around FileReader. + */ + BufferedReader bufferedReader = new BufferedReader( + new FileReader(fileName)); + + /* + * Use the readLine method of the BufferedReader to + * read one line at a time. the readLine method + * returns null when there is nothing else to read. + */ + String line = null; + + while ((line = bufferedReader.readLine()) != null) + { + System.out.println(line); + } + + // Close the BufferedReader when we're done. + bufferedReader.close(); + } + +} \ No newline at end of file diff --git a/BasicJava/ExceptionDemo_throws_App/ExceptionDemo/src/ThrowsDemo2.java b/BasicJava/ExceptionDemo_throws_App/ExceptionDemo/src/ThrowsDemo2.java new file mode 100644 index 000000000..e74a7c94b --- /dev/null +++ b/BasicJava/ExceptionDemo_throws_App/ExceptionDemo/src/ThrowsDemo2.java @@ -0,0 +1,63 @@ +import java.io.BufferedReader; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.util.Scanner; + +public class ThrowsDemo2 +{ + public static void main(String[] args) + { + + try + { + new ThrowsDemo2().getFileInfo(); + } + catch (FileNotFoundException exe) + { + System.out.println("Exception handled inside FileNotFoundException catch block."); + } + catch (IOException exe) + { + System.out.println("Exception handled inside IOException catch block."); + } + catch (Exception exe) + { + System.out.println("Exception handled inside Exception catch block."); + } + System.out.println("normal flow..."); + + } + + private void getFileInfo() throws FileNotFoundException, + IOException, Exception + { + + Scanner scanner = new Scanner(System.in); + System.out.print("Enter the fileName : "); + String fileName = scanner.nextLine(); + scanner.close(); + + /* + * Wrap a BufferedReader around FileReader. + */ + BufferedReader bufferedReader = new BufferedReader( + new FileReader(fileName)); + + /* + * Use the readLine method of the BufferedReader to + * read one line at a time. the readLine method + * returns null when there is nothing else to read. + */ + String line = null; + + while ((line = bufferedReader.readLine()) != null) + { + System.out.println(line); + } + + // Close the BufferedReader when we're done. + bufferedReader.close(); + } + +} \ No newline at end of file diff --git a/BasicJava/ExceptionDemo_throws_App/ExceptionDemo/src/ThrowsDemo3.java b/BasicJava/ExceptionDemo_throws_App/ExceptionDemo/src/ThrowsDemo3.java new file mode 100644 index 000000000..4a10a5ee7 --- /dev/null +++ b/BasicJava/ExceptionDemo_throws_App/ExceptionDemo/src/ThrowsDemo3.java @@ -0,0 +1,46 @@ +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import java.util.Scanner; + +public class ThrowsDemo3 +{ + public static void main(String[] args) throws IOException + { + + new ThrowsDemo3().getFileInfo(); + System.out.println("normal flow..."); + + } + + private void getFileInfo() throws IOException + { + + Scanner scanner = new Scanner(System.in); + System.out.print("Enter the fileName : "); + String fileName = scanner.nextLine(); + scanner.close(); + + /* + * Wrap a BufferedReader around FileReader. + */ + BufferedReader bufferedReader = new BufferedReader( + new FileReader(fileName)); + + /* + * Use the readLine method of the BufferedReader to + * read one line at a time. the readLine method + * returns null when there is nothing else to read. + */ + String line = null; + + while ((line = bufferedReader.readLine()) != null) + { + System.out.println(line); + } + + // Close the BufferedReader when we're done. + bufferedReader.close(); + } + +} \ No newline at end of file diff --git a/BasicJava/ExceptionDemo_throws_App/ThrowsDemo1_Output.txt b/BasicJava/ExceptionDemo_throws_App/ThrowsDemo1_Output.txt new file mode 100644 index 000000000..c120d452d --- /dev/null +++ b/BasicJava/ExceptionDemo_throws_App/ThrowsDemo1_Output.txt @@ -0,0 +1,11 @@ +Enter the fileName : myfile.txt +Peter +David +Julia +normal flow... + +--------------------------------- + +Enter the fileName : hi.txt +Exception handled. +normal flow... diff --git a/BasicJava/ExceptionDemo_throws_App/ThrowsDemo2_Output.txt b/BasicJava/ExceptionDemo_throws_App/ThrowsDemo2_Output.txt new file mode 100644 index 000000000..375bc4826 --- /dev/null +++ b/BasicJava/ExceptionDemo_throws_App/ThrowsDemo2_Output.txt @@ -0,0 +1,3 @@ +Enter the fileName : hi.txt +Exception handled inside FileNotFoundException catch block. +normal flow... diff --git a/BasicJava/ExceptionDemo_throws_App/ThrowsDemo3_Output.txt b/BasicJava/ExceptionDemo_throws_App/ThrowsDemo3_Output.txt new file mode 100644 index 000000000..3fc19ac4a --- /dev/null +++ b/BasicJava/ExceptionDemo_throws_App/ThrowsDemo3_Output.txt @@ -0,0 +1,9 @@ +Enter the fileName : hi.txt +Exception in thread "main" java.io.FileNotFoundException: hi.txt (The system cannot find the file specified) + at java.io.FileInputStream.open0(Native Method) + at java.io.FileInputStream.open(FileInputStream.java:195) + at java.io.FileInputStream.(FileInputStream.java:138) + at java.io.FileInputStream.(FileInputStream.java:93) + at java.io.FileReader.(FileReader.java:58) + at ThrowsDemo3.getFileInfo(ThrowsDemo3.java:28) + at ThrowsDemo3.main(ThrowsDemo3.java:11) diff --git a/BasicJava/ExceptionDemo_try_catch_block_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_try_catch_block_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_try_catch_block_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_try_catch_block_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_try_catch_block_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_try_catch_block_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_try_catch_block_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_try_catch_block_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_try_catch_block_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_try_catch_block_App/ExceptionDemo/bin/ExceptionDemo1.class b/BasicJava/ExceptionDemo_try_catch_block_App/ExceptionDemo/bin/ExceptionDemo1.class new file mode 100644 index 000000000..0c3b9f501 Binary files /dev/null and b/BasicJava/ExceptionDemo_try_catch_block_App/ExceptionDemo/bin/ExceptionDemo1.class differ diff --git a/BasicJava/ExceptionDemo_try_catch_block_App/ExceptionDemo/bin/ExceptionDemo2.class b/BasicJava/ExceptionDemo_try_catch_block_App/ExceptionDemo/bin/ExceptionDemo2.class new file mode 100644 index 000000000..ce7615fe7 Binary files /dev/null and b/BasicJava/ExceptionDemo_try_catch_block_App/ExceptionDemo/bin/ExceptionDemo2.class differ diff --git a/BasicJava/ExceptionDemo_try_catch_block_App/ExceptionDemo/src/ExceptionDemo1.java b/BasicJava/ExceptionDemo_try_catch_block_App/ExceptionDemo/src/ExceptionDemo1.java new file mode 100644 index 000000000..7a35bcf4a --- /dev/null +++ b/BasicJava/ExceptionDemo_try_catch_block_App/ExceptionDemo/src/ExceptionDemo1.java @@ -0,0 +1,14 @@ +public class ExceptionDemo1 +{ + public static void main(String[] args) + { + int a = 10; + int b = 0; + + int c = a / b; + + System.out.println("Welcome"); + System.out.println("Hello"); + } + +} diff --git a/BasicJava/ExceptionDemo_try_catch_block_App/ExceptionDemo/src/ExceptionDemo2.java b/BasicJava/ExceptionDemo_try_catch_block_App/ExceptionDemo/src/ExceptionDemo2.java new file mode 100644 index 000000000..2271baaef --- /dev/null +++ b/BasicJava/ExceptionDemo_try_catch_block_App/ExceptionDemo/src/ExceptionDemo2.java @@ -0,0 +1,19 @@ +public class ExceptionDemo2 +{ + public static void main(String[] args) + { + int a = 10; + int b = 0; + try + { + int c = a / b; + } + catch (ArithmeticException arithmeticException) + { + System.out.println("Divided by zero is not possible"); + } + System.out.println("Welcome"); + System.out.println("Hello"); + } + +} diff --git a/BasicJava/ExceptionDemo_try_catch_block_App/ExceptionDemo1_Output.txt b/BasicJava/ExceptionDemo_try_catch_block_App/ExceptionDemo1_Output.txt new file mode 100644 index 000000000..c623d0f4e --- /dev/null +++ b/BasicJava/ExceptionDemo_try_catch_block_App/ExceptionDemo1_Output.txt @@ -0,0 +1,2 @@ +Exception in thread "main" java.lang.ArithmeticException: / by zero + at ExceptionDemo1.main(ExceptionDemo1.java:8) diff --git a/BasicJava/ExceptionDemo_try_catch_block_App/ExceptionDemo2_Output.txt b/BasicJava/ExceptionDemo_try_catch_block_App/ExceptionDemo2_Output.txt new file mode 100644 index 000000000..5ac8920dc --- /dev/null +++ b/BasicJava/ExceptionDemo_try_catch_block_App/ExceptionDemo2_Output.txt @@ -0,0 +1,3 @@ +Divided by zero is not possible +Welcome +Hello diff --git a/BasicJava/ExceptionDemo_try_finally_block_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_try_finally_block_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_try_finally_block_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_try_finally_block_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_try_finally_block_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_try_finally_block_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_try_finally_block_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_try_finally_block_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_try_finally_block_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_try_finally_block_App/ExceptionDemo/bin/FinallyDemo.class b/BasicJava/ExceptionDemo_try_finally_block_App/ExceptionDemo/bin/FinallyDemo.class new file mode 100644 index 000000000..80a6e2960 Binary files /dev/null and b/BasicJava/ExceptionDemo_try_finally_block_App/ExceptionDemo/bin/FinallyDemo.class differ diff --git a/BasicJava/ExceptionDemo_try_finally_block_App/ExceptionDemo/src/FinallyDemo.java b/BasicJava/ExceptionDemo_try_finally_block_App/ExceptionDemo/src/FinallyDemo.java new file mode 100644 index 000000000..de1cb78a4 --- /dev/null +++ b/BasicJava/ExceptionDemo_try_finally_block_App/ExceptionDemo/src/FinallyDemo.java @@ -0,0 +1,23 @@ +import java.util.Scanner; + +public class FinallyDemo +{ + public static void main(String args[]) + { + try + { + Scanner scanner = new Scanner(System.in); + System.out.print("Enter the value of a : "); + int a = scanner.nextInt(); + System.out.print("Enter the value of b : "); + int b = scanner.nextInt(); + scanner.close(); + int c = a / b; + System.out.println("c = " + c); + } + finally + { + System.out.println("finally block is always executed."); + } + } +} diff --git a/BasicJava/ExceptionDemo_try_finally_block_App/Output.txt b/BasicJava/ExceptionDemo_try_finally_block_App/Output.txt new file mode 100644 index 000000000..61339cb13 --- /dev/null +++ b/BasicJava/ExceptionDemo_try_finally_block_App/Output.txt @@ -0,0 +1,12 @@ +Enter the value of a : 10 +Enter the value of b : 5 +c = 2 +finally block is always executed. + +--------------------------------- + +Enter the value of a : 10 +Enter the value of b : 0 +finally block is always executed. +Exception in thread "main" java.lang.ArithmeticException: / by zero + at FinallyDemo.main(FinallyDemo.java:15) diff --git a/BasicJava/ExceptionDemo_try_with_resources_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_try_with_resources_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_try_with_resources_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_try_with_resources_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_try_with_resources_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_try_with_resources_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_try_with_resources_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_try_with_resources_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_try_with_resources_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_try_with_resources_App/ExceptionDemo/bin/ExceptionHandlingDemo.class b/BasicJava/ExceptionDemo_try_with_resources_App/ExceptionDemo/bin/ExceptionHandlingDemo.class new file mode 100644 index 000000000..6d7db22d0 Binary files /dev/null and b/BasicJava/ExceptionDemo_try_with_resources_App/ExceptionDemo/bin/ExceptionHandlingDemo.class differ diff --git a/BasicJava/ExceptionDemo_try_with_resources_App/ExceptionDemo/bin/TryWithResourcesDemo.class b/BasicJava/ExceptionDemo_try_with_resources_App/ExceptionDemo/bin/TryWithResourcesDemo.class new file mode 100644 index 000000000..1a94d00f4 Binary files /dev/null and b/BasicJava/ExceptionDemo_try_with_resources_App/ExceptionDemo/bin/TryWithResourcesDemo.class differ diff --git a/BasicJava/ExceptionDemo_try_with_resources_App/ExceptionDemo/myfile.txt b/BasicJava/ExceptionDemo_try_with_resources_App/ExceptionDemo/myfile.txt new file mode 100644 index 000000000..40816a2b5 --- /dev/null +++ b/BasicJava/ExceptionDemo_try_with_resources_App/ExceptionDemo/myfile.txt @@ -0,0 +1 @@ +Hi \ No newline at end of file diff --git a/BasicJava/ExceptionDemo_try_with_resources_App/ExceptionDemo/src/ExceptionHandlingDemo.java b/BasicJava/ExceptionDemo_try_with_resources_App/ExceptionDemo/src/ExceptionHandlingDemo.java new file mode 100644 index 000000000..427463779 --- /dev/null +++ b/BasicJava/ExceptionDemo_try_with_resources_App/ExceptionDemo/src/ExceptionHandlingDemo.java @@ -0,0 +1,40 @@ +import java.io.FileInputStream; +import java.io.IOException; + +public class ExceptionHandlingDemo +{ + + public static void main(String[] args) + { + FileInputStream fileInputStream = null; + try + { + fileInputStream = new FileInputStream("myfile.txt"); + int data = fileInputStream.read(); + while (data != -1) + { + System.out.print((char) data); + data = fileInputStream.read(); + } + } + catch (IOException e) + { + e.printStackTrace(); + } + finally + { + if (fileInputStream != null) + { + try + { + fileInputStream.close(); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + } + + } +} diff --git a/BasicJava/ExceptionDemo_try_with_resources_App/ExceptionDemo/src/TryWithResourcesDemo.java b/BasicJava/ExceptionDemo_try_with_resources_App/ExceptionDemo/src/TryWithResourcesDemo.java new file mode 100644 index 000000000..f4872a12f --- /dev/null +++ b/BasicJava/ExceptionDemo_try_with_resources_App/ExceptionDemo/src/TryWithResourcesDemo.java @@ -0,0 +1,21 @@ +import java.io.FileInputStream; +import java.io.IOException; + +public class TryWithResourcesDemo +{ + + public static void main(String[] args) throws IOException + { + try (FileInputStream fileInputStream = new FileInputStream("myfile.txt")) + { + int data = fileInputStream.read(); + while (data != -1) + { + System.out.print((char) data); + data = fileInputStream.read(); + } + } + + } + +} diff --git a/BasicJava/ExceptionDemo_try_with_resources_App/ExceptionHandlingDemo_Output.txt b/BasicJava/ExceptionDemo_try_with_resources_App/ExceptionHandlingDemo_Output.txt new file mode 100644 index 000000000..40816a2b5 --- /dev/null +++ b/BasicJava/ExceptionDemo_try_with_resources_App/ExceptionHandlingDemo_Output.txt @@ -0,0 +1 @@ +Hi \ No newline at end of file diff --git a/BasicJava/ExceptionDemo_try_with_resources_App/TryWithResourcesDemo_Output.txt b/BasicJava/ExceptionDemo_try_with_resources_App/TryWithResourcesDemo_Output.txt new file mode 100644 index 000000000..40816a2b5 --- /dev/null +++ b/BasicJava/ExceptionDemo_try_with_resources_App/TryWithResourcesDemo_Output.txt @@ -0,0 +1 @@ +Hi \ No newline at end of file diff --git a/BasicJava/ExceptionDemo_try_with_resources_catch_finally_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_try_with_resources_catch_finally_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_try_with_resources_catch_finally_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_try_with_resources_catch_finally_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_try_with_resources_catch_finally_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_try_with_resources_catch_finally_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_try_with_resources_catch_finally_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_try_with_resources_catch_finally_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_try_with_resources_catch_finally_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_try_with_resources_catch_finally_App/ExceptionDemo/bin/TryWithResourcesDemo.class b/BasicJava/ExceptionDemo_try_with_resources_catch_finally_App/ExceptionDemo/bin/TryWithResourcesDemo.class new file mode 100644 index 000000000..f3282f5d7 Binary files /dev/null and b/BasicJava/ExceptionDemo_try_with_resources_catch_finally_App/ExceptionDemo/bin/TryWithResourcesDemo.class differ diff --git a/BasicJava/ExceptionDemo_try_with_resources_catch_finally_App/ExceptionDemo/myfile.txt b/BasicJava/ExceptionDemo_try_with_resources_catch_finally_App/ExceptionDemo/myfile.txt new file mode 100644 index 000000000..a4f6ac69e --- /dev/null +++ b/BasicJava/ExceptionDemo_try_with_resources_catch_finally_App/ExceptionDemo/myfile.txt @@ -0,0 +1,3 @@ +Peter +David +John diff --git a/BasicJava/ExceptionDemo_try_with_resources_catch_finally_App/ExceptionDemo/src/TryWithResourcesDemo.java b/BasicJava/ExceptionDemo_try_with_resources_catch_finally_App/ExceptionDemo/src/TryWithResourcesDemo.java new file mode 100644 index 000000000..4350d613b --- /dev/null +++ b/BasicJava/ExceptionDemo_try_with_resources_catch_finally_App/ExceptionDemo/src/TryWithResourcesDemo.java @@ -0,0 +1,35 @@ +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; + +public class TryWithResourcesDemo +{ + + public static void main(String[] args) + { + TryWithResourcesDemo tryWithResourcesDemo = new TryWithResourcesDemo(); + String firstLine = tryWithResourcesDemo + .readFirstLineFromFile("myfile.txt"); + System.out.println("firstLine = " + firstLine); + + } + + public String readFirstLineFromFile(String path) + { + try (BufferedReader br = new BufferedReader(new FileReader( + path))) + { + return br.readLine(); + } + catch (IOException e) + { + e.printStackTrace(); + } + finally + { + System.out.println("finally block is called"); + } + return null; + } + +} diff --git a/BasicJava/ExceptionDemo_try_with_resources_catch_finally_App/Output.txt b/BasicJava/ExceptionDemo_try_with_resources_catch_finally_App/Output.txt new file mode 100644 index 000000000..ce15937d1 --- /dev/null +++ b/BasicJava/ExceptionDemo_try_with_resources_catch_finally_App/Output.txt @@ -0,0 +1,2 @@ +finally block is called +firstLine = Peter diff --git a/BasicJava/ExceptionDemo_try_with_resources_multi_App/ExceptionDemo/.classpath b/BasicJava/ExceptionDemo_try_with_resources_multi_App/ExceptionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ExceptionDemo_try_with_resources_multi_App/ExceptionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ExceptionDemo_try_with_resources_multi_App/ExceptionDemo/.project b/BasicJava/ExceptionDemo_try_with_resources_multi_App/ExceptionDemo/.project new file mode 100644 index 000000000..26795d272 --- /dev/null +++ b/BasicJava/ExceptionDemo_try_with_resources_multi_App/ExceptionDemo/.project @@ -0,0 +1,17 @@ + + + ExceptionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ExceptionDemo_try_with_resources_multi_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ExceptionDemo_try_with_resources_multi_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ExceptionDemo_try_with_resources_multi_App/ExceptionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ExceptionDemo_try_with_resources_multi_App/ExceptionDemo/bin/TryWithResourcesDemo.class b/BasicJava/ExceptionDemo_try_with_resources_multi_App/ExceptionDemo/bin/TryWithResourcesDemo.class new file mode 100644 index 000000000..84dd7f088 Binary files /dev/null and b/BasicJava/ExceptionDemo_try_with_resources_multi_App/ExceptionDemo/bin/TryWithResourcesDemo.class differ diff --git a/BasicJava/ExceptionDemo_try_with_resources_multi_App/ExceptionDemo/myfile.txt b/BasicJava/ExceptionDemo_try_with_resources_multi_App/ExceptionDemo/myfile.txt new file mode 100644 index 000000000..f975aa079 --- /dev/null +++ b/BasicJava/ExceptionDemo_try_with_resources_multi_App/ExceptionDemo/myfile.txt @@ -0,0 +1,3 @@ +Peter +David +Julia \ No newline at end of file diff --git a/BasicJava/ExceptionDemo_try_with_resources_multi_App/ExceptionDemo/src/TryWithResourcesDemo.java b/BasicJava/ExceptionDemo_try_with_resources_multi_App/ExceptionDemo/src/TryWithResourcesDemo.java new file mode 100644 index 000000000..4735b9e88 --- /dev/null +++ b/BasicJava/ExceptionDemo_try_with_resources_multi_App/ExceptionDemo/src/TryWithResourcesDemo.java @@ -0,0 +1,25 @@ +import java.io.BufferedInputStream; +import java.io.FileInputStream; +import java.io.IOException; + +public class TryWithResourcesDemo +{ + + public static void main(String[] args) throws IOException + { + try (FileInputStream fileInputStream = new FileInputStream( + "myfile.txt"); + BufferedInputStream bufferedInputStream = new BufferedInputStream( + fileInputStream)) + { + int data = bufferedInputStream.read(); + while (data != -1) + { + System.out.print((char) data); + data = bufferedInputStream.read(); + } + } + + } + +} diff --git a/BasicJava/ExceptionDemo_try_with_resources_multi_App/Output.txt b/BasicJava/ExceptionDemo_try_with_resources_multi_App/Output.txt new file mode 100644 index 000000000..f975aa079 --- /dev/null +++ b/BasicJava/ExceptionDemo_try_with_resources_multi_App/Output.txt @@ -0,0 +1,3 @@ +Peter +David +Julia \ No newline at end of file diff --git a/BasicJava/GenericMethodDemo_App/GenericsDemo/.classpath b/BasicJava/GenericMethodDemo_App/GenericsDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/GenericMethodDemo_App/GenericsDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/GenericMethodDemo_App/GenericsDemo/.project b/BasicJava/GenericMethodDemo_App/GenericsDemo/.project new file mode 100644 index 000000000..860a850fb --- /dev/null +++ b/BasicJava/GenericMethodDemo_App/GenericsDemo/.project @@ -0,0 +1,17 @@ + + + GenericsDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/GenericMethodDemo_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/GenericMethodDemo_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/GenericMethodDemo_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/GenericMethodDemo_App/GenericsDemo/bin/GenericDemo.class b/BasicJava/GenericMethodDemo_App/GenericsDemo/bin/GenericDemo.class new file mode 100644 index 000000000..cf89c7ee9 Binary files /dev/null and b/BasicJava/GenericMethodDemo_App/GenericsDemo/bin/GenericDemo.class differ diff --git a/BasicJava/GenericMethodDemo_App/GenericsDemo/src/GenericDemo.java b/BasicJava/GenericMethodDemo_App/GenericsDemo/src/GenericDemo.java new file mode 100644 index 000000000..e8daf8ed3 --- /dev/null +++ b/BasicJava/GenericMethodDemo_App/GenericsDemo/src/GenericDemo.java @@ -0,0 +1,33 @@ +/* + * Like generic class, we can create generic method that can accept any type + * of argument. + * + * Let’s see a simple example of java generic method to print + * array elements. We are using here E to denote the element. + */ +public class GenericDemo +{ + public static void main(String[] args) + { + Integer[] intArray = + { 100, 200, 300, 400, 500 }; + + System.out.println("Printing Integer Array"); + printArray(intArray); + + Character[] charArray = + { 'J', 'A', 'V', 'A' }; + + System.out.println("Printing Character Array"); + printArray(charArray); + } + + public static void printArray(E[] elements) + { + for (E element : elements) + { + System.out.println(element); + } + System.out.println(); + } +} \ No newline at end of file diff --git a/BasicJava/GenericMethodDemo_App/Output.txt b/BasicJava/GenericMethodDemo_App/Output.txt new file mode 100644 index 000000000..aead0274b --- /dev/null +++ b/BasicJava/GenericMethodDemo_App/Output.txt @@ -0,0 +1,13 @@ +Printing Integer Array +100 +200 +300 +400 +500 + +Printing Character Array +J +A +V +A + diff --git a/BasicJava/GenericsDemo-wildcard_App/GenericsDemo/.classpath b/BasicJava/GenericsDemo-wildcard_App/GenericsDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/GenericsDemo-wildcard_App/GenericsDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/GenericsDemo-wildcard_App/GenericsDemo/.project b/BasicJava/GenericsDemo-wildcard_App/GenericsDemo/.project new file mode 100644 index 000000000..860a850fb --- /dev/null +++ b/BasicJava/GenericsDemo-wildcard_App/GenericsDemo/.project @@ -0,0 +1,17 @@ + + + GenericsDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/GenericsDemo-wildcard_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/GenericsDemo-wildcard_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/GenericsDemo-wildcard_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/GenericsDemo-wildcard_App/GenericsDemo/bin/Circle.class b/BasicJava/GenericsDemo-wildcard_App/GenericsDemo/bin/Circle.class new file mode 100644 index 000000000..1036ccf56 Binary files /dev/null and b/BasicJava/GenericsDemo-wildcard_App/GenericsDemo/bin/Circle.class differ diff --git a/BasicJava/GenericsDemo-wildcard_App/GenericsDemo/bin/GenericDemo.class b/BasicJava/GenericsDemo-wildcard_App/GenericsDemo/bin/GenericDemo.class new file mode 100644 index 000000000..612557f4b Binary files /dev/null and b/BasicJava/GenericsDemo-wildcard_App/GenericsDemo/bin/GenericDemo.class differ diff --git a/BasicJava/GenericsDemo-wildcard_App/GenericsDemo/bin/Rectangle.class b/BasicJava/GenericsDemo-wildcard_App/GenericsDemo/bin/Rectangle.class new file mode 100644 index 000000000..a017e867f Binary files /dev/null and b/BasicJava/GenericsDemo-wildcard_App/GenericsDemo/bin/Rectangle.class differ diff --git a/BasicJava/GenericsDemo-wildcard_App/GenericsDemo/bin/Shape.class b/BasicJava/GenericsDemo-wildcard_App/GenericsDemo/bin/Shape.class new file mode 100644 index 000000000..4b5cfeab6 Binary files /dev/null and b/BasicJava/GenericsDemo-wildcard_App/GenericsDemo/bin/Shape.class differ diff --git a/BasicJava/GenericsDemo-wildcard_App/GenericsDemo/src/GenericDemo.java b/BasicJava/GenericsDemo-wildcard_App/GenericsDemo/src/GenericDemo.java new file mode 100644 index 000000000..e531612c6 --- /dev/null +++ b/BasicJava/GenericsDemo-wildcard_App/GenericsDemo/src/GenericDemo.java @@ -0,0 +1,31 @@ +import java.util.ArrayList; +import java.util.List; + +public class GenericDemo +{ + + public static void main(String args[]) + { + List recList = new ArrayList(); + recList.add(new Rectangle()); + recList.add(new Rectangle()); + drawShapes(recList); + + List circleList = new ArrayList(); + circleList.add(new Circle()); + circleList.add(new Circle()); + drawShapes(circleList); + } + + /* + * This method accepts only the list contains child class of Shape + */ + public static void drawShapes(List shapeList) + { + for (Shape shape : shapeList) + { + shape.draw(); + } + } + +} \ No newline at end of file diff --git a/BasicJava/GenericsDemo-wildcard_App/GenericsDemo/src/Shape.java b/BasicJava/GenericsDemo-wildcard_App/GenericsDemo/src/Shape.java new file mode 100644 index 000000000..1afcf8abc --- /dev/null +++ b/BasicJava/GenericsDemo-wildcard_App/GenericsDemo/src/Shape.java @@ -0,0 +1,20 @@ +public abstract class Shape +{ + abstract void draw(); +} + +class Circle extends Shape +{ + void draw() + { + System.out.println("drawing circle"); + } +} + +class Rectangle extends Shape +{ + void draw() + { + System.out.println("drawing rectangle"); + } +} diff --git a/BasicJava/GenericsDemo-wildcard_App/Output.txt b/BasicJava/GenericsDemo-wildcard_App/Output.txt new file mode 100644 index 000000000..5ed0c21bd --- /dev/null +++ b/BasicJava/GenericsDemo-wildcard_App/Output.txt @@ -0,0 +1,4 @@ +drawing rectangle +drawing rectangle +drawing circle +drawing circle diff --git a/BasicJava/GenericsDemo_AL_App/GenericsDemo/.classpath b/BasicJava/GenericsDemo_AL_App/GenericsDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/GenericsDemo_AL_App/GenericsDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/GenericsDemo_AL_App/GenericsDemo/.project b/BasicJava/GenericsDemo_AL_App/GenericsDemo/.project new file mode 100644 index 000000000..860a850fb --- /dev/null +++ b/BasicJava/GenericsDemo_AL_App/GenericsDemo/.project @@ -0,0 +1,17 @@ + + + GenericsDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/GenericsDemo_AL_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/GenericsDemo_AL_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/GenericsDemo_AL_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/GenericsDemo_AL_App/GenericsDemo/bin/GenericDemo.class b/BasicJava/GenericsDemo_AL_App/GenericsDemo/bin/GenericDemo.class new file mode 100644 index 000000000..45224fb9a Binary files /dev/null and b/BasicJava/GenericsDemo_AL_App/GenericsDemo/bin/GenericDemo.class differ diff --git a/BasicJava/GenericsDemo_AL_App/GenericsDemo/src/GenericDemo.java b/BasicJava/GenericsDemo_AL_App/GenericsDemo/src/GenericDemo.java new file mode 100644 index 000000000..f96482eeb --- /dev/null +++ b/BasicJava/GenericsDemo_AL_App/GenericsDemo/src/GenericDemo.java @@ -0,0 +1,34 @@ +import java.util.ArrayList; +import java.util.Iterator; +/* + * Example of Generics in Java + * + * Here, we are using the ArrayList class, but you can use any collection + * class such as ArrayList, LinkedList, HashSet, TreeSet, HashMap, + * Comparator etc. + */ + +public class GenericDemo +{ + public static void main(String[] args) + { + ArrayList arrayList = new ArrayList(); + arrayList.add("Peter"); + arrayList.add("Ram"); + arrayList.add("Juli"); + //arrayList.add(32);//compile time error + + System.out.println(arrayList); + /* + * type casting is not required + */ + String stringValue = arrayList.get(0); + System.out.println("stringValue = " + stringValue + "\n"); + + Iterator itr = arrayList.iterator(); + while (itr.hasNext()) + { + System.out.println(itr.next()); + } + } +} \ No newline at end of file diff --git a/BasicJava/GenericsDemo_AL_App/Output.txt b/BasicJava/GenericsDemo_AL_App/Output.txt new file mode 100644 index 000000000..7b148b49b --- /dev/null +++ b/BasicJava/GenericsDemo_AL_App/Output.txt @@ -0,0 +1,6 @@ +[Peter, Ram, Juli] +stringValue = Peter + +Peter +Ram +Juli diff --git a/BasicJava/GenericsDemo_Bounded_TP_App/GenericsDemo/.classpath b/BasicJava/GenericsDemo_Bounded_TP_App/GenericsDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/GenericsDemo_Bounded_TP_App/GenericsDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/GenericsDemo_Bounded_TP_App/GenericsDemo/.project b/BasicJava/GenericsDemo_Bounded_TP_App/GenericsDemo/.project new file mode 100644 index 000000000..860a850fb --- /dev/null +++ b/BasicJava/GenericsDemo_Bounded_TP_App/GenericsDemo/.project @@ -0,0 +1,17 @@ + + + GenericsDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/GenericsDemo_Bounded_TP_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/GenericsDemo_Bounded_TP_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/GenericsDemo_Bounded_TP_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/GenericsDemo_Bounded_TP_App/GenericsDemo/bin/Box.class b/BasicJava/GenericsDemo_Bounded_TP_App/GenericsDemo/bin/Box.class new file mode 100644 index 000000000..76de036f3 Binary files /dev/null and b/BasicJava/GenericsDemo_Bounded_TP_App/GenericsDemo/bin/Box.class differ diff --git a/BasicJava/GenericsDemo_Bounded_TP_App/GenericsDemo/bin/GenericDemo.class b/BasicJava/GenericsDemo_Bounded_TP_App/GenericsDemo/bin/GenericDemo.class new file mode 100644 index 000000000..5e1341476 Binary files /dev/null and b/BasicJava/GenericsDemo_Bounded_TP_App/GenericsDemo/bin/GenericDemo.class differ diff --git a/BasicJava/GenericsDemo_Bounded_TP_App/GenericsDemo/src/Box.java b/BasicJava/GenericsDemo_Bounded_TP_App/GenericsDemo/src/Box.java new file mode 100644 index 000000000..3e943f22b --- /dev/null +++ b/BasicJava/GenericsDemo_Bounded_TP_App/GenericsDemo/src/Box.java @@ -0,0 +1,22 @@ +public class Box +{ + + private T t; + + public void set(T t) + { + this.t = t; + } + + public T get() + { + return t; + } + + public void inspect(U u) + { + System.out.println("T: " + t.getClass().getName()); + System.out.println("U: " + u.getClass().getName()); + } + +} \ No newline at end of file diff --git a/BasicJava/GenericsDemo_Bounded_TP_App/GenericsDemo/src/GenericDemo.java b/BasicJava/GenericsDemo_Bounded_TP_App/GenericsDemo/src/GenericDemo.java new file mode 100644 index 000000000..996be80f7 --- /dev/null +++ b/BasicJava/GenericsDemo_Bounded_TP_App/GenericsDemo/src/GenericDemo.java @@ -0,0 +1,21 @@ +public class GenericDemo +{ + + public static void main(String[] args) + { + Box integerBox = new Box(); + integerBox.set(new Integer(100)); + integerBox.inspect(new Integer(200)); + System.out.println("-------------------"); + integerBox.inspect(new Double(20.23)); + System.out.println("-------------------"); + integerBox.inspect(new Long(2000)); + + /* + * error: this is still String! + */ + //integerBox.inspect("some text"); + + } + +} diff --git a/BasicJava/GenericsDemo_Bounded_TP_App/Output.txt b/BasicJava/GenericsDemo_Bounded_TP_App/Output.txt new file mode 100644 index 000000000..f037defb9 --- /dev/null +++ b/BasicJava/GenericsDemo_Bounded_TP_App/Output.txt @@ -0,0 +1,8 @@ +T: java.lang.Integer +U: java.lang.Integer +------------------- +T: java.lang.Integer +U: java.lang.Double +------------------- +T: java.lang.Integer +U: java.lang.Long diff --git a/BasicJava/GenericsDemo_GenericClass_App/GenericsDemo/.classpath b/BasicJava/GenericsDemo_GenericClass_App/GenericsDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/GenericsDemo_GenericClass_App/GenericsDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/GenericsDemo_GenericClass_App/GenericsDemo/.project b/BasicJava/GenericsDemo_GenericClass_App/GenericsDemo/.project new file mode 100644 index 000000000..860a850fb --- /dev/null +++ b/BasicJava/GenericsDemo_GenericClass_App/GenericsDemo/.project @@ -0,0 +1,17 @@ + + + GenericsDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/GenericsDemo_GenericClass_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/GenericsDemo_GenericClass_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/GenericsDemo_GenericClass_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/GenericsDemo_GenericClass_App/GenericsDemo/bin/GenericDemo.class b/BasicJava/GenericsDemo_GenericClass_App/GenericsDemo/bin/GenericDemo.class new file mode 100644 index 000000000..284ef4096 Binary files /dev/null and b/BasicJava/GenericsDemo_GenericClass_App/GenericsDemo/bin/GenericDemo.class differ diff --git a/BasicJava/GenericsDemo_GenericClass_App/GenericsDemo/bin/MyGeneric.class b/BasicJava/GenericsDemo_GenericClass_App/GenericsDemo/bin/MyGeneric.class new file mode 100644 index 000000000..5042fe4f3 Binary files /dev/null and b/BasicJava/GenericsDemo_GenericClass_App/GenericsDemo/bin/MyGeneric.class differ diff --git a/BasicJava/GenericsDemo_GenericClass_App/GenericsDemo/src/GenericDemo.java b/BasicJava/GenericsDemo_GenericClass_App/GenericsDemo/src/GenericDemo.java new file mode 100644 index 000000000..b18360db7 --- /dev/null +++ b/BasicJava/GenericsDemo_GenericClass_App/GenericsDemo/src/GenericDemo.java @@ -0,0 +1,26 @@ +/* + * Code to use the generic class. + */ +public class GenericDemo +{ + public static void main(String[] args) + { + useInteger(); + useString(); + } + + private static void useInteger() + { + MyGeneric myGeneric=new MyGeneric(); + myGeneric.add(2); + //myGeneric.add("peter");//Compile time error + System.out.println(myGeneric.get()); + } + + private static void useString() + { + MyGeneric myGeneric=new MyGeneric(); + myGeneric.add("Ram"); + System.out.println(myGeneric.get()); + } +} \ No newline at end of file diff --git a/BasicJava/GenericsDemo_GenericClass_App/GenericsDemo/src/MyGeneric.java b/BasicJava/GenericsDemo_GenericClass_App/GenericsDemo/src/MyGeneric.java new file mode 100644 index 000000000..7ccfa65f0 --- /dev/null +++ b/BasicJava/GenericsDemo_GenericClass_App/GenericsDemo/src/MyGeneric.java @@ -0,0 +1,14 @@ +class MyGeneric +{ + T obj; + + void add(T obj) + { + this.obj = obj; + } + + T get() + { + return obj; + } +} \ No newline at end of file diff --git a/BasicJava/GenericsDemo_GenericClass_App/Output.txt b/BasicJava/GenericsDemo_GenericClass_App/Output.txt new file mode 100644 index 000000000..6b1e0fdc9 --- /dev/null +++ b/BasicJava/GenericsDemo_GenericClass_App/Output.txt @@ -0,0 +1,2 @@ +2 +Ram diff --git a/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/.classpath b/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/.project b/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/.project new file mode 100644 index 000000000..860a850fb --- /dev/null +++ b/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/.project @@ -0,0 +1,17 @@ + + + GenericsDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/bin/Bird.class b/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/bin/Bird.class new file mode 100644 index 000000000..1470cdc9b Binary files /dev/null and b/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/bin/Bird.class differ diff --git a/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/bin/Employee.class b/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/bin/Employee.class new file mode 100644 index 000000000..62adc57be Binary files /dev/null and b/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/bin/Employee.class differ diff --git a/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/bin/GenericDemo.class b/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/bin/GenericDemo.class new file mode 100644 index 000000000..30a99c7f8 Binary files /dev/null and b/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/bin/GenericDemo.class differ diff --git a/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/bin/GenericFactory.class b/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/bin/GenericFactory.class new file mode 100644 index 000000000..d15bca67b Binary files /dev/null and b/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/bin/GenericFactory.class differ diff --git a/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/src/Bird.java b/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/src/Bird.java new file mode 100644 index 000000000..efa84a960 --- /dev/null +++ b/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/src/Bird.java @@ -0,0 +1,16 @@ + +public class Bird +{ + private String birdName; + + public String getBirdName() + { + return birdName; + } + + public void setBirdName(String birdName) + { + this.birdName = birdName; + } + +} diff --git a/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/src/Employee.java b/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/src/Employee.java new file mode 100644 index 000000000..8bb3f2ed0 --- /dev/null +++ b/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/src/Employee.java @@ -0,0 +1,16 @@ + +public class Employee +{ + private String name; + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + +} diff --git a/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/src/GenericDemo.java b/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/src/GenericDemo.java new file mode 100644 index 000000000..56466f1d1 --- /dev/null +++ b/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/src/GenericDemo.java @@ -0,0 +1,22 @@ +public class GenericDemo +{ + public static void main(String[] args) + throws IllegalAccessException, InstantiationException + { + + /* + * It is not necessary to cast the object returned from the + * factory.createInstance() method. The compiler can deduct the type of + * the object from the generic type of the GenericFactory created, + * because you specified the type inside the <>. + */ + GenericFactory empFactory = new GenericFactory(Employee.class); + Employee employee = empFactory.createInstance(); + System.out.println(employee); + + GenericFactory birdFactory = new GenericFactory(Bird.class); + Bird bird = birdFactory.createInstance(); + System.out.println(bird); + } + +} \ No newline at end of file diff --git a/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/src/GenericFactory.java b/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/src/GenericFactory.java new file mode 100644 index 000000000..79a7e0683 --- /dev/null +++ b/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/GenericsDemo/src/GenericFactory.java @@ -0,0 +1,23 @@ +/* + * It is possible to generify your own Java classes. Generics is not + * restricted to the predefined classes in the Java API's. + * + * The is a type token that signals that this class can have a type set + * when instantiated. + */ +public class GenericFactory +{ + + Class theClass = null; + + public GenericFactory(Class theClass) + { + this.theClass = theClass; + } + + public T createInstance() + throws IllegalAccessException, InstantiationException + { + return (T) this.theClass.newInstance(); + } +} \ No newline at end of file diff --git a/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/Output.txt b/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/Output.txt new file mode 100644 index 000000000..6367d631b --- /dev/null +++ b/BasicJava/GenericsDemo_GenericClass_Bird_Emp_App/Output.txt @@ -0,0 +1,2 @@ +Employee@1b701da1 +Bird@442d9b6e diff --git a/BasicJava/GenericsDemo_GenericTypes_App/GenericsDemo/.classpath b/BasicJava/GenericsDemo_GenericTypes_App/GenericsDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/GenericsDemo_GenericTypes_App/GenericsDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/GenericsDemo_GenericTypes_App/GenericsDemo/.project b/BasicJava/GenericsDemo_GenericTypes_App/GenericsDemo/.project new file mode 100644 index 000000000..860a850fb --- /dev/null +++ b/BasicJava/GenericsDemo_GenericTypes_App/GenericsDemo/.project @@ -0,0 +1,17 @@ + + + GenericsDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/GenericsDemo_GenericTypes_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/GenericsDemo_GenericTypes_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/GenericsDemo_GenericTypes_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/GenericsDemo_GenericTypes_App/GenericsDemo/bin/Box.class b/BasicJava/GenericsDemo_GenericTypes_App/GenericsDemo/bin/Box.class new file mode 100644 index 000000000..f80509f8a Binary files /dev/null and b/BasicJava/GenericsDemo_GenericTypes_App/GenericsDemo/bin/Box.class differ diff --git a/BasicJava/GenericsDemo_GenericTypes_App/GenericsDemo/bin/GenericDemo.class b/BasicJava/GenericsDemo_GenericTypes_App/GenericsDemo/bin/GenericDemo.class new file mode 100644 index 000000000..4dcfdf2b4 Binary files /dev/null and b/BasicJava/GenericsDemo_GenericTypes_App/GenericsDemo/bin/GenericDemo.class differ diff --git a/BasicJava/GenericsDemo_GenericTypes_App/GenericsDemo/src/Box.java b/BasicJava/GenericsDemo_GenericTypes_App/GenericsDemo/src/Box.java new file mode 100644 index 000000000..64c095b86 --- /dev/null +++ b/BasicJava/GenericsDemo_GenericTypes_App/GenericsDemo/src/Box.java @@ -0,0 +1,21 @@ +/** + * Generic version of the Box class. + * + * @param + * the type of the value being boxed + */ +public class Box +{ + // T stands for "Type" + private T t; + + public void set(T t) + { + this.t = t; + } + + public T get() + { + return t; + } +} \ No newline at end of file diff --git a/BasicJava/GenericsDemo_GenericTypes_App/GenericsDemo/src/GenericDemo.java b/BasicJava/GenericsDemo_GenericTypes_App/GenericsDemo/src/GenericDemo.java new file mode 100644 index 000000000..b84b73d3a --- /dev/null +++ b/BasicJava/GenericsDemo_GenericTypes_App/GenericsDemo/src/GenericDemo.java @@ -0,0 +1,19 @@ +public class GenericDemo +{ + + public static void main(String[] args) + { + Box integerBox = new Box(); + integerBox.set(new Integer(100)); + //integerBox.set("Ram"); //Compile time error + Integer integerValue = integerBox.get(); + System.out.println("integerValue = "+integerValue); + + Box stringBox = new Box(); + stringBox.set("Peter"); + String strValue = stringBox.get(); + System.out.println("strValue = "+strValue); + + } + +} diff --git a/BasicJava/GenericsDemo_GenericTypes_App/Output.txt b/BasicJava/GenericsDemo_GenericTypes_App/Output.txt new file mode 100644 index 000000000..ea1d743d7 --- /dev/null +++ b/BasicJava/GenericsDemo_GenericTypes_App/Output.txt @@ -0,0 +1,2 @@ +integerValue = 100 +strValue = Peter diff --git a/BasicJava/GenericsDemo_HashSet_App/GenericsDemo/.classpath b/BasicJava/GenericsDemo_HashSet_App/GenericsDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/GenericsDemo_HashSet_App/GenericsDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/GenericsDemo_HashSet_App/GenericsDemo/.project b/BasicJava/GenericsDemo_HashSet_App/GenericsDemo/.project new file mode 100644 index 000000000..860a850fb --- /dev/null +++ b/BasicJava/GenericsDemo_HashSet_App/GenericsDemo/.project @@ -0,0 +1,17 @@ + + + GenericsDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/GenericsDemo_HashSet_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/GenericsDemo_HashSet_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/GenericsDemo_HashSet_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/GenericsDemo_HashSet_App/GenericsDemo/bin/GenericDemo.class b/BasicJava/GenericsDemo_HashSet_App/GenericsDemo/bin/GenericDemo.class new file mode 100644 index 000000000..129c05196 Binary files /dev/null and b/BasicJava/GenericsDemo_HashSet_App/GenericsDemo/bin/GenericDemo.class differ diff --git a/BasicJava/GenericsDemo_HashSet_App/GenericsDemo/src/GenericDemo.java b/BasicJava/GenericsDemo_HashSet_App/GenericsDemo/src/GenericDemo.java new file mode 100644 index 000000000..fb1147ba3 --- /dev/null +++ b/BasicJava/GenericsDemo_HashSet_App/GenericsDemo/src/GenericDemo.java @@ -0,0 +1,33 @@ +import java.util.HashSet; +import java.util.Iterator; + +public class GenericDemo +{ + public static void main(String[] args) + { + HashSet nameSet = new HashSet(); + nameSet.add("Peter"); + nameSet.add("John"); + nameSet.add("Juli"); + + System.out.println("----------Using for-each loop---------------"); + /* + * Using for-each loop we can loop and get each name from nameSet + */ + for (String name : nameSet) + { + System.out.println(name); + } + + System.out.println("----------Using Iterator---------------------"); + Iterator iterator = nameSet.iterator(); + + while (iterator.hasNext()) + { + String name = iterator.next(); + System.out.println(name); + } + + } + +} \ No newline at end of file diff --git a/BasicJava/GenericsDemo_HashSet_App/Output.txt b/BasicJava/GenericsDemo_HashSet_App/Output.txt new file mode 100644 index 000000000..8a7a97237 --- /dev/null +++ b/BasicJava/GenericsDemo_HashSet_App/Output.txt @@ -0,0 +1,8 @@ +----------Using for-each loop--------------- +John +Peter +Juli +----------Using Iterator--------------------- +John +Peter +Juli diff --git a/BasicJava/GenericsDemo_Intro_App/GenericDemo_Output.txt b/BasicJava/GenericsDemo_Intro_App/GenericDemo_Output.txt new file mode 100644 index 000000000..ee503e4d5 --- /dev/null +++ b/BasicJava/GenericsDemo_Intro_App/GenericDemo_Output.txt @@ -0,0 +1,2 @@ +[Peter, Ram] +stringValue = Peter diff --git a/BasicJava/GenericsDemo_Intro_App/GenericsDemo/.classpath b/BasicJava/GenericsDemo_Intro_App/GenericsDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/GenericsDemo_Intro_App/GenericsDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/GenericsDemo_Intro_App/GenericsDemo/.project b/BasicJava/GenericsDemo_Intro_App/GenericsDemo/.project new file mode 100644 index 000000000..860a850fb --- /dev/null +++ b/BasicJava/GenericsDemo_Intro_App/GenericsDemo/.project @@ -0,0 +1,17 @@ + + + GenericsDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/GenericsDemo_Intro_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/GenericsDemo_Intro_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/GenericsDemo_Intro_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/GenericsDemo_Intro_App/GenericsDemo/bin/GenericDemo.class b/BasicJava/GenericsDemo_Intro_App/GenericsDemo/bin/GenericDemo.class new file mode 100644 index 000000000..a2931e778 Binary files /dev/null and b/BasicJava/GenericsDemo_Intro_App/GenericsDemo/bin/GenericDemo.class differ diff --git a/BasicJava/GenericsDemo_Intro_App/GenericsDemo/bin/NonGenericDemo.class b/BasicJava/GenericsDemo_Intro_App/GenericsDemo/bin/NonGenericDemo.class new file mode 100644 index 000000000..e8335c516 Binary files /dev/null and b/BasicJava/GenericsDemo_Intro_App/GenericsDemo/bin/NonGenericDemo.class differ diff --git a/BasicJava/GenericsDemo_Intro_App/GenericsDemo/src/GenericDemo.java b/BasicJava/GenericsDemo_Intro_App/GenericsDemo/src/GenericDemo.java new file mode 100644 index 000000000..97110cbf7 --- /dev/null +++ b/BasicJava/GenericsDemo_Intro_App/GenericsDemo/src/GenericDemo.java @@ -0,0 +1,14 @@ +import java.util.ArrayList; + +public class GenericDemo +{ + public static void main(String[] args) + { + ArrayList arrayList = new ArrayList(); + arrayList.add("Peter"); + arrayList.add("Ram"); + System.out.println(arrayList); + String stringValue = arrayList.get(0); + System.out.println("stringValue = " +stringValue); + } +} \ No newline at end of file diff --git a/BasicJava/GenericsDemo_Intro_App/GenericsDemo/src/NonGenericDemo.java b/BasicJava/GenericsDemo_Intro_App/GenericsDemo/src/NonGenericDemo.java new file mode 100644 index 000000000..1ba10cd53 --- /dev/null +++ b/BasicJava/GenericsDemo_Intro_App/GenericsDemo/src/NonGenericDemo.java @@ -0,0 +1,16 @@ +import java.util.ArrayList; + +public class NonGenericDemo +{ + public static void main(String[] args) + { + ArrayList arrayList = new ArrayList(); + arrayList.add("Peter"); + arrayList.add(new Integer(10)); + System.out.println(arrayList); + String stringValue = (String)arrayList.get(0); + Integer integerValue = (Integer)arrayList.get(1); + System.out.println("stringValue = " +stringValue); + System.out.println("integerValue = " +integerValue); + } +} \ No newline at end of file diff --git a/BasicJava/GenericsDemo_Intro_App/NonGenericDemo_Output.txt b/BasicJava/GenericsDemo_Intro_App/NonGenericDemo_Output.txt new file mode 100644 index 000000000..bb0c67f41 --- /dev/null +++ b/BasicJava/GenericsDemo_Intro_App/NonGenericDemo_Output.txt @@ -0,0 +1,3 @@ +[Peter, 10] +stringValue = Peter +integerValue = 10 diff --git a/BasicJava/GenericsDemo_List_Set_Map_App/GenericForDemo1_Output.txt b/BasicJava/GenericsDemo_List_Set_Map_App/GenericForDemo1_Output.txt new file mode 100644 index 000000000..12ec89fb0 --- /dev/null +++ b/BasicJava/GenericsDemo_List_Set_Map_App/GenericForDemo1_Output.txt @@ -0,0 +1,3 @@ +Peter +Juli +Stephan diff --git a/BasicJava/GenericsDemo_List_Set_Map_App/GenericForDemo2_Output.txt b/BasicJava/GenericsDemo_List_Set_Map_App/GenericForDemo2_Output.txt new file mode 100644 index 000000000..336a4ce72 --- /dev/null +++ b/BasicJava/GenericsDemo_List_Set_Map_App/GenericForDemo2_Output.txt @@ -0,0 +1,3 @@ +100 +200 +300 diff --git a/BasicJava/GenericsDemo_List_Set_Map_App/GenericForDemo3_Output.txt b/BasicJava/GenericsDemo_List_Set_Map_App/GenericForDemo3_Output.txt new file mode 100644 index 000000000..cb7a473ad --- /dev/null +++ b/BasicJava/GenericsDemo_List_Set_Map_App/GenericForDemo3_Output.txt @@ -0,0 +1,7 @@ +1:Ram +2:Peter +3:Juli +------------------------------- +Ram +Peter +Juli diff --git a/BasicJava/GenericsDemo_List_Set_Map_App/GenericsDemo/.classpath b/BasicJava/GenericsDemo_List_Set_Map_App/GenericsDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/GenericsDemo_List_Set_Map_App/GenericsDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/GenericsDemo_List_Set_Map_App/GenericsDemo/.project b/BasicJava/GenericsDemo_List_Set_Map_App/GenericsDemo/.project new file mode 100644 index 000000000..860a850fb --- /dev/null +++ b/BasicJava/GenericsDemo_List_Set_Map_App/GenericsDemo/.project @@ -0,0 +1,17 @@ + + + GenericsDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/GenericsDemo_List_Set_Map_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/GenericsDemo_List_Set_Map_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/GenericsDemo_List_Set_Map_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/GenericsDemo_List_Set_Map_App/GenericsDemo/bin/GenericForDemo1.class b/BasicJava/GenericsDemo_List_Set_Map_App/GenericsDemo/bin/GenericForDemo1.class new file mode 100644 index 000000000..c7ecdc300 Binary files /dev/null and b/BasicJava/GenericsDemo_List_Set_Map_App/GenericsDemo/bin/GenericForDemo1.class differ diff --git a/BasicJava/GenericsDemo_List_Set_Map_App/GenericsDemo/bin/GenericForDemo2.class b/BasicJava/GenericsDemo_List_Set_Map_App/GenericsDemo/bin/GenericForDemo2.class new file mode 100644 index 000000000..c39c64a96 Binary files /dev/null and b/BasicJava/GenericsDemo_List_Set_Map_App/GenericsDemo/bin/GenericForDemo2.class differ diff --git a/BasicJava/GenericsDemo_List_Set_Map_App/GenericsDemo/bin/GenericForDemo3.class b/BasicJava/GenericsDemo_List_Set_Map_App/GenericsDemo/bin/GenericForDemo3.class new file mode 100644 index 000000000..9e3739b60 Binary files /dev/null and b/BasicJava/GenericsDemo_List_Set_Map_App/GenericsDemo/bin/GenericForDemo3.class differ diff --git a/BasicJava/GenericsDemo_List_Set_Map_App/GenericsDemo/src/GenericForDemo1.java b/BasicJava/GenericsDemo_List_Set_Map_App/GenericsDemo/src/GenericForDemo1.java new file mode 100644 index 000000000..f1a5e41a2 --- /dev/null +++ b/BasicJava/GenericsDemo_List_Set_Map_App/GenericsDemo/src/GenericForDemo1.java @@ -0,0 +1,24 @@ +import java.util.ArrayList; +import java.util.List; + +public class GenericForDemo1 +{ + public static void main(String[] args) + { + + List list = new ArrayList(); + list.add("Peter"); + list.add("Juli"); + list.add("Stephan"); + + /* + * Java's Generic For Loop or for each loop. + */ + for (String aString : list) + { + System.out.println(aString); + } + + } + +} \ No newline at end of file diff --git a/BasicJava/GenericsDemo_List_Set_Map_App/GenericsDemo/src/GenericForDemo2.java b/BasicJava/GenericsDemo_List_Set_Map_App/GenericsDemo/src/GenericForDemo2.java new file mode 100644 index 000000000..d71e5754d --- /dev/null +++ b/BasicJava/GenericsDemo_List_Set_Map_App/GenericsDemo/src/GenericForDemo2.java @@ -0,0 +1,24 @@ +import java.util.HashSet; +import java.util.Set; + +public class GenericForDemo2 +{ + public static void main(String[] args) + { + + Set set = new HashSet(); + set.add(100); + set.add(200); + set.add(300); + + /* + * Java's Generic For Loop or for each loop. + */ + for (Integer integerValue : set) + { + System.out.println(integerValue); + } + + } + +} \ No newline at end of file diff --git a/BasicJava/GenericsDemo_List_Set_Map_App/GenericsDemo/src/GenericForDemo3.java b/BasicJava/GenericsDemo_List_Set_Map_App/GenericsDemo/src/GenericForDemo3.java new file mode 100644 index 000000000..b65f5c7a3 --- /dev/null +++ b/BasicJava/GenericsDemo_List_Set_Map_App/GenericsDemo/src/GenericForDemo3.java @@ -0,0 +1,33 @@ +import java.util.HashMap; +import java.util.Map; + +public class GenericForDemo3 +{ + public static void main(String[] args) + { + Map map = new HashMap(); + map.put(1, "Ram"); + map.put(2, "Peter"); + map.put(3, "Juli"); + + /* + * Java's Generic For Loop or for each loop. + */ + for (Integer key : map.keySet()) + { + String value = map.get(key); + System.out.println("" + key + ":" + value); + } + + System.out.println("-------------------------------"); + + /* + * Java's Generic For Loop or for each loop. + */ + for (String value : map.values()) + { + System.out.println(value); + } + } + +} \ No newline at end of file diff --git a/BasicJava/GenericsDemo_Map_App/GenericsDemo/.classpath b/BasicJava/GenericsDemo_Map_App/GenericsDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/GenericsDemo_Map_App/GenericsDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/GenericsDemo_Map_App/GenericsDemo/.project b/BasicJava/GenericsDemo_Map_App/GenericsDemo/.project new file mode 100644 index 000000000..860a850fb --- /dev/null +++ b/BasicJava/GenericsDemo_Map_App/GenericsDemo/.project @@ -0,0 +1,17 @@ + + + GenericsDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/GenericsDemo_Map_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/GenericsDemo_Map_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/GenericsDemo_Map_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/GenericsDemo_Map_App/GenericsDemo/bin/GenericDemo.class b/BasicJava/GenericsDemo_Map_App/GenericsDemo/bin/GenericDemo.class new file mode 100644 index 000000000..8f1d2e713 Binary files /dev/null and b/BasicJava/GenericsDemo_Map_App/GenericsDemo/bin/GenericDemo.class differ diff --git a/BasicJava/GenericsDemo_Map_App/GenericsDemo/src/GenericDemo.java b/BasicJava/GenericsDemo_Map_App/GenericsDemo/src/GenericDemo.java new file mode 100644 index 000000000..8ea2ff239 --- /dev/null +++ b/BasicJava/GenericsDemo_Map_App/GenericsDemo/src/GenericDemo.java @@ -0,0 +1,28 @@ +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +/* + * Example of Java Generics using Map + */ +public class GenericDemo +{ + public static void main(String[] args) + { + Map map = new HashMap(); + map.put(1, "Peter"); + map.put(2, "Stephan"); + map.put(3, "Sara"); + + Set> set = map.entrySet(); + + Iterator> itr = set.iterator(); + while (itr.hasNext()) + { + // no need to typecast + Map.Entry e = itr.next(); + System.out.println(e.getKey() + " " + e.getValue()); + } + } +} \ No newline at end of file diff --git a/BasicJava/GenericsDemo_Map_App/Output.txt b/BasicJava/GenericsDemo_Map_App/Output.txt new file mode 100644 index 000000000..36f21d529 --- /dev/null +++ b/BasicJava/GenericsDemo_Map_App/Output.txt @@ -0,0 +1,3 @@ +1 Peter +2 Stephan +3 Sara diff --git a/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/.classpath b/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/.project b/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/.project new file mode 100644 index 000000000..860a850fb --- /dev/null +++ b/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/.project @@ -0,0 +1,17 @@ + + + GenericsDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/bin/A.class b/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/bin/A.class new file mode 100644 index 000000000..a356abba3 Binary files /dev/null and b/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/bin/A.class differ diff --git a/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/bin/B.class b/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/bin/B.class new file mode 100644 index 000000000..5de0c60cd Binary files /dev/null and b/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/bin/B.class differ diff --git a/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/bin/C.class b/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/bin/C.class new file mode 100644 index 000000000..c9037877b Binary files /dev/null and b/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/bin/C.class differ diff --git a/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/bin/GenericDemo.class b/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/bin/GenericDemo.class new file mode 100644 index 000000000..a9d820295 Binary files /dev/null and b/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/bin/GenericDemo.class differ diff --git a/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/src/A.java b/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/src/A.java new file mode 100644 index 000000000..23a6d3fbd --- /dev/null +++ b/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/src/A.java @@ -0,0 +1,16 @@ + +public class A +{ + private int value = 10; + + public int getValue() + { + return value; + } + + public void setValue(int value) + { + this.value = value; + } + +} diff --git a/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/src/B.java b/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/src/B.java new file mode 100644 index 000000000..dfa57829c --- /dev/null +++ b/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/src/B.java @@ -0,0 +1,5 @@ + +public class B extends A +{ + +} diff --git a/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/src/C.java b/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/src/C.java new file mode 100644 index 000000000..370c9d5cd --- /dev/null +++ b/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/src/C.java @@ -0,0 +1,5 @@ + +public class C extends A +{ + +} diff --git a/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/src/GenericDemo.java b/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/src/GenericDemo.java new file mode 100644 index 000000000..d84f1b4a1 --- /dev/null +++ b/BasicJava/GenericsDemo_extends_wildcard_boundary_App/GenericsDemo/src/GenericDemo.java @@ -0,0 +1,34 @@ +import java.util.ArrayList; +import java.util.List; + +public class GenericDemo +{ + + public static void main(String[] args) + { + GenericDemo genericDemo = new GenericDemo(); + + List listA = new ArrayList(); + listA.add(new A()); + genericDemo.processElements(listA); + + List listB = new ArrayList(); + listB.add(new B()); + genericDemo.processElements(listB); + + List listC = new ArrayList(); + listC.add(new C()); + genericDemo.processElements(listC); + } + + public void processElements(List list) + { + for (A a : list) + { + System.out.println(a.getClass()); + System.out.println("value = "+a.getValue()); + System.out.println("------------"); + } + } + +} diff --git a/BasicJava/GenericsDemo_extends_wildcard_boundary_App/Output.txt b/BasicJava/GenericsDemo_extends_wildcard_boundary_App/Output.txt new file mode 100644 index 000000000..3c47be243 --- /dev/null +++ b/BasicJava/GenericsDemo_extends_wildcard_boundary_App/Output.txt @@ -0,0 +1,9 @@ +class A +value = 10 +------------ +class B +value = 10 +------------ +class C +value = 10 +------------ diff --git a/BasicJava/GenericsDemo_lower_bounded_wildcard_App/GenericsDemo/.classpath b/BasicJava/GenericsDemo_lower_bounded_wildcard_App/GenericsDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/GenericsDemo_lower_bounded_wildcard_App/GenericsDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/GenericsDemo_lower_bounded_wildcard_App/GenericsDemo/.project b/BasicJava/GenericsDemo_lower_bounded_wildcard_App/GenericsDemo/.project new file mode 100644 index 000000000..860a850fb --- /dev/null +++ b/BasicJava/GenericsDemo_lower_bounded_wildcard_App/GenericsDemo/.project @@ -0,0 +1,17 @@ + + + GenericsDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/GenericsDemo_lower_bounded_wildcard_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/GenericsDemo_lower_bounded_wildcard_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/GenericsDemo_lower_bounded_wildcard_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/GenericsDemo_lower_bounded_wildcard_App/GenericsDemo/bin/GenericDemo.class b/BasicJava/GenericsDemo_lower_bounded_wildcard_App/GenericsDemo/bin/GenericDemo.class new file mode 100644 index 000000000..9c3be945a Binary files /dev/null and b/BasicJava/GenericsDemo_lower_bounded_wildcard_App/GenericsDemo/bin/GenericDemo.class differ diff --git a/BasicJava/GenericsDemo_lower_bounded_wildcard_App/GenericsDemo/src/GenericDemo.java b/BasicJava/GenericsDemo_lower_bounded_wildcard_App/GenericsDemo/src/GenericDemo.java new file mode 100644 index 000000000..8099c0bcd --- /dev/null +++ b/BasicJava/GenericsDemo_lower_bounded_wildcard_App/GenericsDemo/src/GenericDemo.java @@ -0,0 +1,24 @@ +import java.util.ArrayList; +import java.util.List; + +public class GenericDemo +{ + + public static void main(String[] args) + { + + List integerList = new ArrayList(); + addIntegers(integerList); + + List numberList = new ArrayList(); + addIntegers(numberList); + + } + + public static void addIntegers(List list) + { + list.add(new Integer(50)); + System.out.println(list); + } + +} diff --git a/BasicJava/GenericsDemo_lower_bounded_wildcard_App/Output.txt b/BasicJava/GenericsDemo_lower_bounded_wildcard_App/Output.txt new file mode 100644 index 000000000..9ec991fc8 --- /dev/null +++ b/BasicJava/GenericsDemo_lower_bounded_wildcard_App/Output.txt @@ -0,0 +1,2 @@ +[50] +[50] diff --git a/BasicJava/GenericsDemo_multi_type_param_App/GenericsDemo/.classpath b/BasicJava/GenericsDemo_multi_type_param_App/GenericsDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/GenericsDemo_multi_type_param_App/GenericsDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/GenericsDemo_multi_type_param_App/GenericsDemo/.project b/BasicJava/GenericsDemo_multi_type_param_App/GenericsDemo/.project new file mode 100644 index 000000000..860a850fb --- /dev/null +++ b/BasicJava/GenericsDemo_multi_type_param_App/GenericsDemo/.project @@ -0,0 +1,17 @@ + + + GenericsDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/GenericsDemo_multi_type_param_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/GenericsDemo_multi_type_param_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/GenericsDemo_multi_type_param_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/GenericsDemo_multi_type_param_App/GenericsDemo/bin/GenericDemo.class b/BasicJava/GenericsDemo_multi_type_param_App/GenericsDemo/bin/GenericDemo.class new file mode 100644 index 000000000..8353bdb9c Binary files /dev/null and b/BasicJava/GenericsDemo_multi_type_param_App/GenericsDemo/bin/GenericDemo.class differ diff --git a/BasicJava/GenericsDemo_multi_type_param_App/GenericsDemo/bin/OrderedPair.class b/BasicJava/GenericsDemo_multi_type_param_App/GenericsDemo/bin/OrderedPair.class new file mode 100644 index 000000000..78259ede8 Binary files /dev/null and b/BasicJava/GenericsDemo_multi_type_param_App/GenericsDemo/bin/OrderedPair.class differ diff --git a/BasicJava/GenericsDemo_multi_type_param_App/GenericsDemo/bin/Pair.class b/BasicJava/GenericsDemo_multi_type_param_App/GenericsDemo/bin/Pair.class new file mode 100644 index 000000000..ac13fb071 Binary files /dev/null and b/BasicJava/GenericsDemo_multi_type_param_App/GenericsDemo/bin/Pair.class differ diff --git a/BasicJava/GenericsDemo_multi_type_param_App/GenericsDemo/src/GenericDemo.java b/BasicJava/GenericsDemo_multi_type_param_App/GenericsDemo/src/GenericDemo.java new file mode 100644 index 000000000..898d58635 --- /dev/null +++ b/BasicJava/GenericsDemo_multi_type_param_App/GenericsDemo/src/GenericDemo.java @@ -0,0 +1,29 @@ +import java.util.ArrayList; +import java.util.List; + +public class GenericDemo +{ + + public static void main(String[] args) + { + Pair pair1 = new OrderedPair("age", 12); + System.out.println(pair1.getKey() + "=" + pair1.getValue()); + + Pair pair2 = new OrderedPair("user", "root"); + System.out.println(pair2.getKey() + "=" + pair2.getValue()); + + List nameList = new ArrayList<>(); + nameList.add("Peter"); + nameList.add("Ram"); + + /* + * We can also substitute a type parameter (i.e., K or V) with + * a parameterized type (i.e., List). + */ + Pair> pair3 = new OrderedPair>( + "names", nameList); + System.out.println(pair3.getKey() + "=" + pair3.getValue()); + + } + +} diff --git a/BasicJava/GenericsDemo_multi_type_param_App/GenericsDemo/src/OrderedPair.java b/BasicJava/GenericsDemo_multi_type_param_App/GenericsDemo/src/OrderedPair.java new file mode 100644 index 000000000..8388e3205 --- /dev/null +++ b/BasicJava/GenericsDemo_multi_type_param_App/GenericsDemo/src/OrderedPair.java @@ -0,0 +1,37 @@ +/** + * Multiple Type Parameters + */ +interface Pair +{ + public K getKey(); + + public V getValue(); +} + +/** + * As mentioned previously, a generic class can have multiple type parameters. + * For example, the generic OrderedPair class, which implements the generic Pair + * interface + */ +public class OrderedPair implements Pair +{ + + private K key; + private V value; + + public OrderedPair(K key, V value) + { + this.key = key; + this.value = value; + } + + public K getKey() + { + return key; + } + + public V getValue() + { + return value; + } +} \ No newline at end of file diff --git a/BasicJava/GenericsDemo_multi_type_param_App/Output.txt b/BasicJava/GenericsDemo_multi_type_param_App/Output.txt new file mode 100644 index 000000000..26aa8d329 --- /dev/null +++ b/BasicJava/GenericsDemo_multi_type_param_App/Output.txt @@ -0,0 +1,3 @@ +age=12 +user=root +names=[Peter, Ram] diff --git a/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/.classpath b/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/.project b/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/.project new file mode 100644 index 000000000..860a850fb --- /dev/null +++ b/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/.project @@ -0,0 +1,17 @@ + + + GenericsDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/bin/A.class b/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/bin/A.class new file mode 100644 index 000000000..a356abba3 Binary files /dev/null and b/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/bin/A.class differ diff --git a/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/bin/B.class b/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/bin/B.class new file mode 100644 index 000000000..5de0c60cd Binary files /dev/null and b/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/bin/B.class differ diff --git a/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/bin/C.class b/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/bin/C.class new file mode 100644 index 000000000..c9037877b Binary files /dev/null and b/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/bin/C.class differ diff --git a/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/bin/GenericDemo.class b/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/bin/GenericDemo.class new file mode 100644 index 000000000..3b4a49e97 Binary files /dev/null and b/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/bin/GenericDemo.class differ diff --git a/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/src/A.java b/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/src/A.java new file mode 100644 index 000000000..23a6d3fbd --- /dev/null +++ b/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/src/A.java @@ -0,0 +1,16 @@ + +public class A +{ + private int value = 10; + + public int getValue() + { + return value; + } + + public void setValue(int value) + { + this.value = value; + } + +} diff --git a/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/src/B.java b/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/src/B.java new file mode 100644 index 000000000..dfa57829c --- /dev/null +++ b/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/src/B.java @@ -0,0 +1,5 @@ + +public class B extends A +{ + +} diff --git a/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/src/C.java b/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/src/C.java new file mode 100644 index 000000000..370c9d5cd --- /dev/null +++ b/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/src/C.java @@ -0,0 +1,5 @@ + +public class C extends A +{ + +} diff --git a/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/src/GenericDemo.java b/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/src/GenericDemo.java new file mode 100644 index 000000000..a4f724049 --- /dev/null +++ b/BasicJava/GenericsDemo_super_wildcard_boundary_App/GenericsDemo/src/GenericDemo.java @@ -0,0 +1,27 @@ +import java.util.ArrayList; +import java.util.List; + +public class GenericDemo +{ + + public static void main(String[] args) + { + GenericDemo genericDemo = new GenericDemo(); + + List listA = new ArrayList(); + genericDemo.insertElements(listA); + System.out.println("listA = "+listA); + + List listObject = new ArrayList(); + genericDemo.insertElements(listObject); + System.out.println("listObject = "+listObject); + } + + public void insertElements(List list) + { + list.add(new A()); + list.add(new B()); + list.add(new C()); + } + +} diff --git a/BasicJava/GenericsDemo_super_wildcard_boundary_App/Output.txt b/BasicJava/GenericsDemo_super_wildcard_boundary_App/Output.txt new file mode 100644 index 000000000..b5c858630 --- /dev/null +++ b/BasicJava/GenericsDemo_super_wildcard_boundary_App/Output.txt @@ -0,0 +1,2 @@ +listA = [A@15db9742, B@6d06d69c, C@7852e922] +listObject = [A@4e25154f, B@70dea4e, C@5c647e05] diff --git a/BasicJava/GenericsDemo_unbounded_wildcard_App/GenericsDemo/.classpath b/BasicJava/GenericsDemo_unbounded_wildcard_App/GenericsDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/GenericsDemo_unbounded_wildcard_App/GenericsDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/GenericsDemo_unbounded_wildcard_App/GenericsDemo/.project b/BasicJava/GenericsDemo_unbounded_wildcard_App/GenericsDemo/.project new file mode 100644 index 000000000..860a850fb --- /dev/null +++ b/BasicJava/GenericsDemo_unbounded_wildcard_App/GenericsDemo/.project @@ -0,0 +1,17 @@ + + + GenericsDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/GenericsDemo_unbounded_wildcard_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/GenericsDemo_unbounded_wildcard_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/GenericsDemo_unbounded_wildcard_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/GenericsDemo_unbounded_wildcard_App/GenericsDemo/bin/GenericDemo.class b/BasicJava/GenericsDemo_unbounded_wildcard_App/GenericsDemo/bin/GenericDemo.class new file mode 100644 index 000000000..c6272f84c Binary files /dev/null and b/BasicJava/GenericsDemo_unbounded_wildcard_App/GenericsDemo/bin/GenericDemo.class differ diff --git a/BasicJava/GenericsDemo_unbounded_wildcard_App/GenericsDemo/src/GenericDemo.java b/BasicJava/GenericsDemo_unbounded_wildcard_App/GenericsDemo/src/GenericDemo.java new file mode 100644 index 000000000..0662c0107 --- /dev/null +++ b/BasicJava/GenericsDemo_unbounded_wildcard_App/GenericsDemo/src/GenericDemo.java @@ -0,0 +1,32 @@ +import java.util.ArrayList; +import java.util.List; + +public class GenericDemo +{ + + public static void main(String[] args) + { + List nameList = new ArrayList(); + nameList.add("Peter"); + nameList.add("Ram"); + printData(nameList); + + System.out.println("--------------------------"); + + List integerList = new ArrayList(); + integerList.add(2); + integerList.add(3); + integerList.add(5); + printData(integerList); + + } + + public static void printData(List list) + { + for (Object obj : list) + { + System.out.println(obj); + } + } + +} diff --git a/BasicJava/GenericsDemo_unbounded_wildcard_App/Output.txt b/BasicJava/GenericsDemo_unbounded_wildcard_App/Output.txt new file mode 100644 index 000000000..e35189a25 --- /dev/null +++ b/BasicJava/GenericsDemo_unbounded_wildcard_App/Output.txt @@ -0,0 +1,6 @@ +Peter +Ram +-------------------------- +2 +3 +5 diff --git a/BasicJava/GenericsDemo_unknown_wildcard_App/GenericsDemo/.classpath b/BasicJava/GenericsDemo_unknown_wildcard_App/GenericsDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/GenericsDemo_unknown_wildcard_App/GenericsDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/GenericsDemo_unknown_wildcard_App/GenericsDemo/.project b/BasicJava/GenericsDemo_unknown_wildcard_App/GenericsDemo/.project new file mode 100644 index 000000000..860a850fb --- /dev/null +++ b/BasicJava/GenericsDemo_unknown_wildcard_App/GenericsDemo/.project @@ -0,0 +1,17 @@ + + + GenericsDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/GenericsDemo_unknown_wildcard_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/GenericsDemo_unknown_wildcard_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/GenericsDemo_unknown_wildcard_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/GenericsDemo_unknown_wildcard_App/GenericsDemo/bin/GenericDemo.class b/BasicJava/GenericsDemo_unknown_wildcard_App/GenericsDemo/bin/GenericDemo.class new file mode 100644 index 000000000..988f3f701 Binary files /dev/null and b/BasicJava/GenericsDemo_unknown_wildcard_App/GenericsDemo/bin/GenericDemo.class differ diff --git a/BasicJava/GenericsDemo_unknown_wildcard_App/GenericsDemo/src/GenericDemo.java b/BasicJava/GenericsDemo_unknown_wildcard_App/GenericsDemo/src/GenericDemo.java new file mode 100644 index 000000000..f4ddd12a8 --- /dev/null +++ b/BasicJava/GenericsDemo_unknown_wildcard_App/GenericsDemo/src/GenericDemo.java @@ -0,0 +1,33 @@ +import java.util.ArrayList; +import java.util.List; + +public class GenericDemo +{ + + public static void main(String[] args) + { + GenericDemo genericDemo = new GenericDemo(); + + ArrayList numberList = new ArrayList(); + numberList.add(100); + numberList.add(200); + genericDemo.processElements(numberList); + + System.out.println("--------------------------------"); + + ArrayList nameList = new ArrayList(); + nameList.add("Peter"); + nameList.add("Ram"); + genericDemo.processElements(nameList); + + } + + public void processElements(List list) + { + for (Object o : list) + { + System.out.println(o); + } + } + +} diff --git a/BasicJava/GenericsDemo_unknown_wildcard_App/Output.txt b/BasicJava/GenericsDemo_unknown_wildcard_App/Output.txt new file mode 100644 index 000000000..7fd0c812b --- /dev/null +++ b/BasicJava/GenericsDemo_unknown_wildcard_App/Output.txt @@ -0,0 +1,5 @@ +100 +200 +-------------------------------- +Peter +Ram diff --git a/BasicJava/GenericsDemo_upper_bounded_wildcard_App/GenericDemo1_Output.txt b/BasicJava/GenericsDemo_upper_bounded_wildcard_App/GenericDemo1_Output.txt new file mode 100644 index 000000000..2fb1cc286 --- /dev/null +++ b/BasicJava/GenericsDemo_upper_bounded_wildcard_App/GenericDemo1_Output.txt @@ -0,0 +1,5 @@ +Exception in thread "main" java.lang.Error: Unresolved compilation problem: + The method sum(List) in the type GenericDemo1 + is not applicable for the arguments (List) + + at GenericDemo1.main(GenericDemo1.java:20) diff --git a/BasicJava/GenericsDemo_upper_bounded_wildcard_App/GenericDemo2_Output.txt b/BasicJava/GenericsDemo_upper_bounded_wildcard_App/GenericDemo2_Output.txt new file mode 100644 index 000000000..41528c0a7 --- /dev/null +++ b/BasicJava/GenericsDemo_upper_bounded_wildcard_App/GenericDemo2_Output.txt @@ -0,0 +1,2 @@ +sum = 10.0 +sum = 103.0 diff --git a/BasicJava/GenericsDemo_upper_bounded_wildcard_App/GenericsDemo/.classpath b/BasicJava/GenericsDemo_upper_bounded_wildcard_App/GenericsDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/GenericsDemo_upper_bounded_wildcard_App/GenericsDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/GenericsDemo_upper_bounded_wildcard_App/GenericsDemo/.project b/BasicJava/GenericsDemo_upper_bounded_wildcard_App/GenericsDemo/.project new file mode 100644 index 000000000..860a850fb --- /dev/null +++ b/BasicJava/GenericsDemo_upper_bounded_wildcard_App/GenericsDemo/.project @@ -0,0 +1,17 @@ + + + GenericsDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/GenericsDemo_upper_bounded_wildcard_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/GenericsDemo_upper_bounded_wildcard_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/GenericsDemo_upper_bounded_wildcard_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/GenericsDemo_upper_bounded_wildcard_App/GenericsDemo/bin/GenericDemo1.class b/BasicJava/GenericsDemo_upper_bounded_wildcard_App/GenericsDemo/bin/GenericDemo1.class new file mode 100644 index 000000000..58629589a Binary files /dev/null and b/BasicJava/GenericsDemo_upper_bounded_wildcard_App/GenericsDemo/bin/GenericDemo1.class differ diff --git a/BasicJava/GenericsDemo_upper_bounded_wildcard_App/GenericsDemo/bin/GenericDemo2.class b/BasicJava/GenericsDemo_upper_bounded_wildcard_App/GenericsDemo/bin/GenericDemo2.class new file mode 100644 index 000000000..9b710a8ad Binary files /dev/null and b/BasicJava/GenericsDemo_upper_bounded_wildcard_App/GenericsDemo/bin/GenericDemo2.class differ diff --git a/BasicJava/GenericsDemo_upper_bounded_wildcard_App/GenericsDemo/src/GenericDemo1.java b/BasicJava/GenericsDemo_upper_bounded_wildcard_App/GenericsDemo/src/GenericDemo1.java new file mode 100644 index 000000000..2308ccb60 --- /dev/null +++ b/BasicJava/GenericsDemo_upper_bounded_wildcard_App/GenericsDemo/src/GenericDemo1.java @@ -0,0 +1,35 @@ +import java.util.ArrayList; +import java.util.List; + +public class GenericDemo1 +{ + + public static void main(String[] args) + { + List numberList= new ArrayList(); + numberList.add(2.2); + numberList.add(3.3); + numberList.add(5.5); + double sum = sum(numberList); + System.out.println("sum = " + sum); + + List integerList= new ArrayList(); + integerList.add(2); + integerList.add(3); + integerList.add(5); + sum = sum(integerList); + System.out.println("sum = " + sum); + + } + + public static double sum(List list) + { + double sum = 0; + for (Number n : list) + { + sum += n.doubleValue(); + } + return sum; + } + +} diff --git a/BasicJava/GenericsDemo_upper_bounded_wildcard_App/GenericsDemo/src/GenericDemo2.java b/BasicJava/GenericsDemo_upper_bounded_wildcard_App/GenericsDemo/src/GenericDemo2.java new file mode 100644 index 000000000..ea5e5e4bd --- /dev/null +++ b/BasicJava/GenericsDemo_upper_bounded_wildcard_App/GenericsDemo/src/GenericDemo2.java @@ -0,0 +1,35 @@ +import java.util.ArrayList; +import java.util.List; + +public class GenericDemo2 +{ + + public static void main(String[] args) + { + List numberList= new ArrayList(); + numberList.add(2); + numberList.add(3); + numberList.add(5); + double sum = sum(numberList); + System.out.println("sum = " + sum); + + List integerList= new ArrayList(); + integerList.add(20); + integerList.add(33); + integerList.add(50); + sum = sum(integerList); + System.out.println("sum = " + sum); + + } + + public static double sum(List list) + { + double sum = 0; + for (Number n : list) + { + sum += n.doubleValue(); + } + return sum; + } + +} diff --git a/BasicJava/GenericsMethodDemo_Add_R_App/GenericsDemo/.classpath b/BasicJava/GenericsMethodDemo_Add_R_App/GenericsDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/GenericsMethodDemo_Add_R_App/GenericsDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/GenericsMethodDemo_Add_R_App/GenericsDemo/.project b/BasicJava/GenericsMethodDemo_Add_R_App/GenericsDemo/.project new file mode 100644 index 000000000..860a850fb --- /dev/null +++ b/BasicJava/GenericsMethodDemo_Add_R_App/GenericsDemo/.project @@ -0,0 +1,17 @@ + + + GenericsDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/GenericsMethodDemo_Add_R_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/GenericsMethodDemo_Add_R_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/GenericsMethodDemo_Add_R_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/GenericsMethodDemo_Add_R_App/GenericsDemo/bin/GenericDemo.class b/BasicJava/GenericsMethodDemo_Add_R_App/GenericsDemo/bin/GenericDemo.class new file mode 100644 index 000000000..53cdfd1b0 Binary files /dev/null and b/BasicJava/GenericsMethodDemo_Add_R_App/GenericsDemo/bin/GenericDemo.class differ diff --git a/BasicJava/GenericsMethodDemo_Add_R_App/GenericsDemo/src/GenericDemo.java b/BasicJava/GenericsMethodDemo_Add_R_App/GenericsDemo/src/GenericDemo.java new file mode 100644 index 000000000..9c4ef5188 --- /dev/null +++ b/BasicJava/GenericsMethodDemo_Add_R_App/GenericsDemo/src/GenericDemo.java @@ -0,0 +1,32 @@ +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +public class GenericDemo +{ + public static void main(String[] args) + throws IllegalAccessException, InstantiationException + { + + String stringElement = "Peter"; + List stringList = new ArrayList(); + + String strReturnElement = addAndReturn(stringElement, stringList); + System.out.println(strReturnElement); + + Integer integerElement = new Integer(500); + List integerList = new ArrayList(); + + Integer integerReturnElement = addAndReturn(integerElement, + integerList); + System.out.println(integerReturnElement); + + } + + public static T addAndReturn(T element, Collection collection) + { + collection.add(element); + return element; + } + +} \ No newline at end of file diff --git a/BasicJava/GenericsMethodDemo_Add_R_App/Output.txt b/BasicJava/GenericsMethodDemo_Add_R_App/Output.txt new file mode 100644 index 000000000..0f7dede9c --- /dev/null +++ b/BasicJava/GenericsMethodDemo_Add_R_App/Output.txt @@ -0,0 +1,2 @@ +Peter +500 diff --git a/BasicJava/GenericsMethodDemo_Bird_emp_App/GenericsDemo/.classpath b/BasicJava/GenericsMethodDemo_Bird_emp_App/GenericsDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/GenericsMethodDemo_Bird_emp_App/GenericsDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/GenericsMethodDemo_Bird_emp_App/GenericsDemo/.project b/BasicJava/GenericsMethodDemo_Bird_emp_App/GenericsDemo/.project new file mode 100644 index 000000000..860a850fb --- /dev/null +++ b/BasicJava/GenericsMethodDemo_Bird_emp_App/GenericsDemo/.project @@ -0,0 +1,17 @@ + + + GenericsDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/GenericsMethodDemo_Bird_emp_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/GenericsMethodDemo_Bird_emp_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/GenericsMethodDemo_Bird_emp_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/GenericsMethodDemo_Bird_emp_App/GenericsDemo/bin/Bird.class b/BasicJava/GenericsMethodDemo_Bird_emp_App/GenericsDemo/bin/Bird.class new file mode 100644 index 000000000..1470cdc9b Binary files /dev/null and b/BasicJava/GenericsMethodDemo_Bird_emp_App/GenericsDemo/bin/Bird.class differ diff --git a/BasicJava/GenericsMethodDemo_Bird_emp_App/GenericsDemo/bin/Employee.class b/BasicJava/GenericsMethodDemo_Bird_emp_App/GenericsDemo/bin/Employee.class new file mode 100644 index 000000000..62adc57be Binary files /dev/null and b/BasicJava/GenericsMethodDemo_Bird_emp_App/GenericsDemo/bin/Employee.class differ diff --git a/BasicJava/GenericsMethodDemo_Bird_emp_App/GenericsDemo/bin/GenericDemo.class b/BasicJava/GenericsMethodDemo_Bird_emp_App/GenericsDemo/bin/GenericDemo.class new file mode 100644 index 000000000..67211cd99 Binary files /dev/null and b/BasicJava/GenericsMethodDemo_Bird_emp_App/GenericsDemo/bin/GenericDemo.class differ diff --git a/BasicJava/GenericsMethodDemo_Bird_emp_App/GenericsDemo/src/Bird.java b/BasicJava/GenericsMethodDemo_Bird_emp_App/GenericsDemo/src/Bird.java new file mode 100644 index 000000000..efa84a960 --- /dev/null +++ b/BasicJava/GenericsMethodDemo_Bird_emp_App/GenericsDemo/src/Bird.java @@ -0,0 +1,16 @@ + +public class Bird +{ + private String birdName; + + public String getBirdName() + { + return birdName; + } + + public void setBirdName(String birdName) + { + this.birdName = birdName; + } + +} diff --git a/BasicJava/GenericsMethodDemo_Bird_emp_App/GenericsDemo/src/Employee.java b/BasicJava/GenericsMethodDemo_Bird_emp_App/GenericsDemo/src/Employee.java new file mode 100644 index 000000000..8bb3f2ed0 --- /dev/null +++ b/BasicJava/GenericsMethodDemo_Bird_emp_App/GenericsDemo/src/Employee.java @@ -0,0 +1,16 @@ + +public class Employee +{ + private String name; + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + +} diff --git a/BasicJava/GenericsMethodDemo_Bird_emp_App/GenericsDemo/src/GenericDemo.java b/BasicJava/GenericsMethodDemo_Bird_emp_App/GenericsDemo/src/GenericDemo.java new file mode 100644 index 000000000..12b00bb60 --- /dev/null +++ b/BasicJava/GenericsMethodDemo_Bird_emp_App/GenericsDemo/src/GenericDemo.java @@ -0,0 +1,24 @@ +public class GenericDemo +{ + public static void main(String[] args) + throws IllegalAccessException, InstantiationException + { + + Bird bird = getInstance(Bird.class); + System.out.println(bird); + + Employee employee = getInstance(Employee.class); + System.out.println(employee); + + } + + /* + * Class objects can be used as type specifications too, at runtime. + */ + public static T getInstance(Class theClass) + throws IllegalAccessException, InstantiationException + { + + return theClass.newInstance(); + } +} \ No newline at end of file diff --git a/BasicJava/GenericsMethodDemo_Bird_emp_App/Output.txt b/BasicJava/GenericsMethodDemo_Bird_emp_App/Output.txt new file mode 100644 index 000000000..acb865209 --- /dev/null +++ b/BasicJava/GenericsMethodDemo_Bird_emp_App/Output.txt @@ -0,0 +1,2 @@ +Bird@58d25a40 +Employee@726f3b58 diff --git a/BasicJava/GenericsMethodDemo_OP_App/GenericsDemo/.classpath b/BasicJava/GenericsMethodDemo_OP_App/GenericsDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/GenericsMethodDemo_OP_App/GenericsDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/GenericsMethodDemo_OP_App/GenericsDemo/.project b/BasicJava/GenericsMethodDemo_OP_App/GenericsDemo/.project new file mode 100644 index 000000000..860a850fb --- /dev/null +++ b/BasicJava/GenericsMethodDemo_OP_App/GenericsDemo/.project @@ -0,0 +1,17 @@ + + + GenericsDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/GenericsMethodDemo_OP_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/GenericsMethodDemo_OP_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/GenericsMethodDemo_OP_App/GenericsDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/GenericsMethodDemo_OP_App/GenericsDemo/bin/GenericDemo.class b/BasicJava/GenericsMethodDemo_OP_App/GenericsDemo/bin/GenericDemo.class new file mode 100644 index 000000000..f025f05a9 Binary files /dev/null and b/BasicJava/GenericsMethodDemo_OP_App/GenericsDemo/bin/GenericDemo.class differ diff --git a/BasicJava/GenericsMethodDemo_OP_App/GenericsDemo/bin/OrderPair.class b/BasicJava/GenericsMethodDemo_OP_App/GenericsDemo/bin/OrderPair.class new file mode 100644 index 000000000..f7a34635f Binary files /dev/null and b/BasicJava/GenericsMethodDemo_OP_App/GenericsDemo/bin/OrderPair.class differ diff --git a/BasicJava/GenericsMethodDemo_OP_App/GenericsDemo/src/GenericDemo.java b/BasicJava/GenericsMethodDemo_OP_App/GenericsDemo/src/GenericDemo.java new file mode 100644 index 000000000..8a1998b7b --- /dev/null +++ b/BasicJava/GenericsMethodDemo_OP_App/GenericsDemo/src/GenericDemo.java @@ -0,0 +1,23 @@ +public class GenericDemo +{ + + public static void main(String[] args) + { + OrderPair p1 = new OrderPair(1, "apple"); + OrderPair p2 = new OrderPair(1, "apple"); + boolean same = GenericDemo.compare(p1, p2); + + //Like below also we can invoke. + //boolean same = GenericDemo.compare(p1, p2); + System.out.println("is p1 and p2 are same? = " + same); + + } + + public static boolean compare(OrderPair p1, + OrderPair p2) + { + return p1.getKey().equals(p2.getKey()) + && p1.getValue().equals(p2.getValue()); + } + +} diff --git a/BasicJava/GenericsMethodDemo_OP_App/GenericsDemo/src/OrderPair.java b/BasicJava/GenericsMethodDemo_OP_App/GenericsDemo/src/OrderPair.java new file mode 100644 index 000000000..d0adc43eb --- /dev/null +++ b/BasicJava/GenericsMethodDemo_OP_App/GenericsDemo/src/OrderPair.java @@ -0,0 +1,32 @@ +public class OrderPair +{ + + private K key; + private V value; + + public OrderPair(K key, V value) + { + this.key = key; + this.value = value; + } + + public void setKey(K key) + { + this.key = key; + } + + public void setValue(V value) + { + this.value = value; + } + + public K getKey() + { + return key; + } + + public V getValue() + { + return value; + } +} \ No newline at end of file diff --git a/BasicJava/GenericsMethodDemo_OP_App/Output.txt b/BasicJava/GenericsMethodDemo_OP_App/Output.txt new file mode 100644 index 000000000..fc36d71d0 --- /dev/null +++ b/BasicJava/GenericsMethodDemo_OP_App/Output.txt @@ -0,0 +1 @@ +is p1 and p2 are same? = true diff --git a/BasicJava/HelloWorld_JDK_Install/HelloWorld.java b/BasicJava/HelloWorld_JDK_Install/HelloWorld.java new file mode 100644 index 000000000..0ee26ba66 --- /dev/null +++ b/BasicJava/HelloWorld_JDK_Install/HelloWorld.java @@ -0,0 +1,7 @@ +public class HelloWorld +{ + public static void main(String[] args) + { + System.out.println("Hello, World"); + } +} \ No newline at end of file diff --git a/BasicJava/JavaIODemo_BufferedInputStream_Buffersize_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_BufferedInputStream_Buffersize_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedInputStream_Buffersize_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_BufferedInputStream_Buffersize_App/JavaIODemo/.project b/BasicJava/JavaIODemo_BufferedInputStream_Buffersize_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedInputStream_Buffersize_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_BufferedInputStream_Buffersize_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_BufferedInputStream_Buffersize_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedInputStream_Buffersize_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_BufferedInputStream_Buffersize_App/JavaIODemo/bin/BufferedInputStreamDemo.class b/BasicJava/JavaIODemo_BufferedInputStream_Buffersize_App/JavaIODemo/bin/BufferedInputStreamDemo.class new file mode 100644 index 000000000..ed73d0937 Binary files /dev/null and b/BasicJava/JavaIODemo_BufferedInputStream_Buffersize_App/JavaIODemo/bin/BufferedInputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_BufferedInputStream_Buffersize_App/JavaIODemo/myinputfile.txt b/BasicJava/JavaIODemo_BufferedInputStream_Buffersize_App/JavaIODemo/myinputfile.txt new file mode 100644 index 000000000..b2505dc4a --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedInputStream_Buffersize_App/JavaIODemo/myinputfile.txt @@ -0,0 +1 @@ +Peter is going to India. \ No newline at end of file diff --git a/BasicJava/JavaIODemo_BufferedInputStream_Buffersize_App/JavaIODemo/src/BufferedInputStreamDemo.java b/BasicJava/JavaIODemo_BufferedInputStream_Buffersize_App/JavaIODemo/src/BufferedInputStreamDemo.java new file mode 100644 index 000000000..0559658d9 --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedInputStream_Buffersize_App/JavaIODemo/src/BufferedInputStreamDemo.java @@ -0,0 +1,57 @@ +import java.io.BufferedInputStream; +import java.io.FileInputStream; +import java.io.IOException; + +/* + * public BufferedInputStream(InputStream in, int size) + * + * Parameters: + * ----------- + * + * in - the underlying input stream. + * size - the buffer size. + */ +public class BufferedInputStreamDemo +{ + + public static void main(String[] args) throws IOException + { + BufferedInputStreamDemo bufferedInputStreamDemo = new BufferedInputStreamDemo(); + bufferedInputStreamDemo.readFile(); + } + + private void readFile() throws IOException + { + FileInputStream fileInputStream = null; + BufferedInputStream bufferedInputStream = null; + + try + { + fileInputStream = new FileInputStream("myinputfile.txt"); + int bufferSize = 8 * 1024; + /* + * Creates a BufferedInputStream with the + * specified buffer size + */ + bufferedInputStream = new BufferedInputStream(fileInputStream,bufferSize); + + int i; + while ((i = bufferedInputStream.read()) != -1) + { + System.out.print((char) i); + } + } + + finally + { + if (fileInputStream != null) + { + fileInputStream.close(); + } + if (bufferedInputStream != null) + { + bufferedInputStream.close(); + } + } + } +} diff --git a/BasicJava/JavaIODemo_BufferedInputStream_Buffersize_App/Output.txt b/BasicJava/JavaIODemo_BufferedInputStream_Buffersize_App/Output.txt new file mode 100644 index 000000000..b2505dc4a --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedInputStream_Buffersize_App/Output.txt @@ -0,0 +1 @@ +Peter is going to India. \ No newline at end of file diff --git a/BasicJava/JavaIODemo_BufferedInputStream_DestBuffer_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_BufferedInputStream_DestBuffer_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedInputStream_DestBuffer_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_BufferedInputStream_DestBuffer_App/JavaIODemo/.project b/BasicJava/JavaIODemo_BufferedInputStream_DestBuffer_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedInputStream_DestBuffer_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_BufferedInputStream_DestBuffer_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_BufferedInputStream_DestBuffer_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedInputStream_DestBuffer_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_BufferedInputStream_DestBuffer_App/JavaIODemo/bin/BufferedInputStreamDemo.class b/BasicJava/JavaIODemo_BufferedInputStream_DestBuffer_App/JavaIODemo/bin/BufferedInputStreamDemo.class new file mode 100644 index 000000000..9abb1d1e6 Binary files /dev/null and b/BasicJava/JavaIODemo_BufferedInputStream_DestBuffer_App/JavaIODemo/bin/BufferedInputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_BufferedInputStream_DestBuffer_App/JavaIODemo/myinputfile.txt b/BasicJava/JavaIODemo_BufferedInputStream_DestBuffer_App/JavaIODemo/myinputfile.txt new file mode 100644 index 000000000..b2505dc4a --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedInputStream_DestBuffer_App/JavaIODemo/myinputfile.txt @@ -0,0 +1 @@ +Peter is going to India. \ No newline at end of file diff --git a/BasicJava/JavaIODemo_BufferedInputStream_DestBuffer_App/JavaIODemo/src/BufferedInputStreamDemo.java b/BasicJava/JavaIODemo_BufferedInputStream_DestBuffer_App/JavaIODemo/src/BufferedInputStreamDemo.java new file mode 100644 index 000000000..b3cd3981c --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedInputStream_DestBuffer_App/JavaIODemo/src/BufferedInputStreamDemo.java @@ -0,0 +1,66 @@ +import java.io.BufferedInputStream; +import java.io.FileInputStream; +import java.io.IOException; + +/* + * public int read(byte[] b, int off, int len) + * + * Parameters: + * ---------- + * + * b - destination buffer. + * off - offset at which to start storing bytes. + * len - maximum number of bytes to read. + */ +public class BufferedInputStreamDemo +{ + + public static void main(String[] args) throws IOException + { + BufferedInputStreamDemo bufferedInputStreamDemo = new BufferedInputStreamDemo(); + bufferedInputStreamDemo.readFile(); + } + + private void readFile() throws IOException + { + FileInputStream fileInputStream = null; + BufferedInputStream bufferedInputStream = null; + + try + { + fileInputStream = new FileInputStream("myinputfile.txt"); + bufferedInputStream = new BufferedInputStream(fileInputStream); + + byte[] destBuffer = new byte[10]; + + /* + * Reads bytes from this byte-input stream into + * the specified byte array, starting at the + * given offset. + * + * the number of bytes read, or -1 if the end of + * the stream has been reached. + */ + int numberOfBytesRead =bufferedInputStream.read(destBuffer, 0, 5); + System.out.println("numberOfBytesRead = "+numberOfBytesRead); + + for (byte b : destBuffer) + { + System.out.print((char) b); + } + + } + + finally + { + if (fileInputStream != null) + { + fileInputStream.close(); + } + if (bufferedInputStream != null) + { + bufferedInputStream.close(); + } + } + } +} diff --git a/BasicJava/JavaIODemo_BufferedInputStream_DestBuffer_App/Output.txt b/BasicJava/JavaIODemo_BufferedInputStream_DestBuffer_App/Output.txt new file mode 100644 index 000000000..3a67b1d50 --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedInputStream_DestBuffer_App/Output.txt @@ -0,0 +1,2 @@ +numberOfBytesRead = 5 +Peter \ No newline at end of file diff --git a/BasicJava/JavaIODemo_BufferedInputStream_Intro_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_BufferedInputStream_Intro_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedInputStream_Intro_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_BufferedInputStream_Intro_App/JavaIODemo/.project b/BasicJava/JavaIODemo_BufferedInputStream_Intro_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedInputStream_Intro_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_BufferedInputStream_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_BufferedInputStream_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedInputStream_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_BufferedInputStream_Intro_App/JavaIODemo/bin/BufferedInputStreamDemo.class b/BasicJava/JavaIODemo_BufferedInputStream_Intro_App/JavaIODemo/bin/BufferedInputStreamDemo.class new file mode 100644 index 000000000..8eba11a90 Binary files /dev/null and b/BasicJava/JavaIODemo_BufferedInputStream_Intro_App/JavaIODemo/bin/BufferedInputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_BufferedInputStream_Intro_App/JavaIODemo/myinputfile.txt b/BasicJava/JavaIODemo_BufferedInputStream_Intro_App/JavaIODemo/myinputfile.txt new file mode 100644 index 000000000..b2505dc4a --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedInputStream_Intro_App/JavaIODemo/myinputfile.txt @@ -0,0 +1 @@ +Peter is going to India. \ No newline at end of file diff --git a/BasicJava/JavaIODemo_BufferedInputStream_Intro_App/JavaIODemo/src/BufferedInputStreamDemo.java b/BasicJava/JavaIODemo_BufferedInputStream_Intro_App/JavaIODemo/src/BufferedInputStreamDemo.java new file mode 100644 index 000000000..012ba1c14 --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedInputStream_Intro_App/JavaIODemo/src/BufferedInputStreamDemo.java @@ -0,0 +1,43 @@ +import java.io.BufferedInputStream; +import java.io.FileInputStream; +import java.io.IOException; + +public class BufferedInputStreamDemo +{ + + public static void main(String[] args) throws IOException + { + BufferedInputStreamDemo bufferedInputStreamDemo = new BufferedInputStreamDemo(); + bufferedInputStreamDemo.readFile(); + } + + private void readFile() throws IOException + { + FileInputStream fileInputStream = null; + BufferedInputStream bufferedInputStream = null; + + try + { + fileInputStream = new FileInputStream("myinputfile.txt"); + bufferedInputStream = new BufferedInputStream(fileInputStream); + + int i; + while ((i = bufferedInputStream.read()) != -1) + { + System.out.print((char) i); + } + } + + finally + { + if (fileInputStream != null) + { + fileInputStream.close(); + } + if (bufferedInputStream != null) + { + bufferedInputStream.close(); + } + } + } +} diff --git a/BasicJava/JavaIODemo_BufferedInputStream_Intro_App/Output.txt b/BasicJava/JavaIODemo_BufferedInputStream_Intro_App/Output.txt new file mode 100644 index 000000000..b2505dc4a --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedInputStream_Intro_App/Output.txt @@ -0,0 +1 @@ +Peter is going to India. \ No newline at end of file diff --git a/BasicJava/JavaIODemo_BufferedOutputStream_Intro_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_BufferedOutputStream_Intro_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedOutputStream_Intro_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_BufferedOutputStream_Intro_App/JavaIODemo/.project b/BasicJava/JavaIODemo_BufferedOutputStream_Intro_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedOutputStream_Intro_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_BufferedOutputStream_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_BufferedOutputStream_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedOutputStream_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_BufferedOutputStream_Intro_App/JavaIODemo/bin/BufferedOutputStreamDemo.class b/BasicJava/JavaIODemo_BufferedOutputStream_Intro_App/JavaIODemo/bin/BufferedOutputStreamDemo.class new file mode 100644 index 000000000..67610abc6 Binary files /dev/null and b/BasicJava/JavaIODemo_BufferedOutputStream_Intro_App/JavaIODemo/bin/BufferedOutputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_BufferedOutputStream_Intro_App/JavaIODemo/myoutputfile.txt b/BasicJava/JavaIODemo_BufferedOutputStream_Intro_App/JavaIODemo/myoutputfile.txt new file mode 100644 index 000000000..b2505dc4a --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedOutputStream_Intro_App/JavaIODemo/myoutputfile.txt @@ -0,0 +1 @@ +Peter is going to India. \ No newline at end of file diff --git a/BasicJava/JavaIODemo_BufferedOutputStream_Intro_App/JavaIODemo/src/BufferedOutputStreamDemo.java b/BasicJava/JavaIODemo_BufferedOutputStream_Intro_App/JavaIODemo/src/BufferedOutputStreamDemo.java new file mode 100644 index 000000000..e0a12c131 --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedOutputStream_Intro_App/JavaIODemo/src/BufferedOutputStreamDemo.java @@ -0,0 +1,59 @@ +import java.io.BufferedOutputStream; +import java.io.FileOutputStream; +import java.io.IOException; + +/* + * In this example, we are writing the textual + * information in the BufferedOutputStream object which + * is connected to the FileOutputStream object. The + * flush() flushes the data of one stream and send it + * into another. It is required if you have connected + * the one stream with another. + */ +public class BufferedOutputStreamDemo +{ + + public static void main(String[] args) throws IOException + { + BufferedOutputStreamDemo bufferedOutputStreamDemo = new BufferedOutputStreamDemo(); + bufferedOutputStreamDemo.writeFile(); + } + + private void writeFile() throws IOException + { + + FileOutputStream fileOutputStream = null; + BufferedOutputStream bufferedOutputStream = null; + + try + { + fileOutputStream = new FileOutputStream("myoutputfile.txt"); + bufferedOutputStream = new BufferedOutputStream(fileOutputStream); + + String str = "Peter is going to India."; + byte byteArray[] = str.getBytes(); + bufferedOutputStream.write(byteArray); + /* + * Flushes this buffered output stream. This + * forces any buffered output bytes to be + * written out to the underlying output stream. + */ + bufferedOutputStream.flush(); + System.out.println("Successfully written to the file." + + "please check the file content."); + + } + finally + { + if (fileOutputStream != null) + { + fileOutputStream.close(); + } + if (bufferedOutputStream != null) + { + bufferedOutputStream.close(); + } + } + } + +} diff --git a/BasicJava/JavaIODemo_BufferedOutputStream_Intro_App/Output.txt b/BasicJava/JavaIODemo_BufferedOutputStream_Intro_App/Output.txt new file mode 100644 index 000000000..577f536e2 --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedOutputStream_Intro_App/Output.txt @@ -0,0 +1 @@ +Successfully written to the file.please check the file content. diff --git a/BasicJava/JavaIODemo_BufferedOutputStream_write_offset_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_BufferedOutputStream_write_offset_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedOutputStream_write_offset_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_BufferedOutputStream_write_offset_App/JavaIODemo/.project b/BasicJava/JavaIODemo_BufferedOutputStream_write_offset_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedOutputStream_write_offset_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_BufferedOutputStream_write_offset_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_BufferedOutputStream_write_offset_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedOutputStream_write_offset_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_BufferedOutputStream_write_offset_App/JavaIODemo/bin/BufferedOutputStreamDemo.class b/BasicJava/JavaIODemo_BufferedOutputStream_write_offset_App/JavaIODemo/bin/BufferedOutputStreamDemo.class new file mode 100644 index 000000000..868e80cc5 Binary files /dev/null and b/BasicJava/JavaIODemo_BufferedOutputStream_write_offset_App/JavaIODemo/bin/BufferedOutputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_BufferedOutputStream_write_offset_App/JavaIODemo/myoutputfile.txt b/BasicJava/JavaIODemo_BufferedOutputStream_write_offset_App/JavaIODemo/myoutputfile.txt new file mode 100644 index 000000000..83884b3de --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedOutputStream_write_offset_App/JavaIODemo/myoutputfile.txt @@ -0,0 +1 @@ +India \ No newline at end of file diff --git a/BasicJava/JavaIODemo_BufferedOutputStream_write_offset_App/JavaIODemo/src/BufferedOutputStreamDemo.java b/BasicJava/JavaIODemo_BufferedOutputStream_write_offset_App/JavaIODemo/src/BufferedOutputStreamDemo.java new file mode 100644 index 000000000..08329c5c0 --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedOutputStream_write_offset_App/JavaIODemo/src/BufferedOutputStreamDemo.java @@ -0,0 +1,72 @@ +import java.io.BufferedOutputStream; +import java.io.FileOutputStream; +import java.io.IOException; + +/* + * public void write(byte[] b, int off, int len) throws + * IOException + * + * Parameters: + * ---------- + * b - the data. + * off - the start offset in the data. + * len - the number of bytes to write. + */ +public class BufferedOutputStreamDemo +{ + + public static void main(String[] args) throws IOException + { + BufferedOutputStreamDemo bufferedOutputStreamDemo = new BufferedOutputStreamDemo(); + bufferedOutputStreamDemo.writeFile(); + } + + private void writeFile() throws IOException + { + + FileOutputStream fileOutputStream = null; + BufferedOutputStream bufferedOutputStream = null; + + try + { + fileOutputStream = new FileOutputStream("myoutputfile.txt"); + bufferedOutputStream = new BufferedOutputStream(fileOutputStream); + + String str = "Peter is going to India."; + byte byteArray[] = str.getBytes(); + + /* + * Writes len bytes from the specified byte + * array starting at offset off to this buffered + * output stream. + */ + bufferedOutputStream.write(byteArray, 18, 5); + /* + * Flushes this buffered output stream. This + * forces any buffered output bytes to be + * written out to the underlying output stream. + */ + bufferedOutputStream.flush(); + System.out.println("Successfully written to the file." + + "please check the file content."); + + } + catch (Exception exe) + { + exe.printStackTrace(); + } + + finally + { + if (fileOutputStream != null) + { + fileOutputStream.close(); + } + if (bufferedOutputStream != null) + { + bufferedOutputStream.close(); + } + } + } + +} diff --git a/BasicJava/JavaIODemo_BufferedOutputStream_write_offset_App/Output.txt b/BasicJava/JavaIODemo_BufferedOutputStream_write_offset_App/Output.txt new file mode 100644 index 000000000..577f536e2 --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedOutputStream_write_offset_App/Output.txt @@ -0,0 +1 @@ +Successfully written to the file.please check the file content. diff --git a/BasicJava/JavaIODemo_BufferedReader_Intro_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_BufferedReader_Intro_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedReader_Intro_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_BufferedReader_Intro_App/JavaIODemo/.project b/BasicJava/JavaIODemo_BufferedReader_Intro_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedReader_Intro_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_BufferedReader_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_BufferedReader_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedReader_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_BufferedReader_Intro_App/JavaIODemo/bin/BufferedReaderDemo.class b/BasicJava/JavaIODemo_BufferedReader_Intro_App/JavaIODemo/bin/BufferedReaderDemo.class new file mode 100644 index 000000000..a6128f306 Binary files /dev/null and b/BasicJava/JavaIODemo_BufferedReader_Intro_App/JavaIODemo/bin/BufferedReaderDemo.class differ diff --git a/BasicJava/JavaIODemo_BufferedReader_Intro_App/JavaIODemo/myinputfile.txt b/BasicJava/JavaIODemo_BufferedReader_Intro_App/JavaIODemo/myinputfile.txt new file mode 100644 index 000000000..ddfbd1bdc --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedReader_Intro_App/JavaIODemo/myinputfile.txt @@ -0,0 +1,4 @@ +Peter is going to India. +John is going to Japan. +Juli is going to USA. +Ram is going to UK. \ No newline at end of file diff --git a/BasicJava/JavaIODemo_BufferedReader_Intro_App/JavaIODemo/src/BufferedReaderDemo.java b/BasicJava/JavaIODemo_BufferedReader_Intro_App/JavaIODemo/src/BufferedReaderDemo.java new file mode 100644 index 000000000..3bbfd6dd6 --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedReader_Intro_App/JavaIODemo/src/BufferedReaderDemo.java @@ -0,0 +1,50 @@ +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; + +public class BufferedReaderDemo +{ + + public static void main(String[] args) throws IOException + { + BufferedReaderDemo BufferedReaderDemo = new BufferedReaderDemo(); + BufferedReaderDemo.readFile(); + } + + private void readFile() throws IOException + { + FileReader fileReader = null; + BufferedReader bufferedReader = null; + + try + { + fileReader = new FileReader("myinputfile.txt"); + bufferedReader = new BufferedReader(fileReader); + + String line = null; + /* + * Reads a line of text. A line is considered to + * be terminated by any one of a line feed + * ('\n'), a carriage return ('\r'), or a + * carriage return followed immediately by a + * linefeed. + */ + while ((line = bufferedReader.readLine()) != null) + { + System.out.println(line); + } + } + finally + { + if (fileReader != null) + { + fileReader.close(); + } + if (bufferedReader != null) + { + bufferedReader.close(); + } + } + } + +} diff --git a/BasicJava/JavaIODemo_BufferedReader_Intro_App/Output.txt b/BasicJava/JavaIODemo_BufferedReader_Intro_App/Output.txt new file mode 100644 index 000000000..54b5e327e --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedReader_Intro_App/Output.txt @@ -0,0 +1,4 @@ +Peter is going to India. +John is going to Japan. +Juli is going to USA. +Ram is going to UK. diff --git a/BasicJava/JavaIODemo_BufferedReader_read char_by_char_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_BufferedReader_read char_by_char_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedReader_read char_by_char_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_BufferedReader_read char_by_char_App/JavaIODemo/.project b/BasicJava/JavaIODemo_BufferedReader_read char_by_char_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedReader_read char_by_char_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_BufferedReader_read char_by_char_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_BufferedReader_read char_by_char_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedReader_read char_by_char_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_BufferedReader_read char_by_char_App/JavaIODemo/bin/BufferedReaderDemo.class b/BasicJava/JavaIODemo_BufferedReader_read char_by_char_App/JavaIODemo/bin/BufferedReaderDemo.class new file mode 100644 index 000000000..155f49cbd Binary files /dev/null and b/BasicJava/JavaIODemo_BufferedReader_read char_by_char_App/JavaIODemo/bin/BufferedReaderDemo.class differ diff --git a/BasicJava/JavaIODemo_BufferedReader_read char_by_char_App/JavaIODemo/myinputfile.txt b/BasicJava/JavaIODemo_BufferedReader_read char_by_char_App/JavaIODemo/myinputfile.txt new file mode 100644 index 000000000..ddfbd1bdc --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedReader_read char_by_char_App/JavaIODemo/myinputfile.txt @@ -0,0 +1,4 @@ +Peter is going to India. +John is going to Japan. +Juli is going to USA. +Ram is going to UK. \ No newline at end of file diff --git a/BasicJava/JavaIODemo_BufferedReader_read char_by_char_App/JavaIODemo/src/BufferedReaderDemo.java b/BasicJava/JavaIODemo_BufferedReader_read char_by_char_App/JavaIODemo/src/BufferedReaderDemo.java new file mode 100644 index 000000000..86e9f0b3c --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedReader_read char_by_char_App/JavaIODemo/src/BufferedReaderDemo.java @@ -0,0 +1,45 @@ +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; + +public class BufferedReaderDemo +{ + + public static void main(String[] args) throws IOException + { + BufferedReaderDemo bufferedReaderDemo = new BufferedReaderDemo(); + bufferedReaderDemo.readFile(); + } + + private void readFile() throws IOException + { + FileReader fileReader = null; + BufferedReader bufferedReader = null; + + try + { + fileReader = new FileReader("myinputfile.txt"); + bufferedReader = new BufferedReader(fileReader); + int i; + /* + * Reads a single character. + */ + while ((i = bufferedReader.read()) != -1) + { + System.out.print((char) i); + } + } + finally + { + if (fileReader != null) + { + fileReader.close(); + } + if (bufferedReader != null) + { + bufferedReader.close(); + } + } + } + +} diff --git a/BasicJava/JavaIODemo_BufferedReader_read char_by_char_App/Output.txt b/BasicJava/JavaIODemo_BufferedReader_read char_by_char_App/Output.txt new file mode 100644 index 000000000..ddfbd1bdc --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedReader_read char_by_char_App/Output.txt @@ -0,0 +1,4 @@ +Peter is going to India. +John is going to Japan. +Juli is going to USA. +Ram is going to UK. \ No newline at end of file diff --git a/BasicJava/JavaIODemo_BufferedWriter_Cons_accept_size_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_BufferedWriter_Cons_accept_size_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedWriter_Cons_accept_size_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_BufferedWriter_Cons_accept_size_App/JavaIODemo/.project b/BasicJava/JavaIODemo_BufferedWriter_Cons_accept_size_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedWriter_Cons_accept_size_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_BufferedWriter_Cons_accept_size_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_BufferedWriter_Cons_accept_size_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedWriter_Cons_accept_size_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_BufferedWriter_Cons_accept_size_App/JavaIODemo/bin/BufferedWriterDemo.class b/BasicJava/JavaIODemo_BufferedWriter_Cons_accept_size_App/JavaIODemo/bin/BufferedWriterDemo.class new file mode 100644 index 000000000..888f8f5bf Binary files /dev/null and b/BasicJava/JavaIODemo_BufferedWriter_Cons_accept_size_App/JavaIODemo/bin/BufferedWriterDemo.class differ diff --git a/BasicJava/JavaIODemo_BufferedWriter_Cons_accept_size_App/JavaIODemo/myoutputfile.txt b/BasicJava/JavaIODemo_BufferedWriter_Cons_accept_size_App/JavaIODemo/myoutputfile.txt new file mode 100644 index 000000000..23aebe15b --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedWriter_Cons_accept_size_App/JavaIODemo/myoutputfile.txt @@ -0,0 +1,2 @@ +Peter is going to India. +John is going to India. \ No newline at end of file diff --git a/BasicJava/JavaIODemo_BufferedWriter_Cons_accept_size_App/JavaIODemo/src/BufferedWriterDemo.java b/BasicJava/JavaIODemo_BufferedWriter_Cons_accept_size_App/JavaIODemo/src/BufferedWriterDemo.java new file mode 100644 index 000000000..82f6859cd --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedWriter_Cons_accept_size_App/JavaIODemo/src/BufferedWriterDemo.java @@ -0,0 +1,66 @@ +import java.io.BufferedWriter; +import java.io.FileWriter; +import java.io.IOException; + +/* + * public BufferedWriter(Writer out, int sz) + * + * Parameters: + * ---------- + * + * out - A Writer. + * sz - Output-buffer size, a positive integer. + */ +public class BufferedWriterDemo +{ + + public static void main(String[] args) throws IOException + { + BufferedWriterDemo BufferedWriterDemo = new BufferedWriterDemo(); + BufferedWriterDemo.writeFile(); + } + + private void writeFile() throws IOException + { + FileWriter fileWriter = null; + BufferedWriter bufferedWriter = null; + + try + { + int bufferSize = 8 * 1024; + fileWriter = new FileWriter("myoutputfile.txt"); + /* + * Creates a new buffered character-output + * stream that uses an output buffer of the + * given size. + */ + bufferedWriter = new BufferedWriter(fileWriter, bufferSize); + + String line1 = "Peter is going to India."; + String line2 = "John is going to India."; + + // writing string to writer + bufferedWriter.write(line1); + bufferedWriter.newLine(); + bufferedWriter.write(line2); + + // forces out the characters to file writer + bufferedWriter.flush(); + System.out.println("Sucessfully written to the file," + + " please check the file content."); + + } + finally + { + if (fileWriter != null) + { + fileWriter.close(); + } + if (bufferedWriter != null) + { + bufferedWriter.close(); + } + } + } + +} diff --git a/BasicJava/JavaIODemo_BufferedWriter_Cons_accept_size_App/Output.txt b/BasicJava/JavaIODemo_BufferedWriter_Cons_accept_size_App/Output.txt new file mode 100644 index 000000000..b5083367f --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedWriter_Cons_accept_size_App/Output.txt @@ -0,0 +1 @@ +Sucessfully written to the file, please check the file content. diff --git a/BasicJava/JavaIODemo_BufferedWriter_Intro_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_BufferedWriter_Intro_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedWriter_Intro_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_BufferedWriter_Intro_App/JavaIODemo/.project b/BasicJava/JavaIODemo_BufferedWriter_Intro_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedWriter_Intro_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_BufferedWriter_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_BufferedWriter_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedWriter_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_BufferedWriter_Intro_App/JavaIODemo/bin/BufferedWriterDemo.class b/BasicJava/JavaIODemo_BufferedWriter_Intro_App/JavaIODemo/bin/BufferedWriterDemo.class new file mode 100644 index 000000000..ee9573afb Binary files /dev/null and b/BasicJava/JavaIODemo_BufferedWriter_Intro_App/JavaIODemo/bin/BufferedWriterDemo.class differ diff --git a/BasicJava/JavaIODemo_BufferedWriter_Intro_App/JavaIODemo/myoutputfile.txt b/BasicJava/JavaIODemo_BufferedWriter_Intro_App/JavaIODemo/myoutputfile.txt new file mode 100644 index 000000000..23aebe15b --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedWriter_Intro_App/JavaIODemo/myoutputfile.txt @@ -0,0 +1,2 @@ +Peter is going to India. +John is going to India. \ No newline at end of file diff --git a/BasicJava/JavaIODemo_BufferedWriter_Intro_App/JavaIODemo/src/BufferedWriterDemo.java b/BasicJava/JavaIODemo_BufferedWriter_Intro_App/JavaIODemo/src/BufferedWriterDemo.java new file mode 100644 index 000000000..201ff381c --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedWriter_Intro_App/JavaIODemo/src/BufferedWriterDemo.java @@ -0,0 +1,51 @@ +import java.io.BufferedWriter; +import java.io.FileWriter; +import java.io.IOException; + +public class BufferedWriterDemo +{ + + public static void main(String[] args) throws IOException + { + BufferedWriterDemo BufferedWriterDemo = new BufferedWriterDemo(); + BufferedWriterDemo.writeFile(); + } + + private void writeFile() throws IOException + { + FileWriter fileWriter = null; + BufferedWriter bufferedWriter = null; + + try + { + fileWriter = new FileWriter("myoutputfile.txt"); + bufferedWriter = new BufferedWriter(fileWriter); + + String line1 = "Peter is going to India."; + String line2 = "John is going to India."; + + // writing string to writer + bufferedWriter.write(line1); + bufferedWriter.newLine(); + bufferedWriter.write(line2); + + // forces out the characters to file writer + bufferedWriter.flush(); + System.out.println("Sucessfully written to the file," + + " please check the file content."); + + } + finally + { + if (fileWriter != null) + { + fileWriter.close(); + } + if (bufferedWriter != null) + { + bufferedWriter.close(); + } + } + } + +} diff --git a/BasicJava/JavaIODemo_BufferedWriter_Intro_App/Output.txt b/BasicJava/JavaIODemo_BufferedWriter_Intro_App/Output.txt new file mode 100644 index 000000000..b5083367f --- /dev/null +++ b/BasicJava/JavaIODemo_BufferedWriter_Intro_App/Output.txt @@ -0,0 +1 @@ +Sucessfully written to the file, please check the file content. diff --git a/BasicJava/JavaIODemo_ByteArrayIS_Capitilization_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_ByteArrayIS_Capitilization_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayIS_Capitilization_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_ByteArrayIS_Capitilization_App/JavaIODemo/.project b/BasicJava/JavaIODemo_ByteArrayIS_Capitilization_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayIS_Capitilization_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_ByteArrayIS_Capitilization_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_ByteArrayIS_Capitilization_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayIS_Capitilization_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_ByteArrayIS_Capitilization_App/JavaIODemo/bin/ByteArrayInputStreamDemo.class b/BasicJava/JavaIODemo_ByteArrayIS_Capitilization_App/JavaIODemo/bin/ByteArrayInputStreamDemo.class new file mode 100644 index 000000000..3c378bca5 Binary files /dev/null and b/BasicJava/JavaIODemo_ByteArrayIS_Capitilization_App/JavaIODemo/bin/ByteArrayInputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_ByteArrayIS_Capitilization_App/JavaIODemo/src/ByteArrayInputStreamDemo.java b/BasicJava/JavaIODemo_ByteArrayIS_Capitilization_App/JavaIODemo/src/ByteArrayInputStreamDemo.java new file mode 100644 index 000000000..c9dae4553 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayIS_Capitilization_App/JavaIODemo/src/ByteArrayInputStreamDemo.java @@ -0,0 +1,34 @@ +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.Scanner; + +/* + * Another simple usage of ByteArrayInputStream would be + * a way of capitalizing the input from the user. + */ + +public class ByteArrayInputStreamDemo +{ + + public static void main(String[] args) throws IOException + { + Scanner scanner = new Scanner(System.in); + + System.out.print("Enter the name : "); + String name = scanner.nextLine(); + + scanner.close(); + + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(name.getBytes()); + + StringBuilder sb = new StringBuilder(); + + int ch; + while ((ch = byteArrayInputStream.read()) != -1) + { + sb.append(Character.toUpperCase((char) ch)); + } + System.out.println("Your capitalized name: " + sb.toString()); + + } +} diff --git a/BasicJava/JavaIODemo_ByteArrayIS_Capitilization_App/Output.txt b/BasicJava/JavaIODemo_ByteArrayIS_Capitilization_App/Output.txt new file mode 100644 index 000000000..53079e58e --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayIS_Capitilization_App/Output.txt @@ -0,0 +1,2 @@ +Enter the name : peter +Your capitalized name: PETER diff --git a/BasicJava/JavaIODemo_ByteArrayIS_Cons_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_ByteArrayIS_Cons_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayIS_Cons_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_ByteArrayIS_Cons_App/JavaIODemo/.project b/BasicJava/JavaIODemo_ByteArrayIS_Cons_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayIS_Cons_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_ByteArrayIS_Cons_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_ByteArrayIS_Cons_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayIS_Cons_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_ByteArrayIS_Cons_App/JavaIODemo/bin/ByteArrayInputStreamDemo.class b/BasicJava/JavaIODemo_ByteArrayIS_Cons_App/JavaIODemo/bin/ByteArrayInputStreamDemo.class new file mode 100644 index 000000000..2867355ba Binary files /dev/null and b/BasicJava/JavaIODemo_ByteArrayIS_Cons_App/JavaIODemo/bin/ByteArrayInputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_ByteArrayIS_Cons_App/JavaIODemo/src/ByteArrayInputStreamDemo.java b/BasicJava/JavaIODemo_ByteArrayIS_Cons_App/JavaIODemo/src/ByteArrayInputStreamDemo.java new file mode 100644 index 000000000..fbbe28384 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayIS_Cons_App/JavaIODemo/src/ByteArrayInputStreamDemo.java @@ -0,0 +1,38 @@ +import java.io.ByteArrayInputStream; +import java.io.IOException; + +public class ByteArrayInputStreamDemo +{ + + public static void main(String[] args) throws IOException + { + String str = "abcdefghijklmnopqrstuvwxyz"; + byte[] byteArray = str.getBytes(); + + ByteArrayInputStream byteArrayInputStream1 = new ByteArrayInputStream(byteArray); + + /* + * The byteArrayInputStream1 contains all letters. + */ + displayContent(byteArrayInputStream1); + + ByteArrayInputStream byteArrayInputStream2 = new ByteArrayInputStream(byteArray, 0, 3); + + /* + * The byteArrayInputStream2 contains only the first + * three letters. + */ + displayContent(byteArrayInputStream2); + + } + + private static void displayContent(ByteArrayInputStream byteArrayInputStream) + { + int ch; + while ((ch = byteArrayInputStream.read()) != -1) + { + System.out.print((char) ch); + } + System.out.println(); + } +} diff --git a/BasicJava/JavaIODemo_ByteArrayIS_Cons_App/Output.txt b/BasicJava/JavaIODemo_ByteArrayIS_Cons_App/Output.txt new file mode 100644 index 000000000..9ecf8aa99 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayIS_Cons_App/Output.txt @@ -0,0 +1,2 @@ +abcdefghijklmnopqrstuvwxyz +abc diff --git a/BasicJava/JavaIODemo_ByteArrayIS_Copy_to_DestArray_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_ByteArrayIS_Copy_to_DestArray_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayIS_Copy_to_DestArray_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_ByteArrayIS_Copy_to_DestArray_App/JavaIODemo/.project b/BasicJava/JavaIODemo_ByteArrayIS_Copy_to_DestArray_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayIS_Copy_to_DestArray_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_ByteArrayIS_Copy_to_DestArray_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_ByteArrayIS_Copy_to_DestArray_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayIS_Copy_to_DestArray_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_ByteArrayIS_Copy_to_DestArray_App/JavaIODemo/bin/ByteArrayInputStreamDemo.class b/BasicJava/JavaIODemo_ByteArrayIS_Copy_to_DestArray_App/JavaIODemo/bin/ByteArrayInputStreamDemo.class new file mode 100644 index 000000000..cf90a33cd Binary files /dev/null and b/BasicJava/JavaIODemo_ByteArrayIS_Copy_to_DestArray_App/JavaIODemo/bin/ByteArrayInputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_ByteArrayIS_Copy_to_DestArray_App/JavaIODemo/src/ByteArrayInputStreamDemo.java b/BasicJava/JavaIODemo_ByteArrayIS_Copy_to_DestArray_App/JavaIODemo/src/ByteArrayInputStreamDemo.java new file mode 100644 index 000000000..e132a5564 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayIS_Copy_to_DestArray_App/JavaIODemo/src/ByteArrayInputStreamDemo.java @@ -0,0 +1,77 @@ +import java.io.ByteArrayInputStream; +import java.io.IOException; + +/* + * public int read(byte[] b, int off, int len) + * + * b - the buffer into which the data is read. + * + * off - the start offset in the destination + * array b + * + * len - the maximum number of bytes + * read. + * + * Reads up to len bytes of data into an array + * of bytes from this input stream. + */ +public class ByteArrayInputStreamDemo +{ + + public static void main(String[] args) throws IOException + { + ByteArrayInputStream byteArrayInputStream = null; + + try + { + byte[] srcBuffer = new byte[10]; + + int j = 11; + for (int i = 0; i < srcBuffer.length; i++) + { + srcBuffer[i] = (byte) j++; + } + + System.out.println("All elements form srcBuffer:"); + for (int i = 0; i < srcBuffer.length; i++) + { + System.out.print(srcBuffer[i] + " "); + } + + byteArrayInputStream = new ByteArrayInputStream(srcBuffer); + + byte[] destBuffer = new byte[6]; + + /* + * We put 4 first elements of the + * ByteArrayInputStream instance + * 'byteArrayInputStream' to the destBuffer + * array, starting at the position with index 2. + * This is why the two first indexes will be + * '0'. + */ + byteArrayInputStream.read(destBuffer, 2, 4); + + System.out.println("\n\nAll elements form destBuffer:"); + for (int i = 0; i < destBuffer.length; i++) + { + System.out.print(destBuffer[i] + " "); + } + + } + finally + { + if (byteArrayInputStream != null) + { + /* + * Closing a ByteArrayInputStream has no + * effect. The methods in this class can be + * called after the stream has been closed + * without generating an IOException. + */ + byteArrayInputStream.close(); + } + } + + } +} diff --git a/BasicJava/JavaIODemo_ByteArrayIS_Copy_to_DestArray_App/Output.txt b/BasicJava/JavaIODemo_ByteArrayIS_Copy_to_DestArray_App/Output.txt new file mode 100644 index 000000000..66b989ac9 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayIS_Copy_to_DestArray_App/Output.txt @@ -0,0 +1,5 @@ +All elements form srcBuffer: +11 12 13 14 15 16 17 18 19 20 + +All elements form destBuffer: +0 0 11 12 13 14 \ No newline at end of file diff --git a/BasicJava/JavaIODemo_ByteArrayIS_Read_ByteArray_Num_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_ByteArrayIS_Read_ByteArray_Num_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayIS_Read_ByteArray_Num_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_ByteArrayIS_Read_ByteArray_Num_App/JavaIODemo/.project b/BasicJava/JavaIODemo_ByteArrayIS_Read_ByteArray_Num_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayIS_Read_ByteArray_Num_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_ByteArrayIS_Read_ByteArray_Num_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_ByteArrayIS_Read_ByteArray_Num_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayIS_Read_ByteArray_Num_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_ByteArrayIS_Read_ByteArray_Num_App/JavaIODemo/bin/ByteArrayInputStreamDemo.class b/BasicJava/JavaIODemo_ByteArrayIS_Read_ByteArray_Num_App/JavaIODemo/bin/ByteArrayInputStreamDemo.class new file mode 100644 index 000000000..6f2aaa790 Binary files /dev/null and b/BasicJava/JavaIODemo_ByteArrayIS_Read_ByteArray_Num_App/JavaIODemo/bin/ByteArrayInputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_ByteArrayIS_Read_ByteArray_Num_App/JavaIODemo/src/ByteArrayInputStreamDemo.java b/BasicJava/JavaIODemo_ByteArrayIS_Read_ByteArray_Num_App/JavaIODemo/src/ByteArrayInputStreamDemo.java new file mode 100644 index 000000000..161b8b332 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayIS_Read_ByteArray_Num_App/JavaIODemo/src/ByteArrayInputStreamDemo.java @@ -0,0 +1,50 @@ +import java.io.ByteArrayInputStream; +import java.io.IOException; + +public class ByteArrayInputStreamDemo +{ + + public static void main(String[] args) throws IOException + { + ByteArrayInputStream byteArrayInputStream = null; + + try + { + byte[] buffer = new byte[5]; + + for (int i = 0; i < buffer.length; i++) + { + buffer[i] = (byte) i; + } + + byteArrayInputStream = new ByteArrayInputStream(buffer); + + System.out.println("All the elements in the buffer:"); + + int num; + /* + * Read every number inside the buffer using the + * read() method, which returns -1 if the end of + * the buffer is reached. + */ + while ((num = byteArrayInputStream.read()) != -1) + { + System.out.print(num + " "); + } + } + finally + { + if (byteArrayInputStream != null) + { + /* + * Closing a ByteArrayInputStream has no + * effect. The methods in this class can be + * called after the stream has been closed + * without generating an IOException. + */ + byteArrayInputStream.close(); + } + } + + } +} diff --git a/BasicJava/JavaIODemo_ByteArrayIS_Read_ByteArray_Num_App/Output.txt b/BasicJava/JavaIODemo_ByteArrayIS_Read_ByteArray_Num_App/Output.txt new file mode 100644 index 000000000..6b350a03c --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayIS_Read_ByteArray_Num_App/Output.txt @@ -0,0 +1,2 @@ +All the elements in the buffer: +0 1 2 3 4 \ No newline at end of file diff --git a/BasicJava/JavaIODemo_ByteArrayIS_Reset_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_ByteArrayIS_Reset_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayIS_Reset_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_ByteArrayIS_Reset_App/JavaIODemo/.project b/BasicJava/JavaIODemo_ByteArrayIS_Reset_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayIS_Reset_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_ByteArrayIS_Reset_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_ByteArrayIS_Reset_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayIS_Reset_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_ByteArrayIS_Reset_App/JavaIODemo/bin/ByteArrayInputStreamDemo.class b/BasicJava/JavaIODemo_ByteArrayIS_Reset_App/JavaIODemo/bin/ByteArrayInputStreamDemo.class new file mode 100644 index 000000000..8339ca4de Binary files /dev/null and b/BasicJava/JavaIODemo_ByteArrayIS_Reset_App/JavaIODemo/bin/ByteArrayInputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_ByteArrayIS_Reset_App/JavaIODemo/src/ByteArrayInputStreamDemo.java b/BasicJava/JavaIODemo_ByteArrayIS_Reset_App/JavaIODemo/src/ByteArrayInputStreamDemo.java new file mode 100644 index 000000000..c5ab028f4 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayIS_Reset_App/JavaIODemo/src/ByteArrayInputStreamDemo.java @@ -0,0 +1,52 @@ +import java.io.ByteArrayInputStream; +import java.io.IOException; + +/* + * This example first reads each character from the + * stream and prints it as is, in lowercase. It then + * resets the stream and begins reading again, this time + * converting each character to uppercase before + * printing. + */ + +public class ByteArrayInputStreamDemo +{ + + public static void main(String[] args) throws IOException + { + String str = "ram"; + byte byteArray[] = str.getBytes(); + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray); + for (int i = 0; i < 2; i++) + { + int c; + while ((c = byteArrayInputStream.read()) != -1) + { + if (i == 0) + { + System.out.print((char) c); + } + else + { + System.out.print(Character.toUpperCase((char) c)); + } + } + System.out.println(); + /* + * A ByteArrayInputStream implements both mark() + * and reset(). However, if mark() has not been + * called, then reset() sets the stream pointer + * to the start of the stream, which in this + * case is the start of the byte array passed to + * the constructor. + * + * Resets the buffer to the marked position. The + * marked position is 0 unless another position + * was marked or an offset was specified in the + * constructor. + */ + byteArrayInputStream.reset(); + } + } + +} diff --git a/BasicJava/JavaIODemo_ByteArrayIS_Reset_App/Output.txt b/BasicJava/JavaIODemo_ByteArrayIS_Reset_App/Output.txt new file mode 100644 index 000000000..f68681449 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayIS_Reset_App/Output.txt @@ -0,0 +1,2 @@ +ram +RAM diff --git a/BasicJava/JavaIODemo_ByteArrayIS_available_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_ByteArrayIS_available_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayIS_available_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_ByteArrayIS_available_App/JavaIODemo/.project b/BasicJava/JavaIODemo_ByteArrayIS_available_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayIS_available_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_ByteArrayIS_available_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_ByteArrayIS_available_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayIS_available_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_ByteArrayIS_available_App/JavaIODemo/bin/ByteArrayInputStreamDemo.class b/BasicJava/JavaIODemo_ByteArrayIS_available_App/JavaIODemo/bin/ByteArrayInputStreamDemo.class new file mode 100644 index 000000000..04785fc39 Binary files /dev/null and b/BasicJava/JavaIODemo_ByteArrayIS_available_App/JavaIODemo/bin/ByteArrayInputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_ByteArrayIS_available_App/JavaIODemo/src/ByteArrayInputStreamDemo.java b/BasicJava/JavaIODemo_ByteArrayIS_available_App/JavaIODemo/src/ByteArrayInputStreamDemo.java new file mode 100644 index 000000000..e800331f7 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayIS_available_App/JavaIODemo/src/ByteArrayInputStreamDemo.java @@ -0,0 +1,31 @@ +import java.io.ByteArrayInputStream; +import java.io.IOException; + +public class ByteArrayInputStreamDemo +{ + + public static void main(String[] args) throws IOException + { + String str = "Hello World!"; + byte[] byteArray = str.getBytes(); + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray); + + /* + * Returns: + * ------- + * + * The number of remaining bytes + * that can be read (or skipped over) from this + * input stream without blocking. + * + * The value returned is count - pos, which is the + * number of bytes remaining to be read from the + * input buffer. + */ + while (byteArrayInputStream.available() != 0) + { + System.out.print(new Character((char) byteArrayInputStream.read())); + } + } + +} diff --git a/BasicJava/JavaIODemo_ByteArrayIS_available_App/Output.txt b/BasicJava/JavaIODemo_ByteArrayIS_available_App/Output.txt new file mode 100644 index 000000000..c57eff55e --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayIS_available_App/Output.txt @@ -0,0 +1 @@ +Hello World! \ No newline at end of file diff --git a/BasicJava/JavaIODemo_ByteArrayInputStream_Intro_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_ByteArrayInputStream_Intro_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayInputStream_Intro_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_ByteArrayInputStream_Intro_App/JavaIODemo/.project b/BasicJava/JavaIODemo_ByteArrayInputStream_Intro_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayInputStream_Intro_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_ByteArrayInputStream_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_ByteArrayInputStream_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayInputStream_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_ByteArrayInputStream_Intro_App/JavaIODemo/bin/ByteArrayInputStreamDemo.class b/BasicJava/JavaIODemo_ByteArrayInputStream_Intro_App/JavaIODemo/bin/ByteArrayInputStreamDemo.class new file mode 100644 index 000000000..844d5524c Binary files /dev/null and b/BasicJava/JavaIODemo_ByteArrayInputStream_Intro_App/JavaIODemo/bin/ByteArrayInputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_ByteArrayInputStream_Intro_App/JavaIODemo/src/ByteArrayInputStreamDemo.java b/BasicJava/JavaIODemo_ByteArrayInputStream_Intro_App/JavaIODemo/src/ByteArrayInputStreamDemo.java new file mode 100644 index 000000000..8c40f73fa --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayInputStream_Intro_App/JavaIODemo/src/ByteArrayInputStreamDemo.java @@ -0,0 +1,38 @@ +import java.io.ByteArrayInputStream; +import java.io.IOException; + +public class ByteArrayInputStreamDemo +{ + + public static void main(String[] args) throws IOException + { + ByteArrayInputStream byteArrayInputStream = null; + + try + { + String str = "Peter is going to India."; + byte[] byteArray = str.getBytes(); + + byteArrayInputStream = new ByteArrayInputStream(byteArray); + int ch; + while ((ch = byteArrayInputStream.read()) != -1) + { + System.out.print((char) ch); + } + } + finally + { + if (byteArrayInputStream != null) + { + /* + * Closing a ByteArrayInputStream has no + * effect. The methods in this class can be + * called after the stream has been closed + * without generating an IOException. + */ + byteArrayInputStream.close(); + } + } + + } +} diff --git a/BasicJava/JavaIODemo_ByteArrayInputStream_Intro_App/Output.txt b/BasicJava/JavaIODemo_ByteArrayInputStream_Intro_App/Output.txt new file mode 100644 index 000000000..b2505dc4a --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayInputStream_Intro_App/Output.txt @@ -0,0 +1 @@ +Peter is going to India. \ No newline at end of file diff --git a/BasicJava/JavaIODemo_ByteArrayOS_ByteArrayIS_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_ByteArrayOS_ByteArrayIS_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOS_ByteArrayIS_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_ByteArrayOS_ByteArrayIS_App/JavaIODemo/.project b/BasicJava/JavaIODemo_ByteArrayOS_ByteArrayIS_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOS_ByteArrayIS_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_ByteArrayOS_ByteArrayIS_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_ByteArrayOS_ByteArrayIS_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOS_ByteArrayIS_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_ByteArrayOS_ByteArrayIS_App/JavaIODemo/bin/ByteArrayInputStreamDemo.class b/BasicJava/JavaIODemo_ByteArrayOS_ByteArrayIS_App/JavaIODemo/bin/ByteArrayInputStreamDemo.class new file mode 100644 index 000000000..61be252e0 Binary files /dev/null and b/BasicJava/JavaIODemo_ByteArrayOS_ByteArrayIS_App/JavaIODemo/bin/ByteArrayInputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_ByteArrayOS_ByteArrayIS_App/JavaIODemo/bin/ByteArrayOutputStreamDemo.class b/BasicJava/JavaIODemo_ByteArrayOS_ByteArrayIS_App/JavaIODemo/bin/ByteArrayOutputStreamDemo.class new file mode 100644 index 000000000..9eb83723f Binary files /dev/null and b/BasicJava/JavaIODemo_ByteArrayOS_ByteArrayIS_App/JavaIODemo/bin/ByteArrayOutputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_ByteArrayOS_ByteArrayIS_App/JavaIODemo/src/ByteArrayOutputStreamDemo.java b/BasicJava/JavaIODemo_ByteArrayOS_ByteArrayIS_App/JavaIODemo/src/ByteArrayOutputStreamDemo.java new file mode 100644 index 000000000..c8963f664 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOS_ByteArrayIS_App/JavaIODemo/src/ByteArrayOutputStreamDemo.java @@ -0,0 +1,44 @@ +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +public class ByteArrayOutputStreamDemo +{ + + public static void main(String[] args) throws IOException + { + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + + System.out.println("Enter the chars:"); + while (byteArrayOutputStream.size() != 4) + { + // Gets the inputs from the user + byteArrayOutputStream.write(System.in.read()); + } + + byte[] byteArray = byteArrayOutputStream.toByteArray(); + + System.out.println("\nPrint the content"); + for (int x = 0; x < byteArray.length; x++) + { + // printing the characters + System.out.print((char) byteArray[x] + " "); + } + System.out.println(" \n"); + + int c; + + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray); + + System.out.println("Converting characters to Upper case "); + for (int y = 0; y < 1; y++) + { + while ((c = byteArrayInputStream.read()) != -1) + { + System.out.print(Character.toUpperCase((char) c) + + " "); + } + } + } + +} diff --git a/BasicJava/JavaIODemo_ByteArrayOS_ByteArrayIS_App/Output.txt b/BasicJava/JavaIODemo_ByteArrayOS_ByteArrayIS_App/Output.txt new file mode 100644 index 000000000..e5a3fa6f9 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOS_ByteArrayIS_App/Output.txt @@ -0,0 +1,8 @@ +Enter the chars: +abcd + +Print the content +a b c d + +Converting characters to Upper case +A B C D \ No newline at end of file diff --git a/BasicJava/JavaIODemo_ByteArrayOS_Writeto_multipleFiles_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_ByteArrayOS_Writeto_multipleFiles_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOS_Writeto_multipleFiles_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_ByteArrayOS_Writeto_multipleFiles_App/JavaIODemo/.project b/BasicJava/JavaIODemo_ByteArrayOS_Writeto_multipleFiles_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOS_Writeto_multipleFiles_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_ByteArrayOS_Writeto_multipleFiles_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_ByteArrayOS_Writeto_multipleFiles_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOS_Writeto_multipleFiles_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_ByteArrayOS_Writeto_multipleFiles_App/JavaIODemo/bin/ByteArrayInputStreamDemo.class b/BasicJava/JavaIODemo_ByteArrayOS_Writeto_multipleFiles_App/JavaIODemo/bin/ByteArrayInputStreamDemo.class new file mode 100644 index 000000000..d54f584c9 Binary files /dev/null and b/BasicJava/JavaIODemo_ByteArrayOS_Writeto_multipleFiles_App/JavaIODemo/bin/ByteArrayInputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_ByteArrayOS_Writeto_multipleFiles_App/JavaIODemo/bin/ByteArrayOutputStreamDemo.class b/BasicJava/JavaIODemo_ByteArrayOS_Writeto_multipleFiles_App/JavaIODemo/bin/ByteArrayOutputStreamDemo.class new file mode 100644 index 000000000..6c9bd1fac Binary files /dev/null and b/BasicJava/JavaIODemo_ByteArrayOS_Writeto_multipleFiles_App/JavaIODemo/bin/ByteArrayOutputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_ByteArrayOS_Writeto_multipleFiles_App/JavaIODemo/myfile1.txt b/BasicJava/JavaIODemo_ByteArrayOS_Writeto_multipleFiles_App/JavaIODemo/myfile1.txt new file mode 100644 index 000000000..15a7d77af --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOS_Writeto_multipleFiles_App/JavaIODemo/myfile1.txt @@ -0,0 +1 @@ +Welcome to India \ No newline at end of file diff --git a/BasicJava/JavaIODemo_ByteArrayOS_Writeto_multipleFiles_App/JavaIODemo/myfile2.txt b/BasicJava/JavaIODemo_ByteArrayOS_Writeto_multipleFiles_App/JavaIODemo/myfile2.txt new file mode 100644 index 000000000..15a7d77af --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOS_Writeto_multipleFiles_App/JavaIODemo/myfile2.txt @@ -0,0 +1 @@ +Welcome to India \ No newline at end of file diff --git a/BasicJava/JavaIODemo_ByteArrayOS_Writeto_multipleFiles_App/JavaIODemo/src/ByteArrayOutputStreamDemo.java b/BasicJava/JavaIODemo_ByteArrayOS_Writeto_multipleFiles_App/JavaIODemo/src/ByteArrayOutputStreamDemo.java new file mode 100644 index 000000000..394c868e1 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOS_Writeto_multipleFiles_App/JavaIODemo/src/ByteArrayOutputStreamDemo.java @@ -0,0 +1,50 @@ +import java.io.ByteArrayOutputStream; +import java.io.FileOutputStream; +import java.io.IOException; + +public class ByteArrayOutputStreamDemo +{ + + public static void main(String[] args) throws IOException + { + FileOutputStream fileOutputStream1 = null; + FileOutputStream fileOutputStream2 = null; + ByteArrayOutputStream byteArrayOutputStream = null; + try + { + fileOutputStream1 = new FileOutputStream("myfile1.txt"); + fileOutputStream2 = new FileOutputStream("myfile2.txt"); + byteArrayOutputStream = new ByteArrayOutputStream(); + + String str = "Welcome to India"; + byte[] byteArray = str.getBytes(); + byteArrayOutputStream.write(byteArray); + + /* + * Writes the complete contents of this byte + * array output stream to the specified output + * stream argument + */ + byteArrayOutputStream.writeTo(fileOutputStream1); + byteArrayOutputStream.writeTo(fileOutputStream2); + + byteArrayOutputStream.flush(); + System.out.println("successfully written to two files..."); + } + finally + { + if (fileOutputStream1 != null) + { + fileOutputStream1.close(); + } + if (fileOutputStream2 != null) + { + fileOutputStream2.close(); + } + if (byteArrayOutputStream != null) + { + byteArrayOutputStream.close(); + } + } + } +} diff --git a/BasicJava/JavaIODemo_ByteArrayOS_Writeto_multipleFiles_App/Output.txt b/BasicJava/JavaIODemo_ByteArrayOS_Writeto_multipleFiles_App/Output.txt new file mode 100644 index 000000000..1b0ea1732 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOS_Writeto_multipleFiles_App/Output.txt @@ -0,0 +1 @@ +successfully written to two files... diff --git a/BasicJava/JavaIODemo_ByteArrayOS_get_content_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_ByteArrayOS_get_content_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOS_get_content_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_ByteArrayOS_get_content_App/JavaIODemo/.project b/BasicJava/JavaIODemo_ByteArrayOS_get_content_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOS_get_content_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_ByteArrayOS_get_content_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_ByteArrayOS_get_content_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOS_get_content_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_ByteArrayOS_get_content_App/JavaIODemo/bin/ByteArrayOutputStreamDemo.class b/BasicJava/JavaIODemo_ByteArrayOS_get_content_App/JavaIODemo/bin/ByteArrayOutputStreamDemo.class new file mode 100644 index 000000000..3829bcb18 Binary files /dev/null and b/BasicJava/JavaIODemo_ByteArrayOS_get_content_App/JavaIODemo/bin/ByteArrayOutputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_ByteArrayOS_get_content_App/JavaIODemo/src/ByteArrayOutputStreamDemo.java b/BasicJava/JavaIODemo_ByteArrayOS_get_content_App/JavaIODemo/src/ByteArrayOutputStreamDemo.java new file mode 100644 index 000000000..e00fd1499 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOS_get_content_App/JavaIODemo/src/ByteArrayOutputStreamDemo.java @@ -0,0 +1,25 @@ +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.Arrays; + +public class ByteArrayOutputStreamDemo +{ + + /* + * The following code creates a ByteArrayOutputStream + * and store value in it. Then it get the byte array out + * of ByteArrayOutputStream and print them out. + */ + public static void main(String[] args) throws IOException + { + ByteArrayOutputStream bout = new ByteArrayOutputStream(); + bout.write(("Hello world").getBytes()); + + System.out.println(Arrays.toString(bout.toByteArray())); + + System.out.println(bout.toString()); + + System.out.println(new String(bout.toByteArray())); + } + +} diff --git a/BasicJava/JavaIODemo_ByteArrayOS_get_content_App/Output.txt b/BasicJava/JavaIODemo_ByteArrayOS_get_content_App/Output.txt new file mode 100644 index 000000000..70a09389a --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOS_get_content_App/Output.txt @@ -0,0 +1,3 @@ +[72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100] +Hello world +Hello world diff --git a/BasicJava/JavaIODemo_ByteArrayOS_reset_method_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_ByteArrayOS_reset_method_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOS_reset_method_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_ByteArrayOS_reset_method_App/JavaIODemo/.project b/BasicJava/JavaIODemo_ByteArrayOS_reset_method_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOS_reset_method_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_ByteArrayOS_reset_method_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_ByteArrayOS_reset_method_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOS_reset_method_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_ByteArrayOS_reset_method_App/JavaIODemo/bin/ByteArrayOutputStreamDemo.class b/BasicJava/JavaIODemo_ByteArrayOS_reset_method_App/JavaIODemo/bin/ByteArrayOutputStreamDemo.class new file mode 100644 index 000000000..cb73d7005 Binary files /dev/null and b/BasicJava/JavaIODemo_ByteArrayOS_reset_method_App/JavaIODemo/bin/ByteArrayOutputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_ByteArrayOS_reset_method_App/JavaIODemo/src/ByteArrayOutputStreamDemo.java b/BasicJava/JavaIODemo_ByteArrayOS_reset_method_App/JavaIODemo/src/ByteArrayOutputStreamDemo.java new file mode 100644 index 000000000..5d2b75627 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOS_reset_method_App/JavaIODemo/src/ByteArrayOutputStreamDemo.java @@ -0,0 +1,58 @@ +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +public class ByteArrayOutputStreamDemo +{ + /* + * Created an instance of ByteArrayOutputStream and + * wrote 10 random bytes into it. After that, I turned + * the ByteArrayOutputStream instance into a byte array, + * using the toByteArray() method, and then printed + * every byte using a foreach loop. + * + * Using the reset() method to reset the + * ByteArrayOutputStream instance. Then, using the + * write() method to write four of the elements of + * byteArray, starting from the index 4 (which is the + * offset). + */ + + public static void main(String[] args) throws IOException + { + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + + for (int i = 0; i < 10; i++) + { + byteArrayOutputStream.write((byte) (Math.random() * 100)); + } + + byte[] byteArray = byteArrayOutputStream.toByteArray(); + System.out.println("The original array:"); + for (byte b : byteArray) + { + System.out.print(b + " "); + } + + /* + * Resets the count field of this byte array output + * stream to zero, so that all currently accumulated + * output in the output stream is discarded. The + * output stream can be used again, reusing the + * already allocated buffer space. + */ + byteArrayOutputStream.reset(); + + /* + * Writes len bytes from the specified byte array + * starting at offset off to this byte array output + * stream. + */ + byteArrayOutputStream.write(byteArray, 2, 4); + System.out.println("\n\nThe new byte array:"); + for (byte b : byteArrayOutputStream.toByteArray()) + { + System.out.print(b + " "); + } + } + +} diff --git a/BasicJava/JavaIODemo_ByteArrayOS_reset_method_App/Output.txt b/BasicJava/JavaIODemo_ByteArrayOS_reset_method_App/Output.txt new file mode 100644 index 000000000..f48e966e5 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOS_reset_method_App/Output.txt @@ -0,0 +1,5 @@ +The original array: +99 4 47 40 59 61 14 36 37 57 + +The new byte array: +47 40 59 61 \ No newline at end of file diff --git a/BasicJava/JavaIODemo_ByteArrayOS_size_method_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_ByteArrayOS_size_method_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOS_size_method_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_ByteArrayOS_size_method_App/JavaIODemo/.project b/BasicJava/JavaIODemo_ByteArrayOS_size_method_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOS_size_method_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_ByteArrayOS_size_method_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_ByteArrayOS_size_method_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOS_size_method_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_ByteArrayOS_size_method_App/JavaIODemo/bin/ByteArrayOutputStreamDemo.class b/BasicJava/JavaIODemo_ByteArrayOS_size_method_App/JavaIODemo/bin/ByteArrayOutputStreamDemo.class new file mode 100644 index 000000000..000da20bf Binary files /dev/null and b/BasicJava/JavaIODemo_ByteArrayOS_size_method_App/JavaIODemo/bin/ByteArrayOutputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_ByteArrayOS_size_method_App/JavaIODemo/src/ByteArrayOutputStreamDemo.java b/BasicJava/JavaIODemo_ByteArrayOS_size_method_App/JavaIODemo/src/ByteArrayOutputStreamDemo.java new file mode 100644 index 000000000..3f3e1a172 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOS_size_method_App/JavaIODemo/src/ByteArrayOutputStreamDemo.java @@ -0,0 +1,22 @@ +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +public class ByteArrayOutputStreamDemo +{ + + public static void main(String[] args) throws IOException + { + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + + byteArrayOutputStream.write("Hello world".getBytes()); + System.out.println("byteArrayOutputStream = " + byteArrayOutputStream); + + /* + * Returns the current size of the buffer. + */ + + System.out.println("size = " + byteArrayOutputStream.size()); + byteArrayOutputStream.close(); + } + +} diff --git a/BasicJava/JavaIODemo_ByteArrayOS_size_method_App/Output.txt b/BasicJava/JavaIODemo_ByteArrayOS_size_method_App/Output.txt new file mode 100644 index 000000000..fe2426b60 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOS_size_method_App/Output.txt @@ -0,0 +1,2 @@ +byteArrayOutputStream = Hello world +size = 11 diff --git a/BasicJava/JavaIODemo_ByteArrayOS_toByteArray_method_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_ByteArrayOS_toByteArray_method_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOS_toByteArray_method_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_ByteArrayOS_toByteArray_method_App/JavaIODemo/.project b/BasicJava/JavaIODemo_ByteArrayOS_toByteArray_method_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOS_toByteArray_method_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_ByteArrayOS_toByteArray_method_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_ByteArrayOS_toByteArray_method_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOS_toByteArray_method_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_ByteArrayOS_toByteArray_method_App/JavaIODemo/bin/ByteArrayOutputStreamDemo.class b/BasicJava/JavaIODemo_ByteArrayOS_toByteArray_method_App/JavaIODemo/bin/ByteArrayOutputStreamDemo.class new file mode 100644 index 000000000..d9941fbea Binary files /dev/null and b/BasicJava/JavaIODemo_ByteArrayOS_toByteArray_method_App/JavaIODemo/bin/ByteArrayOutputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_ByteArrayOS_toByteArray_method_App/JavaIODemo/src/ByteArrayOutputStreamDemo.java b/BasicJava/JavaIODemo_ByteArrayOS_toByteArray_method_App/JavaIODemo/src/ByteArrayOutputStreamDemo.java new file mode 100644 index 000000000..2aa1e0c8a --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOS_toByteArray_method_App/JavaIODemo/src/ByteArrayOutputStreamDemo.java @@ -0,0 +1,35 @@ +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +public class ByteArrayOutputStreamDemo +{ + /* + * Created an instance of ByteArrayOutputStream and + * wrote 5 random bytes into it. After that, I turned + * the ByteArrayOutputStream instance into a byte array, + * using the toByteArray() method, and then printed + * every byte using a foreach loop. + */ + + public static void main(String[] args) throws IOException + { + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + + for (int i = 0; i < 5; i++) + { + byteArrayOutputStream.write((byte) (Math.random() * 100)); + } + + /* + * Returns: + * -------- + * the current contents of this output stream, as a byte array. + */ + byte[] byteArray = byteArrayOutputStream.toByteArray(); + for (byte b : byteArray) + { + System.out.print(b + " "); + } + } + +} diff --git a/BasicJava/JavaIODemo_ByteArrayOS_toByteArray_method_App/Output.txt b/BasicJava/JavaIODemo_ByteArrayOS_toByteArray_method_App/Output.txt new file mode 100644 index 000000000..f64b3eead --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOS_toByteArray_method_App/Output.txt @@ -0,0 +1 @@ +1 31 88 43 27 \ No newline at end of file diff --git a/BasicJava/JavaIODemo_ByteArrayOutputStream_Intro_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_ByteArrayOutputStream_Intro_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOutputStream_Intro_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_ByteArrayOutputStream_Intro_App/JavaIODemo/.project b/BasicJava/JavaIODemo_ByteArrayOutputStream_Intro_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOutputStream_Intro_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_ByteArrayOutputStream_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_ByteArrayOutputStream_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOutputStream_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_ByteArrayOutputStream_Intro_App/JavaIODemo/bin/ByteArrayOutputStreamDemo.class b/BasicJava/JavaIODemo_ByteArrayOutputStream_Intro_App/JavaIODemo/bin/ByteArrayOutputStreamDemo.class new file mode 100644 index 000000000..9dafe314e Binary files /dev/null and b/BasicJava/JavaIODemo_ByteArrayOutputStream_Intro_App/JavaIODemo/bin/ByteArrayOutputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_ByteArrayOutputStream_Intro_App/JavaIODemo/src/ByteArrayOutputStreamDemo.java b/BasicJava/JavaIODemo_ByteArrayOutputStream_Intro_App/JavaIODemo/src/ByteArrayOutputStreamDemo.java new file mode 100644 index 000000000..c3413d7f4 --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOutputStream_Intro_App/JavaIODemo/src/ByteArrayOutputStreamDemo.java @@ -0,0 +1,38 @@ +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +public class ByteArrayOutputStreamDemo +{ + + public static void main(String[] args) throws IOException + { + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + + String str = "Welcome to India."; + byte[] byteArray = str.getBytes(); + byteArrayOutputStream.write(byteArray); + + System.out.println("Buffer as a string"); + /* + * Returns String decoded from the buffer's + * contents. + */ + String content = byteArrayOutputStream.toString(); + System.out.println(content); + + System.out.println("----------------------------------"); + System.out.println("Into array"); + + /* + * Returns the current contents of this output + * stream, as a byte array + */ + byte b[] = byteArrayOutputStream.toByteArray(); + + for (int i = 0; i < b.length; i++) + { + System.out.print((char) b[i]); + } + } + +} diff --git a/BasicJava/JavaIODemo_ByteArrayOutputStream_Intro_App/Output.txt b/BasicJava/JavaIODemo_ByteArrayOutputStream_Intro_App/Output.txt new file mode 100644 index 000000000..f92c7c3cc --- /dev/null +++ b/BasicJava/JavaIODemo_ByteArrayOutputStream_Intro_App/Output.txt @@ -0,0 +1,5 @@ +Buffer as a string +Welcome to India. +---------------------------------- +Into array +Welcome to India. \ No newline at end of file diff --git a/BasicJava/JavaIODemo_CharArrayReader_Copy_to_destCharArray_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_CharArrayReader_Copy_to_destCharArray_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayReader_Copy_to_destCharArray_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_CharArrayReader_Copy_to_destCharArray_App/JavaIODemo/.project b/BasicJava/JavaIODemo_CharArrayReader_Copy_to_destCharArray_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayReader_Copy_to_destCharArray_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_CharArrayReader_Copy_to_destCharArray_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_CharArrayReader_Copy_to_destCharArray_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayReader_Copy_to_destCharArray_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_CharArrayReader_Copy_to_destCharArray_App/JavaIODemo/bin/CharArrayReaderDemo.class b/BasicJava/JavaIODemo_CharArrayReader_Copy_to_destCharArray_App/JavaIODemo/bin/CharArrayReaderDemo.class new file mode 100644 index 000000000..ef229a428 Binary files /dev/null and b/BasicJava/JavaIODemo_CharArrayReader_Copy_to_destCharArray_App/JavaIODemo/bin/CharArrayReaderDemo.class differ diff --git a/BasicJava/JavaIODemo_CharArrayReader_Copy_to_destCharArray_App/JavaIODemo/src/CharArrayReaderDemo.java b/BasicJava/JavaIODemo_CharArrayReader_Copy_to_destCharArray_App/JavaIODemo/src/CharArrayReaderDemo.java new file mode 100644 index 000000000..74a024ea3 --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayReader_Copy_to_destCharArray_App/JavaIODemo/src/CharArrayReaderDemo.java @@ -0,0 +1,57 @@ +import java.io.CharArrayReader; +import java.io.IOException; + +/* + * public int read(char[] b, int off, int len) + * throws IOException + * + * Parameters: + * ---------- + * + * b - Destination buffer + * off - Offset at which to start storing characters + * len - Maximum number of characters to read + */ + +public class CharArrayReaderDemo +{ + + public static void main(String[] args) throws IOException + { + CharArrayReader charArrayReader = null; + try + { + + char[] srcCharArray = "Peter won the match".toCharArray(); + + charArrayReader = new CharArrayReader(srcCharArray); + + char[] destCharArray = new char[10]; + + /* + * Reads characters into a portion of an array. + * + * Returns: The actual number of characters + * read, or -1 if the end of the stream has been + * reached + */ + int numberOfCharsRead = charArrayReader.read(destCharArray, 0, 5); + System.out.println("numberOfCharsRead = " + numberOfCharsRead); + + for (int i = 0; i < destCharArray.length; i++) + { + System.out.print(destCharArray[i]); + } + + } + finally + { + if (charArrayReader != null) + { + charArrayReader.close(); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_CharArrayReader_Copy_to_destCharArray_App/Output.txt b/BasicJava/JavaIODemo_CharArrayReader_Copy_to_destCharArray_App/Output.txt new file mode 100644 index 000000000..705d37d44 --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayReader_Copy_to_destCharArray_App/Output.txt @@ -0,0 +1,2 @@ +numberOfCharsRead = 5 +Peter \ No newline at end of file diff --git a/BasicJava/JavaIODemo_CharArrayReader_Copy_to_sb_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_CharArrayReader_Copy_to_sb_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayReader_Copy_to_sb_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_CharArrayReader_Copy_to_sb_App/JavaIODemo/.project b/BasicJava/JavaIODemo_CharArrayReader_Copy_to_sb_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayReader_Copy_to_sb_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_CharArrayReader_Copy_to_sb_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_CharArrayReader_Copy_to_sb_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayReader_Copy_to_sb_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_CharArrayReader_Copy_to_sb_App/JavaIODemo/bin/CharArrayReaderDemo.class b/BasicJava/JavaIODemo_CharArrayReader_Copy_to_sb_App/JavaIODemo/bin/CharArrayReaderDemo.class new file mode 100644 index 000000000..1e8b45595 Binary files /dev/null and b/BasicJava/JavaIODemo_CharArrayReader_Copy_to_sb_App/JavaIODemo/bin/CharArrayReaderDemo.class differ diff --git a/BasicJava/JavaIODemo_CharArrayReader_Copy_to_sb_App/JavaIODemo/src/CharArrayReaderDemo.java b/BasicJava/JavaIODemo_CharArrayReader_Copy_to_sb_App/JavaIODemo/src/CharArrayReaderDemo.java new file mode 100644 index 000000000..f9d805a1e --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayReader_Copy_to_sb_App/JavaIODemo/src/CharArrayReaderDemo.java @@ -0,0 +1,35 @@ +import java.io.CharArrayReader; +import java.io.IOException; + +public class CharArrayReaderDemo +{ + + public static void main(String[] args) throws IOException + { + CharArrayReader charArrayReader = null; + try + { + char[] charArray = new char[] + { 'H', 'e', 'l', 'l', 'o', ' ', 'R', 'a', 'm' }; + + charArrayReader = new CharArrayReader(charArray); + + int ch = 0; + StringBuffer sb = new StringBuffer(""); + while ((ch = charArrayReader.read()) != -1) + { + sb.append((char) ch); + } + System.out.println("sb = " + sb); + + } + finally + { + if (charArrayReader != null) + { + charArrayReader.close(); + } + } + + } +} diff --git a/BasicJava/JavaIODemo_CharArrayReader_Copy_to_sb_App/Output.txt b/BasicJava/JavaIODemo_CharArrayReader_Copy_to_sb_App/Output.txt new file mode 100644 index 000000000..0d6c110fd --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayReader_Copy_to_sb_App/Output.txt @@ -0,0 +1 @@ +sb = Hello Ram diff --git a/BasicJava/JavaIODemo_CharArrayReader_Intro_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_CharArrayReader_Intro_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayReader_Intro_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_CharArrayReader_Intro_App/JavaIODemo/.project b/BasicJava/JavaIODemo_CharArrayReader_Intro_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayReader_Intro_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_CharArrayReader_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_CharArrayReader_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayReader_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_CharArrayReader_Intro_App/JavaIODemo/bin/CharArrayReaderDemo.class b/BasicJava/JavaIODemo_CharArrayReader_Intro_App/JavaIODemo/bin/CharArrayReaderDemo.class new file mode 100644 index 000000000..05d5129ad Binary files /dev/null and b/BasicJava/JavaIODemo_CharArrayReader_Intro_App/JavaIODemo/bin/CharArrayReaderDemo.class differ diff --git a/BasicJava/JavaIODemo_CharArrayReader_Intro_App/JavaIODemo/src/CharArrayReaderDemo.java b/BasicJava/JavaIODemo_CharArrayReader_Intro_App/JavaIODemo/src/CharArrayReaderDemo.java new file mode 100644 index 000000000..ea9763dac --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayReader_Intro_App/JavaIODemo/src/CharArrayReaderDemo.java @@ -0,0 +1,33 @@ +import java.io.CharArrayReader; +import java.io.IOException; + +public class CharArrayReaderDemo +{ + + public static void main(String[] args) throws IOException + { + CharArrayReader charArrayReader = null; + try + { + char[] charArray = "Peter".toCharArray(); + + charArrayReader = new CharArrayReader(charArray); + + int i; + while ((i = charArrayReader.read()) != -1) + { + System.out.print((char) i); + } + + } + finally + { + if (charArrayReader != null) + { + charArrayReader.close(); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_CharArrayReader_Intro_App/Output.txt b/BasicJava/JavaIODemo_CharArrayReader_Intro_App/Output.txt new file mode 100644 index 000000000..9cd89b6b7 --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayReader_Intro_App/Output.txt @@ -0,0 +1 @@ +Peter \ No newline at end of file diff --git a/BasicJava/JavaIODemo_CharArrayReader_Offset_length_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_CharArrayReader_Offset_length_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayReader_Offset_length_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_CharArrayReader_Offset_length_App/JavaIODemo/.project b/BasicJava/JavaIODemo_CharArrayReader_Offset_length_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayReader_Offset_length_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_CharArrayReader_Offset_length_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_CharArrayReader_Offset_length_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayReader_Offset_length_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_CharArrayReader_Offset_length_App/JavaIODemo/bin/CharArrayReaderDemo.class b/BasicJava/JavaIODemo_CharArrayReader_Offset_length_App/JavaIODemo/bin/CharArrayReaderDemo.class new file mode 100644 index 000000000..fb4473088 Binary files /dev/null and b/BasicJava/JavaIODemo_CharArrayReader_Offset_length_App/JavaIODemo/bin/CharArrayReaderDemo.class differ diff --git a/BasicJava/JavaIODemo_CharArrayReader_Offset_length_App/JavaIODemo/src/CharArrayReaderDemo.java b/BasicJava/JavaIODemo_CharArrayReader_Offset_length_App/JavaIODemo/src/CharArrayReaderDemo.java new file mode 100644 index 000000000..3699c13fa --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayReader_Offset_length_App/JavaIODemo/src/CharArrayReaderDemo.java @@ -0,0 +1,54 @@ +import java.io.CharArrayReader; +import java.io.IOException; + +/* + * public CharArrayReader(char[] buf, int offset, int length) + * + * Parameters: + * ----------- + * + * buf - Input buffer (not copied) + * offset - Offset of the first char to read + * length - Number of chars to read + */ + +public class CharArrayReaderDemo +{ + + public static void main(String[] args) throws IOException + { + CharArrayReader charArrayReader = null; + try + { + + char[] charArray = "Peter won the match".toCharArray(); + + /* + * Creates a CharArrayReader from the specified + * array of chars. + * + * The resulting reader will start reading at + * the given offset. The total number of char + * values that can be read from this reader will + * be either length or buf.length-offset, + * whichever is smaller. + */ + charArrayReader = new CharArrayReader(charArray, 14, 5); + + int i; + while ((i = charArrayReader.read()) != -1) + { + System.out.print((char) i); + } + } + finally + { + if (charArrayReader != null) + { + charArrayReader.close(); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_CharArrayReader_Offset_length_App/Output.txt b/BasicJava/JavaIODemo_CharArrayReader_Offset_length_App/Output.txt new file mode 100644 index 000000000..1f2063e23 --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayReader_Offset_length_App/Output.txt @@ -0,0 +1 @@ +match \ No newline at end of file diff --git a/BasicJava/JavaIODemo_CharArrayWriter_Cons_InitialSize_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_CharArrayWriter_Cons_InitialSize_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayWriter_Cons_InitialSize_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_CharArrayWriter_Cons_InitialSize_App/JavaIODemo/.project b/BasicJava/JavaIODemo_CharArrayWriter_Cons_InitialSize_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayWriter_Cons_InitialSize_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_CharArrayWriter_Cons_InitialSize_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_CharArrayWriter_Cons_InitialSize_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayWriter_Cons_InitialSize_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_CharArrayWriter_Cons_InitialSize_App/JavaIODemo/bin/CharArrayWriterDemo.class b/BasicJava/JavaIODemo_CharArrayWriter_Cons_InitialSize_App/JavaIODemo/bin/CharArrayWriterDemo.class new file mode 100644 index 000000000..54a1581c5 Binary files /dev/null and b/BasicJava/JavaIODemo_CharArrayWriter_Cons_InitialSize_App/JavaIODemo/bin/CharArrayWriterDemo.class differ diff --git a/BasicJava/JavaIODemo_CharArrayWriter_Cons_InitialSize_App/JavaIODemo/src/CharArrayWriterDemo.java b/BasicJava/JavaIODemo_CharArrayWriter_Cons_InitialSize_App/JavaIODemo/src/CharArrayWriterDemo.java new file mode 100644 index 000000000..16e2e5ace --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayWriter_Cons_InitialSize_App/JavaIODemo/src/CharArrayWriterDemo.java @@ -0,0 +1,41 @@ +import java.io.CharArrayWriter; +import java.io.IOException; + +/* + * public CharArrayWriter(int initialSize) + * + * Parameters: + * ---------- + * + * initialSize - an int specifying the initial buffer + * size. + */ + +public class CharArrayWriterDemo +{ + + public static void main(String[] args) throws IOException + { + + int initialSize = 1024; + /* + * Creates a new CharArrayWriter with the specified + * initial size. + */ + CharArrayWriter charArrayWriter = new CharArrayWriter(initialSize); + + charArrayWriter.write("Welcome to India."); + + /* + * Returns: an array of chars copied from the input + * data. + */ + char[] charArray = charArrayWriter.toCharArray(); + + for (char c : charArray) + { + System.out.print(c); + } + + } +} diff --git a/BasicJava/JavaIODemo_CharArrayWriter_Cons_InitialSize_App/Output.txt b/BasicJava/JavaIODemo_CharArrayWriter_Cons_InitialSize_App/Output.txt new file mode 100644 index 000000000..26698bfbc --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayWriter_Cons_InitialSize_App/Output.txt @@ -0,0 +1 @@ +Welcome to India. \ No newline at end of file diff --git a/BasicJava/JavaIODemo_CharArrayWriter_Intro_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_CharArrayWriter_Intro_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayWriter_Intro_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_CharArrayWriter_Intro_App/JavaIODemo/.project b/BasicJava/JavaIODemo_CharArrayWriter_Intro_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayWriter_Intro_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_CharArrayWriter_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_CharArrayWriter_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayWriter_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_CharArrayWriter_Intro_App/JavaIODemo/bin/CharArrayWriterDemo.class b/BasicJava/JavaIODemo_CharArrayWriter_Intro_App/JavaIODemo/bin/CharArrayWriterDemo.class new file mode 100644 index 000000000..22a665a69 Binary files /dev/null and b/BasicJava/JavaIODemo_CharArrayWriter_Intro_App/JavaIODemo/bin/CharArrayWriterDemo.class differ diff --git a/BasicJava/JavaIODemo_CharArrayWriter_Intro_App/JavaIODemo/src/CharArrayWriterDemo.java b/BasicJava/JavaIODemo_CharArrayWriter_Intro_App/JavaIODemo/src/CharArrayWriterDemo.java new file mode 100644 index 000000000..cfae6fdf3 --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayWriter_Intro_App/JavaIODemo/src/CharArrayWriterDemo.java @@ -0,0 +1,25 @@ +import java.io.CharArrayWriter; +import java.io.IOException; + +public class CharArrayWriterDemo +{ + + public static void main(String[] args) throws IOException + { + CharArrayWriter charArrayWriter = new CharArrayWriter(); + + charArrayWriter.write("Welcome to India."); + + /* + * Returns: an array of chars copied from the input + * data. + */ + char[] charArray = charArrayWriter.toCharArray(); + + for (char c : charArray) + { + System.out.print(c); + } + + } +} diff --git a/BasicJava/JavaIODemo_CharArrayWriter_Intro_App/Output.txt b/BasicJava/JavaIODemo_CharArrayWriter_Intro_App/Output.txt new file mode 100644 index 000000000..26698bfbc --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayWriter_Intro_App/Output.txt @@ -0,0 +1 @@ +Welcome to India. \ No newline at end of file diff --git a/BasicJava/JavaIODemo_CharArrayWriter_append_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_CharArrayWriter_append_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayWriter_append_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_CharArrayWriter_append_App/JavaIODemo/.project b/BasicJava/JavaIODemo_CharArrayWriter_append_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayWriter_append_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_CharArrayWriter_append_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_CharArrayWriter_append_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayWriter_append_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_CharArrayWriter_append_App/JavaIODemo/bin/CharArrayWriterDemo.class b/BasicJava/JavaIODemo_CharArrayWriter_append_App/JavaIODemo/bin/CharArrayWriterDemo.class new file mode 100644 index 000000000..4b810b953 Binary files /dev/null and b/BasicJava/JavaIODemo_CharArrayWriter_append_App/JavaIODemo/bin/CharArrayWriterDemo.class differ diff --git a/BasicJava/JavaIODemo_CharArrayWriter_append_App/JavaIODemo/src/CharArrayWriterDemo.java b/BasicJava/JavaIODemo_CharArrayWriter_append_App/JavaIODemo/src/CharArrayWriterDemo.java new file mode 100644 index 000000000..322256e46 --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayWriter_append_App/JavaIODemo/src/CharArrayWriterDemo.java @@ -0,0 +1,33 @@ +import java.io.CharArrayWriter; +import java.io.IOException; + +/* + * public CharArrayWriter append(CharSequence csq) + * + * Parameters: + * ---------- + * + * csq - The character sequence to append. If csq is + * null, then the four characters "null" are appended to + * this writer. + */ + +public class CharArrayWriterDemo +{ + + public static void main(String[] args) throws IOException + { + + CharArrayWriter charArrayWriter = new CharArrayWriter(); + charArrayWriter.write("Peter is going to India,"); + + CharSequence csq = "John is going to Japan."; + /* + * Appends the specified character sequence to this + * writer. + */ + charArrayWriter.append(csq); + System.out.println(charArrayWriter.toString()); + + } +} diff --git a/BasicJava/JavaIODemo_CharArrayWriter_append_App/Output.txt b/BasicJava/JavaIODemo_CharArrayWriter_append_App/Output.txt new file mode 100644 index 000000000..b8c369fd1 --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayWriter_append_App/Output.txt @@ -0,0 +1 @@ +Peter is going to India,John is going to Japan. diff --git a/BasicJava/JavaIODemo_CharArrayWriter_append_char_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_CharArrayWriter_append_char_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayWriter_append_char_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_CharArrayWriter_append_char_App/JavaIODemo/.project b/BasicJava/JavaIODemo_CharArrayWriter_append_char_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayWriter_append_char_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_CharArrayWriter_append_char_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_CharArrayWriter_append_char_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayWriter_append_char_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_CharArrayWriter_append_char_App/JavaIODemo/bin/CharArrayWriterDemo.class b/BasicJava/JavaIODemo_CharArrayWriter_append_char_App/JavaIODemo/bin/CharArrayWriterDemo.class new file mode 100644 index 000000000..324d1f1f1 Binary files /dev/null and b/BasicJava/JavaIODemo_CharArrayWriter_append_char_App/JavaIODemo/bin/CharArrayWriterDemo.class differ diff --git a/BasicJava/JavaIODemo_CharArrayWriter_append_char_App/JavaIODemo/src/CharArrayWriterDemo.java b/BasicJava/JavaIODemo_CharArrayWriter_append_char_App/JavaIODemo/src/CharArrayWriterDemo.java new file mode 100644 index 000000000..063092983 --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayWriter_append_char_App/JavaIODemo/src/CharArrayWriterDemo.java @@ -0,0 +1,29 @@ +import java.io.CharArrayWriter; +import java.io.IOException; + +/* + * public CharArrayWriter append(char c) + * + * Parameters: + * ---------- + * + * c - The 16-bit character to append. * + */ +public class CharArrayWriterDemo +{ + + public static void main(String[] args) throws IOException + { + + CharArrayWriter charArrayWriter = new CharArrayWriter(); + charArrayWriter.write("Peter is going to India,"); + + char ch = 'R'; + /* + * Appends the specified character to this writer. + */ + charArrayWriter.append(ch); + System.out.println(charArrayWriter.toString()); + + } +} diff --git a/BasicJava/JavaIODemo_CharArrayWriter_append_char_App/Output.txt b/BasicJava/JavaIODemo_CharArrayWriter_append_char_App/Output.txt new file mode 100644 index 000000000..8b7fb9369 --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayWriter_append_char_App/Output.txt @@ -0,0 +1 @@ +Peter is going to India,R diff --git a/BasicJava/JavaIODemo_CharArrayWriter_append_subsequence_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_CharArrayWriter_append_subsequence_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayWriter_append_subsequence_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_CharArrayWriter_append_subsequence_App/JavaIODemo/.project b/BasicJava/JavaIODemo_CharArrayWriter_append_subsequence_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayWriter_append_subsequence_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_CharArrayWriter_append_subsequence_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_CharArrayWriter_append_subsequence_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayWriter_append_subsequence_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_CharArrayWriter_append_subsequence_App/JavaIODemo/bin/CharArrayWriterDemo.class b/BasicJava/JavaIODemo_CharArrayWriter_append_subsequence_App/JavaIODemo/bin/CharArrayWriterDemo.class new file mode 100644 index 000000000..6b7992158 Binary files /dev/null and b/BasicJava/JavaIODemo_CharArrayWriter_append_subsequence_App/JavaIODemo/bin/CharArrayWriterDemo.class differ diff --git a/BasicJava/JavaIODemo_CharArrayWriter_append_subsequence_App/JavaIODemo/src/CharArrayWriterDemo.java b/BasicJava/JavaIODemo_CharArrayWriter_append_subsequence_App/JavaIODemo/src/CharArrayWriterDemo.java new file mode 100644 index 000000000..c9f408222 --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayWriter_append_subsequence_App/JavaIODemo/src/CharArrayWriterDemo.java @@ -0,0 +1,40 @@ +import java.io.CharArrayWriter; +import java.io.IOException; + +/* + * public CharArrayWriter append(CharSequence csq, int + * start, int end) + * + * Parameters: + * ---------- + * + * csq - The character sequence from which a subsequence + * will be appended. If csq is null, then characters + * will be appended as if csq contained the four + * characters "null". + * + * start - The index of the first character in the + * subsequence + * + * end - The index of the character following the last + * character in the subsequence + */ +public class CharArrayWriterDemo +{ + + public static void main(String[] args) throws IOException + { + + CharArrayWriter charArrayWriter = new CharArrayWriter(); + charArrayWriter.write("Peter is going to India,"); + + CharSequence csq = "John is going to Japan."; + /* + * Appends a subsequence of the specified character + * sequence to this writer. + */ + charArrayWriter.append(csq, 0, 4); + System.out.println(charArrayWriter.toString()); + + } +} diff --git a/BasicJava/JavaIODemo_CharArrayWriter_append_subsequence_App/Output.txt b/BasicJava/JavaIODemo_CharArrayWriter_append_subsequence_App/Output.txt new file mode 100644 index 000000000..e0c089a82 --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayWriter_append_subsequence_App/Output.txt @@ -0,0 +1 @@ +Peter is going to India,John diff --git a/BasicJava/JavaIODemo_CharArrayWriter_multifiles_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_CharArrayWriter_multifiles_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayWriter_multifiles_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_CharArrayWriter_multifiles_App/JavaIODemo/.project b/BasicJava/JavaIODemo_CharArrayWriter_multifiles_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayWriter_multifiles_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_CharArrayWriter_multifiles_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_CharArrayWriter_multifiles_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayWriter_multifiles_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_CharArrayWriter_multifiles_App/JavaIODemo/bin/CharArrayWriterDemo.class b/BasicJava/JavaIODemo_CharArrayWriter_multifiles_App/JavaIODemo/bin/CharArrayWriterDemo.class new file mode 100644 index 000000000..ff5a6bdd9 Binary files /dev/null and b/BasicJava/JavaIODemo_CharArrayWriter_multifiles_App/JavaIODemo/bin/CharArrayWriterDemo.class differ diff --git a/BasicJava/JavaIODemo_CharArrayWriter_multifiles_App/JavaIODemo/myfile1.txt b/BasicJava/JavaIODemo_CharArrayWriter_multifiles_App/JavaIODemo/myfile1.txt new file mode 100644 index 000000000..22c9c4696 --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayWriter_multifiles_App/JavaIODemo/myfile1.txt @@ -0,0 +1 @@ +Peter is going to India \ No newline at end of file diff --git a/BasicJava/JavaIODemo_CharArrayWriter_multifiles_App/JavaIODemo/myfile2.txt b/BasicJava/JavaIODemo_CharArrayWriter_multifiles_App/JavaIODemo/myfile2.txt new file mode 100644 index 000000000..22c9c4696 --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayWriter_multifiles_App/JavaIODemo/myfile2.txt @@ -0,0 +1 @@ +Peter is going to India \ No newline at end of file diff --git a/BasicJava/JavaIODemo_CharArrayWriter_multifiles_App/JavaIODemo/src/CharArrayWriterDemo.java b/BasicJava/JavaIODemo_CharArrayWriter_multifiles_App/JavaIODemo/src/CharArrayWriterDemo.java new file mode 100644 index 000000000..a4189f07b --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayWriter_multifiles_App/JavaIODemo/src/CharArrayWriterDemo.java @@ -0,0 +1,50 @@ +import java.io.CharArrayWriter; +import java.io.FileWriter; +import java.io.IOException; + +/* + * public void writeTo(Writer out) throws IOException + * + * Parameters: + * ----------- + * + * out - the output stream to write to + */ +public class CharArrayWriterDemo +{ + + public static void main(String[] args) throws IOException + { + + FileWriter fileWriter1 = null; + FileWriter fileWriter2 = null; + try + { + CharArrayWriter charArrayWriter = new CharArrayWriter(); + charArrayWriter.write("Peter is going to India"); + + fileWriter1 = new FileWriter("myfile1.txt"); + fileWriter2 = new FileWriter("myfile2.txt"); + + /* + * Writes the contents of the buffer to another + * character stream. + */ + charArrayWriter.writeTo(fileWriter1); + charArrayWriter.writeTo(fileWriter2); + System.out.println("Successfully written to two files."); + } + finally + { + if (fileWriter1 != null) + { + fileWriter1.close(); + } + if (fileWriter2 != null) + { + fileWriter2.close(); + } + } + + } +} diff --git a/BasicJava/JavaIODemo_CharArrayWriter_multifiles_App/Output.txt b/BasicJava/JavaIODemo_CharArrayWriter_multifiles_App/Output.txt new file mode 100644 index 000000000..6fcabc2ee --- /dev/null +++ b/BasicJava/JavaIODemo_CharArrayWriter_multifiles_App/Output.txt @@ -0,0 +1 @@ +Successfully written to two files. diff --git a/BasicJava/JavaIODemo_Console_class_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_Console_class_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_Console_class_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_Console_class_App/JavaIODemo/.project b/BasicJava/JavaIODemo_Console_class_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_Console_class_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_Console_class_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_Console_class_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_Console_class_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_Console_class_App/JavaIODemo/bin/ConsoleDemo.class b/BasicJava/JavaIODemo_Console_class_App/JavaIODemo/bin/ConsoleDemo.class new file mode 100644 index 000000000..939694d86 Binary files /dev/null and b/BasicJava/JavaIODemo_Console_class_App/JavaIODemo/bin/ConsoleDemo.class differ diff --git a/BasicJava/JavaIODemo_Console_class_App/JavaIODemo/myoutputfile.txt b/BasicJava/JavaIODemo_Console_class_App/JavaIODemo/myoutputfile.txt new file mode 100644 index 000000000..23aebe15b --- /dev/null +++ b/BasicJava/JavaIODemo_Console_class_App/JavaIODemo/myoutputfile.txt @@ -0,0 +1,2 @@ +Peter is going to India. +John is going to India. \ No newline at end of file diff --git a/BasicJava/JavaIODemo_Console_class_App/JavaIODemo/src/ConsoleDemo.java b/BasicJava/JavaIODemo_Console_class_App/JavaIODemo/src/ConsoleDemo.java new file mode 100644 index 000000000..b6e6dab24 --- /dev/null +++ b/BasicJava/JavaIODemo_Console_class_App/JavaIODemo/src/ConsoleDemo.java @@ -0,0 +1,31 @@ +import java.io.Console; +import java.io.IOException; + +public class ConsoleDemo +{ + + public static void main(String[] args) throws IOException + { + ConsoleDemo consoleDemo = new ConsoleDemo(); + consoleDemo.readFromConsole(); + } + + private void readFromConsole() throws IOException + { + /* + * System class provides a static method console() + * that returns the unique instance of Console + * class. + */ + Console console = System.console(); + System.out.print("Enter the username : "); + String name = console.readLine(); + System.out.println("UserName = " + name); + + System.out.print("Enter the password : "); + char[] passWordArray = console.readPassword(); + String passWord = new String(passWordArray); + System.out.println("PassWord = " + passWord); + } + +} diff --git a/BasicJava/JavaIODemo_Console_class_App/Output.txt b/BasicJava/JavaIODemo_Console_class_App/Output.txt new file mode 100644 index 000000000..abde22487 --- /dev/null +++ b/BasicJava/JavaIODemo_Console_class_App/Output.txt @@ -0,0 +1,5 @@ +D:\eclipse\workspace\JavaIODemo\bin>java ConsoleDemo +Enter the username : Peter +UserName = Peter +Enter the password : +PassWord = welcome \ No newline at end of file diff --git a/BasicJava/JavaIODemo_DataInputStream_DataOutputStream_App/DataInputStreamDemo_Output.txt b/BasicJava/JavaIODemo_DataInputStream_DataOutputStream_App/DataInputStreamDemo_Output.txt new file mode 100644 index 000000000..0cc5408f6 --- /dev/null +++ b/BasicJava/JavaIODemo_DataInputStream_DataOutputStream_App/DataInputStreamDemo_Output.txt @@ -0,0 +1,4 @@ +intValue = 125 +floatValue = 150.45 +longValue = 9090 +booleanValue = true diff --git a/BasicJava/JavaIODemo_DataInputStream_DataOutputStream_App/DataOutputStreamDemo_Output.txt b/BasicJava/JavaIODemo_DataInputStream_DataOutputStream_App/DataOutputStreamDemo_Output.txt new file mode 100644 index 000000000..7cd149393 --- /dev/null +++ b/BasicJava/JavaIODemo_DataInputStream_DataOutputStream_App/DataOutputStreamDemo_Output.txt @@ -0,0 +1 @@ +Successfully written primitive data's to 'data.bin' file \ No newline at end of file diff --git a/BasicJava/JavaIODemo_DataInputStream_DataOutputStream_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_DataInputStream_DataOutputStream_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_DataInputStream_DataOutputStream_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_DataInputStream_DataOutputStream_App/JavaIODemo/.project b/BasicJava/JavaIODemo_DataInputStream_DataOutputStream_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_DataInputStream_DataOutputStream_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_DataInputStream_DataOutputStream_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_DataInputStream_DataOutputStream_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_DataInputStream_DataOutputStream_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_DataInputStream_DataOutputStream_App/JavaIODemo/bin/DataInputStreamDemo.class b/BasicJava/JavaIODemo_DataInputStream_DataOutputStream_App/JavaIODemo/bin/DataInputStreamDemo.class new file mode 100644 index 000000000..81efab70c Binary files /dev/null and b/BasicJava/JavaIODemo_DataInputStream_DataOutputStream_App/JavaIODemo/bin/DataInputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_DataInputStream_DataOutputStream_App/JavaIODemo/bin/DataOutputStreamDemo.class b/BasicJava/JavaIODemo_DataInputStream_DataOutputStream_App/JavaIODemo/bin/DataOutputStreamDemo.class new file mode 100644 index 000000000..a36396b64 Binary files /dev/null and b/BasicJava/JavaIODemo_DataInputStream_DataOutputStream_App/JavaIODemo/bin/DataOutputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_DataInputStream_DataOutputStream_App/JavaIODemo/data.bin b/BasicJava/JavaIODemo_DataInputStream_DataOutputStream_App/JavaIODemo/data.bin new file mode 100644 index 000000000..db73bd26d Binary files /dev/null and b/BasicJava/JavaIODemo_DataInputStream_DataOutputStream_App/JavaIODemo/data.bin differ diff --git a/BasicJava/JavaIODemo_DataInputStream_DataOutputStream_App/JavaIODemo/src/DataInputStreamDemo.java b/BasicJava/JavaIODemo_DataInputStream_DataOutputStream_App/JavaIODemo/src/DataInputStreamDemo.java new file mode 100644 index 000000000..0447e85a7 --- /dev/null +++ b/BasicJava/JavaIODemo_DataInputStream_DataOutputStream_App/JavaIODemo/src/DataInputStreamDemo.java @@ -0,0 +1,49 @@ +import java.io.DataInputStream; +import java.io.FileInputStream; +import java.io.IOException; + +public class DataInputStreamDemo +{ + + public static void main(String[] args) throws Exception + { + DataInputStreamDemo dataInputStreamDemo = new DataInputStreamDemo(); + dataInputStreamDemo.readPrimitiveData(); + } + + public void readPrimitiveData() throws IOException + { + FileInputStream fileInputStream = null; + DataInputStream dataInputStream = null; + + try + { + fileInputStream = new FileInputStream("data.bin"); + dataInputStream = new DataInputStream(fileInputStream); + + int intValue = dataInputStream.readInt(); + float floatValue = dataInputStream.readFloat(); + long longValue = dataInputStream.readLong(); + boolean booleanValue = dataInputStream.readBoolean(); + + System.out.println("intValue = " + intValue); + System.out.println("floatValue = " + floatValue); + System.out.println("longValue = " + longValue); + System.out.println("booleanValue = " + booleanValue); + } + finally + { + if (dataInputStream != null) + { + /* + * Closing a DataInputStream will also close + * the InputStream instance from which the + * DataInputStream is reading. + */ + dataInputStream.close(); + } + } + + } + +} \ No newline at end of file diff --git a/BasicJava/JavaIODemo_DataInputStream_DataOutputStream_App/JavaIODemo/src/DataOutputStreamDemo.java b/BasicJava/JavaIODemo_DataInputStream_DataOutputStream_App/JavaIODemo/src/DataOutputStreamDemo.java new file mode 100644 index 000000000..bdfd113d7 --- /dev/null +++ b/BasicJava/JavaIODemo_DataInputStream_DataOutputStream_App/JavaIODemo/src/DataOutputStreamDemo.java @@ -0,0 +1,44 @@ +import java.io.DataOutputStream; +import java.io.FileOutputStream; +import java.io.IOException; + +public class DataOutputStreamDemo +{ + + public static void main(String[] args) throws Exception + { + DataOutputStreamDemo dataOutputStreamDemo = new DataOutputStreamDemo(); + dataOutputStreamDemo.writePrimitiveData(); + } + + public void writePrimitiveData() throws IOException + { + DataOutputStream dataOutputStream = null; + FileOutputStream fileOutputStream = null; + try + { + fileOutputStream = new FileOutputStream("data.bin"); + dataOutputStream = new DataOutputStream(fileOutputStream); + + dataOutputStream.writeInt(125); + dataOutputStream.writeFloat(150.45F); + dataOutputStream.writeLong(9090); + dataOutputStream.writeBoolean(true); + + System.out.println("Successfully written primitive data's to \'data.bin\' file\n"); + } + finally + { + if (dataOutputStream != null) + { + /* + * Closing a DataOutputStream will also + * close the OutputStream instance to which + * the DataOutputStream is writing. + */ + dataOutputStream.close(); + } + } + + } +} \ No newline at end of file diff --git a/BasicJava/JavaIODemo_DataInput_and_Output_Stream_Example_App/DataInputStreamDemo_Output.txt b/BasicJava/JavaIODemo_DataInput_and_Output_Stream_Example_App/DataInputStreamDemo_Output.txt new file mode 100644 index 000000000..60df81ede --- /dev/null +++ b/BasicJava/JavaIODemo_DataInput_and_Output_Stream_Example_App/DataInputStreamDemo_Output.txt @@ -0,0 +1,5 @@ +100 +250 +440 +550 +900 diff --git a/BasicJava/JavaIODemo_DataInput_and_Output_Stream_Example_App/DataOutputStreamDemo_Output.txt b/BasicJava/JavaIODemo_DataInput_and_Output_Stream_Example_App/DataOutputStreamDemo_Output.txt new file mode 100644 index 000000000..2c43cb565 --- /dev/null +++ b/BasicJava/JavaIODemo_DataInput_and_Output_Stream_Example_App/DataOutputStreamDemo_Output.txt @@ -0,0 +1 @@ +Successfully written to 'data.txt' file \ No newline at end of file diff --git a/BasicJava/JavaIODemo_DataInput_and_Output_Stream_Example_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_DataInput_and_Output_Stream_Example_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_DataInput_and_Output_Stream_Example_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_DataInput_and_Output_Stream_Example_App/JavaIODemo/.project b/BasicJava/JavaIODemo_DataInput_and_Output_Stream_Example_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_DataInput_and_Output_Stream_Example_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_DataInput_and_Output_Stream_Example_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_DataInput_and_Output_Stream_Example_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_DataInput_and_Output_Stream_Example_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_DataInput_and_Output_Stream_Example_App/JavaIODemo/bin/DataInputStreamDemo.class b/BasicJava/JavaIODemo_DataInput_and_Output_Stream_Example_App/JavaIODemo/bin/DataInputStreamDemo.class new file mode 100644 index 000000000..d7d0799d7 Binary files /dev/null and b/BasicJava/JavaIODemo_DataInput_and_Output_Stream_Example_App/JavaIODemo/bin/DataInputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_DataInput_and_Output_Stream_Example_App/JavaIODemo/bin/DataOutputStreamDemo.class b/BasicJava/JavaIODemo_DataInput_and_Output_Stream_Example_App/JavaIODemo/bin/DataOutputStreamDemo.class new file mode 100644 index 000000000..8c67831d6 Binary files /dev/null and b/BasicJava/JavaIODemo_DataInput_and_Output_Stream_Example_App/JavaIODemo/bin/DataOutputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_DataInput_and_Output_Stream_Example_App/JavaIODemo/data.txt b/BasicJava/JavaIODemo_DataInput_and_Output_Stream_Example_App/JavaIODemo/data.txt new file mode 100644 index 000000000..d5a291093 Binary files /dev/null and b/BasicJava/JavaIODemo_DataInput_and_Output_Stream_Example_App/JavaIODemo/data.txt differ diff --git a/BasicJava/JavaIODemo_DataInput_and_Output_Stream_Example_App/JavaIODemo/src/DataInputStreamDemo.java b/BasicJava/JavaIODemo_DataInput_and_Output_Stream_Example_App/JavaIODemo/src/DataInputStreamDemo.java new file mode 100644 index 000000000..5e3e6af8d --- /dev/null +++ b/BasicJava/JavaIODemo_DataInput_and_Output_Stream_Example_App/JavaIODemo/src/DataInputStreamDemo.java @@ -0,0 +1,46 @@ +import java.io.DataInputStream; +import java.io.FileInputStream; +import java.io.IOException; + +public class DataInputStreamDemo +{ + + public static void main(String[] args) throws Exception + { + DataInputStreamDemo dataInputStreamDemo = new DataInputStreamDemo(); + dataInputStreamDemo.readPrimitiveData(); + } + + public void readPrimitiveData() throws IOException + { + FileInputStream fileInputStream = null; + DataInputStream dataInputStream = null; + + try + { + fileInputStream = new FileInputStream("data.txt"); + dataInputStream = new DataInputStream(fileInputStream); + + while (dataInputStream.available() > 0) + { + int intValue = dataInputStream.readInt(); + System.out.println(intValue); + } + + } + finally + { + if (dataInputStream != null) + { + /* + * Closing a DataInputStream will also close + * the InputStream instance from which the + * DataInputStream is reading. + */ + dataInputStream.close(); + } + } + + } + +} \ No newline at end of file diff --git a/BasicJava/JavaIODemo_DataInput_and_Output_Stream_Example_App/JavaIODemo/src/DataOutputStreamDemo.java b/BasicJava/JavaIODemo_DataInput_and_Output_Stream_Example_App/JavaIODemo/src/DataOutputStreamDemo.java new file mode 100644 index 000000000..724a43b93 --- /dev/null +++ b/BasicJava/JavaIODemo_DataInput_and_Output_Stream_Example_App/JavaIODemo/src/DataOutputStreamDemo.java @@ -0,0 +1,45 @@ +import java.io.DataOutputStream; +import java.io.FileOutputStream; +import java.io.IOException; + +public class DataOutputStreamDemo +{ + + public static void main(String[] args) throws Exception + { + DataOutputStreamDemo dataOutputStreamDemo = new DataOutputStreamDemo(); + dataOutputStreamDemo.writePrimitiveData(); + } + + public void writePrimitiveData() throws IOException + { + DataOutputStream dataOutputStream = null; + FileOutputStream fileOutputStream = null; + try + { + fileOutputStream = new FileOutputStream("data.txt"); + dataOutputStream = new DataOutputStream(fileOutputStream); + int[] intArray = { 100, 250, 440, 550, 900 }; + + for (int j : intArray) + { + dataOutputStream.writeInt(j); + } + + System.out.println("Successfully written to \'data.txt\' file\n"); + } + finally + { + if (dataOutputStream != null) + { + /* + * Closing a DataOutputStream will also + * close the OutputStream instance to which + * the DataOutputStream is writing. + */ + dataOutputStream.close(); + } + } + + } +} \ No newline at end of file diff --git a/BasicJava/JavaIODemo_Externalizable_App/ExternalizableRead_Output.txt b/BasicJava/JavaIODemo_Externalizable_App/ExternalizableRead_Output.txt new file mode 100644 index 000000000..cd0c48d43 --- /dev/null +++ b/BasicJava/JavaIODemo_Externalizable_App/ExternalizableRead_Output.txt @@ -0,0 +1,7 @@ +Inside readExternal +Employee [id=101, name=Peter, age=0] +Successfully read employee object from the file. + +Id = 101 +Name = Peter +Age = 0 diff --git a/BasicJava/JavaIODemo_Externalizable_App/ExternalizableWrite_Output.txt b/BasicJava/JavaIODemo_Externalizable_App/ExternalizableWrite_Output.txt new file mode 100644 index 000000000..c6d028861 --- /dev/null +++ b/BasicJava/JavaIODemo_Externalizable_App/ExternalizableWrite_Output.txt @@ -0,0 +1,4 @@ +Employee [id=101, name=Peter, age=25] +Inside writeExternal +Successfully written employee object to the file. + diff --git a/BasicJava/JavaIODemo_Externalizable_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_Externalizable_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_Externalizable_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_Externalizable_App/JavaIODemo/.project b/BasicJava/JavaIODemo_Externalizable_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_Externalizable_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_Externalizable_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_Externalizable_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_Externalizable_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_Externalizable_App/JavaIODemo/bin/Employee.class b/BasicJava/JavaIODemo_Externalizable_App/JavaIODemo/bin/Employee.class new file mode 100644 index 000000000..649c0a31c Binary files /dev/null and b/BasicJava/JavaIODemo_Externalizable_App/JavaIODemo/bin/Employee.class differ diff --git a/BasicJava/JavaIODemo_Externalizable_App/JavaIODemo/bin/ExternalizableRead.class b/BasicJava/JavaIODemo_Externalizable_App/JavaIODemo/bin/ExternalizableRead.class new file mode 100644 index 000000000..d131730dd Binary files /dev/null and b/BasicJava/JavaIODemo_Externalizable_App/JavaIODemo/bin/ExternalizableRead.class differ diff --git a/BasicJava/JavaIODemo_Externalizable_App/JavaIODemo/bin/ExternalizableWrite.class b/BasicJava/JavaIODemo_Externalizable_App/JavaIODemo/bin/ExternalizableWrite.class new file mode 100644 index 000000000..e7f141be7 Binary files /dev/null and b/BasicJava/JavaIODemo_Externalizable_App/JavaIODemo/bin/ExternalizableWrite.class differ diff --git a/BasicJava/JavaIODemo_Externalizable_App/JavaIODemo/employee.ser b/BasicJava/JavaIODemo_Externalizable_App/JavaIODemo/employee.ser new file mode 100644 index 000000000..0451c7f05 Binary files /dev/null and b/BasicJava/JavaIODemo_Externalizable_App/JavaIODemo/employee.ser differ diff --git a/BasicJava/JavaIODemo_Externalizable_App/JavaIODemo/src/Employee.java b/BasicJava/JavaIODemo_Externalizable_App/JavaIODemo/src/Employee.java new file mode 100644 index 000000000..0fd2721bc --- /dev/null +++ b/BasicJava/JavaIODemo_Externalizable_App/JavaIODemo/src/Employee.java @@ -0,0 +1,71 @@ +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; + +public class Employee implements Externalizable +{ + private int id; + private String name; + private int age; + + public Employee() + { + + } + + public int getId() + { + return id; + } + + public void setId(int id) + { + this.id = id; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + @Override + public String toString() + { + return "Employee [id=" + id + ", name=" + name + + ", age=" + age + "]"; + } + + @Override + public void readExternal(ObjectInput in) throws IOException, + ClassNotFoundException + { + System.out.println("Inside readExternal"); + id = in.readInt(); + name = (String) in.readObject(); + } + + @Override + public void writeExternal(ObjectOutput out) throws IOException + { + System.out.println("Inside writeExternal"); + out.writeInt(id); + out.writeObject(name); + } + +} \ No newline at end of file diff --git a/BasicJava/JavaIODemo_Externalizable_App/JavaIODemo/src/ExternalizableRead.java b/BasicJava/JavaIODemo_Externalizable_App/JavaIODemo/src/ExternalizableRead.java new file mode 100644 index 000000000..9ac9a5702 --- /dev/null +++ b/BasicJava/JavaIODemo_Externalizable_App/JavaIODemo/src/ExternalizableRead.java @@ -0,0 +1,56 @@ +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.ObjectInputStream; + +public class ExternalizableRead +{ + + public static void main(String[] args) throws FileNotFoundException, + IOException, ClassNotFoundException + { + ExternalizableRead externalizableRead = new ExternalizableRead(); + externalizableRead.readEmployeeObject(); + } + + private void readEmployeeObject() throws IOException, + FileNotFoundException, ClassNotFoundException + { + FileInputStream fileInputStream = null; + ObjectInputStream objectInputStream = null; + //Deserialize + try + { + fileInputStream = new FileInputStream("employee.ser"); + objectInputStream = new ObjectInputStream(fileInputStream); + + /* + * Read an object from the ObjectInputStream. + */ + Employee employee = (Employee) objectInputStream.readObject(); + System.out.println(employee); + System.out + .println("Successfully read employee object from the file.\n"); + + System.out.println("Id = " + employee.getId()); + System.out.println("Name = " + employee.getName()); + System.out.println("Age = " + employee.getAge()); + + } + finally + { + + if (objectInputStream != null) + { + /* + * Closing a ObjectInputStream will also + * close the InputStream instance from which + * the ObjectInputStream is reading. + */ + objectInputStream.close(); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_Externalizable_App/JavaIODemo/src/ExternalizableWrite.java b/BasicJava/JavaIODemo_Externalizable_App/JavaIODemo/src/ExternalizableWrite.java new file mode 100644 index 000000000..53dee2c47 --- /dev/null +++ b/BasicJava/JavaIODemo_Externalizable_App/JavaIODemo/src/ExternalizableWrite.java @@ -0,0 +1,58 @@ +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; + +public class ExternalizableWrite +{ + + public static void main(String[] args) throws FileNotFoundException, + IOException, ClassNotFoundException + { + ExternalizableWrite externalizableWrite = new ExternalizableWrite(); + externalizableWrite.writeEmployeeObject(); + } + + private void writeEmployeeObject() throws FileNotFoundException, + IOException + { + FileOutputStream fileOutputStream = null; + ObjectOutputStream objectOutputStream = null; + //Serialize + try + { + fileOutputStream = new FileOutputStream("employee.ser"); + objectOutputStream = new ObjectOutputStream(fileOutputStream); + + Employee employee = new Employee(); + employee.setId(101); + employee.setName("Peter"); + employee.setAge(25); + + System.out.println(employee); + + /* + * Write the specified object to the + * ObjectOutputStream. + */ + objectOutputStream.writeObject(employee); + System.out + .println("Successfully written employee object to the file.\n"); + } + finally + { + + if (objectOutputStream != null) + { + /* + * Closing a ObjectOutputStream will also + * close the OutputStream instance to which + * the ObjectOutputStream is writing. + */ + objectOutputStream.close(); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_FileInputStream_FileOutputStream_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_FileInputStream_FileOutputStream_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_FileInputStream_FileOutputStream_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_FileInputStream_FileOutputStream_App/JavaIODemo/.project b/BasicJava/JavaIODemo_FileInputStream_FileOutputStream_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_FileInputStream_FileOutputStream_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_FileInputStream_FileOutputStream_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_FileInputStream_FileOutputStream_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_FileInputStream_FileOutputStream_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_FileInputStream_FileOutputStream_App/JavaIODemo/bin/FileReadWriteDemo.class b/BasicJava/JavaIODemo_FileInputStream_FileOutputStream_App/JavaIODemo/bin/FileReadWriteDemo.class new file mode 100644 index 000000000..04bd61209 Binary files /dev/null and b/BasicJava/JavaIODemo_FileInputStream_FileOutputStream_App/JavaIODemo/bin/FileReadWriteDemo.class differ diff --git a/BasicJava/JavaIODemo_FileInputStream_FileOutputStream_App/JavaIODemo/myinputfile.txt b/BasicJava/JavaIODemo_FileInputStream_FileOutputStream_App/JavaIODemo/myinputfile.txt new file mode 100644 index 000000000..22c9c4696 --- /dev/null +++ b/BasicJava/JavaIODemo_FileInputStream_FileOutputStream_App/JavaIODemo/myinputfile.txt @@ -0,0 +1 @@ +Peter is going to India \ No newline at end of file diff --git a/BasicJava/JavaIODemo_FileInputStream_FileOutputStream_App/JavaIODemo/myoutputfile.txt b/BasicJava/JavaIODemo_FileInputStream_FileOutputStream_App/JavaIODemo/myoutputfile.txt new file mode 100644 index 000000000..22c9c4696 --- /dev/null +++ b/BasicJava/JavaIODemo_FileInputStream_FileOutputStream_App/JavaIODemo/myoutputfile.txt @@ -0,0 +1 @@ +Peter is going to India \ No newline at end of file diff --git a/BasicJava/JavaIODemo_FileInputStream_FileOutputStream_App/JavaIODemo/src/FileReadWriteDemo.java b/BasicJava/JavaIODemo_FileInputStream_FileOutputStream_App/JavaIODemo/src/FileReadWriteDemo.java new file mode 100644 index 000000000..befd84120 --- /dev/null +++ b/BasicJava/JavaIODemo_FileInputStream_FileOutputStream_App/JavaIODemo/src/FileReadWriteDemo.java @@ -0,0 +1,76 @@ +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; + +public class FileReadWriteDemo +{ + + public static void main(String[] args) throws IOException + { + FileReadWriteDemo fileReadWriteDemo = new FileReadWriteDemo(); + fileReadWriteDemo.readAndWriteFile(); + } + + private void readAndWriteFile() throws IOException + { + FileInputStream fileInputStream = null; + FileOutputStream fileOutputStream = null; + + try + { + /* + * Creates a FileInputStream by opening a + * connection to an actual file, the file named + * by the path name name in the file system. + */ + String inputFileName = "myinputfile.txt"; + fileInputStream = new FileInputStream(inputFileName); + /* + * Creates a file output stream to write to the + * file with the specified name. + */ + String outputFileName = "myoutputfile.txt"; + fileOutputStream = new FileOutputStream(outputFileName); + int i; + + /* + * Reads a byte of data from this input stream. + */ + while ((i = fileInputStream.read()) != -1) + { + /* + * Writes the specified byte to this file + * output stream. + */ + fileOutputStream.write(i); + } + + System.out + .println("Successfully read and " + + "writen to the \'" + outputFileName + + "\'file."); + } + finally + { + if (fileInputStream != null) + { + /* + * Closes this file input stream and + * releases any system resources associated + * with the stream. + */ + fileInputStream.close(); + } + if (fileOutputStream != null) + { + /* + * Closes this file output stream and + * releases any system resources associated + * with this stream. + */ + fileOutputStream.close(); + } + } + } + +} diff --git a/BasicJava/JavaIODemo_FileInputStream_FileOutputStream_App/Output.txt b/BasicJava/JavaIODemo_FileInputStream_FileOutputStream_App/Output.txt new file mode 100644 index 000000000..1e0046da3 --- /dev/null +++ b/BasicJava/JavaIODemo_FileInputStream_FileOutputStream_App/Output.txt @@ -0,0 +1 @@ +Successfully read and writen to the 'myoutputfile.txt'file. diff --git a/BasicJava/JavaIODemo_FileInputStream_File_Obj_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_FileInputStream_File_Obj_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_FileInputStream_File_Obj_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_FileInputStream_File_Obj_App/JavaIODemo/.project b/BasicJava/JavaIODemo_FileInputStream_File_Obj_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_FileInputStream_File_Obj_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_FileInputStream_File_Obj_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_FileInputStream_File_Obj_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_FileInputStream_File_Obj_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_FileInputStream_File_Obj_App/JavaIODemo/bin/FileInputStreamDemo.class b/BasicJava/JavaIODemo_FileInputStream_File_Obj_App/JavaIODemo/bin/FileInputStreamDemo.class new file mode 100644 index 000000000..bd97e0e81 Binary files /dev/null and b/BasicJava/JavaIODemo_FileInputStream_File_Obj_App/JavaIODemo/bin/FileInputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_FileInputStream_File_Obj_App/JavaIODemo/myfile.txt b/BasicJava/JavaIODemo_FileInputStream_File_Obj_App/JavaIODemo/myfile.txt new file mode 100644 index 000000000..ff091b1c1 --- /dev/null +++ b/BasicJava/JavaIODemo_FileInputStream_File_Obj_App/JavaIODemo/myfile.txt @@ -0,0 +1 @@ +Peter is coming to India. \ No newline at end of file diff --git a/BasicJava/JavaIODemo_FileInputStream_File_Obj_App/JavaIODemo/src/FileInputStreamDemo.java b/BasicJava/JavaIODemo_FileInputStream_File_Obj_App/JavaIODemo/src/FileInputStreamDemo.java new file mode 100644 index 000000000..f6f274a2e --- /dev/null +++ b/BasicJava/JavaIODemo_FileInputStream_File_Obj_App/JavaIODemo/src/FileInputStreamDemo.java @@ -0,0 +1,61 @@ +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; + +/* + * public FileInputStream(File file) throws + * FileNotFoundException + * + * Parameters: + * ---------- + * + * file - the file to be opened for reading. + */ + +public class FileInputStreamDemo +{ + + public static void main(String[] args) throws IOException + { + FileInputStreamDemo fileInputStreamDemo = new FileInputStreamDemo(); + fileInputStreamDemo.readFile(); + } + + private void readFile() throws IOException + { + FileInputStream fileInputStream = null; + + try + { + File file = new File("myfile.txt"); + /* + * Creates a FileInputStream by opening a + * connection to an actual file, the file named + * by the File object file in the file system. + */ + fileInputStream = new FileInputStream(file); + int i; + + /* + * Reads a byte of data from this input stream. + */ + while ((i = fileInputStream.read()) != -1) + { + System.out.print((char) i); + } + } + finally + { + if (fileInputStream != null) + { + /* + * Closes this file input stream and + * releases any system resources associated + * with the stream. + */ + fileInputStream.close(); + } + } + } + +} diff --git a/BasicJava/JavaIODemo_FileInputStream_File_Obj_App/Output.txt b/BasicJava/JavaIODemo_FileInputStream_File_Obj_App/Output.txt new file mode 100644 index 000000000..adc5cbc60 --- /dev/null +++ b/BasicJava/JavaIODemo_FileInputStream_File_Obj_App/Output.txt @@ -0,0 +1 @@ +Peter is coming to India. \ No newline at end of file diff --git a/BasicJava/JavaIODemo_FileInputStream_Intro_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_FileInputStream_Intro_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_FileInputStream_Intro_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_FileInputStream_Intro_App/JavaIODemo/.project b/BasicJava/JavaIODemo_FileInputStream_Intro_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_FileInputStream_Intro_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_FileInputStream_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_FileInputStream_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_FileInputStream_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_FileInputStream_Intro_App/JavaIODemo/bin/FileInputStreamDemo.class b/BasicJava/JavaIODemo_FileInputStream_Intro_App/JavaIODemo/bin/FileInputStreamDemo.class new file mode 100644 index 000000000..7aa423bf2 Binary files /dev/null and b/BasicJava/JavaIODemo_FileInputStream_Intro_App/JavaIODemo/bin/FileInputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_FileInputStream_Intro_App/JavaIODemo/myfile.txt b/BasicJava/JavaIODemo_FileInputStream_Intro_App/JavaIODemo/myfile.txt new file mode 100644 index 000000000..22c9c4696 --- /dev/null +++ b/BasicJava/JavaIODemo_FileInputStream_Intro_App/JavaIODemo/myfile.txt @@ -0,0 +1 @@ +Peter is going to India \ No newline at end of file diff --git a/BasicJava/JavaIODemo_FileInputStream_Intro_App/JavaIODemo/src/FileInputStreamDemo.java b/BasicJava/JavaIODemo_FileInputStream_Intro_App/JavaIODemo/src/FileInputStreamDemo.java new file mode 100644 index 000000000..c87fc9e73 --- /dev/null +++ b/BasicJava/JavaIODemo_FileInputStream_Intro_App/JavaIODemo/src/FileInputStreamDemo.java @@ -0,0 +1,59 @@ +import java.io.FileInputStream; +import java.io.IOException; + +/* + * public FileInputStream(String name) throws + * FileNotFoundException + * + * Parameters: + * ---------- + * + * name - the system-dependent file name. + */ + +public class FileInputStreamDemo +{ + + public static void main(String[] args) throws IOException + { + FileInputStreamDemo fileInputStreamDemo = new FileInputStreamDemo(); + fileInputStreamDemo.readFile(); + } + + private void readFile() throws IOException + { + FileInputStream fileInputStream = null; + + try + { + /* + * Creates a FileInputStream by opening a + * connection to an actual file, the file named + * by the path name name in the file system. + */ + fileInputStream = new FileInputStream("myfile.txt"); + int i; + + /* + * Reads a byte of data from this input stream. + */ + while ((i = fileInputStream.read()) != -1) + { + System.out.print((char) i); + } + } + finally + { + if (fileInputStream != null) + { + /* + * Closes this file input stream and + * releases any system resources associated + * with the stream. + */ + fileInputStream.close(); + } + } + } + +} diff --git a/BasicJava/JavaIODemo_FileInputStream_Intro_App/Output.txt b/BasicJava/JavaIODemo_FileInputStream_Intro_App/Output.txt new file mode 100644 index 000000000..22c9c4696 --- /dev/null +++ b/BasicJava/JavaIODemo_FileInputStream_Intro_App/Output.txt @@ -0,0 +1 @@ +Peter is going to India \ No newline at end of file diff --git a/BasicJava/JavaIODemo_FileOutputStream_File_Cons_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_FileOutputStream_File_Cons_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_FileOutputStream_File_Cons_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_FileOutputStream_File_Cons_App/JavaIODemo/.project b/BasicJava/JavaIODemo_FileOutputStream_File_Cons_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_FileOutputStream_File_Cons_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_FileOutputStream_File_Cons_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_FileOutputStream_File_Cons_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_FileOutputStream_File_Cons_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_FileOutputStream_File_Cons_App/JavaIODemo/bin/FileOutputStreamDemo.class b/BasicJava/JavaIODemo_FileOutputStream_File_Cons_App/JavaIODemo/bin/FileOutputStreamDemo.class new file mode 100644 index 000000000..1840a4245 Binary files /dev/null and b/BasicJava/JavaIODemo_FileOutputStream_File_Cons_App/JavaIODemo/bin/FileOutputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_FileOutputStream_File_Cons_App/JavaIODemo/myfile.txt b/BasicJava/JavaIODemo_FileOutputStream_File_Cons_App/JavaIODemo/myfile.txt new file mode 100644 index 000000000..ff091b1c1 --- /dev/null +++ b/BasicJava/JavaIODemo_FileOutputStream_File_Cons_App/JavaIODemo/myfile.txt @@ -0,0 +1 @@ +Peter is coming to India. \ No newline at end of file diff --git a/BasicJava/JavaIODemo_FileOutputStream_File_Cons_App/JavaIODemo/src/FileOutputStreamDemo.java b/BasicJava/JavaIODemo_FileOutputStream_File_Cons_App/JavaIODemo/src/FileOutputStreamDemo.java new file mode 100644 index 000000000..b560c06eb --- /dev/null +++ b/BasicJava/JavaIODemo_FileOutputStream_File_Cons_App/JavaIODemo/src/FileOutputStreamDemo.java @@ -0,0 +1,66 @@ +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +/* + * public FileOutputStream(File file) + * throws FileNotFoundException + * + * Parameters: + * ---------- + * file - the file to be opened for writing. + * + */ +public class FileOutputStreamDemo +{ + + public static void main(String[] args) throws IOException + { + FileOutputStreamDemo fileOutputStreamDemo = new FileOutputStreamDemo(); + fileOutputStreamDemo.writeFile(); + } + + private void writeFile() throws IOException + { + FileOutputStream fileOutputStream = null; + + try + { + File file = new File("myfile.txt"); + + /* + * Creates a file output stream to write to the + * file represented by the specified File + * object. + */ + + fileOutputStream = new FileOutputStream(file); + String str = "Peter is coming to India. "; + + /* + * Converting string into byte array + */ + byte[] byteArray = str.getBytes(); + + /* + * Writes b.length bytes from the specified byte + * array to this file output stream. + */ + fileOutputStream.write(byteArray); + System.out.println("Successfully written to the file."); + } + finally + { + if (fileOutputStream != null) + { + /* + * Closes this file output stream and + * releases any system resources associated + * with this stream. + */ + fileOutputStream.close(); + } + } + } + +} diff --git a/BasicJava/JavaIODemo_FileOutputStream_File_Cons_App/Output.txt b/BasicJava/JavaIODemo_FileOutputStream_File_Cons_App/Output.txt new file mode 100644 index 000000000..c465bb9ae --- /dev/null +++ b/BasicJava/JavaIODemo_FileOutputStream_File_Cons_App/Output.txt @@ -0,0 +1 @@ +Successfully written to the file. diff --git a/BasicJava/JavaIODemo_FileOutputStream_File_boolean_Cons_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_FileOutputStream_File_boolean_Cons_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_FileOutputStream_File_boolean_Cons_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_FileOutputStream_File_boolean_Cons_App/JavaIODemo/.project b/BasicJava/JavaIODemo_FileOutputStream_File_boolean_Cons_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_FileOutputStream_File_boolean_Cons_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_FileOutputStream_File_boolean_Cons_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_FileOutputStream_File_boolean_Cons_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_FileOutputStream_File_boolean_Cons_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_FileOutputStream_File_boolean_Cons_App/JavaIODemo/bin/FileOutputStreamDemo.class b/BasicJava/JavaIODemo_FileOutputStream_File_boolean_Cons_App/JavaIODemo/bin/FileOutputStreamDemo.class new file mode 100644 index 000000000..554e66ccd Binary files /dev/null and b/BasicJava/JavaIODemo_FileOutputStream_File_boolean_Cons_App/JavaIODemo/bin/FileOutputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_FileOutputStream_File_boolean_Cons_App/JavaIODemo/myfile.txt b/BasicJava/JavaIODemo_FileOutputStream_File_boolean_Cons_App/JavaIODemo/myfile.txt new file mode 100644 index 000000000..c233a4088 --- /dev/null +++ b/BasicJava/JavaIODemo_FileOutputStream_File_boolean_Cons_App/JavaIODemo/myfile.txt @@ -0,0 +1,2 @@ +Peter is coming to India. + diff --git a/BasicJava/JavaIODemo_FileOutputStream_File_boolean_Cons_App/JavaIODemo/src/FileOutputStreamDemo.java b/BasicJava/JavaIODemo_FileOutputStream_File_boolean_Cons_App/JavaIODemo/src/FileOutputStreamDemo.java new file mode 100644 index 000000000..f010b14e9 --- /dev/null +++ b/BasicJava/JavaIODemo_FileOutputStream_File_boolean_Cons_App/JavaIODemo/src/FileOutputStreamDemo.java @@ -0,0 +1,72 @@ +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +/* + * public FileOutputStream(File file, boolean append) + * throws FileNotFoundException + * + * Parameters: + * ----------- + * + * file - the file to be opened for writing. + * + * append - if true, then bytes will be written to the + * end of the file rather than the beginning + */ + +public class FileOutputStreamDemo +{ + + public static void main(String[] args) throws IOException + { + FileOutputStreamDemo fileOutputStreamDemo = new FileOutputStreamDemo(); + fileOutputStreamDemo.writeFile(); + } + + private void writeFile() throws IOException + { + FileOutputStream fileOutputStream = null; + + try + { + File file = new File("myfile.txt"); + + /* + * Creates a file output stream to write to the + * file represented by the specified File + * object. If the second argument is true, then + * bytes will be written to the end of the file + * rather than the beginning. + */ + + fileOutputStream = new FileOutputStream(file, true); + String str = "Peter is coming to India.\n"; + + /* + * Converting string into byte array + */ + byte[] byteArray = str.getBytes(); + + /* + * Writes b.length bytes from the specified byte + * array to this file output stream. + */ + fileOutputStream.write(byteArray); + System.out.println("Successfully written to the file."); + } + finally + { + if (fileOutputStream != null) + { + /* + * Closes this file output stream and + * releases any system resources associated + * with this stream. + */ + fileOutputStream.close(); + } + } + } + +} diff --git a/BasicJava/JavaIODemo_FileOutputStream_File_boolean_Cons_App/Output.txt b/BasicJava/JavaIODemo_FileOutputStream_File_boolean_Cons_App/Output.txt new file mode 100644 index 000000000..c465bb9ae --- /dev/null +++ b/BasicJava/JavaIODemo_FileOutputStream_File_boolean_Cons_App/Output.txt @@ -0,0 +1 @@ +Successfully written to the file. diff --git a/BasicJava/JavaIODemo_FileOutputStream_Intro_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_FileOutputStream_Intro_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_FileOutputStream_Intro_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_FileOutputStream_Intro_App/JavaIODemo/.project b/BasicJava/JavaIODemo_FileOutputStream_Intro_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_FileOutputStream_Intro_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_FileOutputStream_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_FileOutputStream_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_FileOutputStream_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_FileOutputStream_Intro_App/JavaIODemo/bin/FileOutputStreamDemo.class b/BasicJava/JavaIODemo_FileOutputStream_Intro_App/JavaIODemo/bin/FileOutputStreamDemo.class new file mode 100644 index 000000000..26ed951a6 Binary files /dev/null and b/BasicJava/JavaIODemo_FileOutputStream_Intro_App/JavaIODemo/bin/FileOutputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_FileOutputStream_Intro_App/JavaIODemo/myfile.txt b/BasicJava/JavaIODemo_FileOutputStream_Intro_App/JavaIODemo/myfile.txt new file mode 100644 index 000000000..0f2b579b4 --- /dev/null +++ b/BasicJava/JavaIODemo_FileOutputStream_Intro_App/JavaIODemo/myfile.txt @@ -0,0 +1 @@ +Peter is coming to India \ No newline at end of file diff --git a/BasicJava/JavaIODemo_FileOutputStream_Intro_App/JavaIODemo/src/FileOutputStreamDemo.java b/BasicJava/JavaIODemo_FileOutputStream_Intro_App/JavaIODemo/src/FileOutputStreamDemo.java new file mode 100644 index 000000000..9490d6d09 --- /dev/null +++ b/BasicJava/JavaIODemo_FileOutputStream_Intro_App/JavaIODemo/src/FileOutputStreamDemo.java @@ -0,0 +1,64 @@ +import java.io.FileOutputStream; +import java.io.IOException; + +/* + public FileOutputStream(String name) + throws FileNotFoundException + + Parameters: + ---------- + name - the system-dependent filename + + */ + +public class FileOutputStreamDemo +{ + + public static void main(String[] args) throws IOException + { + FileOutputStreamDemo fileOutputStreamDemo = new FileOutputStreamDemo(); + fileOutputStreamDemo.writeFile(); + } + + private void writeFile() throws IOException + { + FileOutputStream fileOutputStream = null; + + try + { + /* + * Creates a file output stream to write to the + * file with the specified name. + */ + String fileName = "myfile.txt"; + fileOutputStream = new FileOutputStream(fileName); + String str = "Peter is coming to India"; + + /* + * Converting string into byte array + */ + byte[] byteArray = str.getBytes(); + + /* + * Writes b.length bytes from the specified byte + * array to this file output stream. + */ + fileOutputStream.write(byteArray); + System.out.println("Successfully written to the /'" + + fileName + "'/ file."); + } + finally + { + if (fileOutputStream != null) + { + /* + * Closes this file output stream and + * releases any system resources associated + * with this stream. + */ + fileOutputStream.close(); + } + } + } + +} diff --git a/BasicJava/JavaIODemo_FileOutputStream_Intro_App/Output.txt b/BasicJava/JavaIODemo_FileOutputStream_Intro_App/Output.txt new file mode 100644 index 000000000..242506561 --- /dev/null +++ b/BasicJava/JavaIODemo_FileOutputStream_Intro_App/Output.txt @@ -0,0 +1 @@ +Successfully written to the /'myfile.txt'/ file. diff --git a/BasicJava/JavaIODemo_FileOutputStream_append_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_FileOutputStream_append_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_FileOutputStream_append_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_FileOutputStream_append_App/JavaIODemo/.project b/BasicJava/JavaIODemo_FileOutputStream_append_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_FileOutputStream_append_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_FileOutputStream_append_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_FileOutputStream_append_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_FileOutputStream_append_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_FileOutputStream_append_App/JavaIODemo/bin/FileOutputStreamDemo.class b/BasicJava/JavaIODemo_FileOutputStream_append_App/JavaIODemo/bin/FileOutputStreamDemo.class new file mode 100644 index 000000000..e63318eaa Binary files /dev/null and b/BasicJava/JavaIODemo_FileOutputStream_append_App/JavaIODemo/bin/FileOutputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_FileOutputStream_append_App/JavaIODemo/myfile.txt b/BasicJava/JavaIODemo_FileOutputStream_append_App/JavaIODemo/myfile.txt new file mode 100644 index 000000000..ff091b1c1 --- /dev/null +++ b/BasicJava/JavaIODemo_FileOutputStream_append_App/JavaIODemo/myfile.txt @@ -0,0 +1 @@ +Peter is coming to India. \ No newline at end of file diff --git a/BasicJava/JavaIODemo_FileOutputStream_append_App/JavaIODemo/src/FileOutputStreamDemo.java b/BasicJava/JavaIODemo_FileOutputStream_append_App/JavaIODemo/src/FileOutputStreamDemo.java new file mode 100644 index 000000000..573dabf76 --- /dev/null +++ b/BasicJava/JavaIODemo_FileOutputStream_append_App/JavaIODemo/src/FileOutputStreamDemo.java @@ -0,0 +1,67 @@ +import java.io.FileOutputStream; +import java.io.IOException; +/* + * public FileOutputStream(String name, boolean append) + * throws FileNotFoundException + * + * Parameters: + * ----------- + * + * name - the system-dependent file name + * + * append - if true, then bytes will be written to the + * end of the file rather than the beginning + */ +public class FileOutputStreamDemo +{ + + public static void main(String[] args) throws IOException + { + FileOutputStreamDemo fileOutputStreamDemo = new FileOutputStreamDemo(); + fileOutputStreamDemo.writeFile(); + } + + private void writeFile() throws IOException + { + FileOutputStream fileOutputStream = null; + + try + { + /* + * Creates a file output stream to write to the + * file with the specified name. If the second + * argument is true, then bytes will be written + * to the end of the file rather than the + * beginning. + */ + fileOutputStream = new FileOutputStream("myfile.txt", + true); + String str = "\nPeter is coming to India. "; + + /* + * Converting string into byte array + */ + byte[] byteArray = str.getBytes(); + + /* + * Writes b.length bytes from the specified byte + * array to this file output stream. + */ + fileOutputStream.write(byteArray); + System.out.println("Successfully written to the file."); + } + finally + { + if (fileOutputStream != null) + { + /* + * Closes this file output stream and + * releases any system resources associated + * with this stream. + */ + fileOutputStream.close(); + } + } + } + +} diff --git a/BasicJava/JavaIODemo_FileOutputStream_append_App/Output.txt b/BasicJava/JavaIODemo_FileOutputStream_append_App/Output.txt new file mode 100644 index 000000000..c465bb9ae --- /dev/null +++ b/BasicJava/JavaIODemo_FileOutputStream_append_App/Output.txt @@ -0,0 +1 @@ +Successfully written to the file. diff --git a/BasicJava/JavaIODemo_FileReader_Cons_File_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_FileReader_Cons_File_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_FileReader_Cons_File_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_FileReader_Cons_File_App/JavaIODemo/.project b/BasicJava/JavaIODemo_FileReader_Cons_File_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_FileReader_Cons_File_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_FileReader_Cons_File_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_FileReader_Cons_File_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_FileReader_Cons_File_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_FileReader_Cons_File_App/JavaIODemo/bin/FileReaderDemo.class b/BasicJava/JavaIODemo_FileReader_Cons_File_App/JavaIODemo/bin/FileReaderDemo.class new file mode 100644 index 000000000..06f551d4c Binary files /dev/null and b/BasicJava/JavaIODemo_FileReader_Cons_File_App/JavaIODemo/bin/FileReaderDemo.class differ diff --git a/BasicJava/JavaIODemo_FileReader_Cons_File_App/JavaIODemo/myfile.txt b/BasicJava/JavaIODemo_FileReader_Cons_File_App/JavaIODemo/myfile.txt new file mode 100644 index 000000000..ff091b1c1 --- /dev/null +++ b/BasicJava/JavaIODemo_FileReader_Cons_File_App/JavaIODemo/myfile.txt @@ -0,0 +1 @@ +Peter is coming to India. \ No newline at end of file diff --git a/BasicJava/JavaIODemo_FileReader_Cons_File_App/JavaIODemo/src/FileReaderDemo.java b/BasicJava/JavaIODemo_FileReader_Cons_File_App/JavaIODemo/src/FileReaderDemo.java new file mode 100644 index 000000000..804dada0c --- /dev/null +++ b/BasicJava/JavaIODemo_FileReader_Cons_File_App/JavaIODemo/src/FileReaderDemo.java @@ -0,0 +1,64 @@ +import java.io.File; +import java.io.FileReader; +import java.io.IOException; + +/* + * public FileReader(File file) throws + * FileNotFoundException + * + * Parameters: + * ---------- + * + * file - the File to read from + */ + +public class FileReaderDemo +{ + + public static void main(String[] args) throws IOException + { + FileReaderDemo fileReaderDemo = new FileReaderDemo(); + fileReaderDemo.readFile(); + } + + private void readFile() throws IOException + { + FileReader fileReader = null; + + try + { + File file = new File("myfile.txt"); + /* + * Creates a new FileReader, given the File to + * read from. + */ + fileReader = new FileReader(file); + int i; + + /* + * Reads a single character or -1 if the end of + * the stream has been reached + */ + while ((i = fileReader.read()) != -1) + { + System.out.print((char) i); + } + } + finally + { + if (fileReader != null) + { + /* + * Closes the stream and releases any system + * resources associated with it. Once the + * stream has been closed, further read(), + * ready(), mark(), reset(), or skip() + * invocations will throw an IOException. + * Closing a previously closed stream has no + * effect. + */ + fileReader.close(); + } + } + } +} diff --git a/BasicJava/JavaIODemo_FileReader_Cons_File_App/Output.txt b/BasicJava/JavaIODemo_FileReader_Cons_File_App/Output.txt new file mode 100644 index 000000000..ff091b1c1 --- /dev/null +++ b/BasicJava/JavaIODemo_FileReader_Cons_File_App/Output.txt @@ -0,0 +1 @@ +Peter is coming to India. \ No newline at end of file diff --git a/BasicJava/JavaIODemo_FileReader_FileWriter_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_FileReader_FileWriter_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_FileReader_FileWriter_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_FileReader_FileWriter_App/JavaIODemo/.project b/BasicJava/JavaIODemo_FileReader_FileWriter_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_FileReader_FileWriter_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_FileReader_FileWriter_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_FileReader_FileWriter_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_FileReader_FileWriter_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_FileReader_FileWriter_App/JavaIODemo/bin/FileReadWriteDemo.class b/BasicJava/JavaIODemo_FileReader_FileWriter_App/JavaIODemo/bin/FileReadWriteDemo.class new file mode 100644 index 000000000..c90f704ef Binary files /dev/null and b/BasicJava/JavaIODemo_FileReader_FileWriter_App/JavaIODemo/bin/FileReadWriteDemo.class differ diff --git a/BasicJava/JavaIODemo_FileReader_FileWriter_App/JavaIODemo/myinputfile.txt b/BasicJava/JavaIODemo_FileReader_FileWriter_App/JavaIODemo/myinputfile.txt new file mode 100644 index 000000000..b2505dc4a --- /dev/null +++ b/BasicJava/JavaIODemo_FileReader_FileWriter_App/JavaIODemo/myinputfile.txt @@ -0,0 +1 @@ +Peter is going to India. \ No newline at end of file diff --git a/BasicJava/JavaIODemo_FileReader_FileWriter_App/JavaIODemo/myoutputfile.txt b/BasicJava/JavaIODemo_FileReader_FileWriter_App/JavaIODemo/myoutputfile.txt new file mode 100644 index 000000000..b2505dc4a --- /dev/null +++ b/BasicJava/JavaIODemo_FileReader_FileWriter_App/JavaIODemo/myoutputfile.txt @@ -0,0 +1 @@ +Peter is going to India. \ No newline at end of file diff --git a/BasicJava/JavaIODemo_FileReader_FileWriter_App/JavaIODemo/src/FileReadWriteDemo.java b/BasicJava/JavaIODemo_FileReader_FileWriter_App/JavaIODemo/src/FileReadWriteDemo.java new file mode 100644 index 000000000..baca6f891 --- /dev/null +++ b/BasicJava/JavaIODemo_FileReader_FileWriter_App/JavaIODemo/src/FileReadWriteDemo.java @@ -0,0 +1,47 @@ +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; + +public class FileReadWriteDemo +{ + + public static void main(String[] args) throws IOException + { + FileReadWriteDemo fileReadWriteDemo = new FileReadWriteDemo(); + fileReadWriteDemo.readAndWriteFile(); + } + + private void readAndWriteFile() throws IOException + { + FileReader fileReader = null; + FileWriter fileWritter = null; + + try + { + fileReader = new FileReader("myinputfile.txt"); + fileWritter = new FileWriter("myoutputfile.txt"); + + int c; + while ((c = fileReader.read()) != -1) + { + fileWritter.write(c); + } + System.out + .println("Successfully read from " + + "\'myinputfile.txt\' and written " + + "to \'myoutputfile.txt\'"); + } + finally + { + if (fileReader != null) + { + fileReader.close(); + } + if (fileWritter != null) + { + fileWritter.close(); + } + } + } + +} diff --git a/BasicJava/JavaIODemo_FileReader_FileWriter_App/Output.txt b/BasicJava/JavaIODemo_FileReader_FileWriter_App/Output.txt new file mode 100644 index 000000000..7aaa918e9 --- /dev/null +++ b/BasicJava/JavaIODemo_FileReader_FileWriter_App/Output.txt @@ -0,0 +1 @@ +Successfully read from 'myinputfile.txt' and written to 'myoutputfile.txt' diff --git a/BasicJava/JavaIODemo_FileReader_Intro_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_FileReader_Intro_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_FileReader_Intro_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_FileReader_Intro_App/JavaIODemo/.project b/BasicJava/JavaIODemo_FileReader_Intro_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_FileReader_Intro_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_FileReader_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_FileReader_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_FileReader_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_FileReader_Intro_App/JavaIODemo/bin/FileReaderDemo.class b/BasicJava/JavaIODemo_FileReader_Intro_App/JavaIODemo/bin/FileReaderDemo.class new file mode 100644 index 000000000..a001962c1 Binary files /dev/null and b/BasicJava/JavaIODemo_FileReader_Intro_App/JavaIODemo/bin/FileReaderDemo.class differ diff --git a/BasicJava/JavaIODemo_FileReader_Intro_App/JavaIODemo/myfile.txt b/BasicJava/JavaIODemo_FileReader_Intro_App/JavaIODemo/myfile.txt new file mode 100644 index 000000000..ff091b1c1 --- /dev/null +++ b/BasicJava/JavaIODemo_FileReader_Intro_App/JavaIODemo/myfile.txt @@ -0,0 +1 @@ +Peter is coming to India. \ No newline at end of file diff --git a/BasicJava/JavaIODemo_FileReader_Intro_App/JavaIODemo/src/FileReaderDemo.java b/BasicJava/JavaIODemo_FileReader_Intro_App/JavaIODemo/src/FileReaderDemo.java new file mode 100644 index 000000000..a95987861 --- /dev/null +++ b/BasicJava/JavaIODemo_FileReader_Intro_App/JavaIODemo/src/FileReaderDemo.java @@ -0,0 +1,64 @@ +import java.io.FileReader; +import java.io.IOException; + +/* + * public FileReader(String fileName) throws + * FileNotFoundException + * + * Parameters: + * ---------- + * + * fileName - the name of the file to read from + */ +public class FileReaderDemo +{ + + public static void main(String[] args) throws IOException + { + FileReaderDemo fileReaderDemo = new FileReaderDemo(); + fileReaderDemo.readFile(); + } + + private void readFile() throws IOException + { + FileReader fileReader = null; + + try + { + + /* + * Creates a new FileReader, given the name of + * the file to read from. + */ + String fileName = "myfile.txt"; + fileReader = new FileReader(fileName); + int i; + + /* + * Reads a single character or -1 if the end of + * the stream has been reached + */ + while ((i = fileReader.read()) != -1) + { + System.out.print((char) i); + } + } + finally + { + if (fileReader != null) + { + /* + * Closes the stream and releases any system + * resources associated with it. Once the + * stream has been closed, further read(), + * ready(), mark(), reset(), or skip() + * invocations will throw an IOException. + * Closing a previously closed stream has no + * effect. + */ + fileReader.close(); + } + } + } + +} diff --git a/BasicJava/JavaIODemo_FileReader_Intro_App/Output.txt b/BasicJava/JavaIODemo_FileReader_Intro_App/Output.txt new file mode 100644 index 000000000..adc5cbc60 --- /dev/null +++ b/BasicJava/JavaIODemo_FileReader_Intro_App/Output.txt @@ -0,0 +1 @@ +Peter is coming to India. \ No newline at end of file diff --git a/BasicJava/JavaIODemo_FileWriter_Cons_File_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_FileWriter_Cons_File_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_FileWriter_Cons_File_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_FileWriter_Cons_File_App/JavaIODemo/.project b/BasicJava/JavaIODemo_FileWriter_Cons_File_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_FileWriter_Cons_File_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_FileWriter_Cons_File_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_FileWriter_Cons_File_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_FileWriter_Cons_File_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_FileWriter_Cons_File_App/JavaIODemo/bin/FileWriterDemo.class b/BasicJava/JavaIODemo_FileWriter_Cons_File_App/JavaIODemo/bin/FileWriterDemo.class new file mode 100644 index 000000000..2c981ae48 Binary files /dev/null and b/BasicJava/JavaIODemo_FileWriter_Cons_File_App/JavaIODemo/bin/FileWriterDemo.class differ diff --git a/BasicJava/JavaIODemo_FileWriter_Cons_File_App/JavaIODemo/myfile.txt b/BasicJava/JavaIODemo_FileWriter_Cons_File_App/JavaIODemo/myfile.txt new file mode 100644 index 000000000..64841be28 --- /dev/null +++ b/BasicJava/JavaIODemo_FileWriter_Cons_File_App/JavaIODemo/myfile.txt @@ -0,0 +1 @@ +Welcome to America. \ No newline at end of file diff --git a/BasicJava/JavaIODemo_FileWriter_Cons_File_App/JavaIODemo/src/FileWriterDemo.java b/BasicJava/JavaIODemo_FileWriter_Cons_File_App/JavaIODemo/src/FileWriterDemo.java new file mode 100644 index 000000000..3b0530579 --- /dev/null +++ b/BasicJava/JavaIODemo_FileWriter_Cons_File_App/JavaIODemo/src/FileWriterDemo.java @@ -0,0 +1,60 @@ +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +/* + * public FileWriter(File file) throws IOException + * + * Parameters: + * ---------- + * + * file - a File object to write to. + */ + +public class FileWriterDemo +{ + + public static void main(String[] args) throws IOException + { + FileWriterDemo fileWriterDemo = new FileWriterDemo(); + fileWriterDemo.writeFile(); + } + + private void writeFile() throws IOException + { + FileWriter fileWriter = null; + + try + { + + File file = new File("myfile.txt"); + + /* + * Constructs a FileWriter object given a file + * name. + */ + fileWriter = new FileWriter(file); + /* + * Writes a string. + */ + fileWriter.write("Welcome to America."); + System.out.println("Successfully written to the file." + + "please check the file content."); + } + finally + { + if (fileWriter != null) + { + /* + * Closes the stream, flushing it first. + * Once the stream has been closed, further + * write() or flush() invocations will cause + * an IOException to be thrown. Closing a + * previously closed stream has no effect. + */ + fileWriter.close(); + } + } + } + +} diff --git a/BasicJava/JavaIODemo_FileWriter_Cons_File_App/Output.txt b/BasicJava/JavaIODemo_FileWriter_Cons_File_App/Output.txt new file mode 100644 index 000000000..577f536e2 --- /dev/null +++ b/BasicJava/JavaIODemo_FileWriter_Cons_File_App/Output.txt @@ -0,0 +1 @@ +Successfully written to the file.please check the file content. diff --git a/BasicJava/JavaIODemo_FileWriter_Intro_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_FileWriter_Intro_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_FileWriter_Intro_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_FileWriter_Intro_App/JavaIODemo/.project b/BasicJava/JavaIODemo_FileWriter_Intro_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_FileWriter_Intro_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_FileWriter_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_FileWriter_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_FileWriter_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_FileWriter_Intro_App/JavaIODemo/bin/FileWriterDemo.class b/BasicJava/JavaIODemo_FileWriter_Intro_App/JavaIODemo/bin/FileWriterDemo.class new file mode 100644 index 000000000..c8beff1f9 Binary files /dev/null and b/BasicJava/JavaIODemo_FileWriter_Intro_App/JavaIODemo/bin/FileWriterDemo.class differ diff --git a/BasicJava/JavaIODemo_FileWriter_Intro_App/JavaIODemo/myfile.txt b/BasicJava/JavaIODemo_FileWriter_Intro_App/JavaIODemo/myfile.txt new file mode 100644 index 000000000..03b3a984f --- /dev/null +++ b/BasicJava/JavaIODemo_FileWriter_Intro_App/JavaIODemo/myfile.txt @@ -0,0 +1 @@ +Peter is going to Japan. \ No newline at end of file diff --git a/BasicJava/JavaIODemo_FileWriter_Intro_App/JavaIODemo/src/FileWriterDemo.java b/BasicJava/JavaIODemo_FileWriter_Intro_App/JavaIODemo/src/FileWriterDemo.java new file mode 100644 index 000000000..333273f31 --- /dev/null +++ b/BasicJava/JavaIODemo_FileWriter_Intro_App/JavaIODemo/src/FileWriterDemo.java @@ -0,0 +1,59 @@ +import java.io.FileWriter; +import java.io.IOException; + +/* + * public FileWriter(String fileName) throws IOException + * + * Parameters: + * ---------- + * + * fileName - String The system-dependent filename. + */ + +public class FileWriterDemo +{ + + public static void main(String[] args) throws IOException + { + FileWriterDemo fileWriterDemo = new FileWriterDemo(); + fileWriterDemo.writeFile(); + } + + private void writeFile() throws IOException + { + FileWriter fileWriter = null; + + try + { + + /* + * Constructs a FileWriter object given a file + * name. + */ + String fileName = "myfile.txt"; + fileWriter = new FileWriter(fileName); + /* + * Writes a string. + */ + fileWriter.write("Peter is going to Japan."); + System.out + .println("Successfully written to the file." + + "please check the file content."); + } + finally + { + if (fileWriter != null) + { + /* + * Closes the stream, flushing it first. + * Once the stream has been closed, further + * write() or flush() invocations will cause + * an IOException to be thrown. Closing a + * previously closed stream has no effect. + */ + fileWriter.close(); + } + } + } + +} diff --git a/BasicJava/JavaIODemo_FileWriter_Intro_App/Output.txt b/BasicJava/JavaIODemo_FileWriter_Intro_App/Output.txt new file mode 100644 index 000000000..577f536e2 --- /dev/null +++ b/BasicJava/JavaIODemo_FileWriter_Intro_App/Output.txt @@ -0,0 +1 @@ +Successfully written to the file.please check the file content. diff --git a/BasicJava/JavaIODemo_FileWriter_cons_filename_append_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_FileWriter_cons_filename_append_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_FileWriter_cons_filename_append_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_FileWriter_cons_filename_append_App/JavaIODemo/.project b/BasicJava/JavaIODemo_FileWriter_cons_filename_append_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_FileWriter_cons_filename_append_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_FileWriter_cons_filename_append_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_FileWriter_cons_filename_append_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_FileWriter_cons_filename_append_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_FileWriter_cons_filename_append_App/JavaIODemo/bin/FileWriterDemo.class b/BasicJava/JavaIODemo_FileWriter_cons_filename_append_App/JavaIODemo/bin/FileWriterDemo.class new file mode 100644 index 000000000..bafbb1b9c Binary files /dev/null and b/BasicJava/JavaIODemo_FileWriter_cons_filename_append_App/JavaIODemo/bin/FileWriterDemo.class differ diff --git a/BasicJava/JavaIODemo_FileWriter_cons_filename_append_App/JavaIODemo/myfile.txt b/BasicJava/JavaIODemo_FileWriter_cons_filename_append_App/JavaIODemo/myfile.txt new file mode 100644 index 000000000..32f17f587 --- /dev/null +++ b/BasicJava/JavaIODemo_FileWriter_cons_filename_append_App/JavaIODemo/myfile.txt @@ -0,0 +1,4 @@ +Peter is going to Japan. +Peter is going to Japan. +Peter is going to Japan. +Peter is going to Japan. diff --git a/BasicJava/JavaIODemo_FileWriter_cons_filename_append_App/JavaIODemo/src/FileWriterDemo.java b/BasicJava/JavaIODemo_FileWriter_cons_filename_append_App/JavaIODemo/src/FileWriterDemo.java new file mode 100644 index 000000000..00a18506e --- /dev/null +++ b/BasicJava/JavaIODemo_FileWriter_cons_filename_append_App/JavaIODemo/src/FileWriterDemo.java @@ -0,0 +1,64 @@ +import java.io.FileWriter; +import java.io.IOException; + +/* + * public FileWriter(String fileName, boolean + * append) throws IOException + * + * Parameters: + * ----------- + * + * fileName - String The system-dependent filename. + * + * append - boolean if true, then data will be + * written to the end of the file rather than the + * beginning. + */ + +public class FileWriterDemo +{ + + public static void main(String[] args) throws IOException + { + FileWriterDemo fileWriterDemo = new FileWriterDemo(); + fileWriterDemo.writeFile(); + } + + private void writeFile() throws IOException + { + FileWriter fileWriter = null; + + try + { + + /* + * Constructs a FileWriter object given a file + * name with a boolean indicating whether or not + * to append the data written. + */ + fileWriter = new FileWriter("myfile.txt", true); + /* + * Writes a string. + */ + fileWriter.write("Peter is going to Japan.\n"); + + System.out.println("Successfully written to the file." + + "please check the file content."); + } + finally + { + if (fileWriter != null) + { + /* + * Closes the stream, flushing it first. + * Once the stream has been closed, further + * write() or flush() invocations will cause + * an IOException to be thrown. Closing a + * previously closed stream has no effect. + */ + fileWriter.close(); + } + } + } + +} diff --git a/BasicJava/JavaIODemo_FileWriter_cons_filename_append_App/Output.txt b/BasicJava/JavaIODemo_FileWriter_cons_filename_append_App/Output.txt new file mode 100644 index 000000000..577f536e2 --- /dev/null +++ b/BasicJava/JavaIODemo_FileWriter_cons_filename_append_App/Output.txt @@ -0,0 +1 @@ +Successfully written to the file.please check the file content. diff --git a/BasicJava/JavaIODemo_FileWriter_cons_fileobj_append_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_FileWriter_cons_fileobj_append_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_FileWriter_cons_fileobj_append_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_FileWriter_cons_fileobj_append_App/JavaIODemo/.project b/BasicJava/JavaIODemo_FileWriter_cons_fileobj_append_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_FileWriter_cons_fileobj_append_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_FileWriter_cons_fileobj_append_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_FileWriter_cons_fileobj_append_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_FileWriter_cons_fileobj_append_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_FileWriter_cons_fileobj_append_App/JavaIODemo/bin/FileWriterDemo.class b/BasicJava/JavaIODemo_FileWriter_cons_fileobj_append_App/JavaIODemo/bin/FileWriterDemo.class new file mode 100644 index 000000000..2ac8f6c4d Binary files /dev/null and b/BasicJava/JavaIODemo_FileWriter_cons_fileobj_append_App/JavaIODemo/bin/FileWriterDemo.class differ diff --git a/BasicJava/JavaIODemo_FileWriter_cons_fileobj_append_App/JavaIODemo/myfile.txt b/BasicJava/JavaIODemo_FileWriter_cons_fileobj_append_App/JavaIODemo/myfile.txt new file mode 100644 index 000000000..89a418178 --- /dev/null +++ b/BasicJava/JavaIODemo_FileWriter_cons_fileobj_append_App/JavaIODemo/myfile.txt @@ -0,0 +1,3 @@ +Welcome to America. +Welcome to America. +Welcome to America. diff --git a/BasicJava/JavaIODemo_FileWriter_cons_fileobj_append_App/JavaIODemo/src/FileWriterDemo.java b/BasicJava/JavaIODemo_FileWriter_cons_fileobj_append_App/JavaIODemo/src/FileWriterDemo.java new file mode 100644 index 000000000..99c99342c --- /dev/null +++ b/BasicJava/JavaIODemo_FileWriter_cons_fileobj_append_App/JavaIODemo/src/FileWriterDemo.java @@ -0,0 +1,64 @@ +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +/* + * public FileWriter(File file, boolean append) + * throws IOException + * + * Parameters: + * ---------- + * + * file - a File object to write to + * + * append - if true, then bytes will be written to the + * end of the file rather than the beginning + */ +public class FileWriterDemo +{ + public static void main(String[] args) throws IOException + { + FileWriterDemo fileWriterDemo = new FileWriterDemo(); + fileWriterDemo.writeFile(); + } + + private void writeFile() throws IOException + { + FileWriter fileWriter = null; + + try + { + + File file = new File("myfile.txt"); + + /* + * Constructs a FileWriter object given a File + * object. If the second argument is true, then + * bytes will be written to the end of the file + * rather than the beginning. + */ + fileWriter = new FileWriter(file, true); + /* + * Writes a string. + */ + fileWriter.write("Welcome to America.\n"); + System.out.println("Successfully written to the file." + + "please check the file content."); + } + finally + { + if (fileWriter != null) + { + /* + * Closes the stream, flushing it first. + * Once the stream has been closed, further + * write() or flush() invocations will cause + * an IOException to be thrown. Closing a + * previously closed stream has no effect. + */ + fileWriter.close(); + } + } + } + +} diff --git a/BasicJava/JavaIODemo_FileWriter_cons_fileobj_append_App/Output.txt b/BasicJava/JavaIODemo_FileWriter_cons_fileobj_append_App/Output.txt new file mode 100644 index 000000000..577f536e2 --- /dev/null +++ b/BasicJava/JavaIODemo_FileWriter_cons_fileobj_append_App/Output.txt @@ -0,0 +1 @@ +Successfully written to the file.please check the file content. diff --git a/BasicJava/JavaIODemo_File_CreateDir_App/FileDemo1_Output.txt b/BasicJava/JavaIODemo_File_CreateDir_App/FileDemo1_Output.txt new file mode 100644 index 000000000..73406fbb2 --- /dev/null +++ b/BasicJava/JavaIODemo_File_CreateDir_App/FileDemo1_Output.txt @@ -0,0 +1 @@ +D:\work\java directory Created? = true diff --git a/BasicJava/JavaIODemo_File_CreateDir_App/FileDemo2_Output.txt b/BasicJava/JavaIODemo_File_CreateDir_App/FileDemo2_Output.txt new file mode 100644 index 000000000..28e9e4eb7 --- /dev/null +++ b/BasicJava/JavaIODemo_File_CreateDir_App/FileDemo2_Output.txt @@ -0,0 +1 @@ +D:\work\java\arraylist\src directory Created ? = true diff --git a/BasicJava/JavaIODemo_File_CreateDir_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_File_CreateDir_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_File_CreateDir_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_File_CreateDir_App/JavaIODemo/.project b/BasicJava/JavaIODemo_File_CreateDir_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_File_CreateDir_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_File_CreateDir_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_File_CreateDir_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_File_CreateDir_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_File_CreateDir_App/JavaIODemo/bin/FileDemo1.class b/BasicJava/JavaIODemo_File_CreateDir_App/JavaIODemo/bin/FileDemo1.class new file mode 100644 index 000000000..0eb4f3bde Binary files /dev/null and b/BasicJava/JavaIODemo_File_CreateDir_App/JavaIODemo/bin/FileDemo1.class differ diff --git a/BasicJava/JavaIODemo_File_CreateDir_App/JavaIODemo/bin/FileDemo2.class b/BasicJava/JavaIODemo_File_CreateDir_App/JavaIODemo/bin/FileDemo2.class new file mode 100644 index 000000000..0e073ef1b Binary files /dev/null and b/BasicJava/JavaIODemo_File_CreateDir_App/JavaIODemo/bin/FileDemo2.class differ diff --git a/BasicJava/JavaIODemo_File_CreateDir_App/JavaIODemo/src/FileDemo1.java b/BasicJava/JavaIODemo_File_CreateDir_App/JavaIODemo/src/FileDemo1.java new file mode 100644 index 000000000..ca2ed6975 --- /dev/null +++ b/BasicJava/JavaIODemo_File_CreateDir_App/JavaIODemo/src/FileDemo1.java @@ -0,0 +1,21 @@ +import java.io.File; + +public class FileDemo1 +{ + + public static void main(String[] args) + { + File file = new File("D:/work/java"); + /* + * Creates the directory named by this abstract + * pathname. + * + * Returns: true if and only if the directory was + * created; false otherwise + */ + boolean dirCreated = file.mkdir(); + System.out.println(file.getAbsolutePath() + + " directory Created? = " + dirCreated); + } + +} diff --git a/BasicJava/JavaIODemo_File_CreateDir_App/JavaIODemo/src/FileDemo2.java b/BasicJava/JavaIODemo_File_CreateDir_App/JavaIODemo/src/FileDemo2.java new file mode 100644 index 000000000..e22b00bba --- /dev/null +++ b/BasicJava/JavaIODemo_File_CreateDir_App/JavaIODemo/src/FileDemo2.java @@ -0,0 +1,23 @@ +import java.io.File; + +public class FileDemo2 +{ + + public static void main(String[] args) + { + File file = new File("D:/work/java/arraylist/src"); + /* + * Creates the directory named by this abstract + * pathname, including any necessary but nonexistent + * parent directories. + * + * Returns: true if and only if the directory was + * created, along with all necessary parent + * directories; false otherwise + */ + boolean dirCreated = file.mkdirs(); + System.out.println(file.getAbsolutePath() + + " directory Created ? = " + dirCreated); + } + +} diff --git a/BasicJava/JavaIODemo_File_change_lastModified_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_File_change_lastModified_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_File_change_lastModified_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_File_change_lastModified_App/JavaIODemo/.project b/BasicJava/JavaIODemo_File_change_lastModified_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_File_change_lastModified_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_File_change_lastModified_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_File_change_lastModified_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_File_change_lastModified_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_File_change_lastModified_App/JavaIODemo/bin/FileDemo.class b/BasicJava/JavaIODemo_File_change_lastModified_App/JavaIODemo/bin/FileDemo.class new file mode 100644 index 000000000..ee563d060 Binary files /dev/null and b/BasicJava/JavaIODemo_File_change_lastModified_App/JavaIODemo/bin/FileDemo.class differ diff --git a/BasicJava/JavaIODemo_File_change_lastModified_App/JavaIODemo/src/FileDemo.java b/BasicJava/JavaIODemo_File_change_lastModified_App/JavaIODemo/src/FileDemo.java new file mode 100644 index 000000000..7c0e43a07 --- /dev/null +++ b/BasicJava/JavaIODemo_File_change_lastModified_App/JavaIODemo/src/FileDemo.java @@ -0,0 +1,33 @@ +import java.io.File; +import java.io.IOException; +import java.text.ParseException; +import java.text.SimpleDateFormat; + +public class FileDemo +{ + + public static void main(String[] args) throws IOException, ParseException + { + File file = new File("D:/work/myfile.txt"); + + long lastModified = file.lastModified(); + System.out.println("Before Format : " + lastModified); + + SimpleDateFormat simpleDateFormat = new SimpleDateFormat( + "MM/dd/yyyy HH:mm:ss"); + + String formatedStr = simpleDateFormat.format(lastModified); + System.out.println("After Format,old lastModified : " + formatedStr); + + /* + * Sets the last-modified time of the file or + * directory named by this abstract pathname. + */ + file.setLastModified(System.currentTimeMillis()); + + lastModified = file.lastModified(); + formatedStr = simpleDateFormat.format(lastModified); + System.out.println("After Format,new lastModified : " + formatedStr); + } + +} diff --git a/BasicJava/JavaIODemo_File_change_lastModified_App/Output.txt b/BasicJava/JavaIODemo_File_change_lastModified_App/Output.txt new file mode 100644 index 000000000..ade96a578 --- /dev/null +++ b/BasicJava/JavaIODemo_File_change_lastModified_App/Output.txt @@ -0,0 +1,3 @@ +Before Format : 1477195340491 +After Format,old lastModified : 10/23/2016 09:32:20 +After Format,new lastModified : 10/23/2016 09:34:20 diff --git a/BasicJava/JavaIODemo_File_copy_dir_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_File_copy_dir_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_File_copy_dir_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_File_copy_dir_App/JavaIODemo/.project b/BasicJava/JavaIODemo_File_copy_dir_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_File_copy_dir_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_File_copy_dir_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_File_copy_dir_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_File_copy_dir_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_File_copy_dir_App/JavaIODemo/bin/FileDemo.class b/BasicJava/JavaIODemo_File_copy_dir_App/JavaIODemo/bin/FileDemo.class new file mode 100644 index 000000000..d0a83d95e Binary files /dev/null and b/BasicJava/JavaIODemo_File_copy_dir_App/JavaIODemo/bin/FileDemo.class differ diff --git a/BasicJava/JavaIODemo_File_copy_dir_App/JavaIODemo/src/FileDemo.java b/BasicJava/JavaIODemo_File_copy_dir_App/JavaIODemo/src/FileDemo.java new file mode 100644 index 000000000..dd19ab5cd --- /dev/null +++ b/BasicJava/JavaIODemo_File_copy_dir_App/JavaIODemo/src/FileDemo.java @@ -0,0 +1,100 @@ +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +public class FileDemo +{ + public static void main(String[] args) throws IOException + { + File srcDir = new File("D:/Work/java"); + File destDir = new File("D:/work/javanew"); + + // Make sure srcDir exists + if (!srcDir.exists()) + { + System.out.println("Directory does not exist."); + } + else + { + FileDemo fileDemo = new FileDemo(); + fileDemo.copydir(srcDir, destDir); + System.out.println("Copied successfully."); + } + + } + + public void copydir(File src, File dest) throws IOException + { + + if (src.isDirectory()) + { + + // if directory not exists, create it + if (!dest.exists()) + { + dest.mkdir(); + System.out.println("Directory copied from " + src + " to " + + dest); + } + + // list all the directory contents + String files[] = src.list(); + + for (String fileName : files) + { + // construct the src and dest file structure + File srcFile = new File(src, fileName); + File destFile = new File(dest, fileName); + // recursive copy + copydir(srcFile, destFile); + } + + } + else + { + // If file, then copy it + fileCopy(src, dest); + } + } + + private void fileCopy(File src, File dest) + throws FileNotFoundException, IOException + { + + InputStream in = null; + OutputStream out = null; + + try + { + // If file, then copy it + in = new FileInputStream(src); + out = new FileOutputStream(dest); + + byte[] buffer = new byte[1024]; + + int length; + // Copy the file content in bytes + while ((length = in.read(buffer)) > 0) + { + out.write(buffer, 0, length); + } + + } + finally + { + if (in != null) + { + in.close(); + } + if (out != null) + { + out.close(); + } + } + System.out.println("File copied from " + src + " to " + dest); + } +} diff --git a/BasicJava/JavaIODemo_File_copy_dir_App/Output.txt b/BasicJava/JavaIODemo_File_copy_dir_App/Output.txt new file mode 100644 index 000000000..dde8cdf68 --- /dev/null +++ b/BasicJava/JavaIODemo_File_copy_dir_App/Output.txt @@ -0,0 +1,7 @@ +Directory copied from D:\Work\java to D:\work\javanew +File copied from D:\Work\java\index.html to D:\work\javanew\index.html +---- +---- +File copied from D:\Work\java\websocket-deprecated\index.html to D:\work\javanew\websocket-deprecated\index.html +File copied from D:\Work\java\websocket-deprecated\snake.html to D:\work\javanew\websocket-deprecated\snake.html +Copied successfully. diff --git a/BasicJava/JavaIODemo_File_copy_file_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_File_copy_file_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_File_copy_file_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_File_copy_file_App/JavaIODemo/.project b/BasicJava/JavaIODemo_File_copy_file_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_File_copy_file_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_File_copy_file_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_File_copy_file_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_File_copy_file_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_File_copy_file_App/JavaIODemo/bin/FileDemo.class b/BasicJava/JavaIODemo_File_copy_file_App/JavaIODemo/bin/FileDemo.class new file mode 100644 index 000000000..e8835ccab Binary files /dev/null and b/BasicJava/JavaIODemo_File_copy_file_App/JavaIODemo/bin/FileDemo.class differ diff --git a/BasicJava/JavaIODemo_File_copy_file_App/JavaIODemo/src/FileDemo.java b/BasicJava/JavaIODemo_File_copy_file_App/JavaIODemo/src/FileDemo.java new file mode 100644 index 000000000..d219d0bb2 --- /dev/null +++ b/BasicJava/JavaIODemo_File_copy_file_App/JavaIODemo/src/FileDemo.java @@ -0,0 +1,57 @@ +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +public class FileDemo +{ + public static void main(String[] args) throws IOException + { + FileDemo fileDemo = new FileDemo(); + fileDemo.copyFile("D:/work/hello.txt", "D:/work/New_hello.txt"); + } + + private void copyFile(String srcFileName, String destFileName) + throws IOException + { + InputStream is = null; + OutputStream os = null; + + try + { + + File srcFile = new File(srcFileName); + File destFile = new File(destFileName); + + is = new FileInputStream(srcFile); + os = new FileOutputStream(destFile); + + byte[] buffer = new byte[1024]; + + int length; + // copy the file content in bytes + while ((length = is.read(buffer)) > 0) + { + os.write(buffer, 0, length); + } + + System.out.println("File is copied successful!"); + + } + finally + { + if (is != null) + { + is.close(); + } + if (os != null) + { + os.close(); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_File_copy_file_App/Output.txt b/BasicJava/JavaIODemo_File_copy_file_App/Output.txt new file mode 100644 index 000000000..e504a5cef --- /dev/null +++ b/BasicJava/JavaIODemo_File_copy_file_App/Output.txt @@ -0,0 +1 @@ +File is copied successful! diff --git a/BasicJava/JavaIODemo_File_createTempfile_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_File_createTempfile_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_File_createTempfile_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_File_createTempfile_App/JavaIODemo/.project b/BasicJava/JavaIODemo_File_createTempfile_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_File_createTempfile_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_File_createTempfile_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_File_createTempfile_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_File_createTempfile_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_File_createTempfile_App/JavaIODemo/bin/FileDemo.class b/BasicJava/JavaIODemo_File_createTempfile_App/JavaIODemo/bin/FileDemo.class new file mode 100644 index 000000000..7741e2fa8 Binary files /dev/null and b/BasicJava/JavaIODemo_File_createTempfile_App/JavaIODemo/bin/FileDemo.class differ diff --git a/BasicJava/JavaIODemo_File_createTempfile_App/JavaIODemo/src/FileDemo.java b/BasicJava/JavaIODemo_File_createTempfile_App/JavaIODemo/src/FileDemo.java new file mode 100644 index 000000000..a71ce1380 --- /dev/null +++ b/BasicJava/JavaIODemo_File_createTempfile_App/JavaIODemo/src/FileDemo.java @@ -0,0 +1,20 @@ +import java.io.File; +import java.io.IOException; + +public class FileDemo +{ + + public static void main(String[] args) throws IOException + { + File tempFile = File.createTempFile("temp", ".txt"); + + /* + * Will give you the full complete path name + * (filepath + filename) of a file. + */ + String absolutePath = tempFile.getAbsolutePath(); + System.out.println("File path : " + absolutePath); + + } + +} diff --git a/BasicJava/JavaIODemo_File_createTempfile_App/Output.txt b/BasicJava/JavaIODemo_File_createTempfile_App/Output.txt new file mode 100644 index 000000000..46f807a36 --- /dev/null +++ b/BasicJava/JavaIODemo_File_createTempfile_App/Output.txt @@ -0,0 +1 @@ +File path : C:\Users\Ramesh\AppData\Local\Temp\temp5613613809025056166.txt diff --git a/BasicJava/JavaIODemo_File_create_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_File_create_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_File_create_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_File_create_App/JavaIODemo/.project b/BasicJava/JavaIODemo_File_create_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_File_create_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_File_create_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_File_create_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_File_create_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_File_create_App/JavaIODemo/bin/FileDemo.class b/BasicJava/JavaIODemo_File_create_App/JavaIODemo/bin/FileDemo.class new file mode 100644 index 000000000..78d1db6c6 Binary files /dev/null and b/BasicJava/JavaIODemo_File_create_App/JavaIODemo/bin/FileDemo.class differ diff --git a/BasicJava/JavaIODemo_File_create_App/JavaIODemo/src/FileDemo.java b/BasicJava/JavaIODemo_File_create_App/JavaIODemo/src/FileDemo.java new file mode 100644 index 000000000..56ea217ed --- /dev/null +++ b/BasicJava/JavaIODemo_File_create_App/JavaIODemo/src/FileDemo.java @@ -0,0 +1,33 @@ +import java.io.File; +import java.io.IOException; + +/* + * Create a new file. + */ +public class FileDemo +{ + + public static void main(String[] args) throws IOException + { + File file = new File("D:/work/myfile.txt"); + + /* + * Atomically creates a new, empty file named by + * this abstract pathname if and only if a file with + * this name does not yet exist. + * + * Returns: true if the named file does not exist + * and was successfully created; false if the named + * file already exists + */ + if (file.createNewFile()) + { + System.out.println("File is created!"); + } + else + { + System.out.println("File already exists."); + } + } + +} diff --git a/BasicJava/JavaIODemo_File_create_App/Output.txt b/BasicJava/JavaIODemo_File_create_App/Output.txt new file mode 100644 index 000000000..cd83b10f1 --- /dev/null +++ b/BasicJava/JavaIODemo_File_create_App/Output.txt @@ -0,0 +1 @@ +File is created! diff --git a/BasicJava/JavaIODemo_File_deleteFiles_dir_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_File_deleteFiles_dir_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_File_deleteFiles_dir_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_File_deleteFiles_dir_App/JavaIODemo/.project b/BasicJava/JavaIODemo_File_deleteFiles_dir_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_File_deleteFiles_dir_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_File_deleteFiles_dir_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_File_deleteFiles_dir_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_File_deleteFiles_dir_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_File_deleteFiles_dir_App/JavaIODemo/bin/FileDemo.class b/BasicJava/JavaIODemo_File_deleteFiles_dir_App/JavaIODemo/bin/FileDemo.class new file mode 100644 index 000000000..91242f6c6 Binary files /dev/null and b/BasicJava/JavaIODemo_File_deleteFiles_dir_App/JavaIODemo/bin/FileDemo.class differ diff --git a/BasicJava/JavaIODemo_File_deleteFiles_dir_App/JavaIODemo/src/FileDemo.java b/BasicJava/JavaIODemo_File_deleteFiles_dir_App/JavaIODemo/src/FileDemo.java new file mode 100644 index 000000000..b7e34b684 --- /dev/null +++ b/BasicJava/JavaIODemo_File_deleteFiles_dir_App/JavaIODemo/src/FileDemo.java @@ -0,0 +1,26 @@ +import java.io.File; + +public class FileDemo +{ + private static final String DIRECTORY_NAME = "D:/work"; + + public static void main(String[] args) + { + FileDemo fileDemo = new FileDemo(); + fileDemo.deleteFiles(DIRECTORY_NAME); + } + + public void deleteFiles(String dirName) + { + File fileDir = new File(dirName); + File[] listOfFiles = fileDir.listFiles(); + for (File file : listOfFiles) + { + boolean isDeleted = file.delete(); + System.out.println(file.getAbsolutePath() + " isDeleted = " + + isDeleted); + } + + } + +} diff --git a/BasicJava/JavaIODemo_File_deleteFiles_dir_App/Output.txt b/BasicJava/JavaIODemo_File_deleteFiles_dir_App/Output.txt new file mode 100644 index 000000000..c83a5a90a --- /dev/null +++ b/BasicJava/JavaIODemo_File_deleteFiles_dir_App/Output.txt @@ -0,0 +1,4 @@ +D:\work\HelloWorld.java isDeleted = true +D:\work\Japan.txt isDeleted = true +D:\work\java.doc isDeleted = true +D:\work\myfile.txt isDeleted = true diff --git a/BasicJava/JavaIODemo_File_deleteFiles_dir_App/Work Dir.jpg b/BasicJava/JavaIODemo_File_deleteFiles_dir_App/Work Dir.jpg new file mode 100644 index 000000000..e91527cba Binary files /dev/null and b/BasicJava/JavaIODemo_File_deleteFiles_dir_App/Work Dir.jpg differ diff --git a/BasicJava/JavaIODemo_File_delete_App/FileDemo1_Output.txt b/BasicJava/JavaIODemo_File_delete_App/FileDemo1_Output.txt new file mode 100644 index 000000000..f8626d7b4 --- /dev/null +++ b/BasicJava/JavaIODemo_File_delete_App/FileDemo1_Output.txt @@ -0,0 +1 @@ +success = true diff --git a/BasicJava/JavaIODemo_File_delete_App/FileDemo2_Output.txt b/BasicJava/JavaIODemo_File_delete_App/FileDemo2_Output.txt new file mode 100644 index 000000000..f8626d7b4 --- /dev/null +++ b/BasicJava/JavaIODemo_File_delete_App/FileDemo2_Output.txt @@ -0,0 +1 @@ +success = true diff --git a/BasicJava/JavaIODemo_File_delete_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_File_delete_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_File_delete_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_File_delete_App/JavaIODemo/.project b/BasicJava/JavaIODemo_File_delete_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_File_delete_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_File_delete_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_File_delete_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_File_delete_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_File_delete_App/JavaIODemo/bin/FileDemo1.class b/BasicJava/JavaIODemo_File_delete_App/JavaIODemo/bin/FileDemo1.class new file mode 100644 index 000000000..9d1bd97f3 Binary files /dev/null and b/BasicJava/JavaIODemo_File_delete_App/JavaIODemo/bin/FileDemo1.class differ diff --git a/BasicJava/JavaIODemo_File_delete_App/JavaIODemo/bin/FileDemo2.class b/BasicJava/JavaIODemo_File_delete_App/JavaIODemo/bin/FileDemo2.class new file mode 100644 index 000000000..fbcc96ae0 Binary files /dev/null and b/BasicJava/JavaIODemo_File_delete_App/JavaIODemo/bin/FileDemo2.class differ diff --git a/BasicJava/JavaIODemo_File_delete_App/JavaIODemo/src/FileDemo1.java b/BasicJava/JavaIODemo_File_delete_App/JavaIODemo/src/FileDemo1.java new file mode 100644 index 000000000..51e8ac7bd --- /dev/null +++ b/BasicJava/JavaIODemo_File_delete_App/JavaIODemo/src/FileDemo1.java @@ -0,0 +1,21 @@ +import java.io.File; + +public class FileDemo1 +{ + + public static void main(String[] args) + { + File file = new File("D:/work/myfile.txt"); + /* + * Deletes the file or directory denoted by this + * abstract pathname. + * + * Returns: true if and only if the file or + * directory is successfully deleted; false + * otherwise + */ + boolean success = file.delete(); + System.out.println("success = " + success); + } + +} diff --git a/BasicJava/JavaIODemo_File_delete_App/JavaIODemo/src/FileDemo2.java b/BasicJava/JavaIODemo_File_delete_App/JavaIODemo/src/FileDemo2.java new file mode 100644 index 000000000..0db78b7bf --- /dev/null +++ b/BasicJava/JavaIODemo_File_delete_App/JavaIODemo/src/FileDemo2.java @@ -0,0 +1,21 @@ +import java.io.File; + +public class FileDemo2 +{ + + public static void main(String[] args) + { + File file = new File("D:/work/misc"); + /* + * Deletes the file or directory denoted by this + * abstract pathname. + * + * Returns: true if and only if the file or + * directory is successfully deleted; false + * otherwise + */ + boolean success = file.delete(); + System.out.println("success = " + success); + } + +} diff --git a/BasicJava/JavaIODemo_File_delete_ext_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_File_delete_ext_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_File_delete_ext_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_File_delete_ext_App/JavaIODemo/.project b/BasicJava/JavaIODemo_File_delete_ext_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_File_delete_ext_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_File_delete_ext_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_File_delete_ext_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_File_delete_ext_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_File_delete_ext_App/JavaIODemo/bin/ExtensionFilter.class b/BasicJava/JavaIODemo_File_delete_ext_App/JavaIODemo/bin/ExtensionFilter.class new file mode 100644 index 000000000..10afa0c10 Binary files /dev/null and b/BasicJava/JavaIODemo_File_delete_ext_App/JavaIODemo/bin/ExtensionFilter.class differ diff --git a/BasicJava/JavaIODemo_File_delete_ext_App/JavaIODemo/bin/FileDemo.class b/BasicJava/JavaIODemo_File_delete_ext_App/JavaIODemo/bin/FileDemo.class new file mode 100644 index 000000000..68ab69662 Binary files /dev/null and b/BasicJava/JavaIODemo_File_delete_ext_App/JavaIODemo/bin/FileDemo.class differ diff --git a/BasicJava/JavaIODemo_File_delete_ext_App/JavaIODemo/src/ExtensionFilter.java b/BasicJava/JavaIODemo_File_delete_ext_App/JavaIODemo/src/ExtensionFilter.java new file mode 100644 index 000000000..8be11d440 --- /dev/null +++ b/BasicJava/JavaIODemo_File_delete_ext_App/JavaIODemo/src/ExtensionFilter.java @@ -0,0 +1,36 @@ +import java.io.File; +import java.io.FilenameFilter; + +/* + * boolean accept(File dir, String name) + * + * Parameters: + * ---------- + * + * dir - the directory in which the file was found. + * name - the name of the file. + */ +public class ExtensionFilter implements FilenameFilter +{ + + private String fileExtension; + + public ExtensionFilter(String fileExtension) + { + this.fileExtension = fileExtension; + } + + /* + * Tests if a specified file should be included in a + * file list. + * + * Returns: true if and only if the name should be + * included in the file list; false otherwise. + */ + @Override + public boolean accept(File dir, String name) + { + return (name.endsWith(fileExtension)); + } + +} diff --git a/BasicJava/JavaIODemo_File_delete_ext_App/JavaIODemo/src/FileDemo.java b/BasicJava/JavaIODemo_File_delete_ext_App/JavaIODemo/src/FileDemo.java new file mode 100644 index 000000000..4ea0b1676 --- /dev/null +++ b/BasicJava/JavaIODemo_File_delete_ext_App/JavaIODemo/src/FileDemo.java @@ -0,0 +1,57 @@ +import java.io.File; + +/* + * public String[] list(FilenameFilter filter) + * + * Parameters: + * ---------- + * + * filter - A filename filter + * + * How to use FilenameFilter to list out all files that + * are end with “.txt” extension in folder “D:/work“, + * and then delete it. + */ + +public class FileDemo +{ + + public static void main(String[] args) + { + FileDemo fileDemo = new FileDemo(); + fileDemo.deleteFiles("D:/work", ".txt"); + } + + public void deleteFiles(String dirName, String fileExtension) + { + File fileDir = new File(dirName); + + ExtensionFilter extFilter = new ExtensionFilter(fileExtension); + + /* + * Returns an array of strings naming the files and + * directories in the directory denoted by this + * abstract pathname that satisfy the specified + * filter. + */ + String[] listOfFileNames = fileDir.list(extFilter); + + if (listOfFileNames.length == 0) + { + System.out.println("no files end with : " + fileExtension); + return; + } + + for (String fileName : listOfFileNames) + { + String filePath = new StringBuilder(dirName) + .append(File.separator).append(fileName).toString(); + File file = new File(filePath); + boolean isDeleted = file.delete(); + System.out.println(file.getAbsolutePath() + " isDeleted = " + + isDeleted); + } + + } + +} diff --git a/BasicJava/JavaIODemo_File_delete_ext_App/Output.txt b/BasicJava/JavaIODemo_File_delete_ext_App/Output.txt new file mode 100644 index 000000000..a5f69078c --- /dev/null +++ b/BasicJava/JavaIODemo_File_delete_ext_App/Output.txt @@ -0,0 +1,2 @@ +D:\work\Hello.txt isDeleted = true +D:\work\Java.txt isDeleted = true diff --git a/BasicJava/JavaIODemo_File_delete_ext_App/work-dir.jpg b/BasicJava/JavaIODemo_File_delete_ext_App/work-dir.jpg new file mode 100644 index 000000000..fff3e0bcb Binary files /dev/null and b/BasicJava/JavaIODemo_File_delete_ext_App/work-dir.jpg differ diff --git a/BasicJava/JavaIODemo_File_delete_ext_filearray_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_File_delete_ext_filearray_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_File_delete_ext_filearray_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_File_delete_ext_filearray_App/JavaIODemo/.project b/BasicJava/JavaIODemo_File_delete_ext_filearray_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_File_delete_ext_filearray_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_File_delete_ext_filearray_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_File_delete_ext_filearray_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_File_delete_ext_filearray_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_File_delete_ext_filearray_App/JavaIODemo/bin/ExtensionFilter.class b/BasicJava/JavaIODemo_File_delete_ext_filearray_App/JavaIODemo/bin/ExtensionFilter.class new file mode 100644 index 000000000..10afa0c10 Binary files /dev/null and b/BasicJava/JavaIODemo_File_delete_ext_filearray_App/JavaIODemo/bin/ExtensionFilter.class differ diff --git a/BasicJava/JavaIODemo_File_delete_ext_filearray_App/JavaIODemo/bin/FileDemo.class b/BasicJava/JavaIODemo_File_delete_ext_filearray_App/JavaIODemo/bin/FileDemo.class new file mode 100644 index 000000000..cf03fbdc2 Binary files /dev/null and b/BasicJava/JavaIODemo_File_delete_ext_filearray_App/JavaIODemo/bin/FileDemo.class differ diff --git a/BasicJava/JavaIODemo_File_delete_ext_filearray_App/JavaIODemo/src/ExtensionFilter.java b/BasicJava/JavaIODemo_File_delete_ext_filearray_App/JavaIODemo/src/ExtensionFilter.java new file mode 100644 index 000000000..8be11d440 --- /dev/null +++ b/BasicJava/JavaIODemo_File_delete_ext_filearray_App/JavaIODemo/src/ExtensionFilter.java @@ -0,0 +1,36 @@ +import java.io.File; +import java.io.FilenameFilter; + +/* + * boolean accept(File dir, String name) + * + * Parameters: + * ---------- + * + * dir - the directory in which the file was found. + * name - the name of the file. + */ +public class ExtensionFilter implements FilenameFilter +{ + + private String fileExtension; + + public ExtensionFilter(String fileExtension) + { + this.fileExtension = fileExtension; + } + + /* + * Tests if a specified file should be included in a + * file list. + * + * Returns: true if and only if the name should be + * included in the file list; false otherwise. + */ + @Override + public boolean accept(File dir, String name) + { + return (name.endsWith(fileExtension)); + } + +} diff --git a/BasicJava/JavaIODemo_File_delete_ext_filearray_App/JavaIODemo/src/FileDemo.java b/BasicJava/JavaIODemo_File_delete_ext_filearray_App/JavaIODemo/src/FileDemo.java new file mode 100644 index 000000000..b1dd0dde4 --- /dev/null +++ b/BasicJava/JavaIODemo_File_delete_ext_filearray_App/JavaIODemo/src/FileDemo.java @@ -0,0 +1,52 @@ +import java.io.File; + +/* + * public File[] listFiles(FilenameFilter filter) + * + * Parameters: + * ---------- + * + * filter - A filename filter + * + * How to use FilenameFilter to list out all files that + * are end with “.txt” extension in folder “D:/work“, + * and then delete it. + */ +public class FileDemo +{ + + public static void main(String[] args) + { + FileDemo fileDemo = new FileDemo(); + fileDemo.deleteFiles("D:/work", ".txt"); + } + + public void deleteFiles(String dirName, String fileExtension) + { + File fileDir = new File(dirName); + + ExtensionFilter extFilter = new ExtensionFilter(fileExtension); + + /* + * Returns an array of abstract pathnames denoting + * the files and directories in the directory + * denoted by this abstract pathname that satisfy + * the specified filter. + */ + File[] listOfFiles = fileDir.listFiles(extFilter); + + if (listOfFiles.length == 0) + { + System.out.println("No files end with : " + fileExtension); + return; + } + + for (File file : listOfFiles) + { + boolean isDeleted = file.delete(); + System.out.println(file.getAbsolutePath() + " isDeleted = " + + isDeleted); + } + } + +} diff --git a/BasicJava/JavaIODemo_File_delete_ext_filearray_App/Output.txt b/BasicJava/JavaIODemo_File_delete_ext_filearray_App/Output.txt new file mode 100644 index 000000000..a5f69078c --- /dev/null +++ b/BasicJava/JavaIODemo_File_delete_ext_filearray_App/Output.txt @@ -0,0 +1,2 @@ +D:\work\Hello.txt isDeleted = true +D:\work\Java.txt isDeleted = true diff --git a/BasicJava/JavaIODemo_File_delete_ext_filearray_App/work-dir.jpg b/BasicJava/JavaIODemo_File_delete_ext_filearray_App/work-dir.jpg new file mode 100644 index 000000000..fff3e0bcb Binary files /dev/null and b/BasicJava/JavaIODemo_File_delete_ext_filearray_App/work-dir.jpg differ diff --git a/BasicJava/JavaIODemo_File_dir_empty_check_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_File_dir_empty_check_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_File_dir_empty_check_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_File_dir_empty_check_App/JavaIODemo/.project b/BasicJava/JavaIODemo_File_dir_empty_check_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_File_dir_empty_check_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_File_dir_empty_check_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_File_dir_empty_check_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_File_dir_empty_check_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_File_dir_empty_check_App/JavaIODemo/bin/FileDemo.class b/BasicJava/JavaIODemo_File_dir_empty_check_App/JavaIODemo/bin/FileDemo.class new file mode 100644 index 000000000..470592ae9 Binary files /dev/null and b/BasicJava/JavaIODemo_File_dir_empty_check_App/JavaIODemo/bin/FileDemo.class differ diff --git a/BasicJava/JavaIODemo_File_dir_empty_check_App/JavaIODemo/src/FileDemo.java b/BasicJava/JavaIODemo_File_dir_empty_check_App/JavaIODemo/src/FileDemo.java new file mode 100644 index 000000000..ae0d0c903 --- /dev/null +++ b/BasicJava/JavaIODemo_File_dir_empty_check_App/JavaIODemo/src/FileDemo.java @@ -0,0 +1,33 @@ +import java.io.File; +/* + * Check if a directory is empty + */ +public class FileDemo +{ + + private static final String DIR = "D:/work/java"; + + public static void main(String[] args) + { + + File file = new File(DIR); + + if (file.isDirectory()) + { + if (file.list().length > 0) + { + System.out.println("Directory is not empty!"); + } + else + { + System.out.println("Directory is empty!"); + } + } + else + { + System.out.println("This is not a directory"); + } + + } + +} diff --git a/BasicJava/JavaIODemo_File_dir_empty_check_App/Output.txt b/BasicJava/JavaIODemo_File_dir_empty_check_App/Output.txt new file mode 100644 index 000000000..2e3db652e --- /dev/null +++ b/BasicJava/JavaIODemo_File_dir_empty_check_App/Output.txt @@ -0,0 +1 @@ +Directory is not empty! diff --git a/BasicJava/JavaIODemo_File_displaydirStructure_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_File_displaydirStructure_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_File_displaydirStructure_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_File_displaydirStructure_App/JavaIODemo/.project b/BasicJava/JavaIODemo_File_displaydirStructure_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_File_displaydirStructure_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_File_displaydirStructure_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_File_displaydirStructure_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_File_displaydirStructure_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_File_displaydirStructure_App/JavaIODemo/bin/DisplayDirectoryStructure.class b/BasicJava/JavaIODemo_File_displaydirStructure_App/JavaIODemo/bin/DisplayDirectoryStructure.class new file mode 100644 index 000000000..391652f77 Binary files /dev/null and b/BasicJava/JavaIODemo_File_displaydirStructure_App/JavaIODemo/bin/DisplayDirectoryStructure.class differ diff --git a/BasicJava/JavaIODemo_File_displaydirStructure_App/JavaIODemo/src/DisplayDirectoryStructure.java b/BasicJava/JavaIODemo_File_displaydirStructure_App/JavaIODemo/src/DisplayDirectoryStructure.java new file mode 100644 index 000000000..7d2dd8952 --- /dev/null +++ b/BasicJava/JavaIODemo_File_displaydirStructure_App/JavaIODemo/src/DisplayDirectoryStructure.java @@ -0,0 +1,40 @@ +import java.io.File; +import java.io.IOException; + +public class DisplayDirectoryStructure +{ + + private static final String SRC_FOLDER = "D:/work/java"; + + public static void main(String[] args) throws IOException + { + + File file = new File(SRC_FOLDER); + + DisplayDirectoryStructure displayDirectoryStructure = new DisplayDirectoryStructure(); + displayDirectoryStructure.displayDirStructure(file); + + } + + public void displayDirStructure(File file) throws IOException + { + + System.out.println("Path = " + file.getAbsolutePath()); + + if (file.isDirectory()) + { + // list all the directory contents + File files[] = file.listFiles(); + + for (File displayFile : files) + { + /* + * Recursive call. + */ + displayDirStructure(displayFile); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_File_displaydirStructure_App/Output.txt b/BasicJava/JavaIODemo_File_displaydirStructure_App/Output.txt new file mode 100644 index 000000000..a16bc3a81 --- /dev/null +++ b/BasicJava/JavaIODemo_File_displaydirStructure_App/Output.txt @@ -0,0 +1,9 @@ +Path = D:\work\java +Path = D:\work\java\index.html +Path = D:\work\java\jsp +Path = D:\work\java\jsp\async +Path = D:\work\java\jsp\async\async1.jsp +.... +.... +Path = D:\work\java\websocket-deprecated\echo.html + diff --git a/BasicJava/JavaIODemo_File_drive_size_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_File_drive_size_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_File_drive_size_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_File_drive_size_App/JavaIODemo/.project b/BasicJava/JavaIODemo_File_drive_size_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_File_drive_size_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_File_drive_size_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_File_drive_size_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_File_drive_size_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_File_drive_size_App/JavaIODemo/bin/FileDemo.class b/BasicJava/JavaIODemo_File_drive_size_App/JavaIODemo/bin/FileDemo.class new file mode 100644 index 000000000..7177537dd Binary files /dev/null and b/BasicJava/JavaIODemo_File_drive_size_App/JavaIODemo/bin/FileDemo.class differ diff --git a/BasicJava/JavaIODemo_File_drive_size_App/JavaIODemo/src/FileDemo.java b/BasicJava/JavaIODemo_File_drive_size_App/JavaIODemo/src/FileDemo.java new file mode 100644 index 000000000..62e8ecdfd --- /dev/null +++ b/BasicJava/JavaIODemo_File_drive_size_App/JavaIODemo/src/FileDemo.java @@ -0,0 +1,37 @@ +import java.io.File; + +public class FileDemo +{ + + public static void main(String[] args) + { + File file = new File("c:"); + /* + * Returns the size of the partition named by this + * abstract pathname. + */ + long totalSpace = file.getTotalSpace(); + /* + * Returns the number of bytes available to this + * virtual machine on the partition named by this + * abstract pathname. + */ + long usableSpace = file.getUsableSpace(); + /* + * Returns the number of unallocated bytes in the + * partition named by this abstract path name. + */ + long freeSpace = file.getFreeSpace(); + + System.out.println(" === bytes ==="); + System.out.println("Total size : " + totalSpace + " bytes"); + System.out.println("Space free : " + usableSpace + " bytes"); + System.out.println("Space free : " + freeSpace + " bytes"); + + System.out.println(" === gigabyte ==="); + System.out.println("Total size : " + totalSpace / 1024 / 1024 / 1024 + " GB"); + System.out.println("Space free : " + usableSpace / 1024 / 1024 / 1024 + " GB"); + System.out.println("Space free : " + freeSpace / 1024 / 1024 /1024 + " GB"); + } + +} diff --git a/BasicJava/JavaIODemo_File_drive_size_App/Output.txt b/BasicJava/JavaIODemo_File_drive_size_App/Output.txt new file mode 100644 index 000000000..bf37495db --- /dev/null +++ b/BasicJava/JavaIODemo_File_drive_size_App/Output.txt @@ -0,0 +1,8 @@ + === bytes === +Total size : 129926488064 bytes +Space free : 53480681472 bytes +Space free : 53480681472 bytes + === gigabyte === +Total size : 121 GB +Space free : 49 GB +Space free : 49 GB diff --git a/BasicJava/JavaIODemo_File_exists_App/FileDemo1_Output.txt b/BasicJava/JavaIODemo_File_exists_App/FileDemo1_Output.txt new file mode 100644 index 000000000..eae8f54a4 --- /dev/null +++ b/BasicJava/JavaIODemo_File_exists_App/FileDemo1_Output.txt @@ -0,0 +1 @@ +D:\work\myfile.txt is exist? = true diff --git a/BasicJava/JavaIODemo_File_exists_App/FileDemo2_Output.txt b/BasicJava/JavaIODemo_File_exists_App/FileDemo2_Output.txt new file mode 100644 index 000000000..d6cca7053 --- /dev/null +++ b/BasicJava/JavaIODemo_File_exists_App/FileDemo2_Output.txt @@ -0,0 +1 @@ +D:\work is exist? = true diff --git a/BasicJava/JavaIODemo_File_exists_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_File_exists_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_File_exists_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_File_exists_App/JavaIODemo/.project b/BasicJava/JavaIODemo_File_exists_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_File_exists_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_File_exists_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_File_exists_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_File_exists_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_File_exists_App/JavaIODemo/bin/FileDemo1.class b/BasicJava/JavaIODemo_File_exists_App/JavaIODemo/bin/FileDemo1.class new file mode 100644 index 000000000..53b306e2f Binary files /dev/null and b/BasicJava/JavaIODemo_File_exists_App/JavaIODemo/bin/FileDemo1.class differ diff --git a/BasicJava/JavaIODemo_File_exists_App/JavaIODemo/bin/FileDemo2.class b/BasicJava/JavaIODemo_File_exists_App/JavaIODemo/bin/FileDemo2.class new file mode 100644 index 000000000..886c86e23 Binary files /dev/null and b/BasicJava/JavaIODemo_File_exists_App/JavaIODemo/bin/FileDemo2.class differ diff --git a/BasicJava/JavaIODemo_File_exists_App/JavaIODemo/src/FileDemo1.java b/BasicJava/JavaIODemo_File_exists_App/JavaIODemo/src/FileDemo1.java new file mode 100644 index 000000000..9c0a935fc --- /dev/null +++ b/BasicJava/JavaIODemo_File_exists_App/JavaIODemo/src/FileDemo1.java @@ -0,0 +1,21 @@ +import java.io.File; + +/* + *Once you have instantiated a File object we can check + *if the corresponding file/dir actually exists already. + */ +public class FileDemo1 +{ + + public static void main(String[] args) + { + File file = new File("D:/work/myfile.txt"); + /* + * Tests whether the file or directory denoted by + * this abstract pathname exists. + */ + boolean isExist = file.exists(); + System.out.println(file.getAbsolutePath() + " is exist? = " + isExist); + } + +} diff --git a/BasicJava/JavaIODemo_File_exists_App/JavaIODemo/src/FileDemo2.java b/BasicJava/JavaIODemo_File_exists_App/JavaIODemo/src/FileDemo2.java new file mode 100644 index 000000000..e3bea5376 --- /dev/null +++ b/BasicJava/JavaIODemo_File_exists_App/JavaIODemo/src/FileDemo2.java @@ -0,0 +1,21 @@ +import java.io.File; + +/* + *Once you have instantiated a File object we can check + *if the corresponding file/dir actually exists already. + */ +public class FileDemo2 +{ + + public static void main(String[] args) + { + File file = new File("D:/work/"); + /* + * Tests whether the file or directory denoted by + * this abstract pathname exists. + */ + boolean isExist = file.exists(); + System.out.println(file.getAbsolutePath() + " is exist? = " + isExist); + } + +} diff --git a/BasicJava/JavaIODemo_File_hidden_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_File_hidden_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_File_hidden_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_File_hidden_App/JavaIODemo/.project b/BasicJava/JavaIODemo_File_hidden_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_File_hidden_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_File_hidden_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_File_hidden_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_File_hidden_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_File_hidden_App/JavaIODemo/bin/FileDemo.class b/BasicJava/JavaIODemo_File_hidden_App/JavaIODemo/bin/FileDemo.class new file mode 100644 index 000000000..559bd1720 Binary files /dev/null and b/BasicJava/JavaIODemo_File_hidden_App/JavaIODemo/bin/FileDemo.class differ diff --git a/BasicJava/JavaIODemo_File_hidden_App/JavaIODemo/src/FileDemo.java b/BasicJava/JavaIODemo_File_hidden_App/JavaIODemo/src/FileDemo.java new file mode 100644 index 000000000..31e31030e --- /dev/null +++ b/BasicJava/JavaIODemo_File_hidden_App/JavaIODemo/src/FileDemo.java @@ -0,0 +1,25 @@ +import java.io.File; + +public class FileDemo +{ + + public static void main(String[] args) + { + File file = new File("D:/eclipse/backup/Java/.git"); + + /* + * Returns: true if and only if the file denoted by + * this abstract pathname is hidden according to the + * conventions of the underlying platform + */ + if (file.isHidden()) + { + System.out.println("This file is hidden"); + } + else + { + System.out.println("This file is not hidden"); + } + } + +} diff --git a/BasicJava/JavaIODemo_File_hidden_App/Output.txt b/BasicJava/JavaIODemo_File_hidden_App/Output.txt new file mode 100644 index 000000000..2dc314f8d --- /dev/null +++ b/BasicJava/JavaIODemo_File_hidden_App/Output.txt @@ -0,0 +1 @@ +This file is hidden diff --git a/BasicJava/JavaIODemo_File_lastModified_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_File_lastModified_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_File_lastModified_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_File_lastModified_App/JavaIODemo/.project b/BasicJava/JavaIODemo_File_lastModified_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_File_lastModified_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_File_lastModified_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_File_lastModified_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_File_lastModified_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_File_lastModified_App/JavaIODemo/bin/FileDemo.class b/BasicJava/JavaIODemo_File_lastModified_App/JavaIODemo/bin/FileDemo.class new file mode 100644 index 000000000..8fa73be6a Binary files /dev/null and b/BasicJava/JavaIODemo_File_lastModified_App/JavaIODemo/bin/FileDemo.class differ diff --git a/BasicJava/JavaIODemo_File_lastModified_App/JavaIODemo/src/FileDemo.java b/BasicJava/JavaIODemo_File_lastModified_App/JavaIODemo/src/FileDemo.java new file mode 100644 index 000000000..c062b0ce6 --- /dev/null +++ b/BasicJava/JavaIODemo_File_lastModified_App/JavaIODemo/src/FileDemo.java @@ -0,0 +1,32 @@ +import java.io.File; +import java.io.IOException; +import java.text.SimpleDateFormat; + +public class FileDemo +{ + + public static void main(String[] args) throws IOException + { + File file = new File("D:/work/myfile.txt"); + + /* + * Returns the time that the file denoted by this + * abstract pathname was last modified. + * + * Returns: A long value representing the time the + * file was last modified, measured in milliseconds + * since the epoch (00:00:00 GMT, January 1, 1970), + * or 0L if the file does not exist or if an I/O + * error occurs + */ + long lastModified = file.lastModified(); + System.out.println("Before Format : " + lastModified); + + SimpleDateFormat simpleDateFormat = new SimpleDateFormat( + "MM/dd/yyyy HH:mm:ss"); + + String formatedStr = simpleDateFormat.format(lastModified); + System.out.println("After Format : " + formatedStr); + } + +} diff --git a/BasicJava/JavaIODemo_File_lastModified_App/Output.txt b/BasicJava/JavaIODemo_File_lastModified_App/Output.txt new file mode 100644 index 000000000..63ee663f5 --- /dev/null +++ b/BasicJava/JavaIODemo_File_lastModified_App/Output.txt @@ -0,0 +1,2 @@ +Before Format : 1477106762355 +After Format : 10/22/2016 08:56:02 diff --git a/BasicJava/JavaIODemo_File_length_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_File_length_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_File_length_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_File_length_App/JavaIODemo/.project b/BasicJava/JavaIODemo_File_length_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_File_length_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_File_length_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_File_length_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_File_length_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_File_length_App/JavaIODemo/bin/FileDemo.class b/BasicJava/JavaIODemo_File_length_App/JavaIODemo/bin/FileDemo.class new file mode 100644 index 000000000..eb694e638 Binary files /dev/null and b/BasicJava/JavaIODemo_File_length_App/JavaIODemo/bin/FileDemo.class differ diff --git a/BasicJava/JavaIODemo_File_length_App/JavaIODemo/src/FileDemo.java b/BasicJava/JavaIODemo_File_length_App/JavaIODemo/src/FileDemo.java new file mode 100644 index 000000000..a0811ca69 --- /dev/null +++ b/BasicJava/JavaIODemo_File_length_App/JavaIODemo/src/FileDemo.java @@ -0,0 +1,22 @@ +import java.io.File; + +public class FileDemo +{ + + public static void main(String[] args) + { + File file = new File("D:/work/myfile.txt"); + /* + * Returns the length of the file denoted by this + * abstract pathname. The return value is + * unspecified if this pathname denotes a directory. + * + * Returns: The length, in bytes, of the file + * denoted by this abstract pathname, or 0L if the + * file does not exist. + */ + long length = file.length(); + System.out.println("length = " + length); + } + +} diff --git a/BasicJava/JavaIODemo_File_length_App/Output.txt b/BasicJava/JavaIODemo_File_length_App/Output.txt new file mode 100644 index 000000000..b262c6d57 --- /dev/null +++ b/BasicJava/JavaIODemo_File_length_App/Output.txt @@ -0,0 +1 @@ +length = 36 diff --git a/BasicJava/JavaIODemo_File_listfiles_App/FileDemo1_Output.txt b/BasicJava/JavaIODemo_File_listfiles_App/FileDemo1_Output.txt new file mode 100644 index 000000000..3bfb01459 --- /dev/null +++ b/BasicJava/JavaIODemo_File_listfiles_App/FileDemo1_Output.txt @@ -0,0 +1,4 @@ +HelloWorld.txt +java.txt +misc +myfile.txt diff --git a/BasicJava/JavaIODemo_File_listfiles_App/FileDemo2_Output.txt b/BasicJava/JavaIODemo_File_listfiles_App/FileDemo2_Output.txt new file mode 100644 index 000000000..3bfb01459 --- /dev/null +++ b/BasicJava/JavaIODemo_File_listfiles_App/FileDemo2_Output.txt @@ -0,0 +1,4 @@ +HelloWorld.txt +java.txt +misc +myfile.txt diff --git a/BasicJava/JavaIODemo_File_listfiles_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_File_listfiles_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_File_listfiles_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_File_listfiles_App/JavaIODemo/.project b/BasicJava/JavaIODemo_File_listfiles_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_File_listfiles_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_File_listfiles_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_File_listfiles_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_File_listfiles_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_File_listfiles_App/JavaIODemo/bin/FileDemo1.class b/BasicJava/JavaIODemo_File_listfiles_App/JavaIODemo/bin/FileDemo1.class new file mode 100644 index 000000000..a1cf24652 Binary files /dev/null and b/BasicJava/JavaIODemo_File_listfiles_App/JavaIODemo/bin/FileDemo1.class differ diff --git a/BasicJava/JavaIODemo_File_listfiles_App/JavaIODemo/bin/FileDemo2.class b/BasicJava/JavaIODemo_File_listfiles_App/JavaIODemo/bin/FileDemo2.class new file mode 100644 index 000000000..a6bc90220 Binary files /dev/null and b/BasicJava/JavaIODemo_File_listfiles_App/JavaIODemo/bin/FileDemo2.class differ diff --git a/BasicJava/JavaIODemo_File_listfiles_App/JavaIODemo/src/FileDemo1.java b/BasicJava/JavaIODemo_File_listfiles_App/JavaIODemo/src/FileDemo1.java new file mode 100644 index 000000000..6e6d5b66c --- /dev/null +++ b/BasicJava/JavaIODemo_File_listfiles_App/JavaIODemo/src/FileDemo1.java @@ -0,0 +1,25 @@ +import java.io.File; + +/* + * Read List of Files in a Directory + */ +public class FileDemo1 +{ + + public static void main(String[] args) + { + File file = new File("D:/work/"); + /* + * Returns an array of strings naming the files and + * directories in the directory denoted by this + * abstract pathname. + */ + String[] strArray = file.list(); + + for (String fileName : strArray) + { + System.out.println(fileName); + } + } + +} diff --git a/BasicJava/JavaIODemo_File_listfiles_App/JavaIODemo/src/FileDemo2.java b/BasicJava/JavaIODemo_File_listfiles_App/JavaIODemo/src/FileDemo2.java new file mode 100644 index 000000000..d6c64c069 --- /dev/null +++ b/BasicJava/JavaIODemo_File_listfiles_App/JavaIODemo/src/FileDemo2.java @@ -0,0 +1,25 @@ +import java.io.File; + +/* + * Read List of Files in a Directory + */ +public class FileDemo2 +{ + + public static void main(String[] args) + { + File file = new File("D:/work/"); + /* + * Returns an array of abstract pathnames denoting + * the files in the directory denoted by this + * abstract pathname. + */ + File[] fileArray = file.listFiles(); + + for (File file2 : fileArray) + { + System.out.println(file2.getName()); + } + } + +} diff --git a/BasicJava/JavaIODemo_File_listfiles_App/work_folder.jpg b/BasicJava/JavaIODemo_File_listfiles_App/work_folder.jpg new file mode 100644 index 000000000..44f7bd27c Binary files /dev/null and b/BasicJava/JavaIODemo_File_listfiles_App/work_folder.jpg differ diff --git a/BasicJava/JavaIODemo_File_listout_ext_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_File_listout_ext_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_File_listout_ext_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_File_listout_ext_App/JavaIODemo/.project b/BasicJava/JavaIODemo_File_listout_ext_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_File_listout_ext_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_File_listout_ext_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_File_listout_ext_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_File_listout_ext_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_File_listout_ext_App/JavaIODemo/bin/ExtensionFilter.class b/BasicJava/JavaIODemo_File_listout_ext_App/JavaIODemo/bin/ExtensionFilter.class new file mode 100644 index 000000000..10afa0c10 Binary files /dev/null and b/BasicJava/JavaIODemo_File_listout_ext_App/JavaIODemo/bin/ExtensionFilter.class differ diff --git a/BasicJava/JavaIODemo_File_listout_ext_App/JavaIODemo/bin/FileDemo.class b/BasicJava/JavaIODemo_File_listout_ext_App/JavaIODemo/bin/FileDemo.class new file mode 100644 index 000000000..0e9fb038c Binary files /dev/null and b/BasicJava/JavaIODemo_File_listout_ext_App/JavaIODemo/bin/FileDemo.class differ diff --git a/BasicJava/JavaIODemo_File_listout_ext_App/JavaIODemo/src/ExtensionFilter.java b/BasicJava/JavaIODemo_File_listout_ext_App/JavaIODemo/src/ExtensionFilter.java new file mode 100644 index 000000000..8be11d440 --- /dev/null +++ b/BasicJava/JavaIODemo_File_listout_ext_App/JavaIODemo/src/ExtensionFilter.java @@ -0,0 +1,36 @@ +import java.io.File; +import java.io.FilenameFilter; + +/* + * boolean accept(File dir, String name) + * + * Parameters: + * ---------- + * + * dir - the directory in which the file was found. + * name - the name of the file. + */ +public class ExtensionFilter implements FilenameFilter +{ + + private String fileExtension; + + public ExtensionFilter(String fileExtension) + { + this.fileExtension = fileExtension; + } + + /* + * Tests if a specified file should be included in a + * file list. + * + * Returns: true if and only if the name should be + * included in the file list; false otherwise. + */ + @Override + public boolean accept(File dir, String name) + { + return (name.endsWith(fileExtension)); + } + +} diff --git a/BasicJava/JavaIODemo_File_listout_ext_App/JavaIODemo/src/FileDemo.java b/BasicJava/JavaIODemo_File_listout_ext_App/JavaIODemo/src/FileDemo.java new file mode 100644 index 000000000..f73f406bc --- /dev/null +++ b/BasicJava/JavaIODemo_File_listout_ext_App/JavaIODemo/src/FileDemo.java @@ -0,0 +1,51 @@ +import java.io.File; + +/* + * public String[] list(FilenameFilter filter) + * + * Parameters: + * ---------- + * + * filter - A filename filter + * + * How to use FilenameFilter to list out all files that + * are end with “.txt” extension in folder “D:/work“. * + */ + +public class FileDemo +{ + + public static void main(String[] args) + { + FileDemo fileDemo = new FileDemo(); + fileDemo.listOutFiles("D:/work", ".txt"); + } + + public void listOutFiles(String dirName, String fileExtension) + { + File fileDir = new File(dirName); + + ExtensionFilter extFilter = new ExtensionFilter(fileExtension); + + /* + * Returns an array of strings naming the files and + * directories in the directory denoted by this + * abstract pathname that satisfy the specified + * filter. + */ + String[] listOfFileNames = fileDir.list(extFilter); + + if (listOfFileNames.length == 0) + { + System.out.println("No files end with : " + fileExtension); + return; + } + + for (String fileName : listOfFileNames) + { + System.out.println(fileName); + } + + } + +} diff --git a/BasicJava/JavaIODemo_File_listout_ext_App/Output.txt b/BasicJava/JavaIODemo_File_listout_ext_App/Output.txt new file mode 100644 index 000000000..6622d2bf6 --- /dev/null +++ b/BasicJava/JavaIODemo_File_listout_ext_App/Output.txt @@ -0,0 +1,2 @@ +Hello.txt +Java.txt diff --git a/BasicJava/JavaIODemo_File_listout_ext_App/work-dir.jpg b/BasicJava/JavaIODemo_File_listout_ext_App/work-dir.jpg new file mode 100644 index 000000000..fff3e0bcb Binary files /dev/null and b/BasicJava/JavaIODemo_File_listout_ext_App/work-dir.jpg differ diff --git a/BasicJava/JavaIODemo_File_listout_ext_array_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_File_listout_ext_array_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_File_listout_ext_array_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_File_listout_ext_array_App/JavaIODemo/.project b/BasicJava/JavaIODemo_File_listout_ext_array_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_File_listout_ext_array_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_File_listout_ext_array_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_File_listout_ext_array_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_File_listout_ext_array_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_File_listout_ext_array_App/JavaIODemo/bin/ExtensionFilter.class b/BasicJava/JavaIODemo_File_listout_ext_array_App/JavaIODemo/bin/ExtensionFilter.class new file mode 100644 index 000000000..10afa0c10 Binary files /dev/null and b/BasicJava/JavaIODemo_File_listout_ext_array_App/JavaIODemo/bin/ExtensionFilter.class differ diff --git a/BasicJava/JavaIODemo_File_listout_ext_array_App/JavaIODemo/bin/FileDemo.class b/BasicJava/JavaIODemo_File_listout_ext_array_App/JavaIODemo/bin/FileDemo.class new file mode 100644 index 000000000..9ce432af0 Binary files /dev/null and b/BasicJava/JavaIODemo_File_listout_ext_array_App/JavaIODemo/bin/FileDemo.class differ diff --git a/BasicJava/JavaIODemo_File_listout_ext_array_App/JavaIODemo/src/ExtensionFilter.java b/BasicJava/JavaIODemo_File_listout_ext_array_App/JavaIODemo/src/ExtensionFilter.java new file mode 100644 index 000000000..8be11d440 --- /dev/null +++ b/BasicJava/JavaIODemo_File_listout_ext_array_App/JavaIODemo/src/ExtensionFilter.java @@ -0,0 +1,36 @@ +import java.io.File; +import java.io.FilenameFilter; + +/* + * boolean accept(File dir, String name) + * + * Parameters: + * ---------- + * + * dir - the directory in which the file was found. + * name - the name of the file. + */ +public class ExtensionFilter implements FilenameFilter +{ + + private String fileExtension; + + public ExtensionFilter(String fileExtension) + { + this.fileExtension = fileExtension; + } + + /* + * Tests if a specified file should be included in a + * file list. + * + * Returns: true if and only if the name should be + * included in the file list; false otherwise. + */ + @Override + public boolean accept(File dir, String name) + { + return (name.endsWith(fileExtension)); + } + +} diff --git a/BasicJava/JavaIODemo_File_listout_ext_array_App/JavaIODemo/src/FileDemo.java b/BasicJava/JavaIODemo_File_listout_ext_array_App/JavaIODemo/src/FileDemo.java new file mode 100644 index 000000000..d45f5dd6f --- /dev/null +++ b/BasicJava/JavaIODemo_File_listout_ext_array_App/JavaIODemo/src/FileDemo.java @@ -0,0 +1,49 @@ +import java.io.File; + +/* + * public File[] listFiles(FilenameFilter filter) + * + * Parameters: + * ---------- + * + * filter - A filename filter + * + * How to use FilenameFilter to list out all files that + * are end with “.txt” extension in folder “D:/work“. * + */ +public class FileDemo +{ + + public static void main(String[] args) + { + FileDemo fileDemo = new FileDemo(); + fileDemo.findAndListOutFiles("D:/work", ".txt"); + } + + public void findAndListOutFiles(String dirName, String fileExtension) + { + File fileDir = new File(dirName); + + ExtensionFilter extFilter = new ExtensionFilter(fileExtension); + + /* + * Returns an array of abstract pathnames denoting + * the files and directories in the directory + * denoted by this abstract pathname that satisfy + * the specified filter. + */ + File[] listOfFiles = fileDir.listFiles(extFilter); + + if (listOfFiles.length == 0) + { + System.out.println("No files end with : " + fileExtension); + return; + } + + for (File file : listOfFiles) + { + System.out.println(file.getName()); + } + } + +} diff --git a/BasicJava/JavaIODemo_File_listout_ext_array_App/Output.txt b/BasicJava/JavaIODemo_File_listout_ext_array_App/Output.txt new file mode 100644 index 000000000..6622d2bf6 --- /dev/null +++ b/BasicJava/JavaIODemo_File_listout_ext_array_App/Output.txt @@ -0,0 +1,2 @@ +Hello.txt +Java.txt diff --git a/BasicJava/JavaIODemo_File_listout_ext_array_App/work-dir.jpg b/BasicJava/JavaIODemo_File_listout_ext_array_App/work-dir.jpg new file mode 100644 index 000000000..fff3e0bcb Binary files /dev/null and b/BasicJava/JavaIODemo_File_listout_ext_array_App/work-dir.jpg differ diff --git a/BasicJava/JavaIODemo_File_path_check_App/FileDemo1_Output.txt b/BasicJava/JavaIODemo_File_path_check_App/FileDemo1_Output.txt new file mode 100644 index 000000000..80c30f657 --- /dev/null +++ b/BasicJava/JavaIODemo_File_path_check_App/FileDemo1_Output.txt @@ -0,0 +1 @@ +isFile = true diff --git a/BasicJava/JavaIODemo_File_path_check_App/FileDemo2_Output.txt b/BasicJava/JavaIODemo_File_path_check_App/FileDemo2_Output.txt new file mode 100644 index 000000000..e5fda26f9 --- /dev/null +++ b/BasicJava/JavaIODemo_File_path_check_App/FileDemo2_Output.txt @@ -0,0 +1 @@ +isDir = true diff --git a/BasicJava/JavaIODemo_File_path_check_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_File_path_check_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_File_path_check_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_File_path_check_App/JavaIODemo/.project b/BasicJava/JavaIODemo_File_path_check_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_File_path_check_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_File_path_check_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_File_path_check_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_File_path_check_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_File_path_check_App/JavaIODemo/bin/FileDemo1.class b/BasicJava/JavaIODemo_File_path_check_App/JavaIODemo/bin/FileDemo1.class new file mode 100644 index 000000000..ebb8c4d6e Binary files /dev/null and b/BasicJava/JavaIODemo_File_path_check_App/JavaIODemo/bin/FileDemo1.class differ diff --git a/BasicJava/JavaIODemo_File_path_check_App/JavaIODemo/bin/FileDemo2.class b/BasicJava/JavaIODemo_File_path_check_App/JavaIODemo/bin/FileDemo2.class new file mode 100644 index 000000000..f188ed50d Binary files /dev/null and b/BasicJava/JavaIODemo_File_path_check_App/JavaIODemo/bin/FileDemo2.class differ diff --git a/BasicJava/JavaIODemo_File_path_check_App/JavaIODemo/src/FileDemo1.java b/BasicJava/JavaIODemo_File_path_check_App/JavaIODemo/src/FileDemo1.java new file mode 100644 index 000000000..82a4167c1 --- /dev/null +++ b/BasicJava/JavaIODemo_File_path_check_App/JavaIODemo/src/FileDemo1.java @@ -0,0 +1,24 @@ +import java.io.File; + +/* + * Check if Path is File or Directory + */ +public class FileDemo1 +{ + + public static void main(String[] args) + { + File file = new File("D:/work/myfile.txt"); + /* + * Tests whether the file denoted by this abstract + * pathname is a normal file. + * + * Returns: true if and only if the file denoted by + * this abstract pathname exists and is a normal + * file; false otherwise + */ + boolean isFile = file.isFile(); + System.out.println("isFile = " + isFile); + } + +} diff --git a/BasicJava/JavaIODemo_File_path_check_App/JavaIODemo/src/FileDemo2.java b/BasicJava/JavaIODemo_File_path_check_App/JavaIODemo/src/FileDemo2.java new file mode 100644 index 000000000..f09ded24e --- /dev/null +++ b/BasicJava/JavaIODemo_File_path_check_App/JavaIODemo/src/FileDemo2.java @@ -0,0 +1,24 @@ +import java.io.File; + +/* + * Check if Path is File or Directory + */ +public class FileDemo2 +{ + + public static void main(String[] args) + { + File file = new File("D:/work"); + /* + * Tests whether the file denoted by this abstract + * pathname is a directory. + * + * Returns: true if and only if the file denoted by + * this abstract pathname exists and is a directory; + * false otherwise. + */ + boolean isDir = file.isDirectory(); + System.out.println("isDir = " + isDir); + } + +} diff --git a/BasicJava/JavaIODemo_File_recursive_delete_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_File_recursive_delete_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_File_recursive_delete_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_File_recursive_delete_App/JavaIODemo/.project b/BasicJava/JavaIODemo_File_recursive_delete_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_File_recursive_delete_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_File_recursive_delete_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_File_recursive_delete_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_File_recursive_delete_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_File_recursive_delete_App/JavaIODemo/bin/DeleteDirectory.class b/BasicJava/JavaIODemo_File_recursive_delete_App/JavaIODemo/bin/DeleteDirectory.class new file mode 100644 index 000000000..90672fac2 Binary files /dev/null and b/BasicJava/JavaIODemo_File_recursive_delete_App/JavaIODemo/bin/DeleteDirectory.class differ diff --git a/BasicJava/JavaIODemo_File_recursive_delete_App/JavaIODemo/src/DeleteDirectory.java b/BasicJava/JavaIODemo_File_recursive_delete_App/JavaIODemo/src/DeleteDirectory.java new file mode 100644 index 000000000..0cc41e281 --- /dev/null +++ b/BasicJava/JavaIODemo_File_recursive_delete_App/JavaIODemo/src/DeleteDirectory.java @@ -0,0 +1,81 @@ +import java.io.File; +import java.io.IOException; + +public class DeleteDirectory +{ + + private static final String SRC_FOLDER = "D:/work/java"; + + public static void main(String[] args) throws IOException + { + + File file = new File(SRC_FOLDER); + /* + * make sure directory exists + */ + if (!file.exists()) + { + System.out.println("Directory does not exist."); + } + else + { + DeleteDirectory deleteDirectory = new DeleteDirectory(); + deleteDirectory.deleteDir(file); + } + + } + + public void deleteDir(File file) throws IOException + { + + if (file.isDirectory()) + { + + /* + * If directory is empty, then delete it + */ + if (file.list().length == 0) + { + deleteEmptyDir(file); + } + else + { + // list all the directory contents + File files[] = file.listFiles(); + + for (File fileDelete : files) + { + /* + * Recursive delete + */ + deleteDir(fileDelete); + } + + /* + * check the directory again, if empty then + * delete it. + */ + if (file.list().length == 0) + { + deleteEmptyDir(file); + } + } + + } + else + { + /* + * if file, then delete it + */ + file.delete(); + System.out.println("File is deleted : " + file.getAbsolutePath()); + } + } + + private void deleteEmptyDir(File file) + { + file.delete(); + System.out.println("Directory is deleted : " + file.getAbsolutePath()); + } + +} diff --git a/BasicJava/JavaIODemo_File_recursive_delete_App/Output.txt b/BasicJava/JavaIODemo_File_recursive_delete_App/Output.txt new file mode 100644 index 000000000..ba34743d3 --- /dev/null +++ b/BasicJava/JavaIODemo_File_recursive_delete_App/Output.txt @@ -0,0 +1,6 @@ +File is deleted : D:\work\java\index.html +File is deleted : D:\work\java\jsp\async\async1.jsp +.... +.... +File is deleted : D:\work\java\websocket-deprecated\echo.html +Directory is deleted : D:\work\java diff --git a/BasicJava/JavaIODemo_File_rename_App/FileDemo1_Output.txt b/BasicJava/JavaIODemo_File_rename_App/FileDemo1_Output.txt new file mode 100644 index 000000000..f8626d7b4 --- /dev/null +++ b/BasicJava/JavaIODemo_File_rename_App/FileDemo1_Output.txt @@ -0,0 +1 @@ +success = true diff --git a/BasicJava/JavaIODemo_File_rename_App/FileDemo2_Output.txt b/BasicJava/JavaIODemo_File_rename_App/FileDemo2_Output.txt new file mode 100644 index 000000000..7016750b3 --- /dev/null +++ b/BasicJava/JavaIODemo_File_rename_App/FileDemo2_Output.txt @@ -0,0 +1 @@ +success = true \ No newline at end of file diff --git a/BasicJava/JavaIODemo_File_rename_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_File_rename_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_File_rename_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_File_rename_App/JavaIODemo/.project b/BasicJava/JavaIODemo_File_rename_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_File_rename_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_File_rename_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_File_rename_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_File_rename_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_File_rename_App/JavaIODemo/bin/FileDemo1.class b/BasicJava/JavaIODemo_File_rename_App/JavaIODemo/bin/FileDemo1.class new file mode 100644 index 000000000..468df8031 Binary files /dev/null and b/BasicJava/JavaIODemo_File_rename_App/JavaIODemo/bin/FileDemo1.class differ diff --git a/BasicJava/JavaIODemo_File_rename_App/JavaIODemo/bin/FileDemo2.class b/BasicJava/JavaIODemo_File_rename_App/JavaIODemo/bin/FileDemo2.class new file mode 100644 index 000000000..933382689 Binary files /dev/null and b/BasicJava/JavaIODemo_File_rename_App/JavaIODemo/bin/FileDemo2.class differ diff --git a/BasicJava/JavaIODemo_File_rename_App/JavaIODemo/src/FileDemo1.java b/BasicJava/JavaIODemo_File_rename_App/JavaIODemo/src/FileDemo1.java new file mode 100644 index 000000000..6853541f5 --- /dev/null +++ b/BasicJava/JavaIODemo_File_rename_App/JavaIODemo/src/FileDemo1.java @@ -0,0 +1,28 @@ +import java.io.File; + +/* + * public boolean renameTo(File dest) + * + * Parameters: + * ---------- + * + * dest - The new abstract pathname for the named file + */ +public class FileDemo1 +{ + + public static void main(String[] args) + { + File file = new File("D:/work/myfile.txt"); + /* + * Renames the file denoted by this abstract + * pathname. + * + * Returns: true if and only if the renaming + * succeeded; false otherwise + */ + boolean success = file.renameTo(new File("D:/work/java.txt")); + System.out.println("success = " + success); + } + +} diff --git a/BasicJava/JavaIODemo_File_rename_App/JavaIODemo/src/FileDemo2.java b/BasicJava/JavaIODemo_File_rename_App/JavaIODemo/src/FileDemo2.java new file mode 100644 index 000000000..ff8d80081 --- /dev/null +++ b/BasicJava/JavaIODemo_File_rename_App/JavaIODemo/src/FileDemo2.java @@ -0,0 +1,28 @@ +import java.io.File; + +/* + * public boolean renameTo(File dest) + * + * Parameters: + * ---------- + * + * dest - The new abstract pathname for the named file + */ +public class FileDemo2 +{ + + public static void main(String[] args) + { + File file = new File("D:/work/myfile.txt"); + /* + * Renames the file denoted by this abstract + * pathname. + * + * Returns: true if and only if the renaming + * succeeded; false otherwise + */ + boolean success = file.renameTo(new File("D:/work/misc/java.txt")); + System.out.println("success = " + success); + } + +} diff --git a/BasicJava/JavaIODemo_File_separator_App/FileDemo1_Output.txt b/BasicJava/JavaIODemo_File_separator_App/FileDemo1_Output.txt new file mode 100644 index 000000000..127e0fafa --- /dev/null +++ b/BasicJava/JavaIODemo_File_separator_App/FileDemo1_Output.txt @@ -0,0 +1,2 @@ +filePath : D:\eclipse\workspace\JavaIODemo\myfile.txt +File is created! diff --git a/BasicJava/JavaIODemo_File_separator_App/FileDemo2_Output.txt b/BasicJava/JavaIODemo_File_separator_App/FileDemo2_Output.txt new file mode 100644 index 000000000..56026c2b6 --- /dev/null +++ b/BasicJava/JavaIODemo_File_separator_App/FileDemo2_Output.txt @@ -0,0 +1,2 @@ +filepath : D:\eclipse\workspace\JavaIODemo\myfile.txt +File is already existed! diff --git a/BasicJava/JavaIODemo_File_separator_App/FileDemo3_Output.txt b/BasicJava/JavaIODemo_File_separator_App/FileDemo3_Output.txt new file mode 100644 index 000000000..8525306f2 --- /dev/null +++ b/BasicJava/JavaIODemo_File_separator_App/FileDemo3_Output.txt @@ -0,0 +1,2 @@ +filepath = D:\eclipse\workspace\JavaIODemo\myfile.txt +File already exists! diff --git a/BasicJava/JavaIODemo_File_separator_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_File_separator_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_File_separator_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_File_separator_App/JavaIODemo/.project b/BasicJava/JavaIODemo_File_separator_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_File_separator_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_File_separator_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_File_separator_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_File_separator_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_File_separator_App/JavaIODemo/bin/FileDemo1.class b/BasicJava/JavaIODemo_File_separator_App/JavaIODemo/bin/FileDemo1.class new file mode 100644 index 000000000..0d0c95c85 Binary files /dev/null and b/BasicJava/JavaIODemo_File_separator_App/JavaIODemo/bin/FileDemo1.class differ diff --git a/BasicJava/JavaIODemo_File_separator_App/JavaIODemo/bin/FileDemo2.class b/BasicJava/JavaIODemo_File_separator_App/JavaIODemo/bin/FileDemo2.class new file mode 100644 index 000000000..c16d9e648 Binary files /dev/null and b/BasicJava/JavaIODemo_File_separator_App/JavaIODemo/bin/FileDemo2.class differ diff --git a/BasicJava/JavaIODemo_File_separator_App/JavaIODemo/bin/FileDemo3.class b/BasicJava/JavaIODemo_File_separator_App/JavaIODemo/bin/FileDemo3.class new file mode 100644 index 000000000..ddf60ffff Binary files /dev/null and b/BasicJava/JavaIODemo_File_separator_App/JavaIODemo/bin/FileDemo3.class differ diff --git a/BasicJava/JavaIODemo_File_separator_App/JavaIODemo/myfile.txt b/BasicJava/JavaIODemo_File_separator_App/JavaIODemo/myfile.txt new file mode 100644 index 000000000..e69de29bb diff --git a/BasicJava/JavaIODemo_File_separator_App/JavaIODemo/src/FileDemo1.java b/BasicJava/JavaIODemo_File_separator_App/JavaIODemo/src/FileDemo1.java new file mode 100644 index 000000000..71a26f6d9 --- /dev/null +++ b/BasicJava/JavaIODemo_File_separator_App/JavaIODemo/src/FileDemo1.java @@ -0,0 +1,31 @@ +import java.io.File; +import java.io.IOException; +/* + * Using File.separator construct the file path. + */ +public class FileDemo1 +{ + + public static void main(String[] args) throws IOException + { + String filename = "myfile.txt"; + String workingDirectory = System.getProperty("user.dir"); + + String filePath = workingDirectory + File.separator + filename; + + System.out.println("filePath : " + filePath); + + File file = new File(filePath); + + if (file.createNewFile()) + { + System.out.println("File is created!"); + } + else + { + System.out.println("File is already existed!"); + } + + } + +} diff --git a/BasicJava/JavaIODemo_File_separator_App/JavaIODemo/src/FileDemo2.java b/BasicJava/JavaIODemo_File_separator_App/JavaIODemo/src/FileDemo2.java new file mode 100644 index 000000000..b804d1688 --- /dev/null +++ b/BasicJava/JavaIODemo_File_separator_App/JavaIODemo/src/FileDemo2.java @@ -0,0 +1,31 @@ +import java.io.File; +import java.io.IOException; + +/* + * Like below construct the file path. + * File file = new File(workingDir, filename); + */ +public class FileDemo2 +{ + + public static void main(String[] args) throws IOException + { + String filename = "myfile.txt"; + String workingDirectory = System.getProperty("user.dir"); + + File file = new File(workingDirectory, filename); + + System.out.println("filepath : " + file.getAbsolutePath()); + + if (file.createNewFile()) + { + System.out.println("File is created!"); + } + else + { + System.out.println("File is already existed!"); + } + + } + +} diff --git a/BasicJava/JavaIODemo_File_separator_App/JavaIODemo/src/FileDemo3.java b/BasicJava/JavaIODemo_File_separator_App/JavaIODemo/src/FileDemo3.java new file mode 100644 index 000000000..ad922a6e0 --- /dev/null +++ b/BasicJava/JavaIODemo_File_separator_App/JavaIODemo/src/FileDemo3.java @@ -0,0 +1,57 @@ +import java.io.File; +import java.io.IOException; + +/* + * Check the system OS and create file path manually, not recommend. + */ +public class FileDemo3 +{ + + public static void main(String[] args) throws IOException + { + String filename = "myfile.txt"; + String workingDir = System.getProperty("user.dir"); + + String absoluteFilePath = ""; + + String os = System.getProperty("os.name").toLowerCase(); + + if (os.indexOf("win") >= 0) + { + + // if windows + absoluteFilePath = workingDir + "\\" + filename; + + } + else if (os.indexOf("nix") >= 0 || os.indexOf("nux") >= 0 + || os.indexOf("mac") >= 0) + { + + // if unix or mac + absoluteFilePath = workingDir + "/" + filename; + + } + else + { + + // Unknown OS + absoluteFilePath = workingDir + "/" + filename; + + } + + System.out.println("filepath = " + absoluteFilePath); + + File file = new File(absoluteFilePath); + + if (file.createNewFile()) + { + System.out.println("File is created!"); + } + else + { + System.out.println("File already exists!"); + } + + } + +} diff --git a/BasicJava/JavaIODemo_File_size_mb_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_File_size_mb_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_File_size_mb_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_File_size_mb_App/JavaIODemo/.project b/BasicJava/JavaIODemo_File_size_mb_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_File_size_mb_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_File_size_mb_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_File_size_mb_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_File_size_mb_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_File_size_mb_App/JavaIODemo/bin/FileDemo.class b/BasicJava/JavaIODemo_File_size_mb_App/JavaIODemo/bin/FileDemo.class new file mode 100644 index 000000000..556292ebc Binary files /dev/null and b/BasicJava/JavaIODemo_File_size_mb_App/JavaIODemo/bin/FileDemo.class differ diff --git a/BasicJava/JavaIODemo_File_size_mb_App/JavaIODemo/src/FileDemo.java b/BasicJava/JavaIODemo_File_size_mb_App/JavaIODemo/src/FileDemo.java new file mode 100644 index 000000000..8ebe0f7da --- /dev/null +++ b/BasicJava/JavaIODemo_File_size_mb_App/JavaIODemo/src/FileDemo.java @@ -0,0 +1,44 @@ +import java.io.File; + +public class FileDemo +{ + + public static void main(String[] args) + { + File file = new File("D:/work/java.txt"); + + if (file.exists()) + { + + /* + * Returns: The length, in bytes, of the file + * denoted by this abstract pathname, or 0L if + * the file does not exist. + */ + double bytes = file.length(); + double kilobytes = (bytes / 1024); + double megabytes = (kilobytes / 1024); + double gigabytes = (megabytes / 1024); + double terabytes = (gigabytes / 1024); + double petabytes = (terabytes / 1024); + double exabytes = (petabytes / 1024); + double zettabytes = (exabytes / 1024); + double yottabytes = (zettabytes / 1024); + + System.out.println("bytes : " + bytes); + System.out.println("kilobytes : " + kilobytes); + System.out.println("megabytes : " + megabytes); + System.out.println("gigabytes : " + gigabytes); + System.out.println("terabytes : " + terabytes); + System.out.println("petabytes : " + petabytes); + System.out.println("exabytes : " + exabytes); + System.out.println("zettabytes : " + zettabytes); + System.out.println("yottabytes : " + yottabytes); + } + else + { + System.out.println("File does not exists!"); + } + } + +} diff --git a/BasicJava/JavaIODemo_File_size_mb_App/Output.txt b/BasicJava/JavaIODemo_File_size_mb_App/Output.txt new file mode 100644 index 000000000..6454c38b0 --- /dev/null +++ b/BasicJava/JavaIODemo_File_size_mb_App/Output.txt @@ -0,0 +1,9 @@ +bytes : 2227920.0 +kilobytes : 2175.703125 +megabytes : 2.1247100830078125 +gigabytes : 0.002074912190437317 +terabytes : 2.0262814359739423E-6 +petabytes : 1.978790464818303E-9 +exabytes : 1.932412563299124E-12 +zettabytes : 1.887121643846801E-15 +yottabytes : 1.8428922303191414E-18 diff --git a/BasicJava/JavaIODemo_File_working_dir_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_File_working_dir_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_File_working_dir_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_File_working_dir_App/JavaIODemo/.project b/BasicJava/JavaIODemo_File_working_dir_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_File_working_dir_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_File_working_dir_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_File_working_dir_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_File_working_dir_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_File_working_dir_App/JavaIODemo/bin/FileDemo.class b/BasicJava/JavaIODemo_File_working_dir_App/JavaIODemo/bin/FileDemo.class new file mode 100644 index 000000000..19a997fea Binary files /dev/null and b/BasicJava/JavaIODemo_File_working_dir_App/JavaIODemo/bin/FileDemo.class differ diff --git a/BasicJava/JavaIODemo_File_working_dir_App/JavaIODemo/src/FileDemo.java b/BasicJava/JavaIODemo_File_working_dir_App/JavaIODemo/src/FileDemo.java new file mode 100644 index 000000000..43d6967ac --- /dev/null +++ b/BasicJava/JavaIODemo_File_working_dir_App/JavaIODemo/src/FileDemo.java @@ -0,0 +1,10 @@ +public class FileDemo +{ + + public static void main(String[] args) + { + String workingDir = System.getProperty("user.dir"); + System.out.println("Current working directory : " + workingDir); + } + +} diff --git a/BasicJava/JavaIODemo_File_working_dir_App/Output.txt b/BasicJava/JavaIODemo_File_working_dir_App/Output.txt new file mode 100644 index 000000000..c4513903a --- /dev/null +++ b/BasicJava/JavaIODemo_File_working_dir_App/Output.txt @@ -0,0 +1 @@ +Current working directory : D:\eclipse\workspace\JavaIODemo diff --git a/BasicJava/JavaIODemo_Gzip_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_Gzip_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_Gzip_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_Gzip_App/JavaIODemo/.project b/BasicJava/JavaIODemo_Gzip_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_Gzip_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_Gzip_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_Gzip_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_Gzip_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_Gzip_App/JavaIODemo/bin/GZipDemo.class b/BasicJava/JavaIODemo_Gzip_App/JavaIODemo/bin/GZipDemo.class new file mode 100644 index 000000000..07669247f Binary files /dev/null and b/BasicJava/JavaIODemo_Gzip_App/JavaIODemo/bin/GZipDemo.class differ diff --git a/BasicJava/JavaIODemo_Gzip_App/JavaIODemo/src/GZipDemo.java b/BasicJava/JavaIODemo_Gzip_App/JavaIODemo/src/GZipDemo.java new file mode 100644 index 000000000..4e8c4fc28 --- /dev/null +++ b/BasicJava/JavaIODemo_Gzip_App/JavaIODemo/src/GZipDemo.java @@ -0,0 +1,47 @@ +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.zip.GZIPOutputStream; + +public class GZipDemo +{ + + public static void main(String[] args) throws IOException + { + String outputGzipFile = "D:/work/Helloworld.gz"; + String sourceFile = "D:/work/Helloworld.java"; + + GZipDemo gzipDemo = new GZipDemo(); + gzipDemo.gzipIt(outputGzipFile, sourceFile); + } + + public void gzipIt(String gzipFile, String sourceFile) throws IOException + { + + byte[] buffer = new byte[1024]; + + /* + * If the Streams are within the + * "try-With-Resources" block, then it will be + * closed automatically. + */ + try ( + FileOutputStream fos = new FileOutputStream(gzipFile); + GZIPOutputStream gzos = new GZIPOutputStream(fos); + FileInputStream fin = new FileInputStream(sourceFile);) + { + + int len; + while ((len = fin.read(buffer)) > 0) + { + gzos.write(buffer, 0, len); + } + + gzos.finish(); + + System.out.println("Gzip compression has been done.."); + + } + + } +} \ No newline at end of file diff --git a/BasicJava/JavaIODemo_Gzip_App/Output.txt b/BasicJava/JavaIODemo_Gzip_App/Output.txt new file mode 100644 index 000000000..d1450ab25 --- /dev/null +++ b/BasicJava/JavaIODemo_Gzip_App/Output.txt @@ -0,0 +1 @@ +Gzip compression has been done.. diff --git a/BasicJava/JavaIODemo_Gzip_Serialize_App/GZipDeserializeDemo_Output.txt b/BasicJava/JavaIODemo_Gzip_Serialize_App/GZipDeserializeDemo_Output.txt new file mode 100644 index 000000000..674f6f230 --- /dev/null +++ b/BasicJava/JavaIODemo_Gzip_Serialize_App/GZipDeserializeDemo_Output.txt @@ -0,0 +1,2 @@ +Name : Peter +Age : 45 diff --git a/BasicJava/JavaIODemo_Gzip_Serialize_App/GZipSerializeDemo_Output.txt b/BasicJava/JavaIODemo_Gzip_Serialize_App/GZipSerializeDemo_Output.txt new file mode 100644 index 000000000..c1f64ffa7 --- /dev/null +++ b/BasicJava/JavaIODemo_Gzip_Serialize_App/GZipSerializeDemo_Output.txt @@ -0,0 +1 @@ +Person object is serialized and compressed. diff --git a/BasicJava/JavaIODemo_Gzip_Serialize_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_Gzip_Serialize_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_Gzip_Serialize_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_Gzip_Serialize_App/JavaIODemo/.project b/BasicJava/JavaIODemo_Gzip_Serialize_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_Gzip_Serialize_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_Gzip_Serialize_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_Gzip_Serialize_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_Gzip_Serialize_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_Gzip_Serialize_App/JavaIODemo/bin/GZipDeserializeDemo.class b/BasicJava/JavaIODemo_Gzip_Serialize_App/JavaIODemo/bin/GZipDeserializeDemo.class new file mode 100644 index 000000000..26949d865 Binary files /dev/null and b/BasicJava/JavaIODemo_Gzip_Serialize_App/JavaIODemo/bin/GZipDeserializeDemo.class differ diff --git a/BasicJava/JavaIODemo_Gzip_Serialize_App/JavaIODemo/bin/GZipSerializeDemo.class b/BasicJava/JavaIODemo_Gzip_Serialize_App/JavaIODemo/bin/GZipSerializeDemo.class new file mode 100644 index 000000000..3b3f53d95 Binary files /dev/null and b/BasicJava/JavaIODemo_Gzip_Serialize_App/JavaIODemo/bin/GZipSerializeDemo.class differ diff --git a/BasicJava/JavaIODemo_Gzip_Serialize_App/JavaIODemo/bin/Person.class b/BasicJava/JavaIODemo_Gzip_Serialize_App/JavaIODemo/bin/Person.class new file mode 100644 index 000000000..40f04603b Binary files /dev/null and b/BasicJava/JavaIODemo_Gzip_Serialize_App/JavaIODemo/bin/Person.class differ diff --git a/BasicJava/JavaIODemo_Gzip_Serialize_App/JavaIODemo/src/GZipDeserializeDemo.java b/BasicJava/JavaIODemo_Gzip_Serialize_App/JavaIODemo/src/GZipDeserializeDemo.java new file mode 100644 index 000000000..03ba26f3d --- /dev/null +++ b/BasicJava/JavaIODemo_Gzip_Serialize_App/JavaIODemo/src/GZipDeserializeDemo.java @@ -0,0 +1,42 @@ +import java.io.FileInputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.util.zip.GZIPInputStream; + +/* + * How to decompress serialized object from a Gzip file. + */ +public class GZipDeserializeDemo +{ + + public static void main(String[] args) throws IOException, + ClassNotFoundException + { + GZipDeserializeDemo gzipDeserializeDemo = new GZipDeserializeDemo(); + String gzipPath = "D:/work/person.gz"; + Person person = gzipDeserializeDemo.deserializePersonObject(gzipPath); + System.out.println("Name : " + person.getName()); + System.out.println("Age : " + person.getAge()); + } + + public Person deserializePersonObject(String gzipPath) + throws ClassNotFoundException, IOException + { + /* + * If the Streams are within the + * "try-With-Resources" block, then it will be + * closed automatically. + */ + try (FileInputStream fin = new FileInputStream(gzipPath); + GZIPInputStream gis = new GZIPInputStream(fin); + ObjectInputStream ois = new ObjectInputStream(gis);) + { + + Person person = (Person) ois.readObject(); + + return person; + + } + + } +} \ No newline at end of file diff --git a/BasicJava/JavaIODemo_Gzip_Serialize_App/JavaIODemo/src/GZipSerializeDemo.java b/BasicJava/JavaIODemo_Gzip_Serialize_App/JavaIODemo/src/GZipSerializeDemo.java new file mode 100644 index 000000000..eeccdc7b3 --- /dev/null +++ b/BasicJava/JavaIODemo_Gzip_Serialize_App/JavaIODemo/src/GZipSerializeDemo.java @@ -0,0 +1,41 @@ +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; +import java.util.zip.GZIPOutputStream; + +/* + * We can compress the serialized object to + * reduce the file size. + */ +public class GZipSerializeDemo +{ + + public static void main(String[] args) throws IOException + { + GZipSerializeDemo gzipSerializeDemo = new GZipSerializeDemo(); + String gzipPath = "D:/work/person.gz"; + gzipSerializeDemo.gzipPersonObject(gzipPath); + } + + public void gzipPersonObject(String gzipPath) throws IOException + { + + Person person = new Person("Peter", 45); + /* + * If the Streams are within the + * "try-With-Resources" block, then it will be + * closed automatically. + */ + try (FileOutputStream fos = new FileOutputStream(gzipPath); + GZIPOutputStream gz = new GZIPOutputStream(fos); + ObjectOutputStream oos = new ObjectOutputStream(gz);) + + { + + oos.writeObject(person); + System.out.println("Person object is serialized and compressed."); + + } + + } +} \ No newline at end of file diff --git a/BasicJava/JavaIODemo_Gzip_Serialize_App/JavaIODemo/src/Person.java b/BasicJava/JavaIODemo_Gzip_Serialize_App/JavaIODemo/src/Person.java new file mode 100644 index 000000000..f3acaf186 --- /dev/null +++ b/BasicJava/JavaIODemo_Gzip_Serialize_App/JavaIODemo/src/Person.java @@ -0,0 +1,36 @@ +import java.io.Serializable; + +public class Person implements Serializable +{ + private static final long serialVersionUID = 3069227031912694124L; + private String name; + private int age; + + public Person(String name, int age) + { + super(); + this.name = name; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + +} diff --git a/BasicJava/JavaIODemo_Gzip_decompress_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_Gzip_decompress_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_Gzip_decompress_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_Gzip_decompress_App/JavaIODemo/.project b/BasicJava/JavaIODemo_Gzip_decompress_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_Gzip_decompress_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_Gzip_decompress_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_Gzip_decompress_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_Gzip_decompress_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_Gzip_decompress_App/JavaIODemo/bin/GZipDemo.class b/BasicJava/JavaIODemo_Gzip_decompress_App/JavaIODemo/bin/GZipDemo.class new file mode 100644 index 000000000..28d19a985 Binary files /dev/null and b/BasicJava/JavaIODemo_Gzip_decompress_App/JavaIODemo/bin/GZipDemo.class differ diff --git a/BasicJava/JavaIODemo_Gzip_decompress_App/JavaIODemo/src/GZipDemo.java b/BasicJava/JavaIODemo_Gzip_decompress_App/JavaIODemo/src/GZipDemo.java new file mode 100644 index 000000000..a5fe01fd9 --- /dev/null +++ b/BasicJava/JavaIODemo_Gzip_decompress_App/JavaIODemo/src/GZipDemo.java @@ -0,0 +1,44 @@ +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.zip.GZIPInputStream; + +public class GZipDemo +{ + + public static void main(String[] args) throws IOException + { + String inputGzipFile = "D:/work/Helloworld.gz"; + String dstFile = "D:/work/Helloworld.java"; + + GZipDemo gzipDemo = new GZipDemo(); + gzipDemo.deCompress(inputGzipFile, dstFile); + } + + public void deCompress(String inputGzipFile, String dstFile) throws IOException + { + + byte[] buffer = new byte[1024]; + + /* + * If the Streams are within the + * "try-With-Resources" block, then it will be + * closed automatically. + */ + try ( + FileInputStream fis = new FileInputStream(inputGzipFile); + GZIPInputStream gzis = new GZIPInputStream(fis); + FileOutputStream out = new FileOutputStream(dstFile);) + { + + int len; + while ((len = gzis.read(buffer)) > 0) + { + out.write(buffer, 0, len); + } + + System.out.println("Decompression is done.."); + + } + } +} \ No newline at end of file diff --git a/BasicJava/JavaIODemo_Gzip_decompress_App/Output.txt b/BasicJava/JavaIODemo_Gzip_decompress_App/Output.txt new file mode 100644 index 000000000..35350a5a0 --- /dev/null +++ b/BasicJava/JavaIODemo_Gzip_decompress_App/Output.txt @@ -0,0 +1 @@ +Decompression is done.. diff --git a/BasicJava/JavaIODemo_InputStreamReader_Read_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_InputStreamReader_Read_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_InputStreamReader_Read_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_InputStreamReader_Read_App/JavaIODemo/.project b/BasicJava/JavaIODemo_InputStreamReader_Read_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_InputStreamReader_Read_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_InputStreamReader_Read_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_InputStreamReader_Read_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_InputStreamReader_Read_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_InputStreamReader_Read_App/JavaIODemo/bin/InputStreamReaderDemo.class b/BasicJava/JavaIODemo_InputStreamReader_Read_App/JavaIODemo/bin/InputStreamReaderDemo.class new file mode 100644 index 000000000..036b51ebf Binary files /dev/null and b/BasicJava/JavaIODemo_InputStreamReader_Read_App/JavaIODemo/bin/InputStreamReaderDemo.class differ diff --git a/BasicJava/JavaIODemo_InputStreamReader_Read_App/JavaIODemo/src/InputStreamReaderDemo.java b/BasicJava/JavaIODemo_InputStreamReader_Read_App/JavaIODemo/src/InputStreamReaderDemo.java new file mode 100644 index 000000000..b4a4a9a12 --- /dev/null +++ b/BasicJava/JavaIODemo_InputStreamReader_Read_App/JavaIODemo/src/InputStreamReaderDemo.java @@ -0,0 +1,45 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class InputStreamReaderDemo +{ + + public static void main(String[] args) throws IOException + { + InputStreamReaderDemo inputStreamReaderDemo = new InputStreamReaderDemo(); + inputStreamReaderDemo.readData(); + } + + private void readData() throws IOException + { + InputStreamReader inputStreamReader = null; + BufferedReader bufferedReader = null; + System.out.print("Enter your name : "); + try + { + inputStreamReader = new InputStreamReader(System.in); + /* + * We are connecting the BufferedReader stream + * with the InputStreamReader stream for reading + * the line by line data from the keyboard. + */ + bufferedReader = new BufferedReader(inputStreamReader); + String name = bufferedReader.readLine(); + System.out.println("Welcome " + name); + } + finally + { + if (inputStreamReader != null) + { + inputStreamReader.close(); + } + if (bufferedReader != null) + { + bufferedReader.close(); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_InputStreamReader_Read_App/Output.txt b/BasicJava/JavaIODemo_InputStreamReader_Read_App/Output.txt new file mode 100644 index 000000000..5f82ef3d5 --- /dev/null +++ b/BasicJava/JavaIODemo_InputStreamReader_Read_App/Output.txt @@ -0,0 +1,2 @@ +Enter your name : Peter +Welcome Peter diff --git a/BasicJava/JavaIODemo_InputStreamReader_Read_while_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_InputStreamReader_Read_while_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_InputStreamReader_Read_while_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_InputStreamReader_Read_while_App/JavaIODemo/.project b/BasicJava/JavaIODemo_InputStreamReader_Read_while_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_InputStreamReader_Read_while_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_InputStreamReader_Read_while_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_InputStreamReader_Read_while_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_InputStreamReader_Read_while_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_InputStreamReader_Read_while_App/JavaIODemo/bin/InputStreamReaderDemo.class b/BasicJava/JavaIODemo_InputStreamReader_Read_while_App/JavaIODemo/bin/InputStreamReaderDemo.class new file mode 100644 index 000000000..2f355d550 Binary files /dev/null and b/BasicJava/JavaIODemo_InputStreamReader_Read_while_App/JavaIODemo/bin/InputStreamReaderDemo.class differ diff --git a/BasicJava/JavaIODemo_InputStreamReader_Read_while_App/JavaIODemo/src/InputStreamReaderDemo.java b/BasicJava/JavaIODemo_InputStreamReader_Read_while_App/JavaIODemo/src/InputStreamReaderDemo.java new file mode 100644 index 000000000..63030b674 --- /dev/null +++ b/BasicJava/JavaIODemo_InputStreamReader_Read_while_App/JavaIODemo/src/InputStreamReaderDemo.java @@ -0,0 +1,52 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class InputStreamReaderDemo +{ + + public static void main(String[] args) throws IOException + { + InputStreamReaderDemo inputStreamReaderDemo = new InputStreamReaderDemo(); + inputStreamReaderDemo.readData(); + } + + private void readData() throws IOException + { + InputStreamReader inputStreamReader = null; + BufferedReader bufferedReader = null; + + try + { + inputStreamReader = new InputStreamReader(System.in); + /* + * We are connecting the BufferedReader stream + * with the InputStreamReader stream for reading + * the line by line data from the keyboard. + */ + bufferedReader = new BufferedReader(inputStreamReader); + + String data = ""; + while (!data.equals("stop")) + { + System.out.print("Enter data : "); + data = bufferedReader.readLine(); + System.out.println("data is : " + data); + } + + } + finally + { + if (inputStreamReader != null) + { + inputStreamReader.close(); + } + if (bufferedReader != null) + { + bufferedReader.close(); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_InputStreamReader_Read_while_App/Output.txt b/BasicJava/JavaIODemo_InputStreamReader_Read_while_App/Output.txt new file mode 100644 index 000000000..9746fc7f7 --- /dev/null +++ b/BasicJava/JavaIODemo_InputStreamReader_Read_while_App/Output.txt @@ -0,0 +1,8 @@ +Enter data : hello +data is : hello +Enter data : bye +data is : bye +Enter data : welcome +data is : welcome +Enter data : stop +data is : stop diff --git a/BasicJava/JavaIODemo_LineNumberReaderDemo_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_LineNumberReaderDemo_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_LineNumberReaderDemo_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_LineNumberReaderDemo_App/JavaIODemo/.project b/BasicJava/JavaIODemo_LineNumberReaderDemo_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_LineNumberReaderDemo_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_LineNumberReaderDemo_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_LineNumberReaderDemo_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_LineNumberReaderDemo_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_LineNumberReaderDemo_App/JavaIODemo/bin/LineNumberReaderDemo.class b/BasicJava/JavaIODemo_LineNumberReaderDemo_App/JavaIODemo/bin/LineNumberReaderDemo.class new file mode 100644 index 000000000..c23c0b561 Binary files /dev/null and b/BasicJava/JavaIODemo_LineNumberReaderDemo_App/JavaIODemo/bin/LineNumberReaderDemo.class differ diff --git a/BasicJava/JavaIODemo_LineNumberReaderDemo_App/JavaIODemo/myfile.txt b/BasicJava/JavaIODemo_LineNumberReaderDemo_App/JavaIODemo/myfile.txt new file mode 100644 index 000000000..be8049358 --- /dev/null +++ b/BasicJava/JavaIODemo_LineNumberReaderDemo_App/JavaIODemo/myfile.txt @@ -0,0 +1,3 @@ +Welcome +Hello +Bye \ No newline at end of file diff --git a/BasicJava/JavaIODemo_LineNumberReaderDemo_App/JavaIODemo/src/LineNumberReaderDemo.java b/BasicJava/JavaIODemo_LineNumberReaderDemo_App/JavaIODemo/src/LineNumberReaderDemo.java new file mode 100644 index 000000000..1e5d168ea --- /dev/null +++ b/BasicJava/JavaIODemo_LineNumberReaderDemo_App/JavaIODemo/src/LineNumberReaderDemo.java @@ -0,0 +1,40 @@ +import java.io.FileReader; +import java.io.LineNumberReader; + +public class LineNumberReaderDemo +{ + + public static void main(String[] args) throws Exception + { + LineNumberReader lineNumberReader = null; + FileReader fileReader = null; + try + { + fileReader = new FileReader("myfile.txt"); + lineNumberReader = new LineNumberReader(fileReader); + + String line; + while ((line = lineNumberReader.readLine()) != null) + { + int lineNumber = lineNumberReader.getLineNumber(); + System.out.println(lineNumber + " = " + line); + } + + } + finally + { + if (lineNumberReader != null) + { + /* + * When you are finished reading characters + * from the LineNumberReader you should + * remember to close it. Closing a + * LineNumberReader will also close the + * Reader instance from which the + * LineNumberReader is reading. + */ + lineNumberReader.close(); + } + } + } +} \ No newline at end of file diff --git a/BasicJava/JavaIODemo_LineNumberReaderDemo_App/Output.txt b/BasicJava/JavaIODemo_LineNumberReaderDemo_App/Output.txt new file mode 100644 index 000000000..7443d100b --- /dev/null +++ b/BasicJava/JavaIODemo_LineNumberReaderDemo_App/Output.txt @@ -0,0 +1,3 @@ +1 = Welcome +2 = Hello +3 = Bye diff --git a/BasicJava/JavaIODemo_LineNumberReaderDemo_Cons_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_LineNumberReaderDemo_Cons_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_LineNumberReaderDemo_Cons_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_LineNumberReaderDemo_Cons_App/JavaIODemo/.project b/BasicJava/JavaIODemo_LineNumberReaderDemo_Cons_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_LineNumberReaderDemo_Cons_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_LineNumberReaderDemo_Cons_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_LineNumberReaderDemo_Cons_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_LineNumberReaderDemo_Cons_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_LineNumberReaderDemo_Cons_App/JavaIODemo/bin/LineNumberReaderDemo.class b/BasicJava/JavaIODemo_LineNumberReaderDemo_Cons_App/JavaIODemo/bin/LineNumberReaderDemo.class new file mode 100644 index 000000000..9316abbf8 Binary files /dev/null and b/BasicJava/JavaIODemo_LineNumberReaderDemo_Cons_App/JavaIODemo/bin/LineNumberReaderDemo.class differ diff --git a/BasicJava/JavaIODemo_LineNumberReaderDemo_Cons_App/JavaIODemo/myfile.txt b/BasicJava/JavaIODemo_LineNumberReaderDemo_Cons_App/JavaIODemo/myfile.txt new file mode 100644 index 000000000..be8049358 --- /dev/null +++ b/BasicJava/JavaIODemo_LineNumberReaderDemo_Cons_App/JavaIODemo/myfile.txt @@ -0,0 +1,3 @@ +Welcome +Hello +Bye \ No newline at end of file diff --git a/BasicJava/JavaIODemo_LineNumberReaderDemo_Cons_App/JavaIODemo/src/LineNumberReaderDemo.java b/BasicJava/JavaIODemo_LineNumberReaderDemo_Cons_App/JavaIODemo/src/LineNumberReaderDemo.java new file mode 100644 index 000000000..3851cb7bf --- /dev/null +++ b/BasicJava/JavaIODemo_LineNumberReaderDemo_Cons_App/JavaIODemo/src/LineNumberReaderDemo.java @@ -0,0 +1,53 @@ +import java.io.FileReader; +import java.io.LineNumberReader; + +/* + * public LineNumberReader(Reader in, int sz) + * + * Parameters: + * ---------- + * + * in - A Reader object to provide the underlying stream. + * sz - An int specifying the size of the buffer. + */ +public class LineNumberReaderDemo +{ + + public static void main(String[] args) throws Exception + { + LineNumberReader lineNumberReader = null; + FileReader fileReader = null; + try + { + int bufferSize = 1024; + fileReader = new FileReader("myfile.txt"); + /* + * Create a new line-numbering reader, reading + * characters into a buffer of the given size. + */ + lineNumberReader = new LineNumberReader(fileReader, bufferSize); + + String line; + while ((line = lineNumberReader.readLine()) != null) + { + int lineNumber = lineNumberReader.getLineNumber(); + System.out.println(lineNumber + "." + line); + } + } + finally + { + if (lineNumberReader != null) + { + /* + * When you are finished reading characters + * from the LineNumberReader you should + * remember to close it. Closing a + * LineNumberReader will also close the + * Reader instance from which the + * LineNumberReader is reading. + */ + lineNumberReader.close(); + } + } + } +} \ No newline at end of file diff --git a/BasicJava/JavaIODemo_LineNumberReaderDemo_Cons_App/Output.txt b/BasicJava/JavaIODemo_LineNumberReaderDemo_Cons_App/Output.txt new file mode 100644 index 000000000..cf8ee8e73 --- /dev/null +++ b/BasicJava/JavaIODemo_LineNumberReaderDemo_Cons_App/Output.txt @@ -0,0 +1,3 @@ +1.Welcome +2.Hello +3.Bye diff --git a/BasicJava/JavaIODemo_ObjectInputStream_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_ObjectInputStream_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_ObjectInputStream_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_ObjectInputStream_App/JavaIODemo/.project b/BasicJava/JavaIODemo_ObjectInputStream_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_ObjectInputStream_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_ObjectInputStream_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_ObjectInputStream_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_ObjectInputStream_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_ObjectInputStream_App/JavaIODemo/bin/ObjectInputStreamDemo.class b/BasicJava/JavaIODemo_ObjectInputStream_App/JavaIODemo/bin/ObjectInputStreamDemo.class new file mode 100644 index 000000000..e2f79f3c6 Binary files /dev/null and b/BasicJava/JavaIODemo_ObjectInputStream_App/JavaIODemo/bin/ObjectInputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_ObjectInputStream_App/JavaIODemo/bin/ObjectOutputStreamDemo.class b/BasicJava/JavaIODemo_ObjectInputStream_App/JavaIODemo/bin/ObjectOutputStreamDemo.class new file mode 100644 index 000000000..d056ea0c1 Binary files /dev/null and b/BasicJava/JavaIODemo_ObjectInputStream_App/JavaIODemo/bin/ObjectOutputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_ObjectInputStream_App/JavaIODemo/bin/Student.class b/BasicJava/JavaIODemo_ObjectInputStream_App/JavaIODemo/bin/Student.class new file mode 100644 index 000000000..8bbab79b3 Binary files /dev/null and b/BasicJava/JavaIODemo_ObjectInputStream_App/JavaIODemo/bin/Student.class differ diff --git a/BasicJava/JavaIODemo_ObjectInputStream_App/JavaIODemo/src/ObjectInputStreamDemo.java b/BasicJava/JavaIODemo_ObjectInputStream_App/JavaIODemo/src/ObjectInputStreamDemo.java new file mode 100644 index 000000000..62fa1fae8 --- /dev/null +++ b/BasicJava/JavaIODemo_ObjectInputStream_App/JavaIODemo/src/ObjectInputStreamDemo.java @@ -0,0 +1,55 @@ +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.ObjectInputStream; + +public class ObjectInputStreamDemo +{ + + public static void main(String[] args) throws FileNotFoundException, + IOException, ClassNotFoundException + { + ObjectInputStreamDemo objectInputStreamDemo = new ObjectInputStreamDemo(); + objectInputStreamDemo.readStudentObject(); + } + + private void readStudentObject() throws IOException, FileNotFoundException, + ClassNotFoundException + { + FileInputStream fileInputStream = null; + ObjectInputStream objectInputStream = null; + + try + { + fileInputStream = new FileInputStream("student.tmp"); + objectInputStream = new ObjectInputStream(fileInputStream); + + /* + * Read an object from the ObjectInputStream. + */ + Student student = (Student) objectInputStream.readObject(); + + System.out + .println("Successfully read student object from the file."); + + System.out.println(student); + System.out.println("Name = " + student.getName()); + System.out.println("Age = " + student.getAge()); + } + finally + { + + if (objectInputStream != null) + { + /* + * Closing a ObjectInputStream will also + * close the InputStream instance from which + * the ObjectInputStream is reading. + */ + objectInputStream.close(); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_ObjectInputStream_App/JavaIODemo/src/ObjectOutputStreamDemo.java b/BasicJava/JavaIODemo_ObjectInputStream_App/JavaIODemo/src/ObjectOutputStreamDemo.java new file mode 100644 index 000000000..94d78775b --- /dev/null +++ b/BasicJava/JavaIODemo_ObjectInputStream_App/JavaIODemo/src/ObjectOutputStreamDemo.java @@ -0,0 +1,52 @@ +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; + +public class ObjectOutputStreamDemo +{ + + public static void main(String[] args) throws FileNotFoundException, + IOException, ClassNotFoundException + { + ObjectOutputStreamDemo objectOutputStreamDemo = new ObjectOutputStreamDemo(); + objectOutputStreamDemo.writeStudentObject(); + } + + private void writeStudentObject() throws FileNotFoundException, IOException + { + FileOutputStream fileOutputStream = null; + ObjectOutputStream objectOutputStream = null; + try + { + fileOutputStream = new FileOutputStream("student.tmp"); + objectOutputStream = new ObjectOutputStream(fileOutputStream); + + Student student = new Student("Peter", 15); + System.out.println(student); + + /* + * Write the specified object to the + * ObjectOutputStream. + */ + objectOutputStream.writeObject(student); + System.out + .println("Successfully written student object to the file.\n"); + } + finally + { + + if (objectOutputStream != null) + { + /* + * Closing a ObjectOutputStream will also + * close the OutputStream instance to which + * the ObjectOutputStream is writing. + */ + objectOutputStream.close(); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_ObjectInputStream_App/JavaIODemo/src/Student.java b/BasicJava/JavaIODemo_ObjectInputStream_App/JavaIODemo/src/Student.java new file mode 100644 index 000000000..ce82b1b24 --- /dev/null +++ b/BasicJava/JavaIODemo_ObjectInputStream_App/JavaIODemo/src/Student.java @@ -0,0 +1,47 @@ +import java.io.Serializable; + +/* + * Before you can serialize and de-serialize objects the + * class of the object must implement java.io.Serializable. + */ +public class Student implements Serializable +{ + + private static final long serialVersionUID = -1438960132000208485L; + private String name; + private int age; + + public Student(String name, int age) + { + super(); + this.name = name; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + @Override + public String toString() + { + return "Student [name=" + name + ", age=" + age + "]"; + } + +} \ No newline at end of file diff --git a/BasicJava/JavaIODemo_ObjectInputStream_App/JavaIODemo/student.tmp b/BasicJava/JavaIODemo_ObjectInputStream_App/JavaIODemo/student.tmp new file mode 100644 index 000000000..72e28310c Binary files /dev/null and b/BasicJava/JavaIODemo_ObjectInputStream_App/JavaIODemo/student.tmp differ diff --git a/BasicJava/JavaIODemo_ObjectInputStream_App/ObjectInputStreamDemo_Output.txt b/BasicJava/JavaIODemo_ObjectInputStream_App/ObjectInputStreamDemo_Output.txt new file mode 100644 index 000000000..a3225f1f5 --- /dev/null +++ b/BasicJava/JavaIODemo_ObjectInputStream_App/ObjectInputStreamDemo_Output.txt @@ -0,0 +1,4 @@ +Successfully read student object from the file. +Student [name=Peter, age=15] +Name = Peter +Age = 15 diff --git a/BasicJava/JavaIODemo_ObjectInputStream_App/ObjectOutputStreamDemo_Output.txt b/BasicJava/JavaIODemo_ObjectInputStream_App/ObjectOutputStreamDemo_Output.txt new file mode 100644 index 000000000..b59c1e075 --- /dev/null +++ b/BasicJava/JavaIODemo_ObjectInputStream_App/ObjectOutputStreamDemo_Output.txt @@ -0,0 +1,3 @@ +Student [name=Peter, age=15] +Successfully written student object to the file. + diff --git a/BasicJava/JavaIODemo_ObjectOutputStream_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_ObjectOutputStream_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_ObjectOutputStream_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_ObjectOutputStream_App/JavaIODemo/.project b/BasicJava/JavaIODemo_ObjectOutputStream_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_ObjectOutputStream_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_ObjectOutputStream_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_ObjectOutputStream_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_ObjectOutputStream_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_ObjectOutputStream_App/JavaIODemo/bin/Employee.class b/BasicJava/JavaIODemo_ObjectOutputStream_App/JavaIODemo/bin/Employee.class new file mode 100644 index 000000000..dd30e6bdf Binary files /dev/null and b/BasicJava/JavaIODemo_ObjectOutputStream_App/JavaIODemo/bin/Employee.class differ diff --git a/BasicJava/JavaIODemo_ObjectOutputStream_App/JavaIODemo/bin/ObjectInputStreamDemo.class b/BasicJava/JavaIODemo_ObjectOutputStream_App/JavaIODemo/bin/ObjectInputStreamDemo.class new file mode 100644 index 000000000..b831e2d44 Binary files /dev/null and b/BasicJava/JavaIODemo_ObjectOutputStream_App/JavaIODemo/bin/ObjectInputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_ObjectOutputStream_App/JavaIODemo/bin/ObjectOutputStreamDemo.class b/BasicJava/JavaIODemo_ObjectOutputStream_App/JavaIODemo/bin/ObjectOutputStreamDemo.class new file mode 100644 index 000000000..953d26edf Binary files /dev/null and b/BasicJava/JavaIODemo_ObjectOutputStream_App/JavaIODemo/bin/ObjectOutputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_ObjectOutputStream_App/JavaIODemo/employee.txt b/BasicJava/JavaIODemo_ObjectOutputStream_App/JavaIODemo/employee.txt new file mode 100644 index 000000000..91e109f02 Binary files /dev/null and b/BasicJava/JavaIODemo_ObjectOutputStream_App/JavaIODemo/employee.txt differ diff --git a/BasicJava/JavaIODemo_ObjectOutputStream_App/JavaIODemo/src/Employee.java b/BasicJava/JavaIODemo_ObjectOutputStream_App/JavaIODemo/src/Employee.java new file mode 100644 index 000000000..ade6171d9 --- /dev/null +++ b/BasicJava/JavaIODemo_ObjectOutputStream_App/JavaIODemo/src/Employee.java @@ -0,0 +1,47 @@ +import java.io.Serializable; + +/* + * Before you can serialize and de-serialize objects the + * class of the object must implement java.io.Serializable. + */ +public class Employee implements Serializable +{ + + private static final long serialVersionUID = 3558283530338723147L; + private String name; + private int id; + + public Employee(String name, int id) + { + super(); + this.name = name; + this.id = id; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getId() + { + return id; + } + + public void setId(int id) + { + this.id = id; + } + + @Override + public String toString() + { + return "Employee [name=" + name + ", id=" + id + "]"; + } + +} \ No newline at end of file diff --git a/BasicJava/JavaIODemo_ObjectOutputStream_App/JavaIODemo/src/ObjectInputStreamDemo.java b/BasicJava/JavaIODemo_ObjectOutputStream_App/JavaIODemo/src/ObjectInputStreamDemo.java new file mode 100644 index 000000000..80e1f0dec --- /dev/null +++ b/BasicJava/JavaIODemo_ObjectOutputStream_App/JavaIODemo/src/ObjectInputStreamDemo.java @@ -0,0 +1,54 @@ +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.ObjectInputStream; + +public class ObjectInputStreamDemo +{ + + public static void main(String[] args) throws FileNotFoundException, + IOException, ClassNotFoundException + { + ObjectInputStreamDemo objectInputStreamDemo = new ObjectInputStreamDemo(); + objectInputStreamDemo.readEmployeeObject(); + } + + private void readEmployeeObject() throws IOException, + FileNotFoundException, ClassNotFoundException + { + FileInputStream fileInputStream = null; + ObjectInputStream objectInputStream = null; + + try + { + fileInputStream = new FileInputStream("employee.txt"); + objectInputStream = new ObjectInputStream(fileInputStream); + + /* + * Read an object from the ObjectInputStream. + */ + Employee employee = (Employee) objectInputStream.readObject(); + + System.out + .println("Successfully read employee object from the file."); + System.out.println(employee); + System.out.println("Name = " + employee.getName()); + System.out.println("Id = " + employee.getId()); + } + finally + { + + if (objectInputStream != null) + { + /* + * Closing a ObjectInputStream will also + * close the InputStream instance from which + * the ObjectInputStream is reading. + */ + objectInputStream.close(); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_ObjectOutputStream_App/JavaIODemo/src/ObjectOutputStreamDemo.java b/BasicJava/JavaIODemo_ObjectOutputStream_App/JavaIODemo/src/ObjectOutputStreamDemo.java new file mode 100644 index 000000000..04a5bfed3 --- /dev/null +++ b/BasicJava/JavaIODemo_ObjectOutputStream_App/JavaIODemo/src/ObjectOutputStreamDemo.java @@ -0,0 +1,53 @@ +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; + +public class ObjectOutputStreamDemo +{ + + public static void main(String[] args) throws FileNotFoundException, + IOException, ClassNotFoundException + { + ObjectOutputStreamDemo objectOutputStreamDemo = new ObjectOutputStreamDemo(); + objectOutputStreamDemo.writeEmployeeObject(); + } + + private void writeEmployeeObject() throws FileNotFoundException, + IOException + { + FileOutputStream fileOutputStream = null; + ObjectOutputStream objectOutputStream = null; + try + { + fileOutputStream = new FileOutputStream("employee.txt"); + objectOutputStream = new ObjectOutputStream(fileOutputStream); + + Employee employee = new Employee("Peter",20); + System.out.println(employee); + + /* + * Write the specified object to the + * ObjectOutputStream. + */ + objectOutputStream.writeObject(employee); + System.out + .println("Successfully written employee object to the file.\n"); + } + finally + { + + if (objectOutputStream != null) + { + /* + * Closing a ObjectOutputStream will also + * close the OutputStream instance to which + * the ObjectOutputStream is writing. + */ + objectOutputStream.close(); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_ObjectOutputStream_App/ObjectInputStreamDemo_Output.txt b/BasicJava/JavaIODemo_ObjectOutputStream_App/ObjectInputStreamDemo_Output.txt new file mode 100644 index 000000000..2f255a446 --- /dev/null +++ b/BasicJava/JavaIODemo_ObjectOutputStream_App/ObjectInputStreamDemo_Output.txt @@ -0,0 +1,4 @@ +Successfully read employee object from the file. +Employee [name=Peter, id=20] +Name = Peter +Id = 20 diff --git a/BasicJava/JavaIODemo_ObjectOutputStream_App/ObjectOutputStreamDemo_Output.txt b/BasicJava/JavaIODemo_ObjectOutputStream_App/ObjectOutputStreamDemo_Output.txt new file mode 100644 index 000000000..094596b8c --- /dev/null +++ b/BasicJava/JavaIODemo_ObjectOutputStream_App/ObjectOutputStreamDemo_Output.txt @@ -0,0 +1,3 @@ +Employee [name=Peter, id=20] +Successfully written employee object to the file. + diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_Intro_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_PipedReader_PipedReader_Intro_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_Intro_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_Intro_App/JavaIODemo/.project b/BasicJava/JavaIODemo_PipedReader_PipedReader_Intro_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_Intro_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_PipedReader_PipedReader_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_Intro_App/JavaIODemo/bin/PipedReadWriteDemo$1.class b/BasicJava/JavaIODemo_PipedReader_PipedReader_Intro_App/JavaIODemo/bin/PipedReadWriteDemo$1.class new file mode 100644 index 000000000..341b627ba Binary files /dev/null and b/BasicJava/JavaIODemo_PipedReader_PipedReader_Intro_App/JavaIODemo/bin/PipedReadWriteDemo$1.class differ diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_Intro_App/JavaIODemo/bin/PipedReadWriteDemo$2.class b/BasicJava/JavaIODemo_PipedReader_PipedReader_Intro_App/JavaIODemo/bin/PipedReadWriteDemo$2.class new file mode 100644 index 000000000..d74a02148 Binary files /dev/null and b/BasicJava/JavaIODemo_PipedReader_PipedReader_Intro_App/JavaIODemo/bin/PipedReadWriteDemo$2.class differ diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_Intro_App/JavaIODemo/bin/PipedReadWriteDemo.class b/BasicJava/JavaIODemo_PipedReader_PipedReader_Intro_App/JavaIODemo/bin/PipedReadWriteDemo.class new file mode 100644 index 000000000..4f2c48667 Binary files /dev/null and b/BasicJava/JavaIODemo_PipedReader_PipedReader_Intro_App/JavaIODemo/bin/PipedReadWriteDemo.class differ diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_Intro_App/JavaIODemo/src/PipedReadWriteDemo.java b/BasicJava/JavaIODemo_PipedReader_PipedReader_Intro_App/JavaIODemo/src/PipedReadWriteDemo.java new file mode 100644 index 000000000..15a78c04d --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_Intro_App/JavaIODemo/src/PipedReadWriteDemo.java @@ -0,0 +1,88 @@ +import java.io.IOException; +import java.io.PipedReader; +import java.io.PipedWriter; + +/* + * Here, we have created two threads thread1 and + * thread2. The thread1 thread writes the data using the + * PipedWriter object and the thread2 thread reads the + * data from that pipe using the PipedReader object. + * Both the pipedWriter and pipedreader objects are + * connected with each other. + */ +public class PipedReadWriteDemo +{ + + public static void main(String[] args) throws IOException + { + + final PipedWriter pw = new PipedWriter(); + final PipedReader pr = new PipedReader(); + + /* + * Connects this piped writer to a receiver. * + */ + pw.connect(pr); + /* + * Creating one thread1 which writes the data + */ + Thread thread1 = new Thread() + { + public void run() + { + + try + { + pw.write("Hello World"); + pw.write(",Welcome to india"); + Thread.sleep(1000); + } + catch (Exception exe) + { + exe.printStackTrace(); + } + try + { + pw.close(); + } + catch (IOException e) + { + e.printStackTrace(); + } + + } + }; + /* + * Creating another thread2 which reads the data. + */ + Thread thread2 = new Thread() + { + public void run() + { + try + { + int i; + while ((i = pr.read()) != -1) + { + System.out.print((char) i); + } + } + catch (Exception exe) + { + exe.printStackTrace(); + } + try + { + pr.close(); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + }; + // starting both threads + thread1.start(); + thread2.start(); + } +} diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_Intro_App/Output.txt b/BasicJava/JavaIODemo_PipedReader_PipedReader_Intro_App/Output.txt new file mode 100644 index 000000000..c7d53d73c --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_Intro_App/Output.txt @@ -0,0 +1 @@ +Hello World,Welcome to india \ No newline at end of file diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V2_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_PipedReader_PipedReader_V2_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_V2_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V2_App/JavaIODemo/.project b/BasicJava/JavaIODemo_PipedReader_PipedReader_V2_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_V2_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V2_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_PipedReader_PipedReader_V2_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_V2_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V2_App/JavaIODemo/bin/PipedReadWriteDemo$1.class b/BasicJava/JavaIODemo_PipedReader_PipedReader_V2_App/JavaIODemo/bin/PipedReadWriteDemo$1.class new file mode 100644 index 000000000..668a54ba0 Binary files /dev/null and b/BasicJava/JavaIODemo_PipedReader_PipedReader_V2_App/JavaIODemo/bin/PipedReadWriteDemo$1.class differ diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V2_App/JavaIODemo/bin/PipedReadWriteDemo$2.class b/BasicJava/JavaIODemo_PipedReader_PipedReader_V2_App/JavaIODemo/bin/PipedReadWriteDemo$2.class new file mode 100644 index 000000000..8ee3ad471 Binary files /dev/null and b/BasicJava/JavaIODemo_PipedReader_PipedReader_V2_App/JavaIODemo/bin/PipedReadWriteDemo$2.class differ diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V2_App/JavaIODemo/bin/PipedReadWriteDemo.class b/BasicJava/JavaIODemo_PipedReader_PipedReader_V2_App/JavaIODemo/bin/PipedReadWriteDemo.class new file mode 100644 index 000000000..77863e762 Binary files /dev/null and b/BasicJava/JavaIODemo_PipedReader_PipedReader_V2_App/JavaIODemo/bin/PipedReadWriteDemo.class differ diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V2_App/JavaIODemo/src/PipedReadWriteDemo.java b/BasicJava/JavaIODemo_PipedReader_PipedReader_V2_App/JavaIODemo/src/PipedReadWriteDemo.java new file mode 100644 index 000000000..6ca45c69d --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_V2_App/JavaIODemo/src/PipedReadWriteDemo.java @@ -0,0 +1,82 @@ +import java.io.IOException; +import java.io.PipedReader; +import java.io.PipedWriter; + +/* + * Here, we have created two threads thread1 and + * thread2. The thread1 thread writes the data using the + * PipedWriter object and the thread2 thread reads the + * data from that pipe using the PipedReader object. + * Both the pipedWriter and pipedreader objects are + * connected with each other. + */ +public class PipedReadWriteDemo +{ + + public static void main(String[] args) throws IOException + { + + final PipedWriter pw = new PipedWriter(); + final PipedReader pr = new PipedReader(pw); + + Thread thread1 = new Thread(new Runnable() + { + @Override + public void run() + { + try + { + pw.write("Hello peter, Welcome to india."); + Thread.sleep(1000); + } + catch (Exception exe) + { + exe.printStackTrace(); + } + try + { + pw.close(); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + + }); + + Thread thread2 = new Thread(new Runnable() + { + @Override + public void run() + { + try + { + int data = pr.read(); + while (data != -1) + { + System.out.print((char) data); + data = pr.read(); + } + + } + catch (Exception exe) + { + exe.printStackTrace(); + } + try + { + pr.close(); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + }); + + thread1.start(); + thread2.start(); + + } +} diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V2_App/Output.txt b/BasicJava/JavaIODemo_PipedReader_PipedReader_V2_App/Output.txt new file mode 100644 index 000000000..378852293 --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_V2_App/Output.txt @@ -0,0 +1 @@ +Hello peter, Welcome to india. \ No newline at end of file diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/JavaIODemo/.project b/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/JavaIODemo/bin/PipedReadWriteDemo$PipedInputThread.class b/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/JavaIODemo/bin/PipedReadWriteDemo$PipedInputThread.class new file mode 100644 index 000000000..298e68c90 Binary files /dev/null and b/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/JavaIODemo/bin/PipedReadWriteDemo$PipedInputThread.class differ diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/JavaIODemo/bin/PipedReadWriteDemo$PipedOutputThread.class b/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/JavaIODemo/bin/PipedReadWriteDemo$PipedOutputThread.class new file mode 100644 index 000000000..43f6e763e Binary files /dev/null and b/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/JavaIODemo/bin/PipedReadWriteDemo$PipedOutputThread.class differ diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/JavaIODemo/bin/PipedReadWriteDemo.class b/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/JavaIODemo/bin/PipedReadWriteDemo.class new file mode 100644 index 000000000..db5b3b0c2 Binary files /dev/null and b/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/JavaIODemo/bin/PipedReadWriteDemo.class differ diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/JavaIODemo/bin/PipedWriteReadDemo$PipedInputThread.class b/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/JavaIODemo/bin/PipedWriteReadDemo$PipedInputThread.class new file mode 100644 index 000000000..6c3ed4257 Binary files /dev/null and b/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/JavaIODemo/bin/PipedWriteReadDemo$PipedInputThread.class differ diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/JavaIODemo/bin/PipedWriteReadDemo$PipedOutputThread.class b/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/JavaIODemo/bin/PipedWriteReadDemo$PipedOutputThread.class new file mode 100644 index 000000000..a26799e98 Binary files /dev/null and b/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/JavaIODemo/bin/PipedWriteReadDemo$PipedOutputThread.class differ diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/JavaIODemo/bin/PipedWriteReadDemo.class b/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/JavaIODemo/bin/PipedWriteReadDemo.class new file mode 100644 index 000000000..068de8ea2 Binary files /dev/null and b/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/JavaIODemo/bin/PipedWriteReadDemo.class differ diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/JavaIODemo/src/PipedReadWriteDemo.java b/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/JavaIODemo/src/PipedReadWriteDemo.java new file mode 100644 index 000000000..1c506f58e --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/JavaIODemo/src/PipedReadWriteDemo.java @@ -0,0 +1,89 @@ +import java.io.IOException; +import java.io.PipedReader; +import java.io.PipedWriter; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class PipedReadWriteDemo +{ + + final static PipedWriter pw = new PipedWriter(); + final static PipedReader pr = new PipedReader(); + + class PipedOutputThread implements Runnable + { + @Override + public void run() + { + for (int i = 1; i <= 5; i++) + { + try + { + pw.write("Welcome " + i + "\n"); + Thread.sleep(1000); + } + catch (IOException e) + { + e.printStackTrace(); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + } + try + { + pw.close(); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + } + + class PipedInputThread implements Runnable + { + @Override + public void run() + { + try + { + int i = 0; + while ((i = pr.read()) != -1) + { + System.out.print((char) i); + } + } + catch (IOException e) + { + e.printStackTrace(); + } + + try + { + pr.close(); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + } + + public static void main(String[] args) + { + try + { + pw.connect(pr); + } + catch (IOException e) + { + e.printStackTrace(); + } + ExecutorService service = Executors.newFixedThreadPool(2); + PipedReadWriteDemo pipedWriteReadDemo = new PipedReadWriteDemo(); + service.execute(pipedWriteReadDemo.new PipedOutputThread()); + service.execute(pipedWriteReadDemo.new PipedInputThread()); + } +} diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/Output.txt b/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/Output.txt new file mode 100644 index 000000000..db20edcb8 --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_V3_App/Output.txt @@ -0,0 +1,5 @@ +Welcome 1 +Welcome 2 +Welcome 3 +Welcome 4 +Welcome 5 diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V4_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_PipedReader_PipedReader_V4_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_V4_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V4_App/JavaIODemo/.project b/BasicJava/JavaIODemo_PipedReader_PipedReader_V4_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_V4_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V4_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_PipedReader_PipedReader_V4_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_V4_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V4_App/JavaIODemo/bin/PipedReadWriteDemo.class b/BasicJava/JavaIODemo_PipedReader_PipedReader_V4_App/JavaIODemo/bin/PipedReadWriteDemo.class new file mode 100644 index 000000000..4985396cb Binary files /dev/null and b/BasicJava/JavaIODemo_PipedReader_PipedReader_V4_App/JavaIODemo/bin/PipedReadWriteDemo.class differ diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V4_App/JavaIODemo/bin/PipedWriteReadDemo.class b/BasicJava/JavaIODemo_PipedReader_PipedReader_V4_App/JavaIODemo/bin/PipedWriteReadDemo.class new file mode 100644 index 000000000..c5475d57e Binary files /dev/null and b/BasicJava/JavaIODemo_PipedReader_PipedReader_V4_App/JavaIODemo/bin/PipedWriteReadDemo.class differ diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V4_App/JavaIODemo/src/PipedReadWriteDemo.java b/BasicJava/JavaIODemo_PipedReader_PipedReader_V4_App/JavaIODemo/src/PipedReadWriteDemo.java new file mode 100644 index 000000000..5eaebda64 --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_V4_App/JavaIODemo/src/PipedReadWriteDemo.java @@ -0,0 +1,55 @@ +import java.io.IOException; +import java.io.PipedReader; +import java.io.PipedWriter; + +public class PipedReadWriteDemo +{ + + public static void main(String[] args) throws IOException + { + PipedReader pr = new PipedReader(); + PipedWriter pw = new PipedWriter(); + pw.connect(pr); + + Runnable producer = () -> produceData(pw); + Runnable consumer = () -> consumeData(pr); + new Thread(producer).start(); + new Thread(consumer).start(); + } + + public static void produceData(PipedWriter pw) + { + try + { + for (int i = 1; i <= 5; i++) + { + pw.write("Welcome " + i+"\n"); + pw.flush(); + Thread.sleep(500); + } + pw.close(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + public static void consumeData(PipedReader pr) + { + try + { + int num = -1; + while ((num = pr.read()) != -1) + { + System.out.print((char) num); + } + pr.close(); + } + catch (Exception e) + { + e.printStackTrace(); + } + + } +} diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V4_App/Output.txt b/BasicJava/JavaIODemo_PipedReader_PipedReader_V4_App/Output.txt new file mode 100644 index 000000000..db20edcb8 --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_V4_App/Output.txt @@ -0,0 +1,5 @@ +Welcome 1 +Welcome 2 +Welcome 3 +Welcome 4 +Welcome 5 diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V5_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_PipedReader_PipedReader_V5_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_V5_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V5_App/JavaIODemo/.project b/BasicJava/JavaIODemo_PipedReader_PipedReader_V5_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_V5_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V5_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_PipedReader_PipedReader_V5_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_V5_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V5_App/JavaIODemo/bin/MyThread.class b/BasicJava/JavaIODemo_PipedReader_PipedReader_V5_App/JavaIODemo/bin/MyThread.class new file mode 100644 index 000000000..c3c162f5a Binary files /dev/null and b/BasicJava/JavaIODemo_PipedReader_PipedReader_V5_App/JavaIODemo/bin/MyThread.class differ diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V5_App/JavaIODemo/bin/PipedReadWriteDemo.class b/BasicJava/JavaIODemo_PipedReader_PipedReader_V5_App/JavaIODemo/bin/PipedReadWriteDemo.class new file mode 100644 index 000000000..e9daab780 Binary files /dev/null and b/BasicJava/JavaIODemo_PipedReader_PipedReader_V5_App/JavaIODemo/bin/PipedReadWriteDemo.class differ diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V5_App/JavaIODemo/bin/PipedWriteReadDemo.class b/BasicJava/JavaIODemo_PipedReader_PipedReader_V5_App/JavaIODemo/bin/PipedWriteReadDemo.class new file mode 100644 index 000000000..afd5b75ed Binary files /dev/null and b/BasicJava/JavaIODemo_PipedReader_PipedReader_V5_App/JavaIODemo/bin/PipedWriteReadDemo.class differ diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V5_App/JavaIODemo/src/MyThread.java b/BasicJava/JavaIODemo_PipedReader_PipedReader_V5_App/JavaIODemo/src/MyThread.java new file mode 100644 index 000000000..031b035f3 --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_V5_App/JavaIODemo/src/MyThread.java @@ -0,0 +1,50 @@ +import java.io.IOException; +import java.io.PipedReader; +import java.io.PipedWriter; + +class MyThread extends Thread +{ + + private PipedReader pr; + private PipedWriter pw; + + MyThread(String name, PipedReader pr, PipedWriter pw) + { + + super(name); + this.pr = pr; + this.pw = pw; + } + + @Override + public void run() + { + + try + { + if (getName().equals("Thread 1")) + { + for (int cnt = 0; cnt < 15; cnt++) + { + pw.write("Welcome " + cnt + "\n"); + } + pw.close(); + } + else + { + + int data; + while ((data = pr.read()) != -1) + { + System.out.print((char) data); + } + pr.close(); + } + + } + catch (IOException e) + { + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V5_App/JavaIODemo/src/PipedReadWriteDemo.java b/BasicJava/JavaIODemo_PipedReader_PipedReader_V5_App/JavaIODemo/src/PipedReadWriteDemo.java new file mode 100644 index 000000000..768425a33 --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_V5_App/JavaIODemo/src/PipedReadWriteDemo.java @@ -0,0 +1,37 @@ +import java.io.PipedReader; +import java.io.PipedWriter; + +/* + * We have created a thread, MyThread that extends the + * Thread. It has a PipedReader and a PipedWriter + * property. It overrides the run() API method of + * Thread. In the method, according to the thread name, + * it uses either the PipedReader to read or the + * PipedWriter to write + */ + +public class PipedReadWriteDemo +{ + + public static void main(String[] args) throws Exception + { + + /* + * The PipedWriter is a class for writing to piped + * character-output streams. + */ + PipedWriter pw = new PipedWriter(); + /* + * The PipedReader is a class for reading piped + * character-input streams, + */ + PipedReader pr = new PipedReader(pw); + + MyThread mt1 = new MyThread("Thread 1", pr, pw); + MyThread mt2 = new MyThread("Thread 2", pr, pw); + + mt1.start(); + Thread.sleep(2000); + mt2.start(); + } +} \ No newline at end of file diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V5_App/Output.txt b/BasicJava/JavaIODemo_PipedReader_PipedReader_V5_App/Output.txt new file mode 100644 index 000000000..d1a378bb0 --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_V5_App/Output.txt @@ -0,0 +1,15 @@ +Welcome 0 +Welcome 1 +Welcome 2 +Welcome 3 +Welcome 4 +Welcome 5 +Welcome 6 +Welcome 7 +Welcome 8 +Welcome 9 +Welcome 10 +Welcome 11 +Welcome 12 +Welcome 13 +Welcome 14 diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/JavaIODemo/.project b/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/JavaIODemo/bin/PipeReaderThread.class b/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/JavaIODemo/bin/PipeReaderThread.class new file mode 100644 index 000000000..7f8234622 Binary files /dev/null and b/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/JavaIODemo/bin/PipeReaderThread.class differ diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/JavaIODemo/bin/PipeWriterThread.class b/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/JavaIODemo/bin/PipeWriterThread.class new file mode 100644 index 000000000..66623d381 Binary files /dev/null and b/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/JavaIODemo/bin/PipeWriterThread.class differ diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/JavaIODemo/bin/PipedReadWriteDemo.class b/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/JavaIODemo/bin/PipedReadWriteDemo.class new file mode 100644 index 000000000..18e676d40 Binary files /dev/null and b/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/JavaIODemo/bin/PipedReadWriteDemo.class differ diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/JavaIODemo/bin/PipedWriteReadDemo.class b/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/JavaIODemo/bin/PipedWriteReadDemo.class new file mode 100644 index 000000000..5088a560a Binary files /dev/null and b/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/JavaIODemo/bin/PipedWriteReadDemo.class differ diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/JavaIODemo/src/PipeReaderThread.java b/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/JavaIODemo/src/PipeReaderThread.java new file mode 100644 index 000000000..da4112407 --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/JavaIODemo/src/PipeReaderThread.java @@ -0,0 +1,34 @@ +import java.io.PipedReader; + +public class PipeReaderThread implements Runnable +{ + private PipedReader pr; + private String name = null; + + public PipeReaderThread(String name, PipedReader pr) + { + this.name = name; + this.pr = pr; + } + + public void run() + { + try + { + // continuously read data from stream and print + // it in console + while (true) + { + char c = (char) pr.read(); // read a char + if (c != -1) + { // check for -1 indicating end of file + System.out.print(c); + } + } + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/JavaIODemo/src/PipeWriterThread.java b/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/JavaIODemo/src/PipeWriterThread.java new file mode 100644 index 000000000..ed7476dda --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/JavaIODemo/src/PipeWriterThread.java @@ -0,0 +1,32 @@ +import java.io.PipedWriter; + +public class PipeWriterThread implements Runnable +{ + private PipedWriter pw; + private String name = null; + + public PipeWriterThread(String name, PipedWriter pw) + { + this.name = name; + this.pw = pw; + } + + public void run() + { + try + { + while (true) + { + // Write some data after every two seconds + pw.write("Testing data written...\n"); + pw.flush(); + Thread.sleep(2000); + } + } + catch (Exception e) + { + e.printStackTrace(); + } + } + +} diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/JavaIODemo/src/PipedReadWriteDemo.java b/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/JavaIODemo/src/PipedReadWriteDemo.java new file mode 100644 index 000000000..c32098de6 --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/JavaIODemo/src/PipedReadWriteDemo.java @@ -0,0 +1,40 @@ +import java.io.PipedReader; +import java.io.PipedWriter; + +/* + * Pipe streams are just like real plumbing pipes. You + * put things into to a pipe at one end – using some + * methods. Then you receive the same things back from + * the pipe stream at the other end – using some other + * methods. They come out in FIFO order, first-in + * first-out, just like from real plumbing pipes. + */ + +public class PipedReadWriteDemo +{ + + public static void main(String[] args) throws Exception + { + try + { + // Create writer and reader instances + PipedReader pr = new PipedReader(); + PipedWriter pw = new PipedWriter(); + // Connect the writer with reader + pw.connect(pr); + // Create one writer thread and one reader + // thread + Thread thread1 = new Thread( + new PipeReaderThread("ReaderThread", pr)); + Thread thread2 = new Thread( + new PipeWriterThread("WriterThread", pw)); + // start both threads + thread1.start(); + thread2.start(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/Output.txt b/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/Output.txt new file mode 100644 index 000000000..a0b021af4 --- /dev/null +++ b/BasicJava/JavaIODemo_PipedReader_PipedReader_V6_App/Output.txt @@ -0,0 +1,6 @@ +Testing data written... +Testing data written... +Testing data written... +Testing data written... +Testing data written... + diff --git a/BasicJava/JavaIODemo_Piped_Intro_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_Piped_Intro_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_Piped_Intro_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_Piped_Intro_App/JavaIODemo/.project b/BasicJava/JavaIODemo_Piped_Intro_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_Piped_Intro_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_Piped_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_Piped_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_Piped_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_Piped_Intro_App/JavaIODemo/bin/PipedReadWriteDemo$1.class b/BasicJava/JavaIODemo_Piped_Intro_App/JavaIODemo/bin/PipedReadWriteDemo$1.class new file mode 100644 index 000000000..483b79a19 Binary files /dev/null and b/BasicJava/JavaIODemo_Piped_Intro_App/JavaIODemo/bin/PipedReadWriteDemo$1.class differ diff --git a/BasicJava/JavaIODemo_Piped_Intro_App/JavaIODemo/bin/PipedReadWriteDemo$2.class b/BasicJava/JavaIODemo_Piped_Intro_App/JavaIODemo/bin/PipedReadWriteDemo$2.class new file mode 100644 index 000000000..f1a5b4732 Binary files /dev/null and b/BasicJava/JavaIODemo_Piped_Intro_App/JavaIODemo/bin/PipedReadWriteDemo$2.class differ diff --git a/BasicJava/JavaIODemo_Piped_Intro_App/JavaIODemo/bin/PipedReadWriteDemo.class b/BasicJava/JavaIODemo_Piped_Intro_App/JavaIODemo/bin/PipedReadWriteDemo.class new file mode 100644 index 000000000..eda0009d2 Binary files /dev/null and b/BasicJava/JavaIODemo_Piped_Intro_App/JavaIODemo/bin/PipedReadWriteDemo.class differ diff --git a/BasicJava/JavaIODemo_Piped_Intro_App/JavaIODemo/src/PipedReadWriteDemo.java b/BasicJava/JavaIODemo_Piped_Intro_App/JavaIODemo/src/PipedReadWriteDemo.java new file mode 100644 index 000000000..120e2db2f --- /dev/null +++ b/BasicJava/JavaIODemo_Piped_Intro_App/JavaIODemo/src/PipedReadWriteDemo.java @@ -0,0 +1,83 @@ +import java.io.IOException; +import java.io.PipedInputStream; +import java.io.PipedOutputStream; + +/* + * Here, we have created two threads thread1 and + * thread2. The thread1 thread writes the data using the + * PipedOutputStream object and the thread2 thread reads + * the data from that pipe using the PipedInputStream + * object. Both the piped stream object are connected + * with each other. + */ + +public class PipedReadWriteDemo +{ + + public static void main(String[] args) throws IOException + { + + final PipedOutputStream pout = new PipedOutputStream(); + final PipedInputStream pin = new PipedInputStream(); + + /* + * Connects this piped output stream to a receiver. + * If this piped output stream object is already + * connected to some other piped input stream, an + * IOException is thrown. + */ + pout.connect(pin); + /* + * Creating one thread1 which writes the data + */ + Thread thread1 = new Thread() + { + public void run() + { + try + { + for (int i = 50; i <= 60; i++) + { + + pout.write(i); + System.out.println("PipedOutputStream Writing i =" + i); + Thread.sleep(1000); + } + pout.close(); + + } + + catch (Exception exe) + { + exe.printStackTrace(); + } + + } + }; + /* + * Creating another thread2 which reads the data. + */ + Thread thread2 = new Thread() + { + public void run() + { + try + { + int i; + while ((i = pin.read()) != -1) + { + System.out.println("PipedInputStream Reading i = " + i); + } + pin.close(); + } + catch (Exception exe) + { + exe.printStackTrace(); + } + } + }; + // starting both threads + thread1.start(); + thread2.start(); + } +} diff --git a/BasicJava/JavaIODemo_Piped_Intro_App/Output.txt b/BasicJava/JavaIODemo_Piped_Intro_App/Output.txt new file mode 100644 index 000000000..25fe46ce5 --- /dev/null +++ b/BasicJava/JavaIODemo_Piped_Intro_App/Output.txt @@ -0,0 +1,22 @@ +PipedOutputStream Writing i =50 +PipedInputStream Reading i = 50 +PipedOutputStream Writing i =51 +PipedInputStream Reading i = 51 +PipedOutputStream Writing i =52 +PipedInputStream Reading i = 52 +PipedOutputStream Writing i =53 +PipedInputStream Reading i = 53 +PipedOutputStream Writing i =54 +PipedInputStream Reading i = 54 +PipedOutputStream Writing i =55 +PipedInputStream Reading i = 55 +PipedOutputStream Writing i =56 +PipedInputStream Reading i = 56 +PipedOutputStream Writing i =57 +PipedInputStream Reading i = 57 +PipedOutputStream Writing i =58 +PipedInputStream Reading i = 58 +PipedOutputStream Writing i =59 +PipedInputStream Reading i = 59 +PipedOutputStream Writing i =60 +PipedInputStream Reading i = 60 diff --git a/BasicJava/JavaIODemo_Pipes_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_Pipes_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_Pipes_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_Pipes_App/JavaIODemo/.project b/BasicJava/JavaIODemo_Pipes_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_Pipes_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_Pipes_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_Pipes_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_Pipes_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_Pipes_App/JavaIODemo/bin/PipedReadWriteDemo$1.class b/BasicJava/JavaIODemo_Pipes_App/JavaIODemo/bin/PipedReadWriteDemo$1.class new file mode 100644 index 000000000..1cbc28656 Binary files /dev/null and b/BasicJava/JavaIODemo_Pipes_App/JavaIODemo/bin/PipedReadWriteDemo$1.class differ diff --git a/BasicJava/JavaIODemo_Pipes_App/JavaIODemo/bin/PipedReadWriteDemo$2.class b/BasicJava/JavaIODemo_Pipes_App/JavaIODemo/bin/PipedReadWriteDemo$2.class new file mode 100644 index 000000000..7e1ad4a06 Binary files /dev/null and b/BasicJava/JavaIODemo_Pipes_App/JavaIODemo/bin/PipedReadWriteDemo$2.class differ diff --git a/BasicJava/JavaIODemo_Pipes_App/JavaIODemo/bin/PipedReadWriteDemo.class b/BasicJava/JavaIODemo_Pipes_App/JavaIODemo/bin/PipedReadWriteDemo.class new file mode 100644 index 000000000..6aae76e30 Binary files /dev/null and b/BasicJava/JavaIODemo_Pipes_App/JavaIODemo/bin/PipedReadWriteDemo.class differ diff --git a/BasicJava/JavaIODemo_Pipes_App/JavaIODemo/src/PipedReadWriteDemo.java b/BasicJava/JavaIODemo_Pipes_App/JavaIODemo/src/PipedReadWriteDemo.java new file mode 100644 index 000000000..199d9b5d8 --- /dev/null +++ b/BasicJava/JavaIODemo_Pipes_App/JavaIODemo/src/PipedReadWriteDemo.java @@ -0,0 +1,68 @@ +import java.io.IOException; +import java.io.PipedInputStream; +import java.io.PipedOutputStream; + +/* + * Here, we have created two threads thread1 and + * thread2. The thread1 thread writes the data using the + * PipedOutputStream object and the thread2 thread reads + * the data from that pipe using the PipedInputStream + * object. Both the piped stream object are connected + * with each other. + */ + +public class PipedReadWriteDemo +{ + + public static void main(String[] args) throws IOException + { + + final PipedOutputStream pos = new PipedOutputStream(); + final PipedInputStream pis = new PipedInputStream(pos); + + Thread thread1 = new Thread(new Runnable() + { + @Override + public void run() + { + try + { + String str = "Hello peter, Welcome to india."; + byte[] byteArray = str.getBytes(); + pos.write(byteArray); + Thread.sleep(1000); + pos.close(); + } + catch (Exception exe) + { + exe.printStackTrace(); + } + } + }); + + Thread thread2 = new Thread(new Runnable() + { + @Override + public void run() + { + try + { + int data = pis.read(); + while (data != -1) + { + System.out.print((char) data); + data = pis.read(); + } + pis.close(); + } + catch (Exception exe) + { + exe.printStackTrace(); + } + } + }); + + thread1.start(); + thread2.start(); + } +} diff --git a/BasicJava/JavaIODemo_Pipes_App/Output.txt b/BasicJava/JavaIODemo_Pipes_App/Output.txt new file mode 100644 index 000000000..378852293 --- /dev/null +++ b/BasicJava/JavaIODemo_Pipes_App/Output.txt @@ -0,0 +1 @@ +Hello peter, Welcome to india. \ No newline at end of file diff --git a/BasicJava/JavaIODemo_Pipes_Produce_Consume_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_Pipes_Produce_Consume_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_Pipes_Produce_Consume_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_Pipes_Produce_Consume_App/JavaIODemo/.project b/BasicJava/JavaIODemo_Pipes_Produce_Consume_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_Pipes_Produce_Consume_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_Pipes_Produce_Consume_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_Pipes_Produce_Consume_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_Pipes_Produce_Consume_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_Pipes_Produce_Consume_App/JavaIODemo/bin/PipedReadWriteDemo.class b/BasicJava/JavaIODemo_Pipes_Produce_Consume_App/JavaIODemo/bin/PipedReadWriteDemo.class new file mode 100644 index 000000000..808f285c9 Binary files /dev/null and b/BasicJava/JavaIODemo_Pipes_Produce_Consume_App/JavaIODemo/bin/PipedReadWriteDemo.class differ diff --git a/BasicJava/JavaIODemo_Pipes_Produce_Consume_App/JavaIODemo/bin/PipedWriteReadDemo.class b/BasicJava/JavaIODemo_Pipes_Produce_Consume_App/JavaIODemo/bin/PipedWriteReadDemo.class new file mode 100644 index 000000000..c88cf920b Binary files /dev/null and b/BasicJava/JavaIODemo_Pipes_Produce_Consume_App/JavaIODemo/bin/PipedWriteReadDemo.class differ diff --git a/BasicJava/JavaIODemo_Pipes_Produce_Consume_App/JavaIODemo/src/PipedReadWriteDemo.java b/BasicJava/JavaIODemo_Pipes_Produce_Consume_App/JavaIODemo/src/PipedReadWriteDemo.java new file mode 100644 index 000000000..6b9fca123 --- /dev/null +++ b/BasicJava/JavaIODemo_Pipes_Produce_Consume_App/JavaIODemo/src/PipedReadWriteDemo.java @@ -0,0 +1,56 @@ +import java.io.IOException; +import java.io.PipedInputStream; +import java.io.PipedOutputStream; + +public class PipedReadWriteDemo +{ + + public static void main(String[] args) throws IOException + { + PipedInputStream pis = new PipedInputStream(); + PipedOutputStream pos = new PipedOutputStream(); + pos.connect(pis); + + Runnable producer = () -> produceData(pos); + Runnable consumer = () -> consumeData(pis); + new Thread(producer).start(); + new Thread(consumer).start(); + } + + public static void produceData(PipedOutputStream pos) + { + try + { + for (int i = 1; i <= 5; i++) + { + pos.write((byte) i); + pos.flush(); + System.out.println("Writing: " + i); + Thread.sleep(500); + } + pos.close(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + public static void consumeData(PipedInputStream pis) + { + try + { + int num = -1; + while ((num = pis.read()) != -1) + { + System.out.println("Reading: " + num); + } + pis.close(); + } + catch (Exception e) + { + e.printStackTrace(); + } + + } +} diff --git a/BasicJava/JavaIODemo_Pipes_Produce_Consume_App/Output.txt b/BasicJava/JavaIODemo_Pipes_Produce_Consume_App/Output.txt new file mode 100644 index 000000000..85aa60f95 --- /dev/null +++ b/BasicJava/JavaIODemo_Pipes_Produce_Consume_App/Output.txt @@ -0,0 +1,10 @@ +Writing: 1 +Reading: 1 +Writing: 2 +Reading: 2 +Writing: 3 +Reading: 3 +Reading: 4 +Writing: 4 +Reading: 5 +Writing: 5 diff --git a/BasicJava/JavaIODemo_Pipes_Runnable_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_Pipes_Runnable_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_Pipes_Runnable_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_Pipes_Runnable_App/JavaIODemo/.project b/BasicJava/JavaIODemo_Pipes_Runnable_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_Pipes_Runnable_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_Pipes_Runnable_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_Pipes_Runnable_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_Pipes_Runnable_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_Pipes_Runnable_App/JavaIODemo/bin/PipedReadWriteDemo$PipedInputThread.class b/BasicJava/JavaIODemo_Pipes_Runnable_App/JavaIODemo/bin/PipedReadWriteDemo$PipedInputThread.class new file mode 100644 index 000000000..4c77841db Binary files /dev/null and b/BasicJava/JavaIODemo_Pipes_Runnable_App/JavaIODemo/bin/PipedReadWriteDemo$PipedInputThread.class differ diff --git a/BasicJava/JavaIODemo_Pipes_Runnable_App/JavaIODemo/bin/PipedReadWriteDemo$PipedOutputThread.class b/BasicJava/JavaIODemo_Pipes_Runnable_App/JavaIODemo/bin/PipedReadWriteDemo$PipedOutputThread.class new file mode 100644 index 000000000..e46ff090c Binary files /dev/null and b/BasicJava/JavaIODemo_Pipes_Runnable_App/JavaIODemo/bin/PipedReadWriteDemo$PipedOutputThread.class differ diff --git a/BasicJava/JavaIODemo_Pipes_Runnable_App/JavaIODemo/bin/PipedReadWriteDemo.class b/BasicJava/JavaIODemo_Pipes_Runnable_App/JavaIODemo/bin/PipedReadWriteDemo.class new file mode 100644 index 000000000..bef481524 Binary files /dev/null and b/BasicJava/JavaIODemo_Pipes_Runnable_App/JavaIODemo/bin/PipedReadWriteDemo.class differ diff --git a/BasicJava/JavaIODemo_Pipes_Runnable_App/JavaIODemo/bin/PipedWriteReadDemo$PipedInputThread.class b/BasicJava/JavaIODemo_Pipes_Runnable_App/JavaIODemo/bin/PipedWriteReadDemo$PipedInputThread.class new file mode 100644 index 000000000..dc8cac367 Binary files /dev/null and b/BasicJava/JavaIODemo_Pipes_Runnable_App/JavaIODemo/bin/PipedWriteReadDemo$PipedInputThread.class differ diff --git a/BasicJava/JavaIODemo_Pipes_Runnable_App/JavaIODemo/bin/PipedWriteReadDemo$PipedOutputThread.class b/BasicJava/JavaIODemo_Pipes_Runnable_App/JavaIODemo/bin/PipedWriteReadDemo$PipedOutputThread.class new file mode 100644 index 000000000..2ea2abc31 Binary files /dev/null and b/BasicJava/JavaIODemo_Pipes_Runnable_App/JavaIODemo/bin/PipedWriteReadDemo$PipedOutputThread.class differ diff --git a/BasicJava/JavaIODemo_Pipes_Runnable_App/JavaIODemo/bin/PipedWriteReadDemo.class b/BasicJava/JavaIODemo_Pipes_Runnable_App/JavaIODemo/bin/PipedWriteReadDemo.class new file mode 100644 index 000000000..22549aba5 Binary files /dev/null and b/BasicJava/JavaIODemo_Pipes_Runnable_App/JavaIODemo/bin/PipedWriteReadDemo.class differ diff --git a/BasicJava/JavaIODemo_Pipes_Runnable_App/JavaIODemo/src/PipedReadWriteDemo.java b/BasicJava/JavaIODemo_Pipes_Runnable_App/JavaIODemo/src/PipedReadWriteDemo.java new file mode 100644 index 000000000..8d23e41f3 --- /dev/null +++ b/BasicJava/JavaIODemo_Pipes_Runnable_App/JavaIODemo/src/PipedReadWriteDemo.java @@ -0,0 +1,73 @@ +import java.io.IOException; +import java.io.PipedInputStream; +import java.io.PipedOutputStream; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + + +public class PipedReadWriteDemo +{ + + final static PipedOutputStream pipedOut = new PipedOutputStream(); + final static PipedInputStream pipedIn = new PipedInputStream(); + + class PipedOutputThread implements Runnable + { + @Override + public void run() + { + for (int i = 1; i <= 5; i++) + { + try + { + pipedOut.write(("Hello " + i + "\n").getBytes()); + Thread.sleep(1000); + } + catch (IOException e) + { + e.printStackTrace(); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + } + } + } + + class PipedInputThread implements Runnable + { + @Override + public void run() + { + try + { + int i = 0; + while ((i = pipedIn.read()) != -1) + { + System.out.print((char) i); + } + } + catch (IOException e) + { + e.printStackTrace(); + } + } + } + + public static void main(String[] args) + { + try + { + pipedOut.connect(pipedIn); + } + catch (IOException e) + { + e.printStackTrace(); + } + ExecutorService service = Executors.newFixedThreadPool(2); + PipedReadWriteDemo pipedWriteReadDemo=new PipedReadWriteDemo(); + service.execute(pipedWriteReadDemo.new PipedOutputThread()); + service.execute(pipedWriteReadDemo.new PipedInputThread()); + } +} diff --git a/BasicJava/JavaIODemo_Pipes_Runnable_App/Output.txt b/BasicJava/JavaIODemo_Pipes_Runnable_App/Output.txt new file mode 100644 index 000000000..e5840fd0d --- /dev/null +++ b/BasicJava/JavaIODemo_Pipes_Runnable_App/Output.txt @@ -0,0 +1,5 @@ +Hello 1 +Hello 2 +Hello 3 +Hello 4 +Hello 5 diff --git a/BasicJava/JavaIODemo_PrintStream_intro_app/JavaIODemo/.classpath b/BasicJava/JavaIODemo_PrintStream_intro_app/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_PrintStream_intro_app/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_PrintStream_intro_app/JavaIODemo/.project b/BasicJava/JavaIODemo_PrintStream_intro_app/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_PrintStream_intro_app/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_PrintStream_intro_app/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_PrintStream_intro_app/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_PrintStream_intro_app/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_PrintStream_intro_app/JavaIODemo/bin/PrintStreamDemo.class b/BasicJava/JavaIODemo_PrintStream_intro_app/JavaIODemo/bin/PrintStreamDemo.class new file mode 100644 index 000000000..5964a79f0 Binary files /dev/null and b/BasicJava/JavaIODemo_PrintStream_intro_app/JavaIODemo/bin/PrintStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_PrintStream_intro_app/JavaIODemo/myfile.txt b/BasicJava/JavaIODemo_PrintStream_intro_app/JavaIODemo/myfile.txt new file mode 100644 index 000000000..b4e7241f9 --- /dev/null +++ b/BasicJava/JavaIODemo_PrintStream_intro_app/JavaIODemo/myfile.txt @@ -0,0 +1,4 @@ +2500 +Hello Peter +25.988 +true diff --git a/BasicJava/JavaIODemo_PrintStream_intro_app/JavaIODemo/src/PrintStreamDemo.java b/BasicJava/JavaIODemo_PrintStream_intro_app/JavaIODemo/src/PrintStreamDemo.java new file mode 100644 index 000000000..4ebf3a5a2 --- /dev/null +++ b/BasicJava/JavaIODemo_PrintStream_intro_app/JavaIODemo/src/PrintStreamDemo.java @@ -0,0 +1,49 @@ +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintStream; + +public class PrintStreamDemo +{ + + public static void main(String[] args) throws IOException + { + FileOutputStream fileOutputStream = null; + PrintStream printStream = null; + try + { + fileOutputStream = new FileOutputStream("myfile.txt"); + printStream = new PrintStream(fileOutputStream); + /* + * Prints an integer and then terminate the + * line. + */ + printStream.println(2500); + /* + * Prints a String and then terminate the line. + */ + printStream.println("Hello Peter"); + /* + * Prints a double and then terminate the line. + */ + printStream.println(25.988); + /* + * Prints a boolean and then terminate the line. + */ + printStream.println(true); + System.out.println("Successfully written to the file." + + "please check the file content"); + } + finally + { + if (fileOutputStream != null) + { + fileOutputStream.close(); + } + if (printStream != null) + { + printStream.close(); + } + } + + } +} diff --git a/BasicJava/JavaIODemo_PrintStream_intro_app/Output.txt b/BasicJava/JavaIODemo_PrintStream_intro_app/Output.txt new file mode 100644 index 000000000..77a415459 --- /dev/null +++ b/BasicJava/JavaIODemo_PrintStream_intro_app/Output.txt @@ -0,0 +1 @@ +Successfully written to the file.please check the file content diff --git a/BasicJava/JavaIODemo_PrintStream_out_err_app/JavaIODemo/.classpath b/BasicJava/JavaIODemo_PrintStream_out_err_app/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_PrintStream_out_err_app/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_PrintStream_out_err_app/JavaIODemo/.project b/BasicJava/JavaIODemo_PrintStream_out_err_app/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_PrintStream_out_err_app/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_PrintStream_out_err_app/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_PrintStream_out_err_app/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_PrintStream_out_err_app/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_PrintStream_out_err_app/JavaIODemo/bin/PrintStreamDemo1.class b/BasicJava/JavaIODemo_PrintStream_out_err_app/JavaIODemo/bin/PrintStreamDemo1.class new file mode 100644 index 000000000..46806690d Binary files /dev/null and b/BasicJava/JavaIODemo_PrintStream_out_err_app/JavaIODemo/bin/PrintStreamDemo1.class differ diff --git a/BasicJava/JavaIODemo_PrintStream_out_err_app/JavaIODemo/bin/PrintStreamDemo2.class b/BasicJava/JavaIODemo_PrintStream_out_err_app/JavaIODemo/bin/PrintStreamDemo2.class new file mode 100644 index 000000000..07e6244a6 Binary files /dev/null and b/BasicJava/JavaIODemo_PrintStream_out_err_app/JavaIODemo/bin/PrintStreamDemo2.class differ diff --git a/BasicJava/JavaIODemo_PrintStream_out_err_app/JavaIODemo/bin/PrintStreamDemo3.class b/BasicJava/JavaIODemo_PrintStream_out_err_app/JavaIODemo/bin/PrintStreamDemo3.class new file mode 100644 index 000000000..cc4d73e7c Binary files /dev/null and b/BasicJava/JavaIODemo_PrintStream_out_err_app/JavaIODemo/bin/PrintStreamDemo3.class differ diff --git a/BasicJava/JavaIODemo_PrintStream_out_err_app/JavaIODemo/src/PrintStreamDemo1.java b/BasicJava/JavaIODemo_PrintStream_out_err_app/JavaIODemo/src/PrintStreamDemo1.java new file mode 100644 index 000000000..1136a581a --- /dev/null +++ b/BasicJava/JavaIODemo_PrintStream_out_err_app/JavaIODemo/src/PrintStreamDemo1.java @@ -0,0 +1,37 @@ +import java.io.IOException; +import java.io.PrintStream; + +public class PrintStreamDemo1 +{ + + public static void main(String[] args) throws IOException + + { + PrintStream printStream = null; + try + { + /* + * System.out + * ---------- + * The "standard" output stream. This stream is + * already open and ready to accept output data. + * Typically this stream corresponds to display + * output or another output destination + * specified by the host environment or user. + */ + printStream = new PrintStream(System.out); + printStream.println(2500); + printStream.println("Hello Peter"); + printStream.println(25.988); + printStream.println(true); + } + finally + { + if (printStream != null) + { + printStream.close(); + } + } + + } +} diff --git a/BasicJava/JavaIODemo_PrintStream_out_err_app/JavaIODemo/src/PrintStreamDemo2.java b/BasicJava/JavaIODemo_PrintStream_out_err_app/JavaIODemo/src/PrintStreamDemo2.java new file mode 100644 index 000000000..700952f0c --- /dev/null +++ b/BasicJava/JavaIODemo_PrintStream_out_err_app/JavaIODemo/src/PrintStreamDemo2.java @@ -0,0 +1,42 @@ +import java.io.IOException; +import java.io.PrintStream; + +public class PrintStreamDemo2 +{ + + public static void main(String[] args) throws IOException + + { + PrintStream printStream = null; + try + { + /* + * System.err + * --------- + * The "standard" error output stream. This + * stream is already open and ready to accept + * output data. Typically this stream + * corresponds to display output or another + * output destination specified by the host + * environment or user. By convention, this + * output stream is used to display error + * messages or other information that should + * come to the immediate attention of a user + * even if the principal output stream, the + * value of the variable out, has been + * redirected to a file or other destination + * that is typically not continuously monitored. + */ + printStream = new PrintStream(System.err); + printStream.println("Error occured."); + } + finally + { + if (printStream != null) + { + printStream.close(); + } + } + + } +} diff --git a/BasicJava/JavaIODemo_PrintStream_out_err_app/JavaIODemo/src/PrintStreamDemo3.java b/BasicJava/JavaIODemo_PrintStream_out_err_app/JavaIODemo/src/PrintStreamDemo3.java new file mode 100644 index 000000000..13f6703f7 --- /dev/null +++ b/BasicJava/JavaIODemo_PrintStream_out_err_app/JavaIODemo/src/PrintStreamDemo3.java @@ -0,0 +1,12 @@ +import java.io.IOException; + +public class PrintStreamDemo3 +{ + + public static void main(String[] args) throws IOException + + { + System.out.printf("%f", 25.89); + System.err.println("\nSome error occured"); + } +} diff --git a/BasicJava/JavaIODemo_PrintStream_out_err_app/PrintStreamDemo1_Output.txt b/BasicJava/JavaIODemo_PrintStream_out_err_app/PrintStreamDemo1_Output.txt new file mode 100644 index 000000000..b4e7241f9 --- /dev/null +++ b/BasicJava/JavaIODemo_PrintStream_out_err_app/PrintStreamDemo1_Output.txt @@ -0,0 +1,4 @@ +2500 +Hello Peter +25.988 +true diff --git a/BasicJava/JavaIODemo_PrintStream_out_err_app/PrintStreamDemo2_Output.txt b/BasicJava/JavaIODemo_PrintStream_out_err_app/PrintStreamDemo2_Output.txt new file mode 100644 index 000000000..daeb92634 --- /dev/null +++ b/BasicJava/JavaIODemo_PrintStream_out_err_app/PrintStreamDemo2_Output.txt @@ -0,0 +1 @@ +Error occured. diff --git a/BasicJava/JavaIODemo_PrintStream_out_err_app/PrintStreamDemo3_Output.txt b/BasicJava/JavaIODemo_PrintStream_out_err_app/PrintStreamDemo3_Output.txt new file mode 100644 index 000000000..de315633d --- /dev/null +++ b/BasicJava/JavaIODemo_PrintStream_out_err_app/PrintStreamDemo3_Output.txt @@ -0,0 +1,2 @@ +25.890000 +Some error occured diff --git a/BasicJava/JavaIODemo_PrintStream_printf_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_PrintStream_printf_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_PrintStream_printf_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_PrintStream_printf_App/JavaIODemo/.project b/BasicJava/JavaIODemo_PrintStream_printf_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_PrintStream_printf_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_PrintStream_printf_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_PrintStream_printf_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_PrintStream_printf_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_PrintStream_printf_App/JavaIODemo/bin/PrintStreamDemo.class b/BasicJava/JavaIODemo_PrintStream_printf_App/JavaIODemo/bin/PrintStreamDemo.class new file mode 100644 index 000000000..b41bb3e29 Binary files /dev/null and b/BasicJava/JavaIODemo_PrintStream_printf_App/JavaIODemo/bin/PrintStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_PrintStream_printf_App/JavaIODemo/src/PrintStreamDemo.java b/BasicJava/JavaIODemo_PrintStream_printf_App/JavaIODemo/src/PrintStreamDemo.java new file mode 100644 index 000000000..0e2a12df3 --- /dev/null +++ b/BasicJava/JavaIODemo_PrintStream_printf_App/JavaIODemo/src/PrintStreamDemo.java @@ -0,0 +1,43 @@ +import java.io.IOException; +import java.io.PrintStream; +import java.util.Date; + +public class PrintStreamDemo +{ + + public static void main(String[] args) throws IOException + + { + PrintStream printStream = null; + try + { + printStream = new PrintStream(System.out); + int intValue = 98; + double doubleValue = 899.87; + /* + * public PrintStream printf(String format, + * Object... args) + * + * A convenience method to write a formatted + * string to this output stream using the + * specified format string and arguments. + */ + printStream.printf("i = %d and k = %f", intValue, doubleValue); + Date date = new Date(); + System.out.println(); + /* + * Prints an object. + */ + printStream.print(date); + + } + finally + { + if (printStream != null) + { + printStream.close(); + } + } + + } +} diff --git a/BasicJava/JavaIODemo_PrintStream_printf_App/Output.txt b/BasicJava/JavaIODemo_PrintStream_printf_App/Output.txt new file mode 100644 index 000000000..908abc717 --- /dev/null +++ b/BasicJava/JavaIODemo_PrintStream_printf_App/Output.txt @@ -0,0 +1,2 @@ +i = 98 and k = 899.870000 +Mon Aug 15 09:08:04 IST 2016 \ No newline at end of file diff --git a/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/JavaIODemo/.project b/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/JavaIODemo/bin/PrintWriterDemo.class b/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/JavaIODemo/bin/PrintWriterDemo.class new file mode 100644 index 000000000..6f3847828 Binary files /dev/null and b/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/JavaIODemo/bin/PrintWriterDemo.class differ diff --git a/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/JavaIODemo/bin/PrintWriterDemo1.class b/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/JavaIODemo/bin/PrintWriterDemo1.class new file mode 100644 index 000000000..8fb3d8633 Binary files /dev/null and b/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/JavaIODemo/bin/PrintWriterDemo1.class differ diff --git a/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/JavaIODemo/bin/PrintWriterDemo2.class b/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/JavaIODemo/bin/PrintWriterDemo2.class new file mode 100644 index 000000000..5994e0ae4 Binary files /dev/null and b/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/JavaIODemo/bin/PrintWriterDemo2.class differ diff --git a/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/JavaIODemo/bin/PrintWriterDemo3.class b/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/JavaIODemo/bin/PrintWriterDemo3.class new file mode 100644 index 000000000..dc7903989 Binary files /dev/null and b/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/JavaIODemo/bin/PrintWriterDemo3.class differ diff --git a/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/JavaIODemo/bin/PrintWriterDemo4.class b/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/JavaIODemo/bin/PrintWriterDemo4.class new file mode 100644 index 000000000..89046c766 Binary files /dev/null and b/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/JavaIODemo/bin/PrintWriterDemo4.class differ diff --git a/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/JavaIODemo/myoutputfile.txt b/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/JavaIODemo/myoutputfile.txt new file mode 100644 index 000000000..fb4775617 --- /dev/null +++ b/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/JavaIODemo/myoutputfile.txt @@ -0,0 +1 @@ +i = 10 and k = 50.870000 \ No newline at end of file diff --git a/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/JavaIODemo/src/PrintWriterDemo.java b/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/JavaIODemo/src/PrintWriterDemo.java new file mode 100644 index 000000000..e9aa2f638 --- /dev/null +++ b/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/JavaIODemo/src/PrintWriterDemo.java @@ -0,0 +1,49 @@ +import java.io.IOException; +import java.io.PrintWriter; + +/* + * public PrintWriter(String fileName) throws + * FileNotFoundException + * + * Parameters: + * ---------- + * + * fileName - The name of the file to use as + * the destination of this writer. If the file exists + * then it will be truncated to zero size; otherwise, a + * new file will be created. The output will be written + * to the file and is buffered. + */ +public class PrintWriterDemo +{ + + public static void main(String[] args) throws IOException + { + PrintWriter printWriter = null; + try + { + String fileName = "myoutputfile.txt"; + /* + * Creates a new PrintWriter, without automatic + * line flushing, with the specified file name + */ + printWriter = new PrintWriter(fileName); + + int intValue = 10; + double doubleValue = 50.87; + printWriter.printf("i = %d and k = %f", intValue, doubleValue); + + System.out.println("Successfully written to the file." + + "please check the file \'myoutputfile.txt\'"); + } + finally + { + + if (printWriter != null) + { + printWriter.close(); + } + } + + } +} diff --git a/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/Output.txt b/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/Output.txt new file mode 100644 index 000000000..8c6070877 --- /dev/null +++ b/BasicJava/JavaIODemo_PrintWriter_Cons_FileName_App/Output.txt @@ -0,0 +1 @@ +Successfully written to the file.please check the file 'myoutputfile.txt' diff --git a/BasicJava/JavaIODemo_PrintWriter_Cons_FileObj_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_PrintWriter_Cons_FileObj_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_PrintWriter_Cons_FileObj_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_PrintWriter_Cons_FileObj_App/JavaIODemo/.project b/BasicJava/JavaIODemo_PrintWriter_Cons_FileObj_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_PrintWriter_Cons_FileObj_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_PrintWriter_Cons_FileObj_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_PrintWriter_Cons_FileObj_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_PrintWriter_Cons_FileObj_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_PrintWriter_Cons_FileObj_App/JavaIODemo/bin/PrintWriterDemo.class b/BasicJava/JavaIODemo_PrintWriter_Cons_FileObj_App/JavaIODemo/bin/PrintWriterDemo.class new file mode 100644 index 000000000..a7da1f0d2 Binary files /dev/null and b/BasicJava/JavaIODemo_PrintWriter_Cons_FileObj_App/JavaIODemo/bin/PrintWriterDemo.class differ diff --git a/BasicJava/JavaIODemo_PrintWriter_Cons_FileObj_App/JavaIODemo/myoutputfile.txt b/BasicJava/JavaIODemo_PrintWriter_Cons_FileObj_App/JavaIODemo/myoutputfile.txt new file mode 100644 index 000000000..e6748a226 --- /dev/null +++ b/BasicJava/JavaIODemo_PrintWriter_Cons_FileObj_App/JavaIODemo/myoutputfile.txt @@ -0,0 +1 @@ +i = 100 and k = 200.600000 \ No newline at end of file diff --git a/BasicJava/JavaIODemo_PrintWriter_Cons_FileObj_App/JavaIODemo/src/PrintWriterDemo.java b/BasicJava/JavaIODemo_PrintWriter_Cons_FileObj_App/JavaIODemo/src/PrintWriterDemo.java new file mode 100644 index 000000000..5e111c9e4 --- /dev/null +++ b/BasicJava/JavaIODemo_PrintWriter_Cons_FileObj_App/JavaIODemo/src/PrintWriterDemo.java @@ -0,0 +1,52 @@ +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; + +/* + * public PrintWriter(File file) throws + * FileNotFoundException + * + * Parameters: + * ---------- + * + * file - The file to use as the destination + * of this writer. If the file exists then it will be + * truncated to zero size; otherwise, a new file will be + * created. The output will be written to the file and + * is buffered. + */ + +public class PrintWriterDemo +{ + + public static void main(String[] args) throws IOException + { + PrintWriter printWriter = null; + try + { + File file = new File("myoutputfile.txt"); + /* + * Creates a new PrintWriter, without automatic + * line flushing, with the specified file. + */ + printWriter = new PrintWriter(file); + + int intValue = 100; + double doubleValue = 200.6; + printWriter.printf("i = %d and k = %f", intValue, doubleValue); + + System.out.println("Successfully written to the file." + + "please check the file \'myoutputfile.txt\'"); + + } + finally + { + + if (printWriter != null) + { + printWriter.close(); + } + } + + } +} diff --git a/BasicJava/JavaIODemo_PrintWriter_Cons_FileObj_App/Output.txt b/BasicJava/JavaIODemo_PrintWriter_Cons_FileObj_App/Output.txt new file mode 100644 index 000000000..8c6070877 --- /dev/null +++ b/BasicJava/JavaIODemo_PrintWriter_Cons_FileObj_App/Output.txt @@ -0,0 +1 @@ +Successfully written to the file.please check the file 'myoutputfile.txt' diff --git a/BasicJava/JavaIODemo_PrintWriter_Cons_OutputStream_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_PrintWriter_Cons_OutputStream_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_PrintWriter_Cons_OutputStream_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_PrintWriter_Cons_OutputStream_App/JavaIODemo/.project b/BasicJava/JavaIODemo_PrintWriter_Cons_OutputStream_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_PrintWriter_Cons_OutputStream_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_PrintWriter_Cons_OutputStream_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_PrintWriter_Cons_OutputStream_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_PrintWriter_Cons_OutputStream_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_PrintWriter_Cons_OutputStream_App/JavaIODemo/bin/PrintWriterDemo.class b/BasicJava/JavaIODemo_PrintWriter_Cons_OutputStream_App/JavaIODemo/bin/PrintWriterDemo.class new file mode 100644 index 000000000..6168c5ade Binary files /dev/null and b/BasicJava/JavaIODemo_PrintWriter_Cons_OutputStream_App/JavaIODemo/bin/PrintWriterDemo.class differ diff --git a/BasicJava/JavaIODemo_PrintWriter_Cons_OutputStream_App/JavaIODemo/myoutputfile.txt b/BasicJava/JavaIODemo_PrintWriter_Cons_OutputStream_App/JavaIODemo/myoutputfile.txt new file mode 100644 index 000000000..d6b7d5938 --- /dev/null +++ b/BasicJava/JavaIODemo_PrintWriter_Cons_OutputStream_App/JavaIODemo/myoutputfile.txt @@ -0,0 +1 @@ +i = 13 and k = 67.800000 \ No newline at end of file diff --git a/BasicJava/JavaIODemo_PrintWriter_Cons_OutputStream_App/JavaIODemo/src/PrintWriterDemo.java b/BasicJava/JavaIODemo_PrintWriter_Cons_OutputStream_App/JavaIODemo/src/PrintWriterDemo.java new file mode 100644 index 000000000..5236f9de7 --- /dev/null +++ b/BasicJava/JavaIODemo_PrintWriter_Cons_OutputStream_App/JavaIODemo/src/PrintWriterDemo.java @@ -0,0 +1,54 @@ +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintWriter; + +/* + * public PrintWriter(OutputStream out) + * + * Parameters: + * ---------- + * + * out - An output stream + */ +public class PrintWriterDemo +{ + + public static void main(String[] args) throws IOException + { + FileOutputStream fileOutputStream = null; + PrintWriter printWriter = null; + try + { + fileOutputStream = new FileOutputStream("myoutputfile.txt"); + /* + * Creates a new PrintWriter, without automatic + * line flushing, from an existing OutputStream. + */ + printWriter = new PrintWriter(fileOutputStream); + + int intValue = 13; + double doubleValue = 67.8; + printWriter.printf("i = %d and k = %f", intValue, doubleValue); + /* + * Flushes the stream. + */ + printWriter.flush(); + + System.out.println("Successfully written to the file." + + "please check the file \'myoutputfile.txt\'"); + + } + finally + { + if (fileOutputStream != null) + { + fileOutputStream.close(); + } + if (printWriter != null) + { + printWriter.close(); + } + } + + } +} diff --git a/BasicJava/JavaIODemo_PrintWriter_Cons_OutputStream_App/Output.txt b/BasicJava/JavaIODemo_PrintWriter_Cons_OutputStream_App/Output.txt new file mode 100644 index 000000000..8c6070877 --- /dev/null +++ b/BasicJava/JavaIODemo_PrintWriter_Cons_OutputStream_App/Output.txt @@ -0,0 +1 @@ +Successfully written to the file.please check the file 'myoutputfile.txt' diff --git a/BasicJava/JavaIODemo_PrintWriter_Format_App/FormatDemo1_Output.txt b/BasicJava/JavaIODemo_PrintWriter_Format_App/FormatDemo1_Output.txt new file mode 100644 index 000000000..273f299e6 --- /dev/null +++ b/BasicJava/JavaIODemo_PrintWriter_Format_App/FormatDemo1_Output.txt @@ -0,0 +1,2 @@ +The square root of 5 is 2.23606797749979. +The square root of 10 is 3.1622776601683795. diff --git a/BasicJava/JavaIODemo_PrintWriter_Format_App/FormatDemo2_Output.txt b/BasicJava/JavaIODemo_PrintWriter_Format_App/FormatDemo2_Output.txt new file mode 100644 index 000000000..b05a5a588 --- /dev/null +++ b/BasicJava/JavaIODemo_PrintWriter_Format_App/FormatDemo2_Output.txt @@ -0,0 +1,2 @@ +r = 4.47213595499958 +The square root of 20 is 4.472136. diff --git a/BasicJava/JavaIODemo_PrintWriter_Format_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_PrintWriter_Format_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_PrintWriter_Format_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_PrintWriter_Format_App/JavaIODemo/.project b/BasicJava/JavaIODemo_PrintWriter_Format_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_PrintWriter_Format_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_PrintWriter_Format_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_PrintWriter_Format_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_PrintWriter_Format_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_PrintWriter_Format_App/JavaIODemo/bin/FormatDemo1.class b/BasicJava/JavaIODemo_PrintWriter_Format_App/JavaIODemo/bin/FormatDemo1.class new file mode 100644 index 000000000..f692c6307 Binary files /dev/null and b/BasicJava/JavaIODemo_PrintWriter_Format_App/JavaIODemo/bin/FormatDemo1.class differ diff --git a/BasicJava/JavaIODemo_PrintWriter_Format_App/JavaIODemo/bin/FormatDemo2.class b/BasicJava/JavaIODemo_PrintWriter_Format_App/JavaIODemo/bin/FormatDemo2.class new file mode 100644 index 000000000..11a593c98 Binary files /dev/null and b/BasicJava/JavaIODemo_PrintWriter_Format_App/JavaIODemo/bin/FormatDemo2.class differ diff --git a/BasicJava/JavaIODemo_PrintWriter_Format_App/JavaIODemo/src/FormatDemo1.java b/BasicJava/JavaIODemo_PrintWriter_Format_App/JavaIODemo/src/FormatDemo1.java new file mode 100644 index 000000000..30408cf50 --- /dev/null +++ b/BasicJava/JavaIODemo_PrintWriter_Format_App/JavaIODemo/src/FormatDemo1.java @@ -0,0 +1,35 @@ +import java.io.IOException; + +public class FormatDemo1 +{ + + /* + * The i and r variables are formatted twice: the first + * time using code in an overload of print, the second + * time by conversion code automatically generated by + * the Java compiler, which also utilizes toString. You + * can format any value this way, but you don't have + * much control over the results. + */ + public static void main(String[] args) throws IOException + { + int i = 5; + double r = Math.sqrt(i); + + /* + * Invoking print or println outputs a single value + * after converting the value using the appropriate + * toString method + */ + System.out.print("The square root of "); + System.out.print(i); + System.out.print(" is "); + System.out.print(r); + System.out.println("."); + + i = 10; + r = Math.sqrt(i); + System.out.println("The square root of " + i + " is " + r + "."); + + } +} diff --git a/BasicJava/JavaIODemo_PrintWriter_Format_App/JavaIODemo/src/FormatDemo2.java b/BasicJava/JavaIODemo_PrintWriter_Format_App/JavaIODemo/src/FormatDemo2.java new file mode 100644 index 000000000..93f3019b6 --- /dev/null +++ b/BasicJava/JavaIODemo_PrintWriter_Format_App/JavaIODemo/src/FormatDemo2.java @@ -0,0 +1,28 @@ +import java.io.IOException; + +public class FormatDemo2 +{ + + public static void main(String[] args) throws IOException + { + int i = 20; + double r = Math.sqrt(i); + System.out.println("r = "+r); + + /* + * All format specifiers begin with a % and end with + * a 1- or 2-character conversion that specifies the + * kind of formatted output being generated. The + * three conversions used here are: + * + * d - formats an integer value as a decimal value. + * + * f - formats a floating point value as a decimal + * value. + * + * n - outputs a platform-specific line terminator. + */ + + System.out.format("The square root of %d is %f.%n", i, r); + } +} diff --git a/BasicJava/JavaIODemo_PrintWriter_Intro_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_PrintWriter_Intro_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_PrintWriter_Intro_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_PrintWriter_Intro_App/JavaIODemo/.project b/BasicJava/JavaIODemo_PrintWriter_Intro_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_PrintWriter_Intro_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_PrintWriter_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_PrintWriter_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_PrintWriter_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_PrintWriter_Intro_App/JavaIODemo/bin/PrintWriterDemo.class b/BasicJava/JavaIODemo_PrintWriter_Intro_App/JavaIODemo/bin/PrintWriterDemo.class new file mode 100644 index 000000000..f0d58b7d8 Binary files /dev/null and b/BasicJava/JavaIODemo_PrintWriter_Intro_App/JavaIODemo/bin/PrintWriterDemo.class differ diff --git a/BasicJava/JavaIODemo_PrintWriter_Intro_App/JavaIODemo/bin/PrintWriterDemo1.class b/BasicJava/JavaIODemo_PrintWriter_Intro_App/JavaIODemo/bin/PrintWriterDemo1.class new file mode 100644 index 000000000..8fb3d8633 Binary files /dev/null and b/BasicJava/JavaIODemo_PrintWriter_Intro_App/JavaIODemo/bin/PrintWriterDemo1.class differ diff --git a/BasicJava/JavaIODemo_PrintWriter_Intro_App/JavaIODemo/bin/PrintWriterDemo2.class b/BasicJava/JavaIODemo_PrintWriter_Intro_App/JavaIODemo/bin/PrintWriterDemo2.class new file mode 100644 index 000000000..5994e0ae4 Binary files /dev/null and b/BasicJava/JavaIODemo_PrintWriter_Intro_App/JavaIODemo/bin/PrintWriterDemo2.class differ diff --git a/BasicJava/JavaIODemo_PrintWriter_Intro_App/JavaIODemo/bin/PrintWriterDemo3.class b/BasicJava/JavaIODemo_PrintWriter_Intro_App/JavaIODemo/bin/PrintWriterDemo3.class new file mode 100644 index 000000000..dc7903989 Binary files /dev/null and b/BasicJava/JavaIODemo_PrintWriter_Intro_App/JavaIODemo/bin/PrintWriterDemo3.class differ diff --git a/BasicJava/JavaIODemo_PrintWriter_Intro_App/JavaIODemo/bin/PrintWriterDemo4.class b/BasicJava/JavaIODemo_PrintWriter_Intro_App/JavaIODemo/bin/PrintWriterDemo4.class new file mode 100644 index 000000000..89046c766 Binary files /dev/null and b/BasicJava/JavaIODemo_PrintWriter_Intro_App/JavaIODemo/bin/PrintWriterDemo4.class differ diff --git a/BasicJava/JavaIODemo_PrintWriter_Intro_App/JavaIODemo/myoutputfile.txt b/BasicJava/JavaIODemo_PrintWriter_Intro_App/JavaIODemo/myoutputfile.txt new file mode 100644 index 000000000..136197421 --- /dev/null +++ b/BasicJava/JavaIODemo_PrintWriter_Intro_App/JavaIODemo/myoutputfile.txt @@ -0,0 +1,4 @@ +true +123 +123.456 +i = 98 and k = 899.870000 \ No newline at end of file diff --git a/BasicJava/JavaIODemo_PrintWriter_Intro_App/JavaIODemo/src/PrintWriterDemo.java b/BasicJava/JavaIODemo_PrintWriter_Intro_App/JavaIODemo/src/PrintWriterDemo.java new file mode 100644 index 000000000..dd214a63c --- /dev/null +++ b/BasicJava/JavaIODemo_PrintWriter_Intro_App/JavaIODemo/src/PrintWriterDemo.java @@ -0,0 +1,51 @@ +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; + +public class PrintWriterDemo +{ + + public static void main(String[] args) throws IOException + + { + FileWriter fileWriter = null; + PrintWriter printWriter = null; + try + { + fileWriter = new FileWriter("myoutputfile.txt"); + printWriter = new PrintWriter(fileWriter); + + printWriter.println(true); + printWriter.println((int) 123); + printWriter.println((float) 123.456); + + int intValue = 98; + double doubleValue = 899.87; + /* + * public PrintWriter printf(String format, + * Object... args) + * + * A convenience method to write a formatted + * string to this writer using the specified + * format string and arguments. + */ + printWriter.printf("i = %d and k = %f", intValue, doubleValue); + + System.out.println("Successfully written to the file." + + "please check the file \'myoutputfile.txt\'"); + + } + finally + { + if (fileWriter != null) + { + fileWriter.close(); + } + if (printWriter != null) + { + printWriter.close(); + } + } + + } +} diff --git a/BasicJava/JavaIODemo_PrintWriter_Intro_App/Output.txt b/BasicJava/JavaIODemo_PrintWriter_Intro_App/Output.txt new file mode 100644 index 000000000..8c6070877 --- /dev/null +++ b/BasicJava/JavaIODemo_PrintWriter_Intro_App/Output.txt @@ -0,0 +1 @@ +Successfully written to the file.please check the file 'myoutputfile.txt' diff --git a/BasicJava/JavaIODemo_PushbackInputStream_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_PushbackInputStream_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_PushbackInputStream_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_PushbackInputStream_App/JavaIODemo/.project b/BasicJava/JavaIODemo_PushbackInputStream_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_PushbackInputStream_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_PushbackInputStream_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_PushbackInputStream_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_PushbackInputStream_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_PushbackInputStream_App/JavaIODemo/bin/PushbackInputStreamDemo.class b/BasicJava/JavaIODemo_PushbackInputStream_App/JavaIODemo/bin/PushbackInputStreamDemo.class new file mode 100644 index 000000000..c5207f7f4 Binary files /dev/null and b/BasicJava/JavaIODemo_PushbackInputStream_App/JavaIODemo/bin/PushbackInputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_PushbackInputStream_App/JavaIODemo/myfile.txt b/BasicJava/JavaIODemo_PushbackInputStream_App/JavaIODemo/myfile.txt new file mode 100644 index 000000000..802992c42 --- /dev/null +++ b/BasicJava/JavaIODemo_PushbackInputStream_App/JavaIODemo/myfile.txt @@ -0,0 +1 @@ +Hello world diff --git a/BasicJava/JavaIODemo_PushbackInputStream_App/JavaIODemo/src/PushbackInputStreamDemo.java b/BasicJava/JavaIODemo_PushbackInputStream_App/JavaIODemo/src/PushbackInputStreamDemo.java new file mode 100644 index 000000000..b1456359f --- /dev/null +++ b/BasicJava/JavaIODemo_PushbackInputStream_App/JavaIODemo/src/PushbackInputStreamDemo.java @@ -0,0 +1,49 @@ +import java.io.FileInputStream; +import java.io.IOException; +import java.io.PushbackInputStream; + +public class PushbackInputStreamDemo +{ + + public static void main(String[] args) throws IOException + { + FileInputStream fileInputStream = null; + PushbackInputStream pushbackInputStream = null; + try + { + fileInputStream = new FileInputStream("myfile.txt"); + pushbackInputStream = new PushbackInputStream(fileInputStream); + + /* + * Reads the next byte of data from this input + * stream. + */ + int data = pushbackInputStream.read(); + System.out.println((char) data); + + /* + * Pushes back a byte by copying it to the front + * of the pushback buffer. + */ + pushbackInputStream.unread(data); + + data = pushbackInputStream.read(); + System.out.println((char) data); + + } + finally + { + if (pushbackInputStream != null) + { + /* + * Closing a pushbackInputStream will also + * close the FileInputStream instance from + * which the PushbackReader is reading. + */ + pushbackInputStream.close(); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_PushbackInputStream_App/Output.txt b/BasicJava/JavaIODemo_PushbackInputStream_App/Output.txt new file mode 100644 index 000000000..05d2a1920 --- /dev/null +++ b/BasicJava/JavaIODemo_PushbackInputStream_App/Output.txt @@ -0,0 +1,2 @@ +H +H diff --git a/BasicJava/JavaIODemo_PushbackInputStream_Example_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_PushbackInputStream_Example_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_PushbackInputStream_Example_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_PushbackInputStream_Example_App/JavaIODemo/.project b/BasicJava/JavaIODemo_PushbackInputStream_Example_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_PushbackInputStream_Example_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_PushbackInputStream_Example_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_PushbackInputStream_Example_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_PushbackInputStream_Example_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_PushbackInputStream_Example_App/JavaIODemo/bin/PushbackInputStreamDemo.class b/BasicJava/JavaIODemo_PushbackInputStream_Example_App/JavaIODemo/bin/PushbackInputStreamDemo.class new file mode 100644 index 000000000..487595234 Binary files /dev/null and b/BasicJava/JavaIODemo_PushbackInputStream_Example_App/JavaIODemo/bin/PushbackInputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_PushbackInputStream_Example_App/JavaIODemo/myfile.txt b/BasicJava/JavaIODemo_PushbackInputStream_Example_App/JavaIODemo/myfile.txt new file mode 100644 index 000000000..802992c42 --- /dev/null +++ b/BasicJava/JavaIODemo_PushbackInputStream_Example_App/JavaIODemo/myfile.txt @@ -0,0 +1 @@ +Hello world diff --git a/BasicJava/JavaIODemo_PushbackInputStream_Example_App/JavaIODemo/src/PushbackInputStreamDemo.java b/BasicJava/JavaIODemo_PushbackInputStream_Example_App/JavaIODemo/src/PushbackInputStreamDemo.java new file mode 100644 index 000000000..138a2cc7e --- /dev/null +++ b/BasicJava/JavaIODemo_PushbackInputStream_Example_App/JavaIODemo/src/PushbackInputStreamDemo.java @@ -0,0 +1,69 @@ +import java.io.FileInputStream; +import java.io.IOException; +import java.io.PushbackInputStream; + +/* + * public PushbackInputStream(InputStream in, int size) + * + * Parameters: + * ----------- + * + * in - the input stream from which bytes will be read. + * size - the size of the pushback buffer. + */ +public class PushbackInputStreamDemo +{ + + public static void main(String[] args) throws IOException + { + FileInputStream fileInputStream = null; + PushbackInputStream pushbackInputStream = null; + try + { + fileInputStream = new FileInputStream("myfile.txt"); + + /* + * Creates a PushbackInputStream with a pushback + * buffer of the specified size, and saves its + * argument, the input stream in, for later use. + */ + pushbackInputStream = new PushbackInputStream(fileInputStream, 8); + + byte[] byteArray = new byte[10]; + + /* + * Reads up to len bytes of data from this input + * stream into an array of bytes. + */ + int numberOfBytesRead = pushbackInputStream.read(byteArray, 0, 5); + + System.out.println("numberOfBytesRead = "+numberOfBytesRead); + System.out.println(new String(byteArray)); + + /* + * Pushes back a portion of an array of bytes by + * copying it to the front of the pushback + * buffer. + */ + pushbackInputStream.unread(byteArray, 0, 5); + + numberOfBytesRead = pushbackInputStream.read(byteArray, 0, 5); + System.out.println("numberOfBytesRead = "+numberOfBytesRead); + System.out.println(new String(byteArray)); + + } + finally + { + if (pushbackInputStream != null) + { + /* + * Closing a PushbackInputStream will also + * close the Reader instance from which the + * PushbackInputStream is reading. + */ + pushbackInputStream.close(); + } + } + } + +} diff --git a/BasicJava/JavaIODemo_PushbackInputStream_Example_App/Output.txt b/BasicJava/JavaIODemo_PushbackInputStream_Example_App/Output.txt new file mode 100644 index 000000000..6630e6395 --- /dev/null +++ b/BasicJava/JavaIODemo_PushbackInputStream_Example_App/Output.txt @@ -0,0 +1,4 @@ +numberOfBytesRead = 5 +Hello +numberOfBytesRead = 5 +Hello \ No newline at end of file diff --git a/BasicJava/JavaIODemo_PushbackReader_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_PushbackReader_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_PushbackReader_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_PushbackReader_App/JavaIODemo/.project b/BasicJava/JavaIODemo_PushbackReader_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_PushbackReader_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_PushbackReader_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_PushbackReader_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_PushbackReader_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_PushbackReader_App/JavaIODemo/bin/PushbackReaderDemo.class b/BasicJava/JavaIODemo_PushbackReader_App/JavaIODemo/bin/PushbackReaderDemo.class new file mode 100644 index 000000000..21f15d0c6 Binary files /dev/null and b/BasicJava/JavaIODemo_PushbackReader_App/JavaIODemo/bin/PushbackReaderDemo.class differ diff --git a/BasicJava/JavaIODemo_PushbackReader_App/JavaIODemo/myfile.txt b/BasicJava/JavaIODemo_PushbackReader_App/JavaIODemo/myfile.txt new file mode 100644 index 000000000..802992c42 --- /dev/null +++ b/BasicJava/JavaIODemo_PushbackReader_App/JavaIODemo/myfile.txt @@ -0,0 +1 @@ +Hello world diff --git a/BasicJava/JavaIODemo_PushbackReader_App/JavaIODemo/src/PushbackReaderDemo.java b/BasicJava/JavaIODemo_PushbackReader_App/JavaIODemo/src/PushbackReaderDemo.java new file mode 100644 index 000000000..c24926193 --- /dev/null +++ b/BasicJava/JavaIODemo_PushbackReader_App/JavaIODemo/src/PushbackReaderDemo.java @@ -0,0 +1,49 @@ +import java.io.FileReader; +import java.io.IOException; +import java.io.PushbackReader; + +public class PushbackReaderDemo +{ + + public static void main(String[] args) throws IOException + { + FileReader fileReader = null; + PushbackReader pushbackReader = null; + try + { + fileReader = new FileReader("myfile.txt"); + pushbackReader = new PushbackReader(fileReader); + int data = pushbackReader.read(); + System.out.println((char) data); + + /* + * Pushes back a single character by copying it + * to the front of the pushback buffer. After + * this method returns, the next character to be + * read will have the value (char)c. + */ + pushbackReader.unread(data); + + /* + * Reads a single character. + */ + data = pushbackReader.read(); + System.out.println((char) data); + + } + finally + { + if (pushbackReader != null) + { + /* + * Closing a PushbackReader will also close + * the Reader instance from which the + * PushbackReader is reading. + */ + pushbackReader.close(); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_PushbackReader_App/Output.txt b/BasicJava/JavaIODemo_PushbackReader_App/Output.txt new file mode 100644 index 000000000..05d2a1920 --- /dev/null +++ b/BasicJava/JavaIODemo_PushbackReader_App/Output.txt @@ -0,0 +1,2 @@ +H +H diff --git a/BasicJava/JavaIODemo_PushbackReader_Example_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_PushbackReader_Example_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_PushbackReader_Example_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_PushbackReader_Example_App/JavaIODemo/.project b/BasicJava/JavaIODemo_PushbackReader_Example_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_PushbackReader_Example_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_PushbackReader_Example_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_PushbackReader_Example_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_PushbackReader_Example_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_PushbackReader_Example_App/JavaIODemo/bin/PushbackReaderDemo.class b/BasicJava/JavaIODemo_PushbackReader_Example_App/JavaIODemo/bin/PushbackReaderDemo.class new file mode 100644 index 000000000..e333619d6 Binary files /dev/null and b/BasicJava/JavaIODemo_PushbackReader_Example_App/JavaIODemo/bin/PushbackReaderDemo.class differ diff --git a/BasicJava/JavaIODemo_PushbackReader_Example_App/JavaIODemo/myfile.txt b/BasicJava/JavaIODemo_PushbackReader_Example_App/JavaIODemo/myfile.txt new file mode 100644 index 000000000..802992c42 --- /dev/null +++ b/BasicJava/JavaIODemo_PushbackReader_Example_App/JavaIODemo/myfile.txt @@ -0,0 +1 @@ +Hello world diff --git a/BasicJava/JavaIODemo_PushbackReader_Example_App/JavaIODemo/src/PushbackReaderDemo.java b/BasicJava/JavaIODemo_PushbackReader_Example_App/JavaIODemo/src/PushbackReaderDemo.java new file mode 100644 index 000000000..1bf9e6965 --- /dev/null +++ b/BasicJava/JavaIODemo_PushbackReader_Example_App/JavaIODemo/src/PushbackReaderDemo.java @@ -0,0 +1,64 @@ +import java.io.FileReader; +import java.io.IOException; +import java.io.PushbackReader; + +/* + * public PushbackReader(Reader in, int size) + * + * Parameters: + * ---------- + * in - The reader from which characters will be read + * size - The size of the pushback buffer + */ +public class PushbackReaderDemo +{ + + public static void main(String[] args) throws IOException + { + FileReader fileReader = null; + PushbackReader pushbackReader = null; + try + { + fileReader = new FileReader("myfile.txt"); + /* + * Creates a new pushback reader with a pushback + * buffer of the given size. + */ + pushbackReader = new PushbackReader(fileReader, 8); + + char[] charArray = new char[10]; + /* + * Reads characters into a portion of an array. + */ + int numberOfCharsRead = pushbackReader.read(charArray, 0, 5); + System.out.println("numberOfCharsRead = "+numberOfCharsRead); + System.out.println(new String(charArray)); + + /* + * Pushes back a portion of an array of + * characters by copying it to the front of the + * pushback buffer. + */ + pushbackReader.unread(charArray, 0, 5); + + numberOfCharsRead = pushbackReader.read(charArray, 0, 5); + System.out.println("numberOfCharsRead = "+numberOfCharsRead); + System.out.println(new String(charArray)); + + } + finally + { + if (pushbackReader != null) + { + /* + * Closing a PushbackReader will also close + * the Reader instance from which the + * PushbackReader is reading. + */ + pushbackReader.close(); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_PushbackReader_Example_App/Output.txt b/BasicJava/JavaIODemo_PushbackReader_Example_App/Output.txt new file mode 100644 index 000000000..ac530a5d3 --- /dev/null +++ b/BasicJava/JavaIODemo_PushbackReader_Example_App/Output.txt @@ -0,0 +1,4 @@ +numberOfCharsRead = 5 +Hello +numberOfCharsRead = 5 +Hello \ No newline at end of file diff --git a/BasicJava/JavaIODemo_RandomAccessFile_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_RandomAccessFile_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_RandomAccessFile_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_RandomAccessFile_App/JavaIODemo/.project b/BasicJava/JavaIODemo_RandomAccessFile_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_RandomAccessFile_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_RandomAccessFile_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_RandomAccessFile_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_RandomAccessFile_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_RandomAccessFile_App/JavaIODemo/bin/RandomAccessFileReadDemo.class b/BasicJava/JavaIODemo_RandomAccessFile_App/JavaIODemo/bin/RandomAccessFileReadDemo.class new file mode 100644 index 000000000..51317a9d8 Binary files /dev/null and b/BasicJava/JavaIODemo_RandomAccessFile_App/JavaIODemo/bin/RandomAccessFileReadDemo.class differ diff --git a/BasicJava/JavaIODemo_RandomAccessFile_App/JavaIODemo/bin/RandomAccessFileWriteDemo.class b/BasicJava/JavaIODemo_RandomAccessFile_App/JavaIODemo/bin/RandomAccessFileWriteDemo.class new file mode 100644 index 000000000..2bc66ef49 Binary files /dev/null and b/BasicJava/JavaIODemo_RandomAccessFile_App/JavaIODemo/bin/RandomAccessFileWriteDemo.class differ diff --git a/BasicJava/JavaIODemo_RandomAccessFile_App/JavaIODemo/myfile.txt b/BasicJava/JavaIODemo_RandomAccessFile_App/JavaIODemo/myfile.txt new file mode 100644 index 000000000..56fe02e74 --- /dev/null +++ b/BasicJava/JavaIODemo_RandomAccessFile_App/JavaIODemo/myfile.txt @@ -0,0 +1 @@ +John visits to india and went to Bangalore,TamilNadu and went to Delhi to visit Prime minister. diff --git a/BasicJava/JavaIODemo_RandomAccessFile_App/JavaIODemo/src/RandomAccessFileReadDemo.java b/BasicJava/JavaIODemo_RandomAccessFile_App/JavaIODemo/src/RandomAccessFileReadDemo.java new file mode 100644 index 000000000..e08eced96 --- /dev/null +++ b/BasicJava/JavaIODemo_RandomAccessFile_App/JavaIODemo/src/RandomAccessFileReadDemo.java @@ -0,0 +1,41 @@ +import java.io.IOException; +import java.io.RandomAccessFile; + +public class RandomAccessFileReadDemo +{ + public static void main(String[] args) throws IOException + { + + RandomAccessFile randomAccessFile = null; + try + { + /* + * Second input parameter to the constructor: + * "r". This is the mode you want to open file + * in. "r" means read mode. + */ + randomAccessFile = new RandomAccessFile("myfile.txt", "r"); + + /* + * Sets the file-pointer offset, measured from + * the beginning of this file, at which the next + * read or write occurs. + */ + randomAccessFile.seek(57); + + int byteValue; + while ((byteValue = randomAccessFile.read()) != -1) + { + System.out.print((char) byteValue); + } + } + finally + { + if (randomAccessFile != null) + { + randomAccessFile.close(); + } + } + + } +} diff --git a/BasicJava/JavaIODemo_RandomAccessFile_App/JavaIODemo/src/RandomAccessFileWriteDemo.java b/BasicJava/JavaIODemo_RandomAccessFile_App/JavaIODemo/src/RandomAccessFileWriteDemo.java new file mode 100644 index 000000000..4a27c768e --- /dev/null +++ b/BasicJava/JavaIODemo_RandomAccessFile_App/JavaIODemo/src/RandomAccessFileWriteDemo.java @@ -0,0 +1,37 @@ +import java.io.IOException; +import java.io.RandomAccessFile; + +public class RandomAccessFileWriteDemo +{ + public static void main(String[] args) throws IOException + { + + RandomAccessFile randomAccessFile = null; + try + { + /* + * Second input parameter to the constructor: + * "rw". This is the mode you want to open file + * in. "rw" means read/write mode. + */ + randomAccessFile = new RandomAccessFile("myfile.txt", "rw"); + + /* + * Sets the file-pointer offset, measured from + * the beginning of this file, at which the next + * read or write occurs. + */ + randomAccessFile.seek(43); + randomAccessFile.write("Hydrabad ".getBytes()); + System.out.println("Successfully updated the file content.."); + } + finally + { + if (randomAccessFile != null) + { + randomAccessFile.close(); + } + } + + } +} diff --git a/BasicJava/JavaIODemo_RandomAccessFile_App/RandomAccessFileReadDemo_Output.txt b/BasicJava/JavaIODemo_RandomAccessFile_App/RandomAccessFileReadDemo_Output.txt new file mode 100644 index 000000000..b9cfebebc --- /dev/null +++ b/BasicJava/JavaIODemo_RandomAccessFile_App/RandomAccessFileReadDemo_Output.txt @@ -0,0 +1 @@ +went to Delhi to visit Prime minister. diff --git a/BasicJava/JavaIODemo_RandomAccessFile_App/RandomAccessFileWriteDemo_Output.txt b/BasicJava/JavaIODemo_RandomAccessFile_App/RandomAccessFileWriteDemo_Output.txt new file mode 100644 index 000000000..593947fb2 --- /dev/null +++ b/BasicJava/JavaIODemo_RandomAccessFile_App/RandomAccessFileWriteDemo_Output.txt @@ -0,0 +1 @@ +Successfully updated the file content.. diff --git a/BasicJava/JavaIODemo_RandomAccessFile_V2_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_RandomAccessFile_V2_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_RandomAccessFile_V2_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_RandomAccessFile_V2_App/JavaIODemo/.project b/BasicJava/JavaIODemo_RandomAccessFile_V2_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_RandomAccessFile_V2_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_RandomAccessFile_V2_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_RandomAccessFile_V2_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_RandomAccessFile_V2_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_RandomAccessFile_V2_App/JavaIODemo/bin/RandomAccessFileDemo.class b/BasicJava/JavaIODemo_RandomAccessFile_V2_App/JavaIODemo/bin/RandomAccessFileDemo.class new file mode 100644 index 000000000..dbb30e309 Binary files /dev/null and b/BasicJava/JavaIODemo_RandomAccessFile_V2_App/JavaIODemo/bin/RandomAccessFileDemo.class differ diff --git a/BasicJava/JavaIODemo_RandomAccessFile_V2_App/JavaIODemo/bin/RandomAccessFileReadDemo.class b/BasicJava/JavaIODemo_RandomAccessFile_V2_App/JavaIODemo/bin/RandomAccessFileReadDemo.class new file mode 100644 index 000000000..4a004d748 Binary files /dev/null and b/BasicJava/JavaIODemo_RandomAccessFile_V2_App/JavaIODemo/bin/RandomAccessFileReadDemo.class differ diff --git a/BasicJava/JavaIODemo_RandomAccessFile_V2_App/JavaIODemo/bin/RandomAccessFileWriteDemo.class b/BasicJava/JavaIODemo_RandomAccessFile_V2_App/JavaIODemo/bin/RandomAccessFileWriteDemo.class new file mode 100644 index 000000000..b86fff80b Binary files /dev/null and b/BasicJava/JavaIODemo_RandomAccessFile_V2_App/JavaIODemo/bin/RandomAccessFileWriteDemo.class differ diff --git a/BasicJava/JavaIODemo_RandomAccessFile_V2_App/JavaIODemo/myfile.txt b/BasicJava/JavaIODemo_RandomAccessFile_V2_App/JavaIODemo/myfile.txt new file mode 100644 index 000000000..1c8fe0772 --- /dev/null +++ b/BasicJava/JavaIODemo_RandomAccessFile_V2_App/JavaIODemo/myfile.txt @@ -0,0 +1 @@ +John visits to india and Japan \ No newline at end of file diff --git a/BasicJava/JavaIODemo_RandomAccessFile_V2_App/JavaIODemo/src/RandomAccessFileReadDemo.java b/BasicJava/JavaIODemo_RandomAccessFile_V2_App/JavaIODemo/src/RandomAccessFileReadDemo.java new file mode 100644 index 000000000..5fa5e7caa --- /dev/null +++ b/BasicJava/JavaIODemo_RandomAccessFile_V2_App/JavaIODemo/src/RandomAccessFileReadDemo.java @@ -0,0 +1,44 @@ +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.RandomAccessFile; + +public class RandomAccessFileReadDemo +{ + public static void main(String[] args) throws IOException + { + RandomAccessFileReadDemo randomAccessFileReadDemo = new RandomAccessFileReadDemo(); + randomAccessFileReadDemo.readData("myfile.txt", "r", 5); + } + + private void readData(String fileName, String mode, int position) + throws FileNotFoundException, IOException + { + RandomAccessFile randomAccessFile = null; + try + { + + randomAccessFile = new RandomAccessFile(fileName, mode); + + /* + * Sets the file-pointer offset, measured from + * the beginning of this file, at which the next + * read or write occurs. + */ + randomAccessFile.seek(position); + + int byteValue; + while ((byteValue = randomAccessFile.read()) != -1) + { + System.out.print((char) byteValue); + } + } + finally + { + if (randomAccessFile != null) + { + randomAccessFile.close(); + } + } + } + +} diff --git a/BasicJava/JavaIODemo_RandomAccessFile_V2_App/JavaIODemo/src/RandomAccessFileWriteDemo.java b/BasicJava/JavaIODemo_RandomAccessFile_V2_App/JavaIODemo/src/RandomAccessFileWriteDemo.java new file mode 100644 index 000000000..eb0bc1d0d --- /dev/null +++ b/BasicJava/JavaIODemo_RandomAccessFile_V2_App/JavaIODemo/src/RandomAccessFileWriteDemo.java @@ -0,0 +1,38 @@ +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.RandomAccessFile; + +public class RandomAccessFileWriteDemo +{ + public static void main(String[] args) throws IOException + { + RandomAccessFileWriteDemo randomAccessFileWriteDemo = new RandomAccessFileWriteDemo(); + randomAccessFileWriteDemo.writeData("myfile.txt", "rw", 20); + } + + private void writeData(String fileName, String mode, int position) + throws FileNotFoundException, IOException + { + RandomAccessFile randomAccessFile = null; + try + { + randomAccessFile = new RandomAccessFile(fileName, mode); + + /* + * Sets the file-pointer offset, measured from + * the beginning of this file, at which the next + * read or write occurs. + */ + randomAccessFile.seek(position); + randomAccessFile.write(" and Srilanka".getBytes()); + System.out.println("Successfully written to the file."); + } + finally + { + if (randomAccessFile != null) + { + randomAccessFile.close(); + } + } + } +} diff --git a/BasicJava/JavaIODemo_RandomAccessFile_V2_App/RandomAccessFileReadDemo_Output.txt b/BasicJava/JavaIODemo_RandomAccessFile_V2_App/RandomAccessFileReadDemo_Output.txt new file mode 100644 index 000000000..90779bb2c --- /dev/null +++ b/BasicJava/JavaIODemo_RandomAccessFile_V2_App/RandomAccessFileReadDemo_Output.txt @@ -0,0 +1 @@ +visits to india and Japan \ No newline at end of file diff --git a/BasicJava/JavaIODemo_RandomAccessFile_V2_App/RandomAccessFileWriteDemo_Output.txt b/BasicJava/JavaIODemo_RandomAccessFile_V2_App/RandomAccessFileWriteDemo_Output.txt new file mode 100644 index 000000000..c465bb9ae --- /dev/null +++ b/BasicJava/JavaIODemo_RandomAccessFile_V2_App/RandomAccessFileWriteDemo_Output.txt @@ -0,0 +1 @@ +Successfully written to the file. diff --git a/BasicJava/JavaIODemo_RandomAccessFile_V3_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_RandomAccessFile_V3_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_RandomAccessFile_V3_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_RandomAccessFile_V3_App/JavaIODemo/.project b/BasicJava/JavaIODemo_RandomAccessFile_V3_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_RandomAccessFile_V3_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_RandomAccessFile_V3_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_RandomAccessFile_V3_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_RandomAccessFile_V3_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_RandomAccessFile_V3_App/JavaIODemo/bin/RandomAccessFileReadDemo.class b/BasicJava/JavaIODemo_RandomAccessFile_V3_App/JavaIODemo/bin/RandomAccessFileReadDemo.class new file mode 100644 index 000000000..f5eed0fe3 Binary files /dev/null and b/BasicJava/JavaIODemo_RandomAccessFile_V3_App/JavaIODemo/bin/RandomAccessFileReadDemo.class differ diff --git a/BasicJava/JavaIODemo_RandomAccessFile_V3_App/JavaIODemo/bin/RandomAccessFileWriteDemo.class b/BasicJava/JavaIODemo_RandomAccessFile_V3_App/JavaIODemo/bin/RandomAccessFileWriteDemo.class new file mode 100644 index 000000000..1bed65608 Binary files /dev/null and b/BasicJava/JavaIODemo_RandomAccessFile_V3_App/JavaIODemo/bin/RandomAccessFileWriteDemo.class differ diff --git a/BasicJava/JavaIODemo_RandomAccessFile_V3_App/JavaIODemo/myfile.txt b/BasicJava/JavaIODemo_RandomAccessFile_V3_App/JavaIODemo/myfile.txt new file mode 100644 index 000000000..454790091 --- /dev/null +++ b/BasicJava/JavaIODemo_RandomAccessFile_V3_App/JavaIODemo/myfile.txt @@ -0,0 +1 @@ +John visits to india. diff --git a/BasicJava/JavaIODemo_RandomAccessFile_V3_App/JavaIODemo/src/RandomAccessFileReadDemo.java b/BasicJava/JavaIODemo_RandomAccessFile_V3_App/JavaIODemo/src/RandomAccessFileReadDemo.java new file mode 100644 index 000000000..1d5098af7 --- /dev/null +++ b/BasicJava/JavaIODemo_RandomAccessFile_V3_App/JavaIODemo/src/RandomAccessFileReadDemo.java @@ -0,0 +1,44 @@ +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.RandomAccessFile; + +public class RandomAccessFileReadDemo +{ + public static void main(String[] args) throws IOException + { + RandomAccessFileReadDemo randomAccessFileReadDemo = new RandomAccessFileReadDemo(); + byte[] byteArray = randomAccessFileReadDemo.readFromFile("myfile.txt",15); + System.out.println(new String(byteArray)); + } + + private byte[] readFromFile(String fileName, int position) + throws FileNotFoundException, IOException + { + RandomAccessFile randomAccessFile = null; + byte[] byteArray; + try + { + + randomAccessFile = new RandomAccessFile(fileName, "r"); + + /* + * Sets the file-pointer offset, measured from + * the beginning of this file, at which the next + * read or write occurs. + */ + randomAccessFile.seek(position); + + byteArray = new byte[5]; + randomAccessFile.read(byteArray); + } + finally + { + if (randomAccessFile != null) + { + randomAccessFile.close(); + } + } + return byteArray; + } + +} diff --git a/BasicJava/JavaIODemo_RandomAccessFile_V3_App/JavaIODemo/src/RandomAccessFileWriteDemo.java b/BasicJava/JavaIODemo_RandomAccessFile_V3_App/JavaIODemo/src/RandomAccessFileWriteDemo.java new file mode 100644 index 000000000..58b528cda --- /dev/null +++ b/BasicJava/JavaIODemo_RandomAccessFile_V3_App/JavaIODemo/src/RandomAccessFileWriteDemo.java @@ -0,0 +1,39 @@ +import java.io.IOException; +import java.io.RandomAccessFile; + +public class RandomAccessFileWriteDemo +{ + public static void main(String[] args) throws IOException + { + RandomAccessFileWriteDemo randomAccessFileWriteDemo = new RandomAccessFileWriteDemo(); + randomAccessFileWriteDemo.writeToFile("myfile.txt", " and USA", 20); + } + + private void writeToFile(String fileName, String data, int position) + throws IOException + { + + RandomAccessFile randomAccessFile = null; + try + { + randomAccessFile = new RandomAccessFile(fileName, "rw"); + + /* + * Sets the file-pointer offset, measured from + * the beginning of this file, at which the next + * read or write occurs. + */ + randomAccessFile.seek(position); + randomAccessFile.write(data.getBytes()); + System.out.println("Successfully written to the file."); + } + finally + { + if (randomAccessFile != null) + { + randomAccessFile.close(); + } + } + } + +} diff --git a/BasicJava/JavaIODemo_RandomAccessFile_V3_App/RandomAccessFileReadDemo_Output.txt b/BasicJava/JavaIODemo_RandomAccessFile_V3_App/RandomAccessFileReadDemo_Output.txt new file mode 100644 index 000000000..9be9c8f95 --- /dev/null +++ b/BasicJava/JavaIODemo_RandomAccessFile_V3_App/RandomAccessFileReadDemo_Output.txt @@ -0,0 +1 @@ +india diff --git a/BasicJava/JavaIODemo_RandomAccessFile_V3_App/RandomAccessFileWriteDemo_Output.txt b/BasicJava/JavaIODemo_RandomAccessFile_V3_App/RandomAccessFileWriteDemo_Output.txt new file mode 100644 index 000000000..c465bb9ae --- /dev/null +++ b/BasicJava/JavaIODemo_RandomAccessFile_V3_App/RandomAccessFileWriteDemo_Output.txt @@ -0,0 +1 @@ +Successfully written to the file. diff --git a/BasicJava/JavaIODemo_RandomAccessFile_V4_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_RandomAccessFile_V4_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_RandomAccessFile_V4_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_RandomAccessFile_V4_App/JavaIODemo/.project b/BasicJava/JavaIODemo_RandomAccessFile_V4_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_RandomAccessFile_V4_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_RandomAccessFile_V4_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_RandomAccessFile_V4_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_RandomAccessFile_V4_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_RandomAccessFile_V4_App/JavaIODemo/bin/RandomAccessFileDemo.class b/BasicJava/JavaIODemo_RandomAccessFile_V4_App/JavaIODemo/bin/RandomAccessFileDemo.class new file mode 100644 index 000000000..1456504b3 Binary files /dev/null and b/BasicJava/JavaIODemo_RandomAccessFile_V4_App/JavaIODemo/bin/RandomAccessFileDemo.class differ diff --git a/BasicJava/JavaIODemo_RandomAccessFile_V4_App/JavaIODemo/myfile.txt b/BasicJava/JavaIODemo_RandomAccessFile_V4_App/JavaIODemo/myfile.txt new file mode 100644 index 000000000..454790091 --- /dev/null +++ b/BasicJava/JavaIODemo_RandomAccessFile_V4_App/JavaIODemo/myfile.txt @@ -0,0 +1 @@ +John visits to india. diff --git a/BasicJava/JavaIODemo_RandomAccessFile_V4_App/JavaIODemo/src/RandomAccessFileDemo.java b/BasicJava/JavaIODemo_RandomAccessFile_V4_App/JavaIODemo/src/RandomAccessFileDemo.java new file mode 100644 index 000000000..4406964da --- /dev/null +++ b/BasicJava/JavaIODemo_RandomAccessFile_V4_App/JavaIODemo/src/RandomAccessFileDemo.java @@ -0,0 +1,71 @@ +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.RandomAccessFile; + +public class RandomAccessFileDemo +{ + public static void main(String[] args) throws IOException + { + RandomAccessFileDemo randomAccessFileDemo = new RandomAccessFileDemo(); + String str = randomAccessFileDemo.readFromFile("myfile.txt", 5); + System.out.println(str); + randomAccessFileDemo.writeToFile("myfile.txt", " and USA", 20); + } + + private String readFromFile(String fileName, int position) + throws FileNotFoundException, IOException + { + RandomAccessFile randomAccessFile = null; + String str; + try + { + + randomAccessFile = new RandomAccessFile(fileName, "r"); + + /* + * Sets the file-pointer offset, measured from + * the beginning of this file, at which the next + * read or write occurs. + */ + randomAccessFile.seek(position); + + str = randomAccessFile.readLine(); + } + finally + { + if (randomAccessFile != null) + { + randomAccessFile.close(); + } + } + return str; + } + + private void writeToFile(String fileName, String data, int position) + throws IOException + { + { + RandomAccessFile randomAccessFile = null; + try + { + randomAccessFile = new RandomAccessFile(fileName, "rw"); + + /* + * Sets the file-pointer offset, measured + * from the beginning of this file, at which + * the next read or write occurs. + */ + randomAccessFile.seek(position); + randomAccessFile.writeBytes(data); + System.out.println("Successfully written to the file."); + } + finally + { + if (randomAccessFile != null) + { + randomAccessFile.close(); + } + } + } + } +} diff --git a/BasicJava/JavaIODemo_RandomAccessFile_V4_App/Output.txt b/BasicJava/JavaIODemo_RandomAccessFile_V4_App/Output.txt new file mode 100644 index 000000000..a8b6360da --- /dev/null +++ b/BasicJava/JavaIODemo_RandomAccessFile_V4_App/Output.txt @@ -0,0 +1,2 @@ +visits to india. +Successfully written to the file. diff --git a/BasicJava/JavaIODemo_Scanner_Intro_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_Scanner_Intro_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_Intro_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_Scanner_Intro_App/JavaIODemo/.project b/BasicJava/JavaIODemo_Scanner_Intro_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_Intro_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_Scanner_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_Scanner_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_Scanner_Intro_App/JavaIODemo/bin/ScannerDemo.class b/BasicJava/JavaIODemo_Scanner_Intro_App/JavaIODemo/bin/ScannerDemo.class new file mode 100644 index 000000000..a68f23a12 Binary files /dev/null and b/BasicJava/JavaIODemo_Scanner_Intro_App/JavaIODemo/bin/ScannerDemo.class differ diff --git a/BasicJava/JavaIODemo_Scanner_Intro_App/JavaIODemo/bin/ScannerDemo1.class b/BasicJava/JavaIODemo_Scanner_Intro_App/JavaIODemo/bin/ScannerDemo1.class new file mode 100644 index 000000000..2e85ee7ce Binary files /dev/null and b/BasicJava/JavaIODemo_Scanner_Intro_App/JavaIODemo/bin/ScannerDemo1.class differ diff --git a/BasicJava/JavaIODemo_Scanner_Intro_App/JavaIODemo/bin/ScannerDemo2.class b/BasicJava/JavaIODemo_Scanner_Intro_App/JavaIODemo/bin/ScannerDemo2.class new file mode 100644 index 000000000..149090855 Binary files /dev/null and b/BasicJava/JavaIODemo_Scanner_Intro_App/JavaIODemo/bin/ScannerDemo2.class differ diff --git a/BasicJava/JavaIODemo_Scanner_Intro_App/JavaIODemo/bin/ScannerDemo3.class b/BasicJava/JavaIODemo_Scanner_Intro_App/JavaIODemo/bin/ScannerDemo3.class new file mode 100644 index 000000000..7fb09f0b8 Binary files /dev/null and b/BasicJava/JavaIODemo_Scanner_Intro_App/JavaIODemo/bin/ScannerDemo3.class differ diff --git a/BasicJava/JavaIODemo_Scanner_Intro_App/JavaIODemo/bin/ScannerDemo4.class b/BasicJava/JavaIODemo_Scanner_Intro_App/JavaIODemo/bin/ScannerDemo4.class new file mode 100644 index 000000000..704a1714f Binary files /dev/null and b/BasicJava/JavaIODemo_Scanner_Intro_App/JavaIODemo/bin/ScannerDemo4.class differ diff --git a/BasicJava/JavaIODemo_Scanner_Intro_App/JavaIODemo/src/ScannerDemo.java b/BasicJava/JavaIODemo_Scanner_Intro_App/JavaIODemo/src/ScannerDemo.java new file mode 100644 index 000000000..8e50ce8e2 --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_Intro_App/JavaIODemo/src/ScannerDemo.java @@ -0,0 +1,37 @@ +import java.util.Scanner; + +/* + * Java Scanner class which reads the int, + * string and double value as an input: + */ +public class ScannerDemo +{ + + public static void main(String[] args) + { + Scanner scanner = null; + try + { + scanner = new Scanner(System.in); + + System.out.print("Enter your Id: "); + int rollno = scanner.nextInt(); + + System.out.print("Enter your Name: "); + String name = scanner.next(); + + System.out.print("Enter your Weight: "); + double weight = scanner.nextDouble(); + + System.out.println("Id:" + rollno + ", Name:" + name + + ", Weight:" + weight); + } + finally + { + if (scanner != null) + { + scanner.close(); + } + } + } +} diff --git a/BasicJava/JavaIODemo_Scanner_Intro_App/Output.txt b/BasicJava/JavaIODemo_Scanner_Intro_App/Output.txt new file mode 100644 index 000000000..89bf3c77f --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_Intro_App/Output.txt @@ -0,0 +1,4 @@ +Enter your Id: 54 +Enter your Name: peter +Enter your Weight: 67.89 +Id:54, Name:peter, Weight:67.89 diff --git a/BasicJava/JavaIODemo_Scanner_bufferedReader_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_Scanner_bufferedReader_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_bufferedReader_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_Scanner_bufferedReader_App/JavaIODemo/.project b/BasicJava/JavaIODemo_Scanner_bufferedReader_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_bufferedReader_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_Scanner_bufferedReader_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_Scanner_bufferedReader_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_bufferedReader_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_Scanner_bufferedReader_App/JavaIODemo/bin/ScannerDemo.class b/BasicJava/JavaIODemo_Scanner_bufferedReader_App/JavaIODemo/bin/ScannerDemo.class new file mode 100644 index 000000000..0a10f4c32 Binary files /dev/null and b/BasicJava/JavaIODemo_Scanner_bufferedReader_App/JavaIODemo/bin/ScannerDemo.class differ diff --git a/BasicJava/JavaIODemo_Scanner_bufferedReader_App/JavaIODemo/bin/ScannerDemo1.class b/BasicJava/JavaIODemo_Scanner_bufferedReader_App/JavaIODemo/bin/ScannerDemo1.class new file mode 100644 index 000000000..2e85ee7ce Binary files /dev/null and b/BasicJava/JavaIODemo_Scanner_bufferedReader_App/JavaIODemo/bin/ScannerDemo1.class differ diff --git a/BasicJava/JavaIODemo_Scanner_bufferedReader_App/JavaIODemo/bin/ScannerDemo2.class b/BasicJava/JavaIODemo_Scanner_bufferedReader_App/JavaIODemo/bin/ScannerDemo2.class new file mode 100644 index 000000000..149090855 Binary files /dev/null and b/BasicJava/JavaIODemo_Scanner_bufferedReader_App/JavaIODemo/bin/ScannerDemo2.class differ diff --git a/BasicJava/JavaIODemo_Scanner_bufferedReader_App/JavaIODemo/bin/ScannerDemo3.class b/BasicJava/JavaIODemo_Scanner_bufferedReader_App/JavaIODemo/bin/ScannerDemo3.class new file mode 100644 index 000000000..7fb09f0b8 Binary files /dev/null and b/BasicJava/JavaIODemo_Scanner_bufferedReader_App/JavaIODemo/bin/ScannerDemo3.class differ diff --git a/BasicJava/JavaIODemo_Scanner_bufferedReader_App/JavaIODemo/bin/ScannerDemo4.class b/BasicJava/JavaIODemo_Scanner_bufferedReader_App/JavaIODemo/bin/ScannerDemo4.class new file mode 100644 index 000000000..704a1714f Binary files /dev/null and b/BasicJava/JavaIODemo_Scanner_bufferedReader_App/JavaIODemo/bin/ScannerDemo4.class differ diff --git a/BasicJava/JavaIODemo_Scanner_bufferedReader_App/JavaIODemo/myfile.txt b/BasicJava/JavaIODemo_Scanner_bufferedReader_App/JavaIODemo/myfile.txt new file mode 100644 index 000000000..425223514 --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_bufferedReader_App/JavaIODemo/myfile.txt @@ -0,0 +1,3 @@ +Welcome to India +Welcome to Japan +Welcome to USA \ No newline at end of file diff --git a/BasicJava/JavaIODemo_Scanner_bufferedReader_App/JavaIODemo/src/ScannerDemo.java b/BasicJava/JavaIODemo_Scanner_bufferedReader_App/JavaIODemo/src/ScannerDemo.java new file mode 100644 index 000000000..fdfd711e2 --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_bufferedReader_App/JavaIODemo/src/ScannerDemo.java @@ -0,0 +1,43 @@ +import java.io.BufferedReader; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.util.Scanner; + +/* + * Scanner reads file. + */ +public class ScannerDemo +{ + + public static void main(String[] args) throws FileNotFoundException + { + Scanner scanner = null; + try + { + FileReader fileReader = new FileReader("myfile.txt"); + BufferedReader bufferedReader = new BufferedReader(fileReader); + scanner = new Scanner(bufferedReader); + + while (scanner.hasNext()) + { + String strValue = scanner.nextLine(); + System.out.println(strValue); + } + + } + finally + { + if (scanner != null) + { + /* + * Scanner's close method when it is done + * with the scanner object. Even though a + * scanner is not a stream, you need to + * close it to indicate that you're done + * with its underlying stream. + */ + scanner.close(); + } + } + } +} diff --git a/BasicJava/JavaIODemo_Scanner_bufferedReader_App/Output.txt b/BasicJava/JavaIODemo_Scanner_bufferedReader_App/Output.txt new file mode 100644 index 000000000..090d1bdec --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_bufferedReader_App/Output.txt @@ -0,0 +1,3 @@ +Welcome to India +Welcome to Japan +Welcome to USA diff --git a/BasicJava/JavaIODemo_Scanner_delimiter_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_Scanner_delimiter_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_delimiter_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_Scanner_delimiter_App/JavaIODemo/.project b/BasicJava/JavaIODemo_Scanner_delimiter_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_delimiter_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_Scanner_delimiter_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_Scanner_delimiter_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_delimiter_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_Scanner_delimiter_App/JavaIODemo/bin/ScannerDemo.class b/BasicJava/JavaIODemo_Scanner_delimiter_App/JavaIODemo/bin/ScannerDemo.class new file mode 100644 index 000000000..7e7ab402d Binary files /dev/null and b/BasicJava/JavaIODemo_Scanner_delimiter_App/JavaIODemo/bin/ScannerDemo.class differ diff --git a/BasicJava/JavaIODemo_Scanner_delimiter_App/JavaIODemo/bin/ScannerDemo1.class b/BasicJava/JavaIODemo_Scanner_delimiter_App/JavaIODemo/bin/ScannerDemo1.class new file mode 100644 index 000000000..2e85ee7ce Binary files /dev/null and b/BasicJava/JavaIODemo_Scanner_delimiter_App/JavaIODemo/bin/ScannerDemo1.class differ diff --git a/BasicJava/JavaIODemo_Scanner_delimiter_App/JavaIODemo/bin/ScannerDemo2.class b/BasicJava/JavaIODemo_Scanner_delimiter_App/JavaIODemo/bin/ScannerDemo2.class new file mode 100644 index 000000000..149090855 Binary files /dev/null and b/BasicJava/JavaIODemo_Scanner_delimiter_App/JavaIODemo/bin/ScannerDemo2.class differ diff --git a/BasicJava/JavaIODemo_Scanner_delimiter_App/JavaIODemo/bin/ScannerDemo3.class b/BasicJava/JavaIODemo_Scanner_delimiter_App/JavaIODemo/bin/ScannerDemo3.class new file mode 100644 index 000000000..7fb09f0b8 Binary files /dev/null and b/BasicJava/JavaIODemo_Scanner_delimiter_App/JavaIODemo/bin/ScannerDemo3.class differ diff --git a/BasicJava/JavaIODemo_Scanner_delimiter_App/JavaIODemo/bin/ScannerDemo4.class b/BasicJava/JavaIODemo_Scanner_delimiter_App/JavaIODemo/bin/ScannerDemo4.class new file mode 100644 index 000000000..704a1714f Binary files /dev/null and b/BasicJava/JavaIODemo_Scanner_delimiter_App/JavaIODemo/bin/ScannerDemo4.class differ diff --git a/BasicJava/JavaIODemo_Scanner_delimiter_App/JavaIODemo/src/ScannerDemo.java b/BasicJava/JavaIODemo_Scanner_delimiter_App/JavaIODemo/src/ScannerDemo.java new file mode 100644 index 000000000..8ac27fbf6 --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_delimiter_App/JavaIODemo/src/ScannerDemo.java @@ -0,0 +1,42 @@ +import java.util.Scanner; + +/* + * Scanner class with delimiter(-). + */ +public class ScannerDemo +{ + + public static void main(String[] args) + { + Scanner scanner = null; + try + { + String inputValue = "10-20-30-40"; + scanner = new Scanner(inputValue); + scanner.useDelimiter("-"); + + int sum = 0; + /* + * Returns: true if and only if this scanner's + * next token is a valid int value + */ + while (scanner.hasNextInt()) + { + /* + * Returns: the int scanned from the input + */ + int intValue = scanner.nextInt(); + System.out.println(intValue); + sum = sum + intValue; + } + System.out.println("sum = " + sum); + } + finally + { + if (scanner != null) + { + scanner.close(); + } + } + } +} diff --git a/BasicJava/JavaIODemo_Scanner_delimiter_App/Output.txt b/BasicJava/JavaIODemo_Scanner_delimiter_App/Output.txt new file mode 100644 index 000000000..46dae4d0f --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_delimiter_App/Output.txt @@ -0,0 +1,5 @@ +10 +20 +30 +40 +sum = 100 diff --git a/BasicJava/JavaIODemo_Scanner_file_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_Scanner_file_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_file_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_Scanner_file_App/JavaIODemo/.project b/BasicJava/JavaIODemo_Scanner_file_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_file_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_Scanner_file_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_Scanner_file_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_file_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_Scanner_file_App/JavaIODemo/bin/ScannerDemo.class b/BasicJava/JavaIODemo_Scanner_file_App/JavaIODemo/bin/ScannerDemo.class new file mode 100644 index 000000000..b7624f841 Binary files /dev/null and b/BasicJava/JavaIODemo_Scanner_file_App/JavaIODemo/bin/ScannerDemo.class differ diff --git a/BasicJava/JavaIODemo_Scanner_file_App/JavaIODemo/bin/ScannerDemo1.class b/BasicJava/JavaIODemo_Scanner_file_App/JavaIODemo/bin/ScannerDemo1.class new file mode 100644 index 000000000..2e85ee7ce Binary files /dev/null and b/BasicJava/JavaIODemo_Scanner_file_App/JavaIODemo/bin/ScannerDemo1.class differ diff --git a/BasicJava/JavaIODemo_Scanner_file_App/JavaIODemo/bin/ScannerDemo2.class b/BasicJava/JavaIODemo_Scanner_file_App/JavaIODemo/bin/ScannerDemo2.class new file mode 100644 index 000000000..149090855 Binary files /dev/null and b/BasicJava/JavaIODemo_Scanner_file_App/JavaIODemo/bin/ScannerDemo2.class differ diff --git a/BasicJava/JavaIODemo_Scanner_file_App/JavaIODemo/bin/ScannerDemo3.class b/BasicJava/JavaIODemo_Scanner_file_App/JavaIODemo/bin/ScannerDemo3.class new file mode 100644 index 000000000..7fb09f0b8 Binary files /dev/null and b/BasicJava/JavaIODemo_Scanner_file_App/JavaIODemo/bin/ScannerDemo3.class differ diff --git a/BasicJava/JavaIODemo_Scanner_file_App/JavaIODemo/bin/ScannerDemo4.class b/BasicJava/JavaIODemo_Scanner_file_App/JavaIODemo/bin/ScannerDemo4.class new file mode 100644 index 000000000..704a1714f Binary files /dev/null and b/BasicJava/JavaIODemo_Scanner_file_App/JavaIODemo/bin/ScannerDemo4.class differ diff --git a/BasicJava/JavaIODemo_Scanner_file_App/JavaIODemo/myfile.txt b/BasicJava/JavaIODemo_Scanner_file_App/JavaIODemo/myfile.txt new file mode 100644 index 000000000..669b14b0b --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_file_App/JavaIODemo/myfile.txt @@ -0,0 +1,3 @@ +Dave went to London +Peter gone to Japan +Juli went to USA \ No newline at end of file diff --git a/BasicJava/JavaIODemo_Scanner_file_App/JavaIODemo/src/ScannerDemo.java b/BasicJava/JavaIODemo_Scanner_file_App/JavaIODemo/src/ScannerDemo.java new file mode 100644 index 000000000..3581a324e --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_file_App/JavaIODemo/src/ScannerDemo.java @@ -0,0 +1,34 @@ +import java.io.File; +import java.io.FileNotFoundException; +import java.util.Scanner; + +/* + * Scanner reads file. + */ +public class ScannerDemo +{ + + public static void main(String[] args) throws FileNotFoundException + { + Scanner scanner = null; + try + { + File file = new File("myfile.txt"); + scanner = new Scanner(file); + + while (scanner.hasNext()) + { + String strValue = scanner.nextLine(); + System.out.println(strValue); + } + + } + finally + { + if (scanner != null) + { + scanner.close(); + } + } + } +} diff --git a/BasicJava/JavaIODemo_Scanner_file_App/Output.txt b/BasicJava/JavaIODemo_Scanner_file_App/Output.txt new file mode 100644 index 000000000..d240e1bc4 --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_file_App/Output.txt @@ -0,0 +1,3 @@ +Dave went to London +Peter gone to Japan +Juli went to USA diff --git a/BasicJava/JavaIODemo_Scanner_locale_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_Scanner_locale_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_locale_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_Scanner_locale_App/JavaIODemo/.project b/BasicJava/JavaIODemo_Scanner_locale_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_locale_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_Scanner_locale_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_Scanner_locale_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_locale_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_Scanner_locale_App/JavaIODemo/bin/ScannerDemo.class b/BasicJava/JavaIODemo_Scanner_locale_App/JavaIODemo/bin/ScannerDemo.class new file mode 100644 index 000000000..b8bd388fd Binary files /dev/null and b/BasicJava/JavaIODemo_Scanner_locale_App/JavaIODemo/bin/ScannerDemo.class differ diff --git a/BasicJava/JavaIODemo_Scanner_locale_App/JavaIODemo/myfile.txt b/BasicJava/JavaIODemo_Scanner_locale_App/JavaIODemo/myfile.txt new file mode 100644 index 000000000..532c7b687 --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_locale_App/JavaIODemo/myfile.txt @@ -0,0 +1,4 @@ +8.5 +32,767 +3.14159 +1,000,000.1 \ No newline at end of file diff --git a/BasicJava/JavaIODemo_Scanner_locale_App/JavaIODemo/src/ScannerDemo.java b/BasicJava/JavaIODemo_Scanner_locale_App/JavaIODemo/src/ScannerDemo.java new file mode 100644 index 000000000..7fcc29810 --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_locale_App/JavaIODemo/src/ScannerDemo.java @@ -0,0 +1,56 @@ +import java.io.BufferedReader; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.util.Locale; +import java.util.Scanner; + +public class ScannerDemo +{ + + public static void main(String[] args) throws FileNotFoundException + { + Scanner scanner = null; + double sum = 0; + + try + { + scanner = new Scanner(new BufferedReader(new FileReader( + "myfile.txt"))); + /* + * Sets this scanner's locale to the specified + * locale. + * + * We have to mention the locale, because + * thousands separators and decimal symbols are + * locale specific. So, the this example would + * not work correctly in all locales if we + * didn't specify that the scanner should use + * the US locale. + */ + scanner.useLocale(Locale.US); + + while (scanner.hasNext()) + { + if (scanner.hasNextDouble()) + { + double doubleValue = scanner.nextDouble(); + System.out.println("doubleValue = " + doubleValue); + sum += doubleValue; + } + else + { + scanner.next(); + } + } + } + finally + { + if (scanner != null) + { + scanner.close(); + } + } + + System.out.println("sum = " + sum); + } +} diff --git a/BasicJava/JavaIODemo_Scanner_locale_App/Output.txt b/BasicJava/JavaIODemo_Scanner_locale_App/Output.txt new file mode 100644 index 000000000..4a7edf801 --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_locale_App/Output.txt @@ -0,0 +1,5 @@ +doubleValue = 8.5 +doubleValue = 32767.0 +doubleValue = 3.14159 +doubleValue = 1000000.1 +sum = 1032778.74159 diff --git a/BasicJava/JavaIODemo_Scanner_sum_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_Scanner_sum_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_sum_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_Scanner_sum_App/JavaIODemo/.project b/BasicJava/JavaIODemo_Scanner_sum_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_sum_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_Scanner_sum_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_Scanner_sum_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_sum_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_Scanner_sum_App/JavaIODemo/bin/ScannerDemo.class b/BasicJava/JavaIODemo_Scanner_sum_App/JavaIODemo/bin/ScannerDemo.class new file mode 100644 index 000000000..fd634f52b Binary files /dev/null and b/BasicJava/JavaIODemo_Scanner_sum_App/JavaIODemo/bin/ScannerDemo.class differ diff --git a/BasicJava/JavaIODemo_Scanner_sum_App/JavaIODemo/src/ScannerDemo.java b/BasicJava/JavaIODemo_Scanner_sum_App/JavaIODemo/src/ScannerDemo.java new file mode 100644 index 000000000..192875673 --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_sum_App/JavaIODemo/src/ScannerDemo.java @@ -0,0 +1,30 @@ +import java.util.Scanner; + +public class ScannerDemo +{ + + public static void main(String[] args) + { + Scanner scanner = null; + try + { + scanner = new Scanner(System.in); + System.out.print("Enter the first number: "); + int number1 = scanner.nextInt(); + System.out.print("Enter the second number: "); + int number2 = scanner.nextInt(); + + int sum = number1 + number2; + System.out.println("sum = " + sum); + + } + finally + { + if (scanner != null) + { + scanner.close(); + } + } + + } +} diff --git a/BasicJava/JavaIODemo_Scanner_sum_App/Output.txt b/BasicJava/JavaIODemo_Scanner_sum_App/Output.txt new file mode 100644 index 000000000..526d59878 --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_sum_App/Output.txt @@ -0,0 +1,3 @@ +Enter the first number: 10 +Enter the second number: 20 +sum = 30 diff --git a/BasicJava/JavaIODemo_Scanner_while loop_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_Scanner_while loop_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_while loop_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_Scanner_while loop_App/JavaIODemo/.project b/BasicJava/JavaIODemo_Scanner_while loop_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_while loop_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_Scanner_while loop_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_Scanner_while loop_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_while loop_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_Scanner_while loop_App/JavaIODemo/bin/ScannerDemo.class b/BasicJava/JavaIODemo_Scanner_while loop_App/JavaIODemo/bin/ScannerDemo.class new file mode 100644 index 000000000..da6c02530 Binary files /dev/null and b/BasicJava/JavaIODemo_Scanner_while loop_App/JavaIODemo/bin/ScannerDemo.class differ diff --git a/BasicJava/JavaIODemo_Scanner_while loop_App/JavaIODemo/src/ScannerDemo.java b/BasicJava/JavaIODemo_Scanner_while loop_App/JavaIODemo/src/ScannerDemo.java new file mode 100644 index 000000000..19a25ee7b --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_while loop_App/JavaIODemo/src/ScannerDemo.java @@ -0,0 +1,37 @@ +import java.util.ArrayList; +import java.util.Scanner; + +public class ScannerDemo +{ + + public static void main(String[] args) + { + Scanner scanner = null; + try + { + ArrayList listOfNames = new ArrayList(); + scanner = new Scanner(System.in); + System.out.print("Enter the name: "); + while (scanner.hasNextLine()) + { + + String name = scanner.nextLine(); + if (name.equalsIgnoreCase("quit")) + { + break; + } + listOfNames.add(name); + System.out.print("Enter the name: "); + } + System.out.println("listOfNames = "+listOfNames); + } + finally + { + if (scanner != null) + { + scanner.close(); + } + } + + } +} diff --git a/BasicJava/JavaIODemo_Scanner_while loop_App/Output.txt b/BasicJava/JavaIODemo_Scanner_while loop_App/Output.txt new file mode 100644 index 000000000..45de5b691 --- /dev/null +++ b/BasicJava/JavaIODemo_Scanner_while loop_App/Output.txt @@ -0,0 +1,5 @@ +Enter the name: peter +Enter the name: dave +Enter the name: ram +Enter the name: quit +listOfNames = [peter, dave, ram] diff --git a/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_App/JavaIODemo/.project b/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_App/JavaIODemo/bin/SequenceInputStreamDemo.class b/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_App/JavaIODemo/bin/SequenceInputStreamDemo.class new file mode 100644 index 000000000..9f8840c56 Binary files /dev/null and b/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_App/JavaIODemo/bin/SequenceInputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_App/JavaIODemo/myfile1.txt b/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_App/JavaIODemo/myfile1.txt new file mode 100644 index 000000000..97d77abb4 --- /dev/null +++ b/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_App/JavaIODemo/myfile1.txt @@ -0,0 +1 @@ +1,2,3,4,5, \ No newline at end of file diff --git a/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_App/JavaIODemo/myfile2.txt b/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_App/JavaIODemo/myfile2.txt new file mode 100644 index 000000000..c5e266844 --- /dev/null +++ b/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_App/JavaIODemo/myfile2.txt @@ -0,0 +1 @@ +6,7,8,9,10, \ No newline at end of file diff --git a/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_App/JavaIODemo/myfile3.txt b/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_App/JavaIODemo/myfile3.txt new file mode 100644 index 000000000..0eccb3c6a --- /dev/null +++ b/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_App/JavaIODemo/myfile3.txt @@ -0,0 +1 @@ +11,12,13,14,15 \ No newline at end of file diff --git a/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_App/JavaIODemo/src/SequenceInputStreamDemo.java b/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_App/JavaIODemo/src/SequenceInputStreamDemo.java new file mode 100644 index 000000000..983362293 --- /dev/null +++ b/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_App/JavaIODemo/src/SequenceInputStreamDemo.java @@ -0,0 +1,68 @@ +import java.io.FileInputStream; +import java.io.IOException; +import java.io.SequenceInputStream; +import java.util.Enumeration; +import java.util.Vector; + +/* + * public SequenceInputStream(Enumeration e) + * + * Parameters: + * ----------- + * + * e - an enumeration of input streams. + */ + +public class SequenceInputStreamDemo +{ + + public static void main(String[] args) throws IOException + { + FileInputStream fileInputStream1 = null; + FileInputStream fileInputStream2 = null; + FileInputStream fileInputStream3 = null; + SequenceInputStream sequenceInputStream = null; + + try + { + fileInputStream1 = new FileInputStream("myfile1.txt"); + fileInputStream2 = new FileInputStream("myfile2.txt"); + fileInputStream3 = new FileInputStream("myfile3.txt"); + + Vector vector = new Vector(); + vector.add(fileInputStream1); + vector.add(fileInputStream2); + vector.add(fileInputStream3); + + Enumeration enumeration = vector.elements(); + + sequenceInputStream = new SequenceInputStream(enumeration); + int i; + while ((i = sequenceInputStream.read()) != -1) + { + System.out.print((char) i); + } + } + finally + { + if (fileInputStream1 != null) + { + fileInputStream1.close(); + } + if (fileInputStream2 != null) + { + fileInputStream2.close(); + } + if (fileInputStream3 != null) + { + fileInputStream3.close(); + } + if (sequenceInputStream != null) + { + sequenceInputStream.close(); + } + } + } + +} diff --git a/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_App/Output.txt b/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_App/Output.txt new file mode 100644 index 000000000..61bcfea21 --- /dev/null +++ b/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_App/Output.txt @@ -0,0 +1 @@ +1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 \ No newline at end of file diff --git a/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_BAIS_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_BAIS_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_BAIS_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_BAIS_App/JavaIODemo/.project b/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_BAIS_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_BAIS_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_BAIS_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_BAIS_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_BAIS_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_BAIS_App/JavaIODemo/bin/SequenceInputStreamDemo.class b/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_BAIS_App/JavaIODemo/bin/SequenceInputStreamDemo.class new file mode 100644 index 000000000..f8eb52d49 Binary files /dev/null and b/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_BAIS_App/JavaIODemo/bin/SequenceInputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_BAIS_App/JavaIODemo/src/SequenceInputStreamDemo.java b/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_BAIS_App/JavaIODemo/src/SequenceInputStreamDemo.java new file mode 100644 index 000000000..2dce777a1 --- /dev/null +++ b/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_BAIS_App/JavaIODemo/src/SequenceInputStreamDemo.java @@ -0,0 +1,67 @@ +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.SequenceInputStream; +import java.util.Enumeration; +import java.util.Vector; + +/* + * public SequenceInputStream(Enumeration e) + * + * Parameters: + * ----------- + * + * e - an enumeration of input streams. + */ + +public class SequenceInputStreamDemo +{ + + public static void main(String[] args) throws IOException + { + ByteArrayInputStream byteArrayInputStream1 = null; + ByteArrayInputStream byteArrayInputStream2 = null; + SequenceInputStream sequenceInputStream = null; + + try + { + String str1 = "Hello"; + String str2 = " Peter"; + byte[] byteArray1 = str1.getBytes(); + byte[] byteArray2 = str2.getBytes(); + + byteArrayInputStream1 = new ByteArrayInputStream(byteArray1); + byteArrayInputStream2 = new ByteArrayInputStream(byteArray2); + + Vector vector = new Vector(); + vector.add(byteArrayInputStream1); + vector.add(byteArrayInputStream2); + + Enumeration enumeration = vector.elements(); + + sequenceInputStream = new SequenceInputStream(enumeration); + int i; + while ((i = sequenceInputStream.read()) != -1) + { + System.out.print((char) i); + } + + } + finally + { + if (byteArrayInputStream1 != null) + { + byteArrayInputStream1.close(); + } + if (byteArrayInputStream2 != null) + { + byteArrayInputStream2.close(); + } + if (sequenceInputStream != null) + { + sequenceInputStream.close(); + } + } + } + +} diff --git a/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_BAIS_App/Output.txt b/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_BAIS_App/Output.txt new file mode 100644 index 000000000..6d260cf27 --- /dev/null +++ b/BasicJava/JavaIODemo_SequenceInputStream_Enumeration_BAIS_App/Output.txt @@ -0,0 +1 @@ +Hello Peter \ No newline at end of file diff --git a/BasicJava/JavaIODemo_SequenceInputStream_Intro_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_SequenceInputStream_Intro_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_SequenceInputStream_Intro_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_SequenceInputStream_Intro_App/JavaIODemo/.project b/BasicJava/JavaIODemo_SequenceInputStream_Intro_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_SequenceInputStream_Intro_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_SequenceInputStream_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_SequenceInputStream_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_SequenceInputStream_Intro_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_SequenceInputStream_Intro_App/JavaIODemo/bin/SequenceInputStreamDemo.class b/BasicJava/JavaIODemo_SequenceInputStream_Intro_App/JavaIODemo/bin/SequenceInputStreamDemo.class new file mode 100644 index 000000000..d298eeeb8 Binary files /dev/null and b/BasicJava/JavaIODemo_SequenceInputStream_Intro_App/JavaIODemo/bin/SequenceInputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_SequenceInputStream_Intro_App/JavaIODemo/myfile1.txt b/BasicJava/JavaIODemo_SequenceInputStream_Intro_App/JavaIODemo/myfile1.txt new file mode 100644 index 000000000..32c344d91 --- /dev/null +++ b/BasicJava/JavaIODemo_SequenceInputStream_Intro_App/JavaIODemo/myfile1.txt @@ -0,0 +1 @@ +Peter is going to India,Join is going to India, \ No newline at end of file diff --git a/BasicJava/JavaIODemo_SequenceInputStream_Intro_App/JavaIODemo/myfile2.txt b/BasicJava/JavaIODemo_SequenceInputStream_Intro_App/JavaIODemo/myfile2.txt new file mode 100644 index 000000000..dd28e567e --- /dev/null +++ b/BasicJava/JavaIODemo_SequenceInputStream_Intro_App/JavaIODemo/myfile2.txt @@ -0,0 +1 @@ +Welcome to America,Welcome to India \ No newline at end of file diff --git a/BasicJava/JavaIODemo_SequenceInputStream_Intro_App/JavaIODemo/src/SequenceInputStreamDemo.java b/BasicJava/JavaIODemo_SequenceInputStream_Intro_App/JavaIODemo/src/SequenceInputStreamDemo.java new file mode 100644 index 000000000..3ab7fc809 --- /dev/null +++ b/BasicJava/JavaIODemo_SequenceInputStream_Intro_App/JavaIODemo/src/SequenceInputStreamDemo.java @@ -0,0 +1,44 @@ +import java.io.FileInputStream; +import java.io.IOException; +import java.io.SequenceInputStream; + +public class SequenceInputStreamDemo +{ + + public static void main(String[] args) throws IOException + { + FileInputStream fileInputStream1 = null; + FileInputStream fileInputStream2 = null; + SequenceInputStream sequenceInputStream = null; + + try + { + fileInputStream1 = new FileInputStream("myfile1.txt"); + fileInputStream2 = new FileInputStream("myfile2.txt"); + + sequenceInputStream = new SequenceInputStream(fileInputStream1, + fileInputStream2); + int i; + while ((i = sequenceInputStream.read()) != -1) + { + System.out.print((char) i); + } + } + finally + { + if(fileInputStream1!=null) + { + fileInputStream1.close(); + } + if(fileInputStream2!=null) + { + fileInputStream2.close(); + } + if(sequenceInputStream!=null) + { + sequenceInputStream.close(); + } + } + } + +} diff --git a/BasicJava/JavaIODemo_SequenceInputStream_Intro_App/Output.txt b/BasicJava/JavaIODemo_SequenceInputStream_Intro_App/Output.txt new file mode 100644 index 000000000..e67d6d50b --- /dev/null +++ b/BasicJava/JavaIODemo_SequenceInputStream_Intro_App/Output.txt @@ -0,0 +1 @@ +Peter is going to India,Join is going to India,Welcome to America,Welcome to India \ No newline at end of file diff --git a/BasicJava/JavaIODemo_SequenceInputStream_RW_Enumeration_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_SequenceInputStream_RW_Enumeration_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_SequenceInputStream_RW_Enumeration_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_SequenceInputStream_RW_Enumeration_App/JavaIODemo/.project b/BasicJava/JavaIODemo_SequenceInputStream_RW_Enumeration_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_SequenceInputStream_RW_Enumeration_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_SequenceInputStream_RW_Enumeration_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_SequenceInputStream_RW_Enumeration_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_SequenceInputStream_RW_Enumeration_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_SequenceInputStream_RW_Enumeration_App/JavaIODemo/bin/SequenceInputStreamDemo.class b/BasicJava/JavaIODemo_SequenceInputStream_RW_Enumeration_App/JavaIODemo/bin/SequenceInputStreamDemo.class new file mode 100644 index 000000000..f27700d84 Binary files /dev/null and b/BasicJava/JavaIODemo_SequenceInputStream_RW_Enumeration_App/JavaIODemo/bin/SequenceInputStreamDemo.class differ diff --git a/BasicJava/JavaIODemo_SequenceInputStream_RW_Enumeration_App/JavaIODemo/myfile1.txt b/BasicJava/JavaIODemo_SequenceInputStream_RW_Enumeration_App/JavaIODemo/myfile1.txt new file mode 100644 index 000000000..97d77abb4 --- /dev/null +++ b/BasicJava/JavaIODemo_SequenceInputStream_RW_Enumeration_App/JavaIODemo/myfile1.txt @@ -0,0 +1 @@ +1,2,3,4,5, \ No newline at end of file diff --git a/BasicJava/JavaIODemo_SequenceInputStream_RW_Enumeration_App/JavaIODemo/myfile2.txt b/BasicJava/JavaIODemo_SequenceInputStream_RW_Enumeration_App/JavaIODemo/myfile2.txt new file mode 100644 index 000000000..c5e266844 --- /dev/null +++ b/BasicJava/JavaIODemo_SequenceInputStream_RW_Enumeration_App/JavaIODemo/myfile2.txt @@ -0,0 +1 @@ +6,7,8,9,10, \ No newline at end of file diff --git a/BasicJava/JavaIODemo_SequenceInputStream_RW_Enumeration_App/JavaIODemo/myfile3.txt b/BasicJava/JavaIODemo_SequenceInputStream_RW_Enumeration_App/JavaIODemo/myfile3.txt new file mode 100644 index 000000000..0eccb3c6a --- /dev/null +++ b/BasicJava/JavaIODemo_SequenceInputStream_RW_Enumeration_App/JavaIODemo/myfile3.txt @@ -0,0 +1 @@ +11,12,13,14,15 \ No newline at end of file diff --git a/BasicJava/JavaIODemo_SequenceInputStream_RW_Enumeration_App/JavaIODemo/myoutputfile.txt b/BasicJava/JavaIODemo_SequenceInputStream_RW_Enumeration_App/JavaIODemo/myoutputfile.txt new file mode 100644 index 000000000..61bcfea21 --- /dev/null +++ b/BasicJava/JavaIODemo_SequenceInputStream_RW_Enumeration_App/JavaIODemo/myoutputfile.txt @@ -0,0 +1 @@ +1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 \ No newline at end of file diff --git a/BasicJava/JavaIODemo_SequenceInputStream_RW_Enumeration_App/JavaIODemo/src/SequenceInputStreamDemo.java b/BasicJava/JavaIODemo_SequenceInputStream_RW_Enumeration_App/JavaIODemo/src/SequenceInputStreamDemo.java new file mode 100644 index 000000000..2a2061621 --- /dev/null +++ b/BasicJava/JavaIODemo_SequenceInputStream_RW_Enumeration_App/JavaIODemo/src/SequenceInputStreamDemo.java @@ -0,0 +1,78 @@ +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.SequenceInputStream; +import java.util.Enumeration; +import java.util.Vector; + +/* + * public SequenceInputStream(Enumeration e) + * + * Parameters: + * ----------- + * + * e - an enumeration of input streams. + */ + +public class SequenceInputStreamDemo +{ + + public static void main(String[] args) throws IOException + { + FileInputStream fileInputStream1 = null; + FileInputStream fileInputStream2 = null; + FileInputStream fileInputStream3 = null; + FileOutputStream fileOutputStream = null; + SequenceInputStream sequenceInputStream = null; + + try + { + fileInputStream1 = new FileInputStream("myfile1.txt"); + fileInputStream2 = new FileInputStream("myfile2.txt"); + fileInputStream3 = new FileInputStream("myfile3.txt"); + + fileOutputStream = new FileOutputStream("myoutputfile.txt"); + + Vector vector = new Vector(); + vector.add(fileInputStream1); + vector.add(fileInputStream2); + vector.add(fileInputStream3); + + Enumeration enumeration = vector.elements(); + + sequenceInputStream = new SequenceInputStream(enumeration); + int i; + while ((i = sequenceInputStream.read()) != -1) + { + fileOutputStream.write(i); + } + System.out + .println("Successfully read from 3 files and written to one file."); + } + finally + { + if (fileInputStream1 != null) + { + fileInputStream1.close(); + } + if (fileInputStream2 != null) + { + fileInputStream2.close(); + } + if (fileInputStream3 != null) + { + fileInputStream3.close(); + } + if (fileOutputStream != null) + { + fileOutputStream.close(); + } + if (sequenceInputStream != null) + { + sequenceInputStream.close(); + } + } + } + +} diff --git a/BasicJava/JavaIODemo_SequenceInputStream_RW_Enumeration_App/Output.txt b/BasicJava/JavaIODemo_SequenceInputStream_RW_Enumeration_App/Output.txt new file mode 100644 index 000000000..961ea01f1 --- /dev/null +++ b/BasicJava/JavaIODemo_SequenceInputStream_RW_Enumeration_App/Output.txt @@ -0,0 +1 @@ +Successfully read from 3 files and written to one file. diff --git a/BasicJava/JavaIODemo_Serializable_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_Serializable_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_Serializable_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_Serializable_App/JavaIODemo/.project b/BasicJava/JavaIODemo_Serializable_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_Serializable_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_Serializable_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_Serializable_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_Serializable_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_Serializable_App/JavaIODemo/bin/Employee.class b/BasicJava/JavaIODemo_Serializable_App/JavaIODemo/bin/Employee.class new file mode 100644 index 000000000..81f87e4c4 Binary files /dev/null and b/BasicJava/JavaIODemo_Serializable_App/JavaIODemo/bin/Employee.class differ diff --git a/BasicJava/JavaIODemo_Serializable_App/JavaIODemo/src/Employee.java b/BasicJava/JavaIODemo_Serializable_App/JavaIODemo/src/Employee.java new file mode 100644 index 000000000..b4e8ab303 --- /dev/null +++ b/BasicJava/JavaIODemo_Serializable_App/JavaIODemo/src/Employee.java @@ -0,0 +1,29 @@ +import java.io.Serializable; + +public class Employee implements Serializable +{ + private static final long serialVersionUID = 3558283530338723147L; + private int id; + private String name; + + public int getId() + { + return id; + } + + public void setId(int id) + { + this.id = id; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + +} \ No newline at end of file diff --git a/BasicJava/JavaIODemo_Serialization_Collection_App/DeSerializationDemo_Output.txt b/BasicJava/JavaIODemo_Serialization_Collection_App/DeSerializationDemo_Output.txt new file mode 100644 index 000000000..4929f3fa6 --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_Collection_App/DeSerializationDemo_Output.txt @@ -0,0 +1,11 @@ +Successfully read list of employee objects from the file. + +Id = 101 +Name = Peter +-------------------------- +Id = 102 +Name = Dave +-------------------------- +Id = 103 +Name = Ram +-------------------------- diff --git a/BasicJava/JavaIODemo_Serialization_Collection_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_Serialization_Collection_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_Collection_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_Serialization_Collection_App/JavaIODemo/.project b/BasicJava/JavaIODemo_Serialization_Collection_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_Collection_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_Serialization_Collection_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_Serialization_Collection_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_Collection_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_Serialization_Collection_App/JavaIODemo/bin/DeSerializationDemo.class b/BasicJava/JavaIODemo_Serialization_Collection_App/JavaIODemo/bin/DeSerializationDemo.class new file mode 100644 index 000000000..91e344083 Binary files /dev/null and b/BasicJava/JavaIODemo_Serialization_Collection_App/JavaIODemo/bin/DeSerializationDemo.class differ diff --git a/BasicJava/JavaIODemo_Serialization_Collection_App/JavaIODemo/bin/Employee.class b/BasicJava/JavaIODemo_Serialization_Collection_App/JavaIODemo/bin/Employee.class new file mode 100644 index 000000000..9f7aafe61 Binary files /dev/null and b/BasicJava/JavaIODemo_Serialization_Collection_App/JavaIODemo/bin/Employee.class differ diff --git a/BasicJava/JavaIODemo_Serialization_Collection_App/JavaIODemo/bin/SerializationDemo.class b/BasicJava/JavaIODemo_Serialization_Collection_App/JavaIODemo/bin/SerializationDemo.class new file mode 100644 index 000000000..2b2ba598e Binary files /dev/null and b/BasicJava/JavaIODemo_Serialization_Collection_App/JavaIODemo/bin/SerializationDemo.class differ diff --git a/BasicJava/JavaIODemo_Serialization_Collection_App/JavaIODemo/employee.tmp b/BasicJava/JavaIODemo_Serialization_Collection_App/JavaIODemo/employee.tmp new file mode 100644 index 000000000..3958b2c34 Binary files /dev/null and b/BasicJava/JavaIODemo_Serialization_Collection_App/JavaIODemo/employee.tmp differ diff --git a/BasicJava/JavaIODemo_Serialization_Collection_App/JavaIODemo/src/DeSerializationDemo.java b/BasicJava/JavaIODemo_Serialization_Collection_App/JavaIODemo/src/DeSerializationDemo.java new file mode 100644 index 000000000..456606454 --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_Collection_App/JavaIODemo/src/DeSerializationDemo.java @@ -0,0 +1,60 @@ +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.util.ArrayList; + +public class DeSerializationDemo +{ + + public static void main(String[] args) throws FileNotFoundException, + IOException, ClassNotFoundException + { + DeSerializationDemo deSerializationDemo = new DeSerializationDemo(); + deSerializationDemo.readEmployeeObject(); + } + + private void readEmployeeObject() throws IOException, + FileNotFoundException, ClassNotFoundException + { + FileInputStream fileInputStream = null; + ObjectInputStream objectInputStream = null; + + try + { + fileInputStream = new FileInputStream("employee.tmp"); + objectInputStream = new ObjectInputStream(fileInputStream); + + /* + * Read an object from the ObjectInputStream. + */ + ArrayList listOfEmployees = (ArrayList) objectInputStream + .readObject(); + System.out + .println("Successfully read list of employee objects from the file.\n"); + + for (Employee employee : listOfEmployees) + { + System.out.println("Id = " + employee.getId()); + System.out.println("Name = " + employee.getName()); + System.out.println("--------------------------"); + } + + } + finally + { + + if (objectInputStream != null) + { + /* + * Closing a ObjectInputStream will also + * close the InputStream instance from which + * the ObjectInputStream is reading. + */ + objectInputStream.close(); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_Serialization_Collection_App/JavaIODemo/src/Employee.java b/BasicJava/JavaIODemo_Serialization_Collection_App/JavaIODemo/src/Employee.java new file mode 100644 index 000000000..a1f1863ca --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_Collection_App/JavaIODemo/src/Employee.java @@ -0,0 +1,36 @@ +import java.io.Serializable; + +public class Employee implements Serializable +{ + private static final long serialVersionUID = 765764534241652904L; + private int id; + private String name; + + public Employee(int id, String name) + { + super(); + this.id = id; + this.name = name; + } + + public int getId() + { + return id; + } + + public void setId(int id) + { + this.id = id; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + +} \ No newline at end of file diff --git a/BasicJava/JavaIODemo_Serialization_Collection_App/JavaIODemo/src/SerializationDemo.java b/BasicJava/JavaIODemo_Serialization_Collection_App/JavaIODemo/src/SerializationDemo.java new file mode 100644 index 000000000..76ff1264b --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_Collection_App/JavaIODemo/src/SerializationDemo.java @@ -0,0 +1,60 @@ +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; +import java.util.ArrayList; + +public class SerializationDemo +{ + + public static void main(String[] args) throws FileNotFoundException, + IOException, ClassNotFoundException + { + SerializationDemo serializationDemo = new SerializationDemo(); + serializationDemo.writeEmployeeObject(); + } + + private void writeEmployeeObject() throws FileNotFoundException, + IOException + { + FileOutputStream fileOutputStream = null; + ObjectOutputStream objectOutputStream = null; + try + { + fileOutputStream = new FileOutputStream("employee.tmp"); + objectOutputStream = new ObjectOutputStream(fileOutputStream); + + Employee employee1 = new Employee(101, "Peter"); + Employee employee2 = new Employee(102, "Dave"); + Employee employee3 = new Employee(103, "Ram"); + + ArrayList listOfEmployees = new ArrayList(); + listOfEmployees.add(employee1); + listOfEmployees.add(employee2); + listOfEmployees.add(employee3); + + /* + * Write the specified object to the + * ObjectOutputStream. + */ + objectOutputStream.writeObject(listOfEmployees); + System.out + .println("Successfully written list of employee objects to the file.\n"); + } + finally + { + + if (objectOutputStream != null) + { + /* + * Closing a ObjectOutputStream will also + * close the OutputStream instance to which + * the ObjectOutputStream is writing. + */ + objectOutputStream.close(); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_Serialization_Collection_App/SerializationDemo_Output.txt b/BasicJava/JavaIODemo_Serialization_Collection_App/SerializationDemo_Output.txt new file mode 100644 index 000000000..e3a06cf12 --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_Collection_App/SerializationDemo_Output.txt @@ -0,0 +1,2 @@ +Successfully written list of employee objects to the file. + diff --git a/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/DeSerializationDemo_Output.txt b/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/DeSerializationDemo_Output.txt new file mode 100644 index 000000000..9e4541835 --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/DeSerializationDemo_Output.txt @@ -0,0 +1,4 @@ +Successfully read employee object from the file. +Id = 101 +Name = Peter +Address = Address [streetName=North Street, city=Chennai, state=Tamil Nadu] diff --git a/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/.project b/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/bin/Address.class b/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/bin/Address.class new file mode 100644 index 000000000..721ea8c6c Binary files /dev/null and b/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/bin/Address.class differ diff --git a/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/bin/DeSerializationDemo.class b/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/bin/DeSerializationDemo.class new file mode 100644 index 000000000..a2df1ac28 Binary files /dev/null and b/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/bin/DeSerializationDemo.class differ diff --git a/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/bin/Employee.class b/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/bin/Employee.class new file mode 100644 index 000000000..dfebfbb13 Binary files /dev/null and b/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/bin/Employee.class differ diff --git a/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/bin/SerializationDemo.class b/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/bin/SerializationDemo.class new file mode 100644 index 000000000..f7f56eed0 Binary files /dev/null and b/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/bin/SerializationDemo.class differ diff --git a/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/employee.tmp b/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/employee.tmp new file mode 100644 index 000000000..a684a2c4d Binary files /dev/null and b/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/employee.tmp differ diff --git a/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/src/Address.java b/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/src/Address.java new file mode 100644 index 000000000..1ab3394c9 --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/src/Address.java @@ -0,0 +1,55 @@ +import java.io.Serializable; + +public class Address implements Serializable +{ + private static final long serialVersionUID = 8899023823185198093L; + private String streetName; + private String city; + private String state; + + public Address(String streetName, String city, String state) + { + super(); + this.streetName = streetName; + this.city = city; + this.state = state; + } + + public String getStreetName() + { + return streetName; + } + + public void setStreetName(String streetName) + { + this.streetName = streetName; + } + + public String getCity() + { + return city; + } + + public void setCity(String city) + { + this.city = city; + } + + public String getState() + { + return state; + } + + public void setState(String state) + { + this.state = state; + } + + @Override + public String toString() + { + return "Address [streetName=" + streetName + ", city=" + city + + ", state=" + state + "]"; + } + +} diff --git a/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/src/DeSerializationDemo.java b/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/src/DeSerializationDemo.java new file mode 100644 index 000000000..e114b9420 --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/src/DeSerializationDemo.java @@ -0,0 +1,56 @@ +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.ObjectInputStream; + +public class DeSerializationDemo +{ + + public static void main(String[] args) throws FileNotFoundException, + IOException, ClassNotFoundException + { + DeSerializationDemo deSerializationDemo = new DeSerializationDemo(); + deSerializationDemo.readEmployeeObject(); + } + + private void readEmployeeObject() throws IOException, + FileNotFoundException, ClassNotFoundException + { + FileInputStream fileInputStream = null; + ObjectInputStream objectInputStream = null; + + try + { + fileInputStream = new FileInputStream("employee.tmp"); + objectInputStream = new ObjectInputStream(fileInputStream); + + /* + * Read an object from the ObjectInputStream. + */ + Employee employee = (Employee) objectInputStream.readObject(); + + System.out + .println("Successfully read employee object from the file."); + + System.out.println("Id = " + employee.getId()); + System.out.println("Name = " + employee.getName()); + Address address = employee.getAddress(); + System.out.println("Address = " + address); + } + finally + { + + if (objectInputStream != null) + { + /* + * Closing a ObjectInputStream will also + * close the InputStream instance from which + * the ObjectInputStream is reading. + */ + objectInputStream.close(); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/src/Employee.java b/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/src/Employee.java new file mode 100644 index 000000000..c3b179a22 --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/src/Employee.java @@ -0,0 +1,58 @@ +import java.io.Serializable; + +/* + * If a class has a reference of another class, all the + * references must be Serializable otherwise + * serialization process will not be performed. In such + * case, NotSerializableException is thrown at runtime. + * + * If Address is not Serializable, we cannot serialize + * the instance of Employee class. + */ +public class Employee implements Serializable +{ + + private static final long serialVersionUID = 765764534241652904L; + private int id; + private String name; + private Address address; // HAS-A + + public Employee(int id, String name, Address address) + { + super(); + this.id = id; + this.name = name; + this.address = address; + } + + public int getId() + { + return id; + } + + public void setId(int id) + { + this.id = id; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public Address getAddress() + { + return address; + } + + public void setAddress(Address address) + { + this.address = address; + } + +} \ No newline at end of file diff --git a/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/src/SerializationDemo.java b/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/src/SerializationDemo.java new file mode 100644 index 000000000..a07706306 --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/JavaIODemo/src/SerializationDemo.java @@ -0,0 +1,55 @@ +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; + +public class SerializationDemo +{ + + public static void main(String[] args) throws FileNotFoundException, + IOException, ClassNotFoundException + { + SerializationDemo serializationDemo = new SerializationDemo(); + serializationDemo.writeEmployeeObject(); + } + + private void writeEmployeeObject() throws FileNotFoundException, + IOException + { + FileOutputStream fileOutputStream = null; + ObjectOutputStream objectOutputStream = null; + try + { + fileOutputStream = new FileOutputStream("employee.tmp"); + objectOutputStream = new ObjectOutputStream(fileOutputStream); + + Address address = new Address("North Street", "Chennai", + "Tamil Nadu"); + + Employee employee = new Employee(101, "Peter", address); + + /* + * Write the specified object to the + * ObjectOutputStream. + */ + objectOutputStream.writeObject(employee); + System.out + .println("Successfully written employee object to the file.\n"); + } + finally + { + + if (objectOutputStream != null) + { + /* + * Closing a ObjectOutputStream will also + * close the OutputStream instance to which + * the ObjectOutputStream is writing. + */ + objectOutputStream.close(); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/SerializationDemo_Output.txt b/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/SerializationDemo_Output.txt new file mode 100644 index 000000000..76b231da1 --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_HAS_A_Relationship_App/SerializationDemo_Output.txt @@ -0,0 +1,2 @@ +Successfully written employee object to the file. + diff --git a/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/DeSerializationDemo_Output.txt b/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/DeSerializationDemo_Output.txt new file mode 100644 index 000000000..e3074250d --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/DeSerializationDemo_Output.txt @@ -0,0 +1,4 @@ +Successfully read employee object from the file. +Name = Peter +Age = 29 +Salary = 80000 diff --git a/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/.project b/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/bin/DeSerializationDemo.class b/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/bin/DeSerializationDemo.class new file mode 100644 index 000000000..399f607e9 Binary files /dev/null and b/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/bin/DeSerializationDemo.class differ diff --git a/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/bin/Employee.class b/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/bin/Employee.class new file mode 100644 index 000000000..2169341db Binary files /dev/null and b/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/bin/Employee.class differ diff --git a/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/bin/Person.class b/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/bin/Person.class new file mode 100644 index 000000000..da17f05c3 Binary files /dev/null and b/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/bin/Person.class differ diff --git a/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/bin/SerializationDemo.class b/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/bin/SerializationDemo.class new file mode 100644 index 000000000..e78d4acce Binary files /dev/null and b/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/bin/SerializationDemo.class differ diff --git a/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/employee.tmp b/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/employee.tmp new file mode 100644 index 000000000..ad5cc2ad2 Binary files /dev/null and b/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/employee.tmp differ diff --git a/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/src/DeSerializationDemo.java b/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/src/DeSerializationDemo.java new file mode 100644 index 000000000..67fb2c1bf --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/src/DeSerializationDemo.java @@ -0,0 +1,55 @@ +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.ObjectInputStream; + +public class DeSerializationDemo +{ + + public static void main(String[] args) throws FileNotFoundException, + IOException, ClassNotFoundException + { + DeSerializationDemo deSerializationDemo = new DeSerializationDemo(); + deSerializationDemo.readEmployeeObject(); + } + + private void readEmployeeObject() throws IOException, + FileNotFoundException, ClassNotFoundException + { + FileInputStream fileInputStream = null; + ObjectInputStream objectInputStream = null; + + try + { + fileInputStream = new FileInputStream("employee.tmp"); + objectInputStream = new ObjectInputStream(fileInputStream); + + /* + * Read an object from the ObjectInputStream. + */ + Employee employee = (Employee) objectInputStream.readObject(); + + System.out + .println("Successfully read employee object from the file."); + + System.out.println("Name = " + employee.getName()); + System.out.println("Age = " + employee.getAge()); + System.out.println("Salary = " + employee.getSalary()); + } + finally + { + + if (objectInputStream != null) + { + /* + * Closing a ObjectInputStream will also + * close the InputStream instance from which + * the ObjectInputStream is reading. + */ + objectInputStream.close(); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/src/Employee.java b/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/src/Employee.java new file mode 100644 index 000000000..99f424672 --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/src/Employee.java @@ -0,0 +1,29 @@ +/* + * We can serialize the Employee class object that + * extends the Person class which is Serializable.Parent + * class properties are inherited to subclasses so if + * parent class is Serializable, subclass would also be. + */ +public class Employee extends Person +{ + + private static final long serialVersionUID = 312396230370712755L; + private int salary; + + public Employee(String name, int age, int salary) + { + super(name, age); + this.salary = salary; + } + + public int getSalary() + { + return salary; + } + + public void setSalary(int salary) + { + this.salary = salary; + } + +} \ No newline at end of file diff --git a/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/src/Person.java b/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/src/Person.java new file mode 100644 index 000000000..f0c37d9e1 --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/src/Person.java @@ -0,0 +1,41 @@ +import java.io.Serializable; + +/* + * If a class implements serializable then all its sub + * classes will also be serializable. + */ +public class Person implements Serializable +{ + + private static final long serialVersionUID = -7438582605700356851L; + protected String name; + protected int age; + + public Person(String name, int age) + { + super(); + this.name = name; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + +} diff --git a/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/src/SerializationDemo.java b/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/src/SerializationDemo.java new file mode 100644 index 000000000..fe636c9ed --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/JavaIODemo/src/SerializationDemo.java @@ -0,0 +1,52 @@ +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; + +public class SerializationDemo +{ + + public static void main(String[] args) throws FileNotFoundException, + IOException, ClassNotFoundException + { + SerializationDemo serializationDemo = new SerializationDemo(); + serializationDemo.writeEmployeeObject(); + } + + private void writeEmployeeObject() throws FileNotFoundException, + IOException + { + FileOutputStream fileOutputStream = null; + ObjectOutputStream objectOutputStream = null; + try + { + fileOutputStream = new FileOutputStream("employee.tmp"); + objectOutputStream = new ObjectOutputStream(fileOutputStream); + + Employee employee = new Employee("Peter", 29, 80000); + + /* + * Write the specified object to the + * ObjectOutputStream. + */ + objectOutputStream.writeObject(employee); + System.out + .println("Successfully written employee object to the file.\n"); + } + finally + { + + if (objectOutputStream != null) + { + /* + * Closing a ObjectOutputStream will also + * close the OutputStream instance to which + * the ObjectOutputStream is writing. + */ + objectOutputStream.close(); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/SerializationDemo_Output.txt b/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/SerializationDemo_Output.txt new file mode 100644 index 000000000..76b231da1 --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_IS_A_Relationship_App/SerializationDemo_Output.txt @@ -0,0 +1,2 @@ +Successfully written employee object to the file. + diff --git a/BasicJava/JavaIODemo_Serialization_primitive_App/DeSerialization_Output.txt b/BasicJava/JavaIODemo_Serialization_primitive_App/DeSerialization_Output.txt new file mode 100644 index 000000000..0c22f81eb --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_primitive_App/DeSerialization_Output.txt @@ -0,0 +1,5 @@ +Successfully read primitive values from the file. + +intValue = 10 +doubleValue = 50.55 +booleanValue = true diff --git a/BasicJava/JavaIODemo_Serialization_primitive_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_Serialization_primitive_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_primitive_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_Serialization_primitive_App/JavaIODemo/.project b/BasicJava/JavaIODemo_Serialization_primitive_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_primitive_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_Serialization_primitive_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_Serialization_primitive_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_primitive_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_Serialization_primitive_App/JavaIODemo/bin/DeSerialization.class b/BasicJava/JavaIODemo_Serialization_primitive_App/JavaIODemo/bin/DeSerialization.class new file mode 100644 index 000000000..f896b80d1 Binary files /dev/null and b/BasicJava/JavaIODemo_Serialization_primitive_App/JavaIODemo/bin/DeSerialization.class differ diff --git a/BasicJava/JavaIODemo_Serialization_primitive_App/JavaIODemo/bin/Serialization.class b/BasicJava/JavaIODemo_Serialization_primitive_App/JavaIODemo/bin/Serialization.class new file mode 100644 index 000000000..379a3291f Binary files /dev/null and b/BasicJava/JavaIODemo_Serialization_primitive_App/JavaIODemo/bin/Serialization.class differ diff --git a/BasicJava/JavaIODemo_Serialization_primitive_App/JavaIODemo/myfile.txt b/BasicJava/JavaIODemo_Serialization_primitive_App/JavaIODemo/myfile.txt new file mode 100644 index 000000000..5ccb9ccbd Binary files /dev/null and b/BasicJava/JavaIODemo_Serialization_primitive_App/JavaIODemo/myfile.txt differ diff --git a/BasicJava/JavaIODemo_Serialization_primitive_App/JavaIODemo/src/DeSerialization.java b/BasicJava/JavaIODemo_Serialization_primitive_App/JavaIODemo/src/DeSerialization.java new file mode 100644 index 000000000..3f9c84235 --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_primitive_App/JavaIODemo/src/DeSerialization.java @@ -0,0 +1,55 @@ +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.ObjectInputStream; + +public class DeSerialization +{ + + public static void main(String[] args) throws FileNotFoundException, + IOException, ClassNotFoundException + { + DeSerialization deSerialization = new DeSerialization(); + deSerialization.readPrimitiveValues(); + } + + private void readPrimitiveValues() throws IOException, + FileNotFoundException, ClassNotFoundException + { + FileInputStream fileInputStream = null; + ObjectInputStream objectInputStream = null; + + try + { + fileInputStream = new FileInputStream("myfile.txt"); + objectInputStream = new ObjectInputStream(fileInputStream); + + System.out + .println("Successfully read primitive values from the file.\n"); + + int intValue = objectInputStream.readInt(); + double doubleValue = objectInputStream.readDouble(); + boolean booleanValue = objectInputStream.readBoolean(); + + System.out.println("intValue = " + intValue); + System.out.println("doubleValue = " + doubleValue); + System.out.println("booleanValue = " + booleanValue); + + } + finally + { + + if (objectInputStream != null) + { + /* + * Closing a ObjectInputStream will also + * close the InputStream instance from which + * the ObjectInputStream is reading. + */ + objectInputStream.close(); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_Serialization_primitive_App/JavaIODemo/src/Serialization.java b/BasicJava/JavaIODemo_Serialization_primitive_App/JavaIODemo/src/Serialization.java new file mode 100644 index 000000000..c06664ab2 --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_primitive_App/JavaIODemo/src/Serialization.java @@ -0,0 +1,49 @@ +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; + +public class Serialization +{ + + public static void main(String[] args) throws FileNotFoundException, + IOException, ClassNotFoundException + { + Serialization serialization = new Serialization(); + serialization.writePrimitiveValues(); + } + + private void writePrimitiveValues() throws FileNotFoundException, + IOException + { + FileOutputStream fileOutputStream = null; + ObjectOutputStream objectOutputStream = null; + try + { + fileOutputStream = new FileOutputStream("myfile.txt"); + objectOutputStream = new ObjectOutputStream(fileOutputStream); + + objectOutputStream.writeInt(10); + objectOutputStream.writeDouble(50.55); + objectOutputStream.writeBoolean(true); + + System.out + .println("Successfully written primitive values to the file.\n"); + } + finally + { + + if (objectOutputStream != null) + { + /* + * Closing a ObjectOutputStream will also + * close the OutputStream instance to which + * the ObjectOutputStream is writing. + */ + objectOutputStream.close(); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_Serialization_primitive_App/Serialization_Output.txt b/BasicJava/JavaIODemo_Serialization_primitive_App/Serialization_Output.txt new file mode 100644 index 000000000..d35281c7f --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_primitive_App/Serialization_Output.txt @@ -0,0 +1,2 @@ +Successfully written primitive values to the file. + diff --git a/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/DeSerialization_Output.txt b/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/DeSerialization_Output.txt new file mode 100644 index 000000000..5bfd718fe --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/DeSerialization_Output.txt @@ -0,0 +1,4 @@ +Successfully read employee object from the file. + +Id = 101 +Name = Peter diff --git a/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/JavaIODemo/.project b/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/JavaIODemo/bin/DeSerialization.class b/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/JavaIODemo/bin/DeSerialization.class new file mode 100644 index 000000000..8042e5dec Binary files /dev/null and b/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/JavaIODemo/bin/DeSerialization.class differ diff --git a/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/JavaIODemo/bin/Employee.class b/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/JavaIODemo/bin/Employee.class new file mode 100644 index 000000000..f969c50d1 Binary files /dev/null and b/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/JavaIODemo/bin/Employee.class differ diff --git a/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/JavaIODemo/bin/Serialization.class b/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/JavaIODemo/bin/Serialization.class new file mode 100644 index 000000000..43b9ea09b Binary files /dev/null and b/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/JavaIODemo/bin/Serialization.class differ diff --git a/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/JavaIODemo/employee.ser b/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/JavaIODemo/employee.ser new file mode 100644 index 000000000..90b0483fc Binary files /dev/null and b/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/JavaIODemo/employee.ser differ diff --git a/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/JavaIODemo/src/DeSerialization.java b/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/JavaIODemo/src/DeSerialization.java new file mode 100644 index 000000000..7da0db6a1 --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/JavaIODemo/src/DeSerialization.java @@ -0,0 +1,54 @@ +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.ObjectInputStream; + +public class DeSerialization +{ + + public static void main(String[] args) throws FileNotFoundException, + IOException, ClassNotFoundException + { + DeSerialization deSerialization = new DeSerialization(); + deSerialization.readEmployeeObject(); + } + + private void readEmployeeObject() throws IOException, + FileNotFoundException, ClassNotFoundException + { + FileInputStream fileInputStream = null; + ObjectInputStream objectInputStream = null; + + try + { + fileInputStream = new FileInputStream("employee.ser"); + objectInputStream = new ObjectInputStream(fileInputStream); + + /* + * Read an object from the ObjectInputStream. + */ + Employee employee = (Employee) objectInputStream.readObject(); + System.out + .println("Successfully read employee object from the file.\n"); + + System.out.println("Id = " + employee.getId()); + System.out.println("Name = " + employee.getName()); + + } + finally + { + + if (objectInputStream != null) + { + /* + * Closing a ObjectInputStream will also + * close the InputStream instance from which + * the ObjectInputStream is reading. + */ + objectInputStream.close(); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/JavaIODemo/src/Employee.java b/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/JavaIODemo/src/Employee.java new file mode 100644 index 000000000..bfe158fde --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/JavaIODemo/src/Employee.java @@ -0,0 +1,36 @@ +import java.io.Serializable; + +public class Employee implements Serializable +{ + private static final long serialVersionUID = 4676072847340124979L; + private int id; + private String name; + + public Employee(int id, String name) + { + super(); + this.id = id; + this.name = name; + } + + public int getId() + { + return id; + } + + public void setId(int id) + { + this.id = id; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + +} \ No newline at end of file diff --git a/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/JavaIODemo/src/Serialization.java b/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/JavaIODemo/src/Serialization.java new file mode 100644 index 000000000..696f1f10b --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/JavaIODemo/src/Serialization.java @@ -0,0 +1,52 @@ +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; + +public class Serialization +{ + + public static void main(String[] args) throws FileNotFoundException, + IOException, ClassNotFoundException + { + Serialization serialization = new Serialization(); + serialization.writeEmployeeObject(); + } + + private void writeEmployeeObject() throws FileNotFoundException, + IOException + { + FileOutputStream fileOutputStream = null; + ObjectOutputStream objectOutputStream = null; + try + { + fileOutputStream = new FileOutputStream("employee.ser"); + objectOutputStream = new ObjectOutputStream(fileOutputStream); + + Employee employee = new Employee(101, "Peter"); + + /* + * Write the specified object to the + * ObjectOutputStream. + */ + objectOutputStream.writeObject(employee); + System.out + .println("Successfully written employee object to the file.\n"); + } + finally + { + + if (objectOutputStream != null) + { + /* + * Closing a ObjectOutputStream will also + * close the OutputStream instance to which + * the ObjectOutputStream is writing. + */ + objectOutputStream.close(); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/Serialization_Output.txt b/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/Serialization_Output.txt new file mode 100644 index 000000000..76b231da1 --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_serialVersionUID_App/Serialization_Output.txt @@ -0,0 +1,2 @@ +Successfully written employee object to the file. + diff --git a/BasicJava/JavaIODemo_Serialization_transient_App/DeSerializationDemo_Output.txt b/BasicJava/JavaIODemo_Serialization_transient_App/DeSerializationDemo_Output.txt new file mode 100644 index 000000000..bfa9f561f --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_transient_App/DeSerializationDemo_Output.txt @@ -0,0 +1,4 @@ +Successfully read employee object from the file. +Id = 101 +Name = Peter +Age = 0 diff --git a/BasicJava/JavaIODemo_Serialization_transient_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_Serialization_transient_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_transient_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_Serialization_transient_App/JavaIODemo/.project b/BasicJava/JavaIODemo_Serialization_transient_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_transient_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_Serialization_transient_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_Serialization_transient_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_transient_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_Serialization_transient_App/JavaIODemo/bin/DeSerializationDemo.class b/BasicJava/JavaIODemo_Serialization_transient_App/JavaIODemo/bin/DeSerializationDemo.class new file mode 100644 index 000000000..b8e05d5a5 Binary files /dev/null and b/BasicJava/JavaIODemo_Serialization_transient_App/JavaIODemo/bin/DeSerializationDemo.class differ diff --git a/BasicJava/JavaIODemo_Serialization_transient_App/JavaIODemo/bin/Employee.class b/BasicJava/JavaIODemo_Serialization_transient_App/JavaIODemo/bin/Employee.class new file mode 100644 index 000000000..47910d853 Binary files /dev/null and b/BasicJava/JavaIODemo_Serialization_transient_App/JavaIODemo/bin/Employee.class differ diff --git a/BasicJava/JavaIODemo_Serialization_transient_App/JavaIODemo/bin/SerializationDemo.class b/BasicJava/JavaIODemo_Serialization_transient_App/JavaIODemo/bin/SerializationDemo.class new file mode 100644 index 000000000..88ce002f1 Binary files /dev/null and b/BasicJava/JavaIODemo_Serialization_transient_App/JavaIODemo/bin/SerializationDemo.class differ diff --git a/BasicJava/JavaIODemo_Serialization_transient_App/JavaIODemo/employee.txt b/BasicJava/JavaIODemo_Serialization_transient_App/JavaIODemo/employee.txt new file mode 100644 index 000000000..68a5e6a06 Binary files /dev/null and b/BasicJava/JavaIODemo_Serialization_transient_App/JavaIODemo/employee.txt differ diff --git a/BasicJava/JavaIODemo_Serialization_transient_App/JavaIODemo/src/DeSerializationDemo.java b/BasicJava/JavaIODemo_Serialization_transient_App/JavaIODemo/src/DeSerializationDemo.java new file mode 100644 index 000000000..ed2cf324a --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_transient_App/JavaIODemo/src/DeSerializationDemo.java @@ -0,0 +1,60 @@ +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.ObjectInputStream; + +public class DeSerializationDemo +{ + + public static void main(String[] args) throws FileNotFoundException, + IOException, ClassNotFoundException + { + DeSerializationDemo deSerializationDemo = new DeSerializationDemo(); + deSerializationDemo.readEmployeeObject(); + } + + private void readEmployeeObject() throws IOException, + FileNotFoundException, ClassNotFoundException + { + FileInputStream fileInputStream = null; + ObjectInputStream objectInputStream = null; + + try + { + fileInputStream = new FileInputStream("employee.txt"); + objectInputStream = new ObjectInputStream(fileInputStream); + + /* + * Read an object from the ObjectInputStream. + */ + Employee employee = (Employee) objectInputStream.readObject(); + + System.out + .println("Successfully read employee object from the file."); + + System.out.println("Id = " + employee.getId()); + System.out.println("Name = " + employee.getName()); + /* + * If you deserialize the object, you will get + * the default value for transient variable,So + * for age we will get 0 + */ + System.out.println("Age = " + employee.getAge()); + } + finally + { + + if (objectInputStream != null) + { + /* + * Closing a ObjectInputStream will also + * close the InputStream instance from which + * the ObjectInputStream is reading. + */ + objectInputStream.close(); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_Serialization_transient_App/JavaIODemo/src/Employee.java b/BasicJava/JavaIODemo_Serialization_transient_App/JavaIODemo/src/Employee.java new file mode 100644 index 000000000..abd15699b --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_transient_App/JavaIODemo/src/Employee.java @@ -0,0 +1,52 @@ +import java.io.Serializable; + +public class Employee implements Serializable +{ + private static final long serialVersionUID = 765764534241652904L; + private int id; + private String name; + /* + * If we don't want to serialize any data member of a + * class, you can mark it as transient. + */ + private transient int age; + + public Employee(int id, String name, int age) + { + super(); + this.id = id; + this.name = name; + this.age = age; + } + + public int getId() + { + return id; + } + + public void setId(int id) + { + this.id = id; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + +} \ No newline at end of file diff --git a/BasicJava/JavaIODemo_Serialization_transient_App/JavaIODemo/src/SerializationDemo.java b/BasicJava/JavaIODemo_Serialization_transient_App/JavaIODemo/src/SerializationDemo.java new file mode 100644 index 000000000..10da60f06 --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_transient_App/JavaIODemo/src/SerializationDemo.java @@ -0,0 +1,56 @@ +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; + +public class SerializationDemo +{ + + public static void main(String[] args) throws FileNotFoundException, + IOException, ClassNotFoundException + { + SerializationDemo serializationDemo = new SerializationDemo(); + serializationDemo.writeEmployeeObject(); + } + + private void writeEmployeeObject() throws FileNotFoundException, + IOException + { + FileOutputStream fileOutputStream = null; + ObjectOutputStream objectOutputStream = null; + try + { + fileOutputStream = new FileOutputStream("employee.txt"); + objectOutputStream = new ObjectOutputStream(fileOutputStream); + + Employee employee = new Employee(101, "Peter", 32); + + System.out.println("Id = " + employee.getId()); + System.out.println("Name = " + employee.getName()); + System.out.println("Age = " + employee.getAge()); + + /* + * Write the specified object to the + * ObjectOutputStream. + */ + objectOutputStream.writeObject(employee); + System.out + .println("Successfully written employee object to the file.\n"); + } + finally + { + + if (objectOutputStream != null) + { + /* + * Closing a ObjectOutputStream will also + * close the OutputStream instance to which + * the ObjectOutputStream is writing. + */ + objectOutputStream.close(); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_Serialization_transient_App/SerializationDemo_Output.txt b/BasicJava/JavaIODemo_Serialization_transient_App/SerializationDemo_Output.txt new file mode 100644 index 000000000..46008447b --- /dev/null +++ b/BasicJava/JavaIODemo_Serialization_transient_App/SerializationDemo_Output.txt @@ -0,0 +1,5 @@ +Id = 101 +Name = Peter +Age = 32 +Successfully written employee object to the file. + diff --git a/BasicJava/JavaIODemo_StreamTokenizerDemo_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_StreamTokenizerDemo_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_StreamTokenizerDemo_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_StreamTokenizerDemo_App/JavaIODemo/.project b/BasicJava/JavaIODemo_StreamTokenizerDemo_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_StreamTokenizerDemo_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_StreamTokenizerDemo_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_StreamTokenizerDemo_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_StreamTokenizerDemo_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_StreamTokenizerDemo_App/JavaIODemo/bin/StreamTokenizerDemo.class b/BasicJava/JavaIODemo_StreamTokenizerDemo_App/JavaIODemo/bin/StreamTokenizerDemo.class new file mode 100644 index 000000000..28f81255c Binary files /dev/null and b/BasicJava/JavaIODemo_StreamTokenizerDemo_App/JavaIODemo/bin/StreamTokenizerDemo.class differ diff --git a/BasicJava/JavaIODemo_StreamTokenizerDemo_App/JavaIODemo/src/StreamTokenizerDemo.java b/BasicJava/JavaIODemo_StreamTokenizerDemo_App/JavaIODemo/src/StreamTokenizerDemo.java new file mode 100644 index 000000000..3a803dca1 --- /dev/null +++ b/BasicJava/JavaIODemo_StreamTokenizerDemo_App/JavaIODemo/src/StreamTokenizerDemo.java @@ -0,0 +1,31 @@ +import java.io.IOException; +import java.io.StreamTokenizer; +import java.io.StringReader; + +public class StreamTokenizerDemo +{ + + public static void main(String[] args) throws IOException + { + StreamTokenizer streamTokenizer = null; + StringReader stringReader = new StringReader("Peter had 1 pen."); + + streamTokenizer = new StreamTokenizer(stringReader); + + while (streamTokenizer.nextToken() != StreamTokenizer.TT_EOF) + { + + if (streamTokenizer.ttype == StreamTokenizer.TT_WORD) + { + System.out.println("Inside TT_Word = " + streamTokenizer.sval); + } + else if (streamTokenizer.ttype == StreamTokenizer.TT_NUMBER) + { + System.out + .println("Inside TT_NUMBER = " + streamTokenizer.nval); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_StreamTokenizerDemo_App/Output.txt b/BasicJava/JavaIODemo_StreamTokenizerDemo_App/Output.txt new file mode 100644 index 000000000..b7af970dd --- /dev/null +++ b/BasicJava/JavaIODemo_StreamTokenizerDemo_App/Output.txt @@ -0,0 +1,4 @@ +Inside TT_Word = Peter +Inside TT_Word = had +Inside TT_NUMBER = 1.0 +Inside TT_Word = pen. diff --git a/BasicJava/JavaIODemo_StreamTokenizerDemo_file_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_StreamTokenizerDemo_file_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_StreamTokenizerDemo_file_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_StreamTokenizerDemo_file_App/JavaIODemo/.project b/BasicJava/JavaIODemo_StreamTokenizerDemo_file_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_StreamTokenizerDemo_file_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_StreamTokenizerDemo_file_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_StreamTokenizerDemo_file_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_StreamTokenizerDemo_file_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_StreamTokenizerDemo_file_App/JavaIODemo/bin/StreamTokenizerDemo.class b/BasicJava/JavaIODemo_StreamTokenizerDemo_file_App/JavaIODemo/bin/StreamTokenizerDemo.class new file mode 100644 index 000000000..848212717 Binary files /dev/null and b/BasicJava/JavaIODemo_StreamTokenizerDemo_file_App/JavaIODemo/bin/StreamTokenizerDemo.class differ diff --git a/BasicJava/JavaIODemo_StreamTokenizerDemo_file_App/JavaIODemo/myfile.txt b/BasicJava/JavaIODemo_StreamTokenizerDemo_file_App/JavaIODemo/myfile.txt new file mode 100644 index 000000000..bacbb0ef7 --- /dev/null +++ b/BasicJava/JavaIODemo_StreamTokenizerDemo_file_App/JavaIODemo/myfile.txt @@ -0,0 +1,2 @@ +Hello, How are you peter? +Shall we go to India. 2+2=4 diff --git a/BasicJava/JavaIODemo_StreamTokenizerDemo_file_App/JavaIODemo/src/StreamTokenizerDemo.java b/BasicJava/JavaIODemo_StreamTokenizerDemo_file_App/JavaIODemo/src/StreamTokenizerDemo.java new file mode 100644 index 000000000..3bbfc551f --- /dev/null +++ b/BasicJava/JavaIODemo_StreamTokenizerDemo_file_App/JavaIODemo/src/StreamTokenizerDemo.java @@ -0,0 +1,74 @@ +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import java.io.StreamTokenizer; + +public class StreamTokenizerDemo +{ + + public static void main(String[] args) throws IOException + { + FileReader fileReader = null; + BufferedReader bufferedReader = null; + try + { + fileReader = new FileReader("myfile.txt"); + bufferedReader = new BufferedReader(fileReader); + StreamTokenizer st = new StreamTokenizer(bufferedReader); + + // print the stream tokens + boolean eof = false; + do + { + /* + * Parses the next token from the input + * stream of this tokenizer. The type of the + * next token is returned in the ttype + * field. Additional information about the + * token may be in the nval field or the + * sval field of this tokenizer. + * + * Typical clients of this class first set + * up the syntax tables and then sit in a + * loop calling nextToken to parse + * successive tokens until TT_EOF is + * returned. + */ + int token = st.nextToken(); + switch (token) + { + case StreamTokenizer.TT_EOF: + System.out.println("End of File encountered."); + eof = true; + break; + case StreamTokenizer.TT_EOL: + System.out.println("End of Line encountered."); + System.out.println("Line Number:" + st.lineno()); + break; + case StreamTokenizer.TT_WORD: + System.out.println("Word: " + st.sval); + break; + case StreamTokenizer.TT_NUMBER: + System.out.println("Number: " + st.nval); + break; + default: + System.out.println((char) token + " encountered."); + if (token == '!') + { + eof = true; + } + } + } + while (!eof); + } + finally + { + if (bufferedReader != null) + { + bufferedReader.close(); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_StreamTokenizerDemo_file_App/Output.txt b/BasicJava/JavaIODemo_StreamTokenizerDemo_file_App/Output.txt new file mode 100644 index 000000000..1d21ff857 --- /dev/null +++ b/BasicJava/JavaIODemo_StreamTokenizerDemo_file_App/Output.txt @@ -0,0 +1,18 @@ +Word: Hello +, encountered. +Word: How +Word: are +Word: you +Word: peter +? encountered. +Word: Shall +Word: we +Word: go +Word: to +Word: India. +Number: 2.0 ++ encountered. +Number: 2.0 += encountered. +Number: 4.0 +End of File encountered. diff --git a/BasicJava/JavaIODemo_StreamTokenizerDemo_word_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_StreamTokenizerDemo_word_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_StreamTokenizerDemo_word_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_StreamTokenizerDemo_word_App/JavaIODemo/.project b/BasicJava/JavaIODemo_StreamTokenizerDemo_word_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_StreamTokenizerDemo_word_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_StreamTokenizerDemo_word_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_StreamTokenizerDemo_word_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_StreamTokenizerDemo_word_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_StreamTokenizerDemo_word_App/JavaIODemo/bin/StreamTokenizerDemo.class b/BasicJava/JavaIODemo_StreamTokenizerDemo_word_App/JavaIODemo/bin/StreamTokenizerDemo.class new file mode 100644 index 000000000..ba2f6f7da Binary files /dev/null and b/BasicJava/JavaIODemo_StreamTokenizerDemo_word_App/JavaIODemo/bin/StreamTokenizerDemo.class differ diff --git a/BasicJava/JavaIODemo_StreamTokenizerDemo_word_App/JavaIODemo/src/StreamTokenizerDemo.java b/BasicJava/JavaIODemo_StreamTokenizerDemo_word_App/JavaIODemo/src/StreamTokenizerDemo.java new file mode 100644 index 000000000..15db0a8ae --- /dev/null +++ b/BasicJava/JavaIODemo_StreamTokenizerDemo_word_App/JavaIODemo/src/StreamTokenizerDemo.java @@ -0,0 +1,26 @@ +import java.io.IOException; +import java.io.StreamTokenizer; +import java.io.StringReader; + +public class StreamTokenizerDemo +{ + + public static void main(String[] args) throws IOException + { + StringReader stringReader = new StringReader("Peter welcome to India"); + StreamTokenizer tokenizer = new StreamTokenizer(stringReader); + /* + * TT_EOL is used to determine end of line + */ + while (tokenizer.nextToken() != StreamTokenizer.TT_EOF) + { + /* + * sval-The string value of the token, if the + * token was a string (word) + */ + System.out.println(tokenizer.sval); + } + + } + +} diff --git a/BasicJava/JavaIODemo_StreamTokenizerDemo_word_App/Output.txt b/BasicJava/JavaIODemo_StreamTokenizerDemo_word_App/Output.txt new file mode 100644 index 000000000..79458a131 --- /dev/null +++ b/BasicJava/JavaIODemo_StreamTokenizerDemo_word_App/Output.txt @@ -0,0 +1,4 @@ +Peter +welcome +to +India diff --git a/BasicJava/JavaIODemo_StringReader_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_StringReader_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_StringReader_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_StringReader_App/JavaIODemo/.project b/BasicJava/JavaIODemo_StringReader_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_StringReader_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_StringReader_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_StringReader_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_StringReader_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_StringReader_App/JavaIODemo/bin/StringReaderDemo.class b/BasicJava/JavaIODemo_StringReader_App/JavaIODemo/bin/StringReaderDemo.class new file mode 100644 index 000000000..3f6c616a4 Binary files /dev/null and b/BasicJava/JavaIODemo_StringReader_App/JavaIODemo/bin/StringReaderDemo.class differ diff --git a/BasicJava/JavaIODemo_StringReader_App/JavaIODemo/src/StringReaderDemo.java b/BasicJava/JavaIODemo_StringReader_App/JavaIODemo/src/StringReaderDemo.java new file mode 100644 index 000000000..fc71e8281 --- /dev/null +++ b/BasicJava/JavaIODemo_StringReader_App/JavaIODemo/src/StringReaderDemo.java @@ -0,0 +1,29 @@ +import java.io.StringReader; + +public class StringReaderDemo +{ + + public static void main(String[] args) throws Exception + { + StringReader stringReader = null; + try + { + String str = "Hello"; + stringReader = new StringReader(str); + + int data; + while ((data = stringReader.read()) != -1) + { + System.out.print((char) data); + } + + } + finally + { + if (stringReader != null) + { + stringReader.close(); + } + } + } +} \ No newline at end of file diff --git a/BasicJava/JavaIODemo_StringReader_App/Output.txt b/BasicJava/JavaIODemo_StringReader_App/Output.txt new file mode 100644 index 000000000..5ab2f8a43 --- /dev/null +++ b/BasicJava/JavaIODemo_StringReader_App/Output.txt @@ -0,0 +1 @@ +Hello \ No newline at end of file diff --git a/BasicJava/JavaIODemo_StringWriter_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_StringWriter_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_StringWriter_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_StringWriter_App/JavaIODemo/.project b/BasicJava/JavaIODemo_StringWriter_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_StringWriter_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_StringWriter_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_StringWriter_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_StringWriter_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_StringWriter_App/JavaIODemo/bin/StringWriterDemo.class b/BasicJava/JavaIODemo_StringWriter_App/JavaIODemo/bin/StringWriterDemo.class new file mode 100644 index 000000000..896185ab2 Binary files /dev/null and b/BasicJava/JavaIODemo_StringWriter_App/JavaIODemo/bin/StringWriterDemo.class differ diff --git a/BasicJava/JavaIODemo_StringWriter_App/JavaIODemo/src/StringWriterDemo.java b/BasicJava/JavaIODemo_StringWriter_App/JavaIODemo/src/StringWriterDemo.java new file mode 100644 index 000000000..38b38b3ed --- /dev/null +++ b/BasicJava/JavaIODemo_StringWriter_App/JavaIODemo/src/StringWriterDemo.java @@ -0,0 +1,42 @@ +import java.io.StringWriter; + +public class StringWriterDemo +{ + + public static void main(String[] args) throws Exception + { + StringWriter stringWriter = null; + try + { + /* + * Create a new string writer using the default + * initial string-buffer size. + */ + stringWriter = new StringWriter(); + + // write characters to writer. + stringWriter.write("Welcome to India"); + + /* + * Return the buffer's current value as a + * string. + */ + String str = stringWriter.toString(); + System.out.println("str = " + str); + /* + * Returns: StringBuffer holding the current + * buffer value. + */ + StringBuffer sb = stringWriter.getBuffer(); + System.out.println("sb = " + sb); + + } + finally + { + if (stringWriter != null) + { + stringWriter.close(); + } + } + } +} \ No newline at end of file diff --git a/BasicJava/JavaIODemo_StringWriter_App/Output.txt b/BasicJava/JavaIODemo_StringWriter_App/Output.txt new file mode 100644 index 000000000..9a647f4dc --- /dev/null +++ b/BasicJava/JavaIODemo_StringWriter_App/Output.txt @@ -0,0 +1,2 @@ +str = Welcome to India +sb = Welcome to India diff --git a/BasicJava/JavaIODemo_StringWriter_Cons_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_StringWriter_Cons_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_StringWriter_Cons_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_StringWriter_Cons_App/JavaIODemo/.project b/BasicJava/JavaIODemo_StringWriter_Cons_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_StringWriter_Cons_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_StringWriter_Cons_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_StringWriter_Cons_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_StringWriter_Cons_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_StringWriter_Cons_App/JavaIODemo/bin/StringWriterDemo.class b/BasicJava/JavaIODemo_StringWriter_Cons_App/JavaIODemo/bin/StringWriterDemo.class new file mode 100644 index 000000000..a1536ee12 Binary files /dev/null and b/BasicJava/JavaIODemo_StringWriter_Cons_App/JavaIODemo/bin/StringWriterDemo.class differ diff --git a/BasicJava/JavaIODemo_StringWriter_Cons_App/JavaIODemo/src/StringWriterDemo.java b/BasicJava/JavaIODemo_StringWriter_Cons_App/JavaIODemo/src/StringWriterDemo.java new file mode 100644 index 000000000..796f13bc6 --- /dev/null +++ b/BasicJava/JavaIODemo_StringWriter_Cons_App/JavaIODemo/src/StringWriterDemo.java @@ -0,0 +1,52 @@ +import java.io.StringWriter; + +/* + * public StringWriter(int initialSize) + * + * Parameters: + * ---------- + * + * initialSize - The number of char values that will fit + * into this buffer before it is automatically expanded + */ + +public class StringWriterDemo +{ + + public static void main(String[] args) throws Exception + { + StringWriter stringWriter = null; + try + { + /* + * Create a new string writer using the + * specified initial string-buffer size. + */ + stringWriter = new StringWriter(32); + + // write characters to writer. + stringWriter.write("Welcome to India"); + + /* + * Return the buffer's current value as a + * string. + */ + String str = stringWriter.toString(); + System.out.println("str = " + str); + /* + * Returns: StringBuffer holding the current + * buffer value. + */ + StringBuffer sb = stringWriter.getBuffer(); + System.out.println("sb = " + sb); + + } + finally + { + if (stringWriter != null) + { + stringWriter.close(); + } + } + } +} \ No newline at end of file diff --git a/BasicJava/JavaIODemo_StringWriter_Cons_App/Output.txt b/BasicJava/JavaIODemo_StringWriter_Cons_App/Output.txt new file mode 100644 index 000000000..9a647f4dc --- /dev/null +++ b/BasicJava/JavaIODemo_StringWriter_Cons_App/Output.txt @@ -0,0 +1,2 @@ +str = Welcome to India +sb = Welcome to India diff --git a/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/ExternalizableRead_Output.txt b/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/ExternalizableRead_Output.txt new file mode 100644 index 000000000..a1107b68c --- /dev/null +++ b/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/ExternalizableRead_Output.txt @@ -0,0 +1,6 @@ +Inside readExternal method of Employee. +Inside readExternal method of Person. +Successfully read employee object from the file. + +After DeSerializing. +Employee [getId()=101, getName()=Peter, getAge()=25, getHeight()=4.7, getWeight()=60.0] diff --git a/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/ExternalizableWrite_Output.txt b/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/ExternalizableWrite_Output.txt new file mode 100644 index 000000000..678acd5db --- /dev/null +++ b/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/ExternalizableWrite_Output.txt @@ -0,0 +1,6 @@ +Before Serializing. +Employee [getId()=101, getName()=Peter, getAge()=25, getHeight()=4.7, getWeight()=60.0] +Inside writeExternal method of Employee. +Inside writeExternal method of Person. +Successfully written employee object to the file. + diff --git a/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/.project b/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/bin/Employee.class b/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/bin/Employee.class new file mode 100644 index 000000000..476a4ca06 Binary files /dev/null and b/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/bin/Employee.class differ diff --git a/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/bin/ExternalizableRead.class b/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/bin/ExternalizableRead.class new file mode 100644 index 000000000..fb8447d70 Binary files /dev/null and b/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/bin/ExternalizableRead.class differ diff --git a/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/bin/ExternalizableWrite.class b/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/bin/ExternalizableWrite.class new file mode 100644 index 000000000..340922696 Binary files /dev/null and b/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/bin/ExternalizableWrite.class differ diff --git a/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/bin/Person.class b/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/bin/Person.class new file mode 100644 index 000000000..4c6d1ac0f Binary files /dev/null and b/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/bin/Person.class differ diff --git a/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/employee.ser b/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/employee.ser new file mode 100644 index 000000000..9781e4352 Binary files /dev/null and b/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/employee.ser differ diff --git a/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/src/Employee.java b/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/src/Employee.java new file mode 100644 index 000000000..e383f287e --- /dev/null +++ b/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/src/Employee.java @@ -0,0 +1,65 @@ +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; + +public class Employee extends Person implements Externalizable +{ + private int id; + private String name; + + public Employee() + { + + } + + public int getId() + { + return id; + } + + public void setId(int id) + { + this.id = id; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + @Override + public String toString() + { + return "Employee [getId()=" + getId() + ", getName()=" + getName() + + ", getAge()=" + getAge() + ", getHeight()=" + getHeight() + + ", getWeight()=" + getWeight() + "]"; + } + + @Override + public void writeExternal(ObjectOutput out) throws IOException + { + System.out.println("Inside writeExternal method of Employee."); + super.writeExternal(out); + /* Employee class fields */ + out.writeInt(id); + out.writeObject(name); + } + + @Override + public void readExternal(ObjectInput in) throws IOException, + ClassNotFoundException + { + System.out.println("Inside readExternal method of Employee."); + super.readExternal(in); + /* Employee class fields */ + id = in.readInt(); + name = (String) in.readObject(); + } + +} \ No newline at end of file diff --git a/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/src/ExternalizableRead.java b/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/src/ExternalizableRead.java new file mode 100644 index 000000000..42e48158b --- /dev/null +++ b/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/src/ExternalizableRead.java @@ -0,0 +1,54 @@ +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.ObjectInputStream; + +public class ExternalizableRead +{ + + public static void main(String[] args) throws FileNotFoundException, + IOException, ClassNotFoundException + { + ExternalizableRead externalizableRead = new ExternalizableRead(); + externalizableRead.readEmployeeObject(); + } + + private void readEmployeeObject() throws IOException, + FileNotFoundException, ClassNotFoundException + { + FileInputStream fileInputStream = null; + ObjectInputStream objectInputStream = null; + //Deserialize + try + { + fileInputStream = new FileInputStream("employee.ser"); + objectInputStream = new ObjectInputStream(fileInputStream); + + /* + * Read an object from the ObjectInputStream. + */ + Employee employee = (Employee) objectInputStream.readObject(); + System.out + .println("Successfully read employee object from the file.\n"); + + System.out.println("After DeSerializing."); + System.out.println(employee.toString()); + + } + finally + { + + if (objectInputStream != null) + { + /* + * Closing a ObjectInputStream will also + * close the InputStream instance from which + * the ObjectInputStream is reading. + */ + objectInputStream.close(); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/src/ExternalizableWrite.java b/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/src/ExternalizableWrite.java new file mode 100644 index 000000000..8c02847ae --- /dev/null +++ b/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/src/ExternalizableWrite.java @@ -0,0 +1,61 @@ +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; + +public class ExternalizableWrite +{ + + public static void main(String[] args) throws FileNotFoundException, + IOException, ClassNotFoundException + { + ExternalizableWrite externalizableWrite = new ExternalizableWrite(); + externalizableWrite.writeEmployeeObject(); + } + + private void writeEmployeeObject() throws FileNotFoundException, + IOException + { + FileOutputStream fileOutputStream = null; + ObjectOutputStream objectOutputStream = null; + //Serialize + try + { + fileOutputStream = new FileOutputStream("employee.ser"); + objectOutputStream = new ObjectOutputStream(fileOutputStream); + + Employee employee = new Employee(); + employee.setId(101); + employee.setName("Peter"); + employee.setAge(25); + employee.setHeight(4.7d); + employee.setWeight(60d); + + System.out.println("Before Serializing."); + System.out.println(employee.toString()); + + /* + * Write the specified object to the + * ObjectOutputStream. + */ + objectOutputStream.writeObject(employee); + System.out + .println("Successfully written employee object to the file.\n"); + } + finally + { + + if (objectOutputStream != null) + { + /* + * Closing a ObjectOutputStream will also + * close the OutputStream instance to which + * the ObjectOutputStream is writing. + */ + objectOutputStream.close(); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/src/Person.java b/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/src/Person.java new file mode 100644 index 000000000..f25479984 --- /dev/null +++ b/BasicJava/JavaIODemo_SuperClass_Impl_Externalizable_App/JavaIODemo/src/Person.java @@ -0,0 +1,68 @@ +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; + +public class Person implements Externalizable +{ + private int age; + private double height; + private double weight; + + public Person() + { + + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + public double getHeight() + { + return height; + } + + public void setHeight(double height) + { + this.height = height; + } + + public double getWeight() + { + return weight; + } + + public void setWeight(double weight) + { + this.weight = weight; + } + + @Override + public void writeExternal(ObjectOutput out) throws IOException + { + System.out.println("Inside writeExternal method of Person."); + /* Person class fields */ + out.writeInt(age); + out.writeDouble(height); + out.writeDouble(weight); + } + + @Override + public void readExternal(ObjectInput in) throws IOException, + ClassNotFoundException + { + System.out.println("Inside readExternal method of Person."); + /* Person class fields */ + age = in.readInt(); + height = in.readDouble(); + weight = in.readDouble(); + } + +} diff --git a/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/ExternalizableRead_Output.txt b/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/ExternalizableRead_Output.txt new file mode 100644 index 000000000..ba3470eb9 --- /dev/null +++ b/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/ExternalizableRead_Output.txt @@ -0,0 +1,5 @@ +Inside readExternal +Successfully read employee object from the file. + +After DeSerializing. +Employee [getId()=101, getName()=Peter, getAge()=25, getHeight()=4.7, getWeight()=60.0] diff --git a/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/ExternalizableWrite_Output.txt b/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/ExternalizableWrite_Output.txt new file mode 100644 index 000000000..849a9a11b --- /dev/null +++ b/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/ExternalizableWrite_Output.txt @@ -0,0 +1,5 @@ +Before Serializing. +Employee [getId()=101, getName()=Peter, getAge()=25, getHeight()=4.7, getWeight()=60.0] +Inside writeExternal +Successfully written employee object to the file. + diff --git a/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/.project b/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/bin/Employee.class b/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/bin/Employee.class new file mode 100644 index 000000000..651da6b01 Binary files /dev/null and b/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/bin/Employee.class differ diff --git a/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/bin/ExternalizableRead.class b/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/bin/ExternalizableRead.class new file mode 100644 index 000000000..fb8447d70 Binary files /dev/null and b/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/bin/ExternalizableRead.class differ diff --git a/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/bin/ExternalizableWrite.class b/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/bin/ExternalizableWrite.class new file mode 100644 index 000000000..340922696 Binary files /dev/null and b/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/bin/ExternalizableWrite.class differ diff --git a/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/bin/Person.class b/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/bin/Person.class new file mode 100644 index 000000000..acd274c54 Binary files /dev/null and b/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/bin/Person.class differ diff --git a/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/employee.ser b/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/employee.ser new file mode 100644 index 000000000..a39777f3f Binary files /dev/null and b/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/employee.ser differ diff --git a/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/src/Employee.java b/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/src/Employee.java new file mode 100644 index 000000000..f475952c3 --- /dev/null +++ b/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/src/Employee.java @@ -0,0 +1,88 @@ +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; + +public class Employee extends Person implements Externalizable +{ + private int id; + private String name; + + public Employee() + { + + } + + public int getId() + { + return id; + } + + public void setId(int id) + { + this.id = id; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + @Override + public String toString() + { + return "Employee [getId()=" + getId() + ", getName()=" + getName() + + ", getAge()=" + getAge() + ", getHeight()=" + getHeight() + + ", getWeight()=" + getWeight() + "]"; + } + + @Override + public void writeExternal(ObjectOutput out) throws IOException + { + System.out.println("Inside writeExternal"); + + /* + * Since superclass does not implement + * externalizable, we need to serialize super class + * field in this class itself + * + * Person class[Super class] fields + */ + out.writeInt(super.getAge()); + out.writeDouble(super.getHeight()); + out.writeDouble(super.getWeight()); + + /* Employee class fields */ + out.writeInt(id); + out.writeObject(name); + } + + @Override + public void readExternal(ObjectInput in) throws IOException, + ClassNotFoundException + { + System.out.println("Inside readExternal"); + + /* + * Since superclass does not implement + * externalizable, we need to deserialize super + * class field in this class itself. + * + * Person class[Super class] fields. + */ + + super.setAge(in.readInt()); + super.setHeight(in.readDouble()); + super.setWeight(in.readDouble()); + + /* Employee class fields */ + id = in.readInt(); + name = (String) in.readObject(); + } + +} \ No newline at end of file diff --git a/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/src/ExternalizableRead.java b/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/src/ExternalizableRead.java new file mode 100644 index 000000000..42e48158b --- /dev/null +++ b/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/src/ExternalizableRead.java @@ -0,0 +1,54 @@ +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.ObjectInputStream; + +public class ExternalizableRead +{ + + public static void main(String[] args) throws FileNotFoundException, + IOException, ClassNotFoundException + { + ExternalizableRead externalizableRead = new ExternalizableRead(); + externalizableRead.readEmployeeObject(); + } + + private void readEmployeeObject() throws IOException, + FileNotFoundException, ClassNotFoundException + { + FileInputStream fileInputStream = null; + ObjectInputStream objectInputStream = null; + //Deserialize + try + { + fileInputStream = new FileInputStream("employee.ser"); + objectInputStream = new ObjectInputStream(fileInputStream); + + /* + * Read an object from the ObjectInputStream. + */ + Employee employee = (Employee) objectInputStream.readObject(); + System.out + .println("Successfully read employee object from the file.\n"); + + System.out.println("After DeSerializing."); + System.out.println(employee.toString()); + + } + finally + { + + if (objectInputStream != null) + { + /* + * Closing a ObjectInputStream will also + * close the InputStream instance from which + * the ObjectInputStream is reading. + */ + objectInputStream.close(); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/src/ExternalizableWrite.java b/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/src/ExternalizableWrite.java new file mode 100644 index 000000000..8c02847ae --- /dev/null +++ b/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/src/ExternalizableWrite.java @@ -0,0 +1,61 @@ +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; + +public class ExternalizableWrite +{ + + public static void main(String[] args) throws FileNotFoundException, + IOException, ClassNotFoundException + { + ExternalizableWrite externalizableWrite = new ExternalizableWrite(); + externalizableWrite.writeEmployeeObject(); + } + + private void writeEmployeeObject() throws FileNotFoundException, + IOException + { + FileOutputStream fileOutputStream = null; + ObjectOutputStream objectOutputStream = null; + //Serialize + try + { + fileOutputStream = new FileOutputStream("employee.ser"); + objectOutputStream = new ObjectOutputStream(fileOutputStream); + + Employee employee = new Employee(); + employee.setId(101); + employee.setName("Peter"); + employee.setAge(25); + employee.setHeight(4.7d); + employee.setWeight(60d); + + System.out.println("Before Serializing."); + System.out.println(employee.toString()); + + /* + * Write the specified object to the + * ObjectOutputStream. + */ + objectOutputStream.writeObject(employee); + System.out + .println("Successfully written employee object to the file.\n"); + } + finally + { + + if (objectOutputStream != null) + { + /* + * Closing a ObjectOutputStream will also + * close the OutputStream instance to which + * the ObjectOutputStream is writing. + */ + objectOutputStream.close(); + } + } + + } + +} diff --git a/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/src/Person.java b/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/src/Person.java new file mode 100644 index 000000000..5245a5c57 --- /dev/null +++ b/BasicJava/JavaIODemo_SuperClass_Not_Externalizable_App/JavaIODemo/src/Person.java @@ -0,0 +1,42 @@ +public class Person +{ + private int age; + private double height; + private double weight; + + public Person() + { + + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + public double getHeight() + { + return height; + } + + public void setHeight(double height) + { + this.height = height; + } + + public double getWeight() + { + return weight; + } + + public void setWeight(double weight) + { + this.weight = weight; + } + +} diff --git a/BasicJava/JavaIODemo_What_is_JAVAIO_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_What_is_JAVAIO_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_What_is_JAVAIO_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_What_is_JAVAIO_App/JavaIODemo/.project b/BasicJava/JavaIODemo_What_is_JAVAIO_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_What_is_JAVAIO_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_What_is_JAVAIO_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_What_is_JAVAIO_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_What_is_JAVAIO_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_What_is_JAVAIO_App/JavaIODemo/bin/JavaIODemo1.class b/BasicJava/JavaIODemo_What_is_JAVAIO_App/JavaIODemo/bin/JavaIODemo1.class new file mode 100644 index 000000000..bc2f70171 Binary files /dev/null and b/BasicJava/JavaIODemo_What_is_JAVAIO_App/JavaIODemo/bin/JavaIODemo1.class differ diff --git a/BasicJava/JavaIODemo_What_is_JAVAIO_App/JavaIODemo/bin/JavaIODemo2.class b/BasicJava/JavaIODemo_What_is_JAVAIO_App/JavaIODemo/bin/JavaIODemo2.class new file mode 100644 index 000000000..e8acce839 Binary files /dev/null and b/BasicJava/JavaIODemo_What_is_JAVAIO_App/JavaIODemo/bin/JavaIODemo2.class differ diff --git a/BasicJava/JavaIODemo_What_is_JAVAIO_App/JavaIODemo/src/JavaIODemo1.java b/BasicJava/JavaIODemo_What_is_JAVAIO_App/JavaIODemo/src/JavaIODemo1.java new file mode 100644 index 000000000..d6ecefba1 --- /dev/null +++ b/BasicJava/JavaIODemo_What_is_JAVAIO_App/JavaIODemo/src/JavaIODemo1.java @@ -0,0 +1,11 @@ + +public class JavaIODemo1 +{ + + public static void main(String[] args) + { + System.out.println("Hello...\n"); + System.err.println("Error..."); + } + +} diff --git a/BasicJava/JavaIODemo_What_is_JAVAIO_App/JavaIODemo/src/JavaIODemo2.java b/BasicJava/JavaIODemo_What_is_JAVAIO_App/JavaIODemo/src/JavaIODemo2.java new file mode 100644 index 000000000..b6147b10a --- /dev/null +++ b/BasicJava/JavaIODemo_What_is_JAVAIO_App/JavaIODemo/src/JavaIODemo2.java @@ -0,0 +1,22 @@ +import java.io.IOException; + +public class JavaIODemo2 +{ + + public static void main(String[] args) + { + try + { + System.out.print("Enter the Value = "); + // returns ASCII code of 1st character + int intValue = System.in.read(); + System.out.println("intValue = " + intValue); + System.out.println((char) intValue); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + +} diff --git a/BasicJava/JavaIODemo_What_is_JAVAIO_App/JavaIODemo1_Output.txt b/BasicJava/JavaIODemo_What_is_JAVAIO_App/JavaIODemo1_Output.txt new file mode 100644 index 000000000..f4eb76881 --- /dev/null +++ b/BasicJava/JavaIODemo_What_is_JAVAIO_App/JavaIODemo1_Output.txt @@ -0,0 +1,3 @@ +Hello... +Error... + diff --git a/BasicJava/JavaIODemo_What_is_JAVAIO_App/JavaIODemo2_Output.txt b/BasicJava/JavaIODemo_What_is_JAVAIO_App/JavaIODemo2_Output.txt new file mode 100644 index 000000000..ea256c305 --- /dev/null +++ b/BasicJava/JavaIODemo_What_is_JAVAIO_App/JavaIODemo2_Output.txt @@ -0,0 +1,3 @@ +Enter the Value = a +intValue = 97 +a diff --git a/BasicJava/JavaIODemo_deflate_compress_App/CompressFileDemo_Output.txt b/BasicJava/JavaIODemo_deflate_compress_App/CompressFileDemo_Output.txt new file mode 100644 index 000000000..68655a160 --- /dev/null +++ b/BasicJava/JavaIODemo_deflate_compress_App/CompressFileDemo_Output.txt @@ -0,0 +1 @@ +Compression is done.. diff --git a/BasicJava/JavaIODemo_deflate_compress_App/DecompressFileDemo_Output.txt b/BasicJava/JavaIODemo_deflate_compress_App/DecompressFileDemo_Output.txt new file mode 100644 index 000000000..4500a193b --- /dev/null +++ b/BasicJava/JavaIODemo_deflate_compress_App/DecompressFileDemo_Output.txt @@ -0,0 +1 @@ +DeCompression is done.. diff --git a/BasicJava/JavaIODemo_deflate_compress_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_deflate_compress_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_deflate_compress_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_deflate_compress_App/JavaIODemo/.project b/BasicJava/JavaIODemo_deflate_compress_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_deflate_compress_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_deflate_compress_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_deflate_compress_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_deflate_compress_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_deflate_compress_App/JavaIODemo/bin/CompressFileDemo.class b/BasicJava/JavaIODemo_deflate_compress_App/JavaIODemo/bin/CompressFileDemo.class new file mode 100644 index 000000000..4bc6f001b Binary files /dev/null and b/BasicJava/JavaIODemo_deflate_compress_App/JavaIODemo/bin/CompressFileDemo.class differ diff --git a/BasicJava/JavaIODemo_deflate_compress_App/JavaIODemo/bin/DecompressFileDemo.class b/BasicJava/JavaIODemo_deflate_compress_App/JavaIODemo/bin/DecompressFileDemo.class new file mode 100644 index 000000000..008fe4b5e Binary files /dev/null and b/BasicJava/JavaIODemo_deflate_compress_App/JavaIODemo/bin/DecompressFileDemo.class differ diff --git a/BasicJava/JavaIODemo_deflate_compress_App/JavaIODemo/src/CompressFileDemo.java b/BasicJava/JavaIODemo_deflate_compress_App/JavaIODemo/src/CompressFileDemo.java new file mode 100644 index 000000000..50da16670 --- /dev/null +++ b/BasicJava/JavaIODemo_deflate_compress_App/JavaIODemo/src/CompressFileDemo.java @@ -0,0 +1,35 @@ +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.zip.DeflaterOutputStream; + +class CompressFileDemo +{ + public static void main(String args[]) throws IOException + { + CompressFileDemo compressFileDemo = new CompressFileDemo(); + compressFileDemo.compressFile("D:/work/HelloWorld.java", + "D:/work/Compressed.txt"); + } + + private void compressFile(String fileToCompress, String compressFile) + throws IOException + { + try ( + FileInputStream fin = new FileInputStream(fileToCompress); + FileOutputStream fout = new FileOutputStream(compressFile); + DeflaterOutputStream dos = new DeflaterOutputStream(fout);) + { + + int i; + while ((i = fin.read()) != -1) + { + dos.write((byte) i); + dos.flush(); + } + + } + + System.out.println("Compression is done.."); + } +} \ No newline at end of file diff --git a/BasicJava/JavaIODemo_deflate_compress_App/JavaIODemo/src/DecompressFileDemo.java b/BasicJava/JavaIODemo_deflate_compress_App/JavaIODemo/src/DecompressFileDemo.java new file mode 100644 index 000000000..884b80fe3 --- /dev/null +++ b/BasicJava/JavaIODemo_deflate_compress_App/JavaIODemo/src/DecompressFileDemo.java @@ -0,0 +1,39 @@ +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.zip.InflaterInputStream; + +public class DecompressFileDemo +{ + + public static void main(String[] args) throws IOException + { + DecompressFileDemo decompressFileDemo = new DecompressFileDemo(); + decompressFileDemo.decompressFile("D:/work/Compressed.txt", + "D:/work/HelloWorld.java"); + + } + + private void decompressFile(String fileToDeCompress, String deCompressFile) + throws IOException + { + try ( + FileInputStream fin = new FileInputStream(fileToDeCompress); + InflaterInputStream in = new InflaterInputStream(fin); + FileOutputStream fout = new FileOutputStream(deCompressFile);) + { + + int i; + while ((i = in.read()) != -1) + { + fout.write((byte) i); + fout.flush(); + } + + } + + System.out.println("DeCompression is done.."); + + } + +} diff --git a/BasicJava/JavaIODemo_file_permission_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_file_permission_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_file_permission_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_file_permission_App/JavaIODemo/.project b/BasicJava/JavaIODemo_file_permission_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_file_permission_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_file_permission_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_file_permission_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_file_permission_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_file_permission_App/JavaIODemo/bin/FileDemo.class b/BasicJava/JavaIODemo_file_permission_App/JavaIODemo/bin/FileDemo.class new file mode 100644 index 000000000..84461e65e Binary files /dev/null and b/BasicJava/JavaIODemo_file_permission_App/JavaIODemo/bin/FileDemo.class differ diff --git a/BasicJava/JavaIODemo_file_permission_App/JavaIODemo/src/FileDemo.java b/BasicJava/JavaIODemo_file_permission_App/JavaIODemo/src/FileDemo.java new file mode 100644 index 000000000..202095ad0 --- /dev/null +++ b/BasicJava/JavaIODemo_file_permission_App/JavaIODemo/src/FileDemo.java @@ -0,0 +1,25 @@ +import java.io.File; + +public class FileDemo +{ + + public static void main(String[] args) + { + File file = new File("/home/start.sh"); + + System.out.println("Is Execute allow : " + file.canExecute()); + System.out.println("Is Write allow : " + file.canWrite()); + System.out.println("Is Read allow : " + file.canRead()); + + file.setExecutable(false); + file.setReadable(false); + file.setWritable(false); + + System.out.println("----------------------------------------"); + System.out.println("Is Execute allow : " + file.canExecute()); + System.out.println("Is Write allow : " + file.canWrite()); + System.out.println("Is Read allow : " + file.canRead()); + + } + +} diff --git a/BasicJava/JavaIODemo_file_permission_App/JavaIODemo/src/FileDemo1.java b/BasicJava/JavaIODemo_file_permission_App/JavaIODemo/src/FileDemo1.java new file mode 100644 index 000000000..5084d5bc1 --- /dev/null +++ b/BasicJava/JavaIODemo_file_permission_App/JavaIODemo/src/FileDemo1.java @@ -0,0 +1,43 @@ +import java.io.File; + +public class FileDemo1 +{ + + public static void main(String[] args) + { + File file = new File("/home/hello.sh"); + + /* + * Marks the file or directory named by this + * abstract pathname so that only read operations + * are allowed. + */ + file.setReadOnly(); + + if (file.canWrite()) + { + System.out.println("This file is writable"); + } + else + { + System.out.println("This file is read only"); + } + + /* + * A convenience method to set the owner's write + * permission for this abstract pathname. + */ + file.setWritable(true); + + if (file.canWrite()) + { + System.out.println("This file is writable"); + } + else + { + System.out.println("This file is read only"); + } + + } + +} diff --git a/BasicJava/JavaIODemo_unzip_dir_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_unzip_dir_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_unzip_dir_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_unzip_dir_App/JavaIODemo/.project b/BasicJava/JavaIODemo_unzip_dir_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_unzip_dir_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_unzip_dir_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_unzip_dir_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_unzip_dir_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_unzip_dir_App/JavaIODemo/bin/UnZipDemo.class b/BasicJava/JavaIODemo_unzip_dir_App/JavaIODemo/bin/UnZipDemo.class new file mode 100644 index 000000000..9b41cead7 Binary files /dev/null and b/BasicJava/JavaIODemo_unzip_dir_App/JavaIODemo/bin/UnZipDemo.class differ diff --git a/BasicJava/JavaIODemo_unzip_dir_App/JavaIODemo/src/UnZipDemo.java b/BasicJava/JavaIODemo_unzip_dir_App/JavaIODemo/src/UnZipDemo.java new file mode 100644 index 000000000..bbabc8b57 --- /dev/null +++ b/BasicJava/JavaIODemo_unzip_dir_App/JavaIODemo/src/UnZipDemo.java @@ -0,0 +1,81 @@ +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; + +public class UnZipDemo +{ + private static final String INPUT_ZIP_FILE = "D:/work/Java.zip"; + private static final String OUTPUT_FOLDER = "D:/work/java"; + + public static void main(String[] args) throws IOException + { + UnZipDemo unZipDemo = new UnZipDemo(); + unZipDemo.unZip(INPUT_ZIP_FILE, OUTPUT_FOLDER); + } + + public void unZip(String zipFile, String outputFolder) throws IOException + { + + createDir(outputFolder); + + /* + * If the Streams are within the + * "try-With-Resources" block, then it will be + * closed automatically. + */ + try ( + // Get the zip file content + ZipInputStream zis = new ZipInputStream(new FileInputStream( + zipFile))) + { + // Get the zipped file list entry + ZipEntry ze = zis.getNextEntry(); + byte[] buffer = new byte[1024]; + while (ze != null) + { + + String fileName = ze.getName(); + File newFile = new File(outputFolder + File.separator + + fileName); + + System.out.println("file unzip : " + newFile.getAbsoluteFile()); + + /* + * Create all non exists folders + */ + new File(newFile.getParent()).mkdirs(); + + FileOutputStream fos = new FileOutputStream(newFile); + + int len; + while ((len = zis.read(buffer)) > 0) + { + fos.write(buffer, 0, len); + } + + fos.close(); + ze = zis.getNextEntry(); + } + + zis.closeEntry(); + + System.out.println("Unzip is completed.."); + } + + } + + private void createDir(String outputFolder) + { + /* + * Create output directory is not exists + */ + File folder = new File(outputFolder); + if (!folder.exists()) + { + folder.mkdir(); + } + } +} \ No newline at end of file diff --git a/BasicJava/JavaIODemo_unzip_dir_App/Output.txt b/BasicJava/JavaIODemo_unzip_dir_App/Output.txt new file mode 100644 index 000000000..ba45d775a --- /dev/null +++ b/BasicJava/JavaIODemo_unzip_dir_App/Output.txt @@ -0,0 +1,7 @@ +file unzip : D:\work\java\CityInfoDemo\.classpath +file unzip : D:\work\java\CityInfoDemo\.project +file unzip : D:\work\java\CityInfoDemo\.settings\.jsdtscope +--- +--- +file unzip : D:\work\java\CityInfoDemo\WebContent\WEB-INF\web.xml +Unzip is completed.. diff --git a/BasicJava/JavaIODemo_zip_dir_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_zip_dir_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_zip_dir_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_zip_dir_App/JavaIODemo/.project b/BasicJava/JavaIODemo_zip_dir_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_zip_dir_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_zip_dir_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_zip_dir_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_zip_dir_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_zip_dir_App/JavaIODemo/bin/ZipDemo.class b/BasicJava/JavaIODemo_zip_dir_App/JavaIODemo/bin/ZipDemo.class new file mode 100644 index 000000000..ef152f160 Binary files /dev/null and b/BasicJava/JavaIODemo_zip_dir_App/JavaIODemo/bin/ZipDemo.class differ diff --git a/BasicJava/JavaIODemo_zip_dir_App/JavaIODemo/src/ZipDemo.java b/BasicJava/JavaIODemo_zip_dir_App/JavaIODemo/src/ZipDemo.java new file mode 100644 index 000000000..ddec7e3ad --- /dev/null +++ b/BasicJava/JavaIODemo_zip_dir_App/JavaIODemo/src/ZipDemo.java @@ -0,0 +1,101 @@ +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +public class ZipDemo +{ + private ArrayList fileList; + private static final String OUTPUT_ZIP_FILE = "D:/work/Java.zip"; + private static final String SOURCE_FOLDER = "D:/work/java"; + + public ZipDemo() + { + fileList = new ArrayList(); + } + + public static void main(String[] args) throws IOException + { + ZipDemo zipDemo = new ZipDemo(); + zipDemo.generateFileList(new File(SOURCE_FOLDER)); + zipDemo.zipIt(OUTPUT_ZIP_FILE); + } + + public void zipIt(String zipFile) throws IOException + { + + byte[] buffer = new byte[1024]; + + /* + * If the Streams are within the + * "try-With-Resources" block, then it will be + * closed automatically. + */ + try ( + FileOutputStream fos = new FileOutputStream(zipFile); + ZipOutputStream zos = new ZipOutputStream(fos)) + { + + System.out.println("Output to Zip : " + zipFile); + + for (String file : this.fileList) + { + + System.out.println("File Added : " + file); + ZipEntry ze = new ZipEntry(file); + zos.putNextEntry(ze); + + FileInputStream in = new FileInputStream(SOURCE_FOLDER + + File.separator + file); + + int len; + while ((len = in.read(buffer)) > 0) + { + zos.write(buffer, 0, len); + } + + in.close(); + } + + zos.closeEntry(); + + System.out.println("Zip file is created..."); + } + + } + + /** + * Traverse a directory and get all files, and add the + * file into fileList. + */ + public void generateFileList(File node) + { + + // add file only + if (node.isFile()) + { + fileList.add(generateZipEntry(node.getAbsoluteFile().toString())); + } + + if (node.isDirectory()) + { + String[] subNote = node.list(); + for (String filename : subNote) + { + generateFileList(new File(node, filename)); + } + } + + } + + /** + * Format the file path for zip + */ + private String generateZipEntry(String file) + { + return file.substring(SOURCE_FOLDER.length() + 1, file.length()); + } +} diff --git a/BasicJava/JavaIODemo_zip_dir_App/Output.txt b/BasicJava/JavaIODemo_zip_dir_App/Output.txt new file mode 100644 index 000000000..819f4b872 --- /dev/null +++ b/BasicJava/JavaIODemo_zip_dir_App/Output.txt @@ -0,0 +1,8 @@ +Output to Zip : D:/work/Java.zip +File Added : CityInfoDemo\.classpath +File Added : CityInfoDemo\.project +File Added : CityInfoDemo\.settings\.jsdtscope +--- +--- +File Added : CityInfoDemo\WebContent\WEB-INF\web.xml +Zip file is created... diff --git a/BasicJava/JavaIODemo_zip_single_file_App/JavaIODemo/.classpath b/BasicJava/JavaIODemo_zip_single_file_App/JavaIODemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/JavaIODemo_zip_single_file_App/JavaIODemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/JavaIODemo_zip_single_file_App/JavaIODemo/.project b/BasicJava/JavaIODemo_zip_single_file_App/JavaIODemo/.project new file mode 100644 index 000000000..8d280bf2d --- /dev/null +++ b/BasicJava/JavaIODemo_zip_single_file_App/JavaIODemo/.project @@ -0,0 +1,17 @@ + + + JavaIODemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/JavaIODemo_zip_single_file_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/JavaIODemo_zip_single_file_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/JavaIODemo_zip_single_file_App/JavaIODemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/JavaIODemo_zip_single_file_App/JavaIODemo/bin/ZipDemo.class b/BasicJava/JavaIODemo_zip_single_file_App/JavaIODemo/bin/ZipDemo.class new file mode 100644 index 000000000..df124857f Binary files /dev/null and b/BasicJava/JavaIODemo_zip_single_file_App/JavaIODemo/bin/ZipDemo.class differ diff --git a/BasicJava/JavaIODemo_zip_single_file_App/JavaIODemo/src/ZipDemo.java b/BasicJava/JavaIODemo_zip_single_file_App/JavaIODemo/src/ZipDemo.java new file mode 100644 index 000000000..0b44c050f --- /dev/null +++ b/BasicJava/JavaIODemo_zip_single_file_App/JavaIODemo/src/ZipDemo.java @@ -0,0 +1,50 @@ +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +public class ZipDemo +{ + public static void main(String[] args) throws IOException + { + ZipDemo zipDemo = new ZipDemo(); + File file = new File("D:/work/HelloWorld.java"); + zipDemo.zipFile("D:/work/java.zip", file); + } + + private void zipFile(String outputZipFileName, File file) + throws IOException + { + byte[] buffer = new byte[1024]; + + /* + * All Streams will be closed automatically because they + * are within the "try-With-Resources" block. + */ + try (FileOutputStream fos = new FileOutputStream(outputZipFileName); + ZipOutputStream zos = new ZipOutputStream(fos); + FileInputStream fin = new FileInputStream(file)) + { + + ZipEntry ze = new ZipEntry(file.getName()); + zos.putNextEntry(ze); + + int len; + while ((len = fin.read(buffer)) > 0) + { + zos.write(buffer, 0, len); + } + + /* + * Closes the current ZIP entry and positions + * the stream for writing the next entry. + */ + zos.closeEntry(); + } + + System.out.println("Zip file is created..."); + } + +} diff --git a/BasicJava/JavaIODemo_zip_single_file_App/Output.txt b/BasicJava/JavaIODemo_zip_single_file_App/Output.txt new file mode 100644 index 000000000..6f67e1aed --- /dev/null +++ b/BasicJava/JavaIODemo_zip_single_file_App/Output.txt @@ -0,0 +1 @@ +Zip file is created... diff --git a/BasicJava/Java_MultiThreading_App/Output.txt b/BasicJava/Java_MultiThreading_App/Output.txt new file mode 100644 index 000000000..c07bc060d --- /dev/null +++ b/BasicJava/Java_MultiThreading_App/Output.txt @@ -0,0 +1 @@ +Name of thread = Thread[MainThread,5,main] diff --git a/BasicJava/Java_MultiThreading_App/ThreadDemo/.classpath b/BasicJava/Java_MultiThreading_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/Java_MultiThreading_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/Java_MultiThreading_App/ThreadDemo/.project b/BasicJava/Java_MultiThreading_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/Java_MultiThreading_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/Java_MultiThreading_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/Java_MultiThreading_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/Java_MultiThreading_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/Java_MultiThreading_App/ThreadDemo/bin/MainThread.class b/BasicJava/Java_MultiThreading_App/ThreadDemo/bin/MainThread.class new file mode 100644 index 000000000..b2aa64258 Binary files /dev/null and b/BasicJava/Java_MultiThreading_App/ThreadDemo/bin/MainThread.class differ diff --git a/BasicJava/Java_MultiThreading_App/ThreadDemo/src/MainThread.java b/BasicJava/Java_MultiThreading_App/ThreadDemo/src/MainThread.java new file mode 100644 index 000000000..cd49a92e8 --- /dev/null +++ b/BasicJava/Java_MultiThreading_App/ThreadDemo/src/MainThread.java @@ -0,0 +1,11 @@ +public class MainThread +{ + + public static void main(String[] args) + { + Thread thread = Thread.currentThread(); + thread.setName("MainThread"); + System.out.println("Name of thread = " + thread); + } + +} diff --git a/BasicJava/LambdaDemo_Cons_ref_app/LambdaDemo/.classpath b/BasicJava/LambdaDemo_Cons_ref_app/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_Cons_ref_app/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_Cons_ref_app/LambdaDemo/.project b/BasicJava/LambdaDemo_Cons_ref_app/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_Cons_ref_app/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_Cons_ref_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_Cons_ref_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_Cons_ref_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_Cons_ref_app/LambdaDemo/bin/LambdaDemo.class b/BasicJava/LambdaDemo_Cons_ref_app/LambdaDemo/bin/LambdaDemo.class new file mode 100644 index 000000000..3a4afaf29 Binary files /dev/null and b/BasicJava/LambdaDemo_Cons_ref_app/LambdaDemo/bin/LambdaDemo.class differ diff --git a/BasicJava/LambdaDemo_Cons_ref_app/LambdaDemo/bin/Message.class b/BasicJava/LambdaDemo_Cons_ref_app/LambdaDemo/bin/Message.class new file mode 100644 index 000000000..583ba146c Binary files /dev/null and b/BasicJava/LambdaDemo_Cons_ref_app/LambdaDemo/bin/Message.class differ diff --git a/BasicJava/LambdaDemo_Cons_ref_app/LambdaDemo/src/LambdaDemo.java b/BasicJava/LambdaDemo_Cons_ref_app/LambdaDemo/src/LambdaDemo.java new file mode 100644 index 000000000..40d20ab51 --- /dev/null +++ b/BasicJava/LambdaDemo_Cons_ref_app/LambdaDemo/src/LambdaDemo.java @@ -0,0 +1,34 @@ +@FunctionalInterface +interface Message +{ + String displayMessage(char[] chArray); +} + +public class LambdaDemo +{ + public static void main(String[] args) + { + + /* + * Note that, in this program strFunc() of FunctionalInterface + * returns a reference of type String. In this program, the + * expression "String::new" creates a constructor reference to + * the String's constructor. + */ + Message message = String::new; + + char[] charArray = { 'P', 'e', 't', 'e', 'r' }; + + /* + * Here the method StrFunc() takes a Character array as an + * argument, so the parameterized constructor + * String(char[] charArray) is referred here. + * + * So finally, when ever you call the method strFunc() on + * FunctionalInterface reference, a String object is + * constructed and returned. + */ + System.out.println(message.displayMessage(charArray)); + } + +} diff --git a/BasicJava/LambdaDemo_Cons_ref_app/Output.txt b/BasicJava/LambdaDemo_Cons_ref_app/Output.txt new file mode 100644 index 000000000..5089231f7 --- /dev/null +++ b/BasicJava/LambdaDemo_Cons_ref_app/Output.txt @@ -0,0 +1 @@ +Peter diff --git a/BasicJava/LambdaDemo_FI_App/LambdaDemo/.classpath b/BasicJava/LambdaDemo_FI_App/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_FI_App/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_FI_App/LambdaDemo/.project b/BasicJava/LambdaDemo_FI_App/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_FI_App/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_FI_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_FI_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_FI_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_FI_App/LambdaDemo/bin/StringLengthLambda.class b/BasicJava/LambdaDemo_FI_App/LambdaDemo/bin/StringLengthLambda.class new file mode 100644 index 000000000..5dba32d5b Binary files /dev/null and b/BasicJava/LambdaDemo_FI_App/LambdaDemo/bin/StringLengthLambda.class differ diff --git a/BasicJava/LambdaDemo_FI_App/LambdaDemo/src/StringLengthLambda.java b/BasicJava/LambdaDemo_FI_App/LambdaDemo/src/StringLengthLambda.java new file mode 100644 index 000000000..da2debb2e --- /dev/null +++ b/BasicJava/LambdaDemo_FI_App/LambdaDemo/src/StringLengthLambda.java @@ -0,0 +1,7 @@ +@FunctionalInterface +public interface StringLengthLambda +{ + public int getLength(String str); +} + + diff --git a/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app/LambdaDemo/.classpath b/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app/LambdaDemo/.project b/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app/LambdaDemo/bin/Car.class b/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app/LambdaDemo/bin/Car.class new file mode 100644 index 000000000..13b00539d Binary files /dev/null and b/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app/LambdaDemo/bin/Car.class differ diff --git a/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app/LambdaDemo/bin/LambdaDemo$1.class b/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app/LambdaDemo/bin/LambdaDemo$1.class new file mode 100644 index 000000000..98cf454f0 Binary files /dev/null and b/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app/LambdaDemo/bin/LambdaDemo$1.class differ diff --git a/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app/LambdaDemo/bin/LambdaDemo.class b/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app/LambdaDemo/bin/LambdaDemo.class new file mode 100644 index 000000000..824d0f5d1 Binary files /dev/null and b/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app/LambdaDemo/bin/LambdaDemo.class differ diff --git a/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app/LambdaDemo/bin/Mechanic.class b/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app/LambdaDemo/bin/Mechanic.class new file mode 100644 index 000000000..0a36373af Binary files /dev/null and b/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app/LambdaDemo/bin/Mechanic.class differ diff --git a/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app/LambdaDemo/src/LambdaDemo.java b/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app/LambdaDemo/src/LambdaDemo.java new file mode 100644 index 000000000..552744159 --- /dev/null +++ b/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app/LambdaDemo/src/LambdaDemo.java @@ -0,0 +1,27 @@ +import java.util.function.Consumer; + +public class LambdaDemo +{ + public static void main(String[] args) + { + + final Mechanic mechanic = new Mechanic(); + Car car = new Car("Honda Jazz"); + + // Using an anonymous class + mechanic.execute(car, new Consumer() + { + public void accept(Car c) + { + mechanic.fix(c); + } + }); + + // Using a lambda expression + mechanic.execute(car, c -> mechanic.fix(c)); + + // Using a method reference + mechanic.execute(car, mechanic::fix); + } + +} diff --git a/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app/LambdaDemo/src/Mechanic.java b/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app/LambdaDemo/src/Mechanic.java new file mode 100644 index 000000000..601a54358 --- /dev/null +++ b/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app/LambdaDemo/src/Mechanic.java @@ -0,0 +1,36 @@ +import java.util.function.Consumer; + +class Car +{ + private String name; + + public Car(String name) + { + super(); + this.name = name; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + +} + +public class Mechanic +{ + public void fix(Car c) + { + System.out.println("Mechanic is fixing " + c.getName()); + } + + public void execute(Car car, Consumer c) + { + c.accept(car); + } +} \ No newline at end of file diff --git a/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app/Output.txt b/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app/Output.txt new file mode 100644 index 000000000..78ad47a6b --- /dev/null +++ b/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app/Output.txt @@ -0,0 +1,3 @@ +Mechanic is fixing Honda Jazz +Mechanic is fixing Honda Jazz +Mechanic is fixing Honda Jazz diff --git a/BasicJava/LambdaDemo_consumer_App/LambdaDemo/.classpath b/BasicJava/LambdaDemo_consumer_App/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_consumer_App/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_consumer_App/LambdaDemo/.project b/BasicJava/LambdaDemo_consumer_App/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_consumer_App/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_consumer_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_consumer_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_consumer_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_consumer_App/LambdaDemo/bin/LambdaPredicateConsumerDemo.class b/BasicJava/LambdaDemo_consumer_App/LambdaDemo/bin/LambdaPredicateConsumerDemo.class new file mode 100644 index 000000000..2a7515e23 Binary files /dev/null and b/BasicJava/LambdaDemo_consumer_App/LambdaDemo/bin/LambdaPredicateConsumerDemo.class differ diff --git a/BasicJava/LambdaDemo_consumer_App/LambdaDemo/bin/Person.class b/BasicJava/LambdaDemo_consumer_App/LambdaDemo/bin/Person.class new file mode 100644 index 000000000..943cff944 Binary files /dev/null and b/BasicJava/LambdaDemo_consumer_App/LambdaDemo/bin/Person.class differ diff --git a/BasicJava/LambdaDemo_consumer_App/LambdaDemo/src/LambdaPredicateConsumerDemo.java b/BasicJava/LambdaDemo_consumer_App/LambdaDemo/src/LambdaPredicateConsumerDemo.java new file mode 100644 index 000000000..6607885e8 --- /dev/null +++ b/BasicJava/LambdaDemo_consumer_App/LambdaDemo/src/LambdaPredicateConsumerDemo.java @@ -0,0 +1,50 @@ +import java.util.Arrays; +import java.util.List; +import java.util.function.Consumer; +import java.util.function.Predicate; + +public class LambdaPredicateConsumerDemo +{ + public static void main(String[] args) + { + List personList = Arrays.asList( + new Person("Carla", 33), new Person("Balu", 32), + new Person("Bharth", 40), new Person("Ajay", 31)); + + System.out.println("------------Name Starts with B---------"); + /* + * Create a method that prints all people that have name + * begins with B. + */ + printNameBeginWith_B(personList, + p -> p.getName().startsWith("B"), + p -> System.out.println(p)); + + System.out.println("----------------------------------------"); + + printNameBeginWith_B(personList, + p -> p.getName().startsWith("B"), + p -> System.out.println(p.getName())); + + System.out.println("----------------------------------------"); + + printNameBeginWith_B(personList, + p -> p.getName().startsWith("B"), + p -> System.out.println(p.getAge())); + + } + + private static void printNameBeginWith_B(List personList, + Predicate predicate, Consumer consumer) + { + for (Person person : personList) + { + if (predicate.test(person)) + { + consumer.accept(person); + } + } + + } + +} diff --git a/BasicJava/LambdaDemo_consumer_App/LambdaDemo/src/Person.java b/BasicJava/LambdaDemo_consumer_App/LambdaDemo/src/Person.java new file mode 100644 index 000000000..5c3924f59 --- /dev/null +++ b/BasicJava/LambdaDemo_consumer_App/LambdaDemo/src/Person.java @@ -0,0 +1,39 @@ +public class Person +{ + private String name; + private int age; + + public Person(String name, int age) + { + super(); + this.name = name; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + @Override + public String toString() + { + return "Person [name=" + name + ", age=" + age + "]"; + } + +} diff --git a/BasicJava/LambdaDemo_consumer_App/Output.txt b/BasicJava/LambdaDemo_consumer_App/Output.txt new file mode 100644 index 000000000..09a3dd324 --- /dev/null +++ b/BasicJava/LambdaDemo_consumer_App/Output.txt @@ -0,0 +1,9 @@ +------------Name Starts with B--------- +Person [name=Balu, age=32] +Person [name=Bharth, age=40] +---------------------------------------- +Balu +Bharth +---------------------------------------- +32 +40 diff --git a/BasicJava/LambdaDemo_filter_list_person_startswith_app/LambdaDemo/.classpath b/BasicJava/LambdaDemo_filter_list_person_startswith_app/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_filter_list_person_startswith_app/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_filter_list_person_startswith_app/LambdaDemo/.project b/BasicJava/LambdaDemo_filter_list_person_startswith_app/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_filter_list_person_startswith_app/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_filter_list_person_startswith_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_filter_list_person_startswith_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_filter_list_person_startswith_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_filter_list_person_startswith_app/LambdaDemo/bin/LambdaDemo.class b/BasicJava/LambdaDemo_filter_list_person_startswith_app/LambdaDemo/bin/LambdaDemo.class new file mode 100644 index 000000000..7e234e35b Binary files /dev/null and b/BasicJava/LambdaDemo_filter_list_person_startswith_app/LambdaDemo/bin/LambdaDemo.class differ diff --git a/BasicJava/LambdaDemo_filter_list_person_startswith_app/LambdaDemo/bin/Person.class b/BasicJava/LambdaDemo_filter_list_person_startswith_app/LambdaDemo/bin/Person.class new file mode 100644 index 000000000..943cff944 Binary files /dev/null and b/BasicJava/LambdaDemo_filter_list_person_startswith_app/LambdaDemo/bin/Person.class differ diff --git a/BasicJava/LambdaDemo_filter_list_person_startswith_app/LambdaDemo/src/LambdaDemo.java b/BasicJava/LambdaDemo_filter_list_person_startswith_app/LambdaDemo/src/LambdaDemo.java new file mode 100644 index 000000000..4423bfd5d --- /dev/null +++ b/BasicJava/LambdaDemo_filter_list_person_startswith_app/LambdaDemo/src/LambdaDemo.java @@ -0,0 +1,17 @@ +import java.util.Arrays; +import java.util.List; + +public class LambdaDemo +{ + public static void main(String[] args) + { + + List personList = Arrays.asList(new Person("Carla", 33), + new Person("Balu", 32), new Person("Bharth", 40), + new Person("Ajay", 31)); + + personList.stream().filter(person -> person.getName().startsWith("B")) + .forEach(person -> System.out.println(person)); + } + +} diff --git a/BasicJava/LambdaDemo_filter_list_person_startswith_app/LambdaDemo/src/Person.java b/BasicJava/LambdaDemo_filter_list_person_startswith_app/LambdaDemo/src/Person.java new file mode 100644 index 000000000..5c3924f59 --- /dev/null +++ b/BasicJava/LambdaDemo_filter_list_person_startswith_app/LambdaDemo/src/Person.java @@ -0,0 +1,39 @@ +public class Person +{ + private String name; + private int age; + + public Person(String name, int age) + { + super(); + this.name = name; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + @Override + public String toString() + { + return "Person [name=" + name + ", age=" + age + "]"; + } + +} diff --git a/BasicJava/LambdaDemo_filter_list_person_startswith_app/Output.txt b/BasicJava/LambdaDemo_filter_list_person_startswith_app/Output.txt new file mode 100644 index 000000000..90b3cf25c --- /dev/null +++ b/BasicJava/LambdaDemo_filter_list_person_startswith_app/Output.txt @@ -0,0 +1,2 @@ +Person [name=Balu, age=32] +Person [name=Bharth, age=40] diff --git a/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/.classpath b/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/.project b/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/bin/LambdaDemo.class b/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/bin/LambdaDemo.class new file mode 100644 index 000000000..a7969d18a Binary files /dev/null and b/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/bin/LambdaDemo.class differ diff --git a/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/bin/NonLambdaDemo$1.class b/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/bin/NonLambdaDemo$1.class new file mode 100644 index 000000000..27fce4617 Binary files /dev/null and b/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/bin/NonLambdaDemo$1.class differ diff --git a/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/bin/NonLambdaDemo.class b/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/bin/NonLambdaDemo.class new file mode 100644 index 000000000..a811a8154 Binary files /dev/null and b/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/bin/NonLambdaDemo.class differ diff --git a/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/bin/Person.class b/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/bin/Person.class new file mode 100644 index 000000000..943cff944 Binary files /dev/null and b/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/bin/Person.class differ diff --git a/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/bin/PersonFilter.class b/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/bin/PersonFilter.class new file mode 100644 index 000000000..d896250fd Binary files /dev/null and b/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/bin/PersonFilter.class differ diff --git a/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/src/LambdaDemo.java b/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/src/LambdaDemo.java new file mode 100644 index 000000000..7af923e14 --- /dev/null +++ b/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/src/LambdaDemo.java @@ -0,0 +1,37 @@ +import java.util.Arrays; +import java.util.List; + +public class LambdaDemo +{ + public static void main(String[] args) + { + List personList = Arrays.asList( + new Person("Carla", 33), new Person("Balu", 32), + new Person("Bharth", 40), new Person("Ajay", 31)); + + System.out.println("------------Name Starts with B---------"); + + PersonFilter personFilter = person -> person.getName().startsWith("B"); + printNameBeginWith_B(personList,personFilter); + + System.out.println("----------------------------------------"); + + } + + /* + * Method to print all people that have name begins with B. + */ + private static void printNameBeginWith_B(List personList, + PersonFilter personFilter) + { + for (Person person : personList) + { + if (personFilter.filter(person)) + { + System.out.println(person); + } + } + + } + +} diff --git a/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/src/NonLambdaDemo.java b/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/src/NonLambdaDemo.java new file mode 100644 index 000000000..95a5cde2c --- /dev/null +++ b/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/src/NonLambdaDemo.java @@ -0,0 +1,44 @@ +import java.util.Arrays; +import java.util.List; + +public class NonLambdaDemo +{ + public static void main(String[] args) + { + List personList = Arrays.asList( + new Person("Carla", 33), new Person("Balu", 32), + new Person("Bharth", 40), new Person("Ajay", 31)); + + System.out.println("------------Name Starts with B---------"); + + PersonFilter personFilter = new PersonFilter() + { + @Override + public boolean filter(Person person) + { + return person.getName().startsWith("B"); + } + }; + + printNameBeginWith_B(personList, personFilter); + System.out.println("---------------------------------"); + + } + + /* + * Method to print all people that have name begins with B. + */ + private static void printNameBeginWith_B(List personList, + PersonFilter personFilter) + { + for (Person person : personList) + { + if (personFilter.filter(person)) + { + System.out.println(person); + } + } + + } + +} diff --git a/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/src/Person.java b/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/src/Person.java new file mode 100644 index 000000000..5c3924f59 --- /dev/null +++ b/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/src/Person.java @@ -0,0 +1,39 @@ +public class Person +{ + private String name; + private int age; + + public Person(String name, int age) + { + super(); + this.name = name; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + @Override + public String toString() + { + return "Person [name=" + name + ", age=" + age + "]"; + } + +} diff --git a/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/src/PersonFilter.java b/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/src/PersonFilter.java new file mode 100644 index 000000000..ccd4bb9b3 --- /dev/null +++ b/BasicJava/LambdaDemo_filter_person_App/LambdaDemo/src/PersonFilter.java @@ -0,0 +1,5 @@ +@FunctionalInterface +public interface PersonFilter +{ + public boolean filter(Person person); +} \ No newline at end of file diff --git a/BasicJava/LambdaDemo_filter_person_App/LambdaDemo_Output.txt b/BasicJava/LambdaDemo_filter_person_App/LambdaDemo_Output.txt new file mode 100644 index 000000000..53a385bbb --- /dev/null +++ b/BasicJava/LambdaDemo_filter_person_App/LambdaDemo_Output.txt @@ -0,0 +1,4 @@ +------------Name Starts with B--------- +Person [name=Balu, age=32] +Person [name=Bharth, age=40] +---------------------------------------- diff --git a/BasicJava/LambdaDemo_filter_person_App/NonLambdaDemo_Output.txt b/BasicJava/LambdaDemo_filter_person_App/NonLambdaDemo_Output.txt new file mode 100644 index 000000000..3de1140ce --- /dev/null +++ b/BasicJava/LambdaDemo_filter_person_App/NonLambdaDemo_Output.txt @@ -0,0 +1,4 @@ +------------Name Starts with B--------- +Person [name=Balu, age=32] +Person [name=Bharth, age=40] +--------------------------------- diff --git a/BasicJava/LambdaDemo_filter_product_App/LambdaDemo/.classpath b/BasicJava/LambdaDemo_filter_product_App/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_filter_product_App/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_filter_product_App/LambdaDemo/.project b/BasicJava/LambdaDemo_filter_product_App/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_filter_product_App/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_filter_product_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_filter_product_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_filter_product_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_filter_product_App/LambdaDemo/bin/LambdaDemo.class b/BasicJava/LambdaDemo_filter_product_App/LambdaDemo/bin/LambdaDemo.class new file mode 100644 index 000000000..0588a2c22 Binary files /dev/null and b/BasicJava/LambdaDemo_filter_product_App/LambdaDemo/bin/LambdaDemo.class differ diff --git a/BasicJava/LambdaDemo_filter_product_App/LambdaDemo/bin/Product.class b/BasicJava/LambdaDemo_filter_product_App/LambdaDemo/bin/Product.class new file mode 100644 index 000000000..ee2818bad Binary files /dev/null and b/BasicJava/LambdaDemo_filter_product_App/LambdaDemo/bin/Product.class differ diff --git a/BasicJava/LambdaDemo_filter_product_App/LambdaDemo/src/LambdaDemo.java b/BasicJava/LambdaDemo_filter_product_App/LambdaDemo/src/LambdaDemo.java new file mode 100644 index 000000000..e03d6001c --- /dev/null +++ b/BasicJava/LambdaDemo_filter_product_App/LambdaDemo/src/LambdaDemo.java @@ -0,0 +1,36 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; + +/** + * Java Lambda Expression Example: Filter Collection Data + * + */ +public class LambdaDemo +{ + + public static void main(String[] args) + { + List list = new ArrayList(); + + // Adding Products + list.add(new Product(1, "Sony LED TV", 60000f)); + list.add(new Product(2, "Radio", 3000f)); + list.add(new Product(3, "Laptop", 80000f)); + list.add(new Product(4, "Smart phone", 70000f)); + list.add(new Product(5, "Mouse", 1500f)); + + /* + * Using lambda to filter data + */ + Stream filteredStream = list.stream() + .filter(p -> p.getPrice() > 50000); + + /* + * Using lambda to iterate through collection + */ + filteredStream.forEach(product -> System.out.println( + product.getName() + ": " + product.getPrice())); + } + +} diff --git a/BasicJava/LambdaDemo_filter_product_App/LambdaDemo/src/Product.java b/BasicJava/LambdaDemo_filter_product_App/LambdaDemo/src/Product.java new file mode 100644 index 000000000..0f9624db5 --- /dev/null +++ b/BasicJava/LambdaDemo_filter_product_App/LambdaDemo/src/Product.java @@ -0,0 +1,45 @@ +class Product +{ + private int id; + private String name; + private float price; + + public Product(int id, String name, float price) + { + super(); + this.id = id; + this.name = name; + this.price = price; + } + + public int getId() + { + return id; + } + + public void setId(int id) + { + this.id = id; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public float getPrice() + { + return price; + } + + public void setPrice(float price) + { + this.price = price; + } + +} \ No newline at end of file diff --git a/BasicJava/LambdaDemo_filter_product_App/Output.txt b/BasicJava/LambdaDemo_filter_product_App/Output.txt new file mode 100644 index 000000000..935adf5e8 --- /dev/null +++ b/BasicJava/LambdaDemo_filter_product_App/Output.txt @@ -0,0 +1,3 @@ +Sony LED TV: 60000.0 +Laptop: 80000.0 +Smart phone: 70000.0 diff --git a/BasicJava/LambdaDemo_for_each_App/LambdaDemo/.classpath b/BasicJava/LambdaDemo_for_each_App/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_for_each_App/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_for_each_App/LambdaDemo/.project b/BasicJava/LambdaDemo_for_each_App/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_for_each_App/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_for_each_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_for_each_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_for_each_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_for_each_App/LambdaDemo/bin/LambdaDemo.class b/BasicJava/LambdaDemo_for_each_App/LambdaDemo/bin/LambdaDemo.class new file mode 100644 index 000000000..ee7649c44 Binary files /dev/null and b/BasicJava/LambdaDemo_for_each_App/LambdaDemo/bin/LambdaDemo.class differ diff --git a/BasicJava/LambdaDemo_for_each_App/LambdaDemo/src/LambdaDemo.java b/BasicJava/LambdaDemo_for_each_App/LambdaDemo/src/LambdaDemo.java new file mode 100644 index 000000000..828000ec3 --- /dev/null +++ b/BasicJava/LambdaDemo_for_each_App/LambdaDemo/src/LambdaDemo.java @@ -0,0 +1,22 @@ +import java.util.ArrayList; +import java.util.List; + +/** + * + * Java Lambda Expression Example: For-each Loop + * + */ +public class LambdaDemo +{ + + public static void main(String[] args) + { + List nameList = new ArrayList(); + nameList.add("Ram"); + nameList.add("Peter"); + nameList.add("John"); + + nameList.forEach((name) -> System.out.println(name)); + } + +} diff --git a/BasicJava/LambdaDemo_for_each_App/Output.txt b/BasicJava/LambdaDemo_for_each_App/Output.txt new file mode 100644 index 000000000..c579986ed --- /dev/null +++ b/BasicJava/LambdaDemo_for_each_App/Output.txt @@ -0,0 +1,3 @@ +Ram +Peter +John diff --git a/BasicJava/LambdaDemo_intro_App/LambdaDemo/.classpath b/BasicJava/LambdaDemo_intro_App/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_intro_App/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_intro_App/LambdaDemo/.project b/BasicJava/LambdaDemo_intro_App/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_intro_App/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_intro_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_intro_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_intro_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_intro_App/LambdaDemo/bin/Dog.class b/BasicJava/LambdaDemo_intro_App/LambdaDemo/bin/Dog.class new file mode 100644 index 000000000..1f4d27e13 Binary files /dev/null and b/BasicJava/LambdaDemo_intro_App/LambdaDemo/bin/Dog.class differ diff --git a/BasicJava/LambdaDemo_intro_App/LambdaDemo/bin/LambdaDemo.class b/BasicJava/LambdaDemo_intro_App/LambdaDemo/bin/LambdaDemo.class new file mode 100644 index 000000000..f0027efd6 Binary files /dev/null and b/BasicJava/LambdaDemo_intro_App/LambdaDemo/bin/LambdaDemo.class differ diff --git a/BasicJava/LambdaDemo_intro_App/LambdaDemo/bin/NoLambdaDemo$1.class b/BasicJava/LambdaDemo_intro_App/LambdaDemo/bin/NoLambdaDemo$1.class new file mode 100644 index 000000000..5b178c546 Binary files /dev/null and b/BasicJava/LambdaDemo_intro_App/LambdaDemo/bin/NoLambdaDemo$1.class differ diff --git a/BasicJava/LambdaDemo_intro_App/LambdaDemo/bin/NoLambdaDemo.class b/BasicJava/LambdaDemo_intro_App/LambdaDemo/bin/NoLambdaDemo.class new file mode 100644 index 000000000..e782eca6a Binary files /dev/null and b/BasicJava/LambdaDemo_intro_App/LambdaDemo/bin/NoLambdaDemo.class differ diff --git a/BasicJava/LambdaDemo_intro_App/LambdaDemo/src/Dog.java b/BasicJava/LambdaDemo_intro_App/LambdaDemo/src/Dog.java new file mode 100644 index 000000000..011f30014 --- /dev/null +++ b/BasicJava/LambdaDemo_intro_App/LambdaDemo/src/Dog.java @@ -0,0 +1,5 @@ +@FunctionalInterface //It is optional +public interface Dog +{ + public void eat(); +} \ No newline at end of file diff --git a/BasicJava/LambdaDemo_intro_App/LambdaDemo/src/LambdaDemo.java b/BasicJava/LambdaDemo_intro_App/LambdaDemo/src/LambdaDemo.java new file mode 100644 index 000000000..c5e07412f --- /dev/null +++ b/BasicJava/LambdaDemo_intro_App/LambdaDemo/src/LambdaDemo.java @@ -0,0 +1,19 @@ +public class LambdaDemo +{ + + public static void main(String[] args) + { + + /* + * With lambda + */ + Dog dog = () -> + { + System.out.println("eating chicken"); + }; + + dog.eat(); + + } + +} diff --git a/BasicJava/LambdaDemo_intro_App/LambdaDemo/src/NoLambdaDemo.java b/BasicJava/LambdaDemo_intro_App/LambdaDemo/src/NoLambdaDemo.java new file mode 100644 index 000000000..5af42388a --- /dev/null +++ b/BasicJava/LambdaDemo_intro_App/LambdaDemo/src/NoLambdaDemo.java @@ -0,0 +1,22 @@ + +public class NoLambdaDemo +{ + + public static void main(String[] args) + { + + /* + * Without lambda, Dog implementation using anonymous class + */ + Dog dog = new Dog() + { + @Override + public void eat() + { + System.out.println("eating chicken"); + } + }; + dog.eat(); + } + +} diff --git a/BasicJava/LambdaDemo_intro_App/LambdaDemo_Output.txt b/BasicJava/LambdaDemo_intro_App/LambdaDemo_Output.txt new file mode 100644 index 000000000..f6c9f5c9a --- /dev/null +++ b/BasicJava/LambdaDemo_intro_App/LambdaDemo_Output.txt @@ -0,0 +1 @@ +eating chicken diff --git a/BasicJava/LambdaDemo_intro_App/NoLambdaDemo_Output.txt b/BasicJava/LambdaDemo_intro_App/NoLambdaDemo_Output.txt new file mode 100644 index 000000000..f6c9f5c9a --- /dev/null +++ b/BasicJava/LambdaDemo_intro_App/NoLambdaDemo_Output.txt @@ -0,0 +1 @@ +eating chicken diff --git a/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/.classpath b/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/.project b/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/bin/LambdaDemo1.class b/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/bin/LambdaDemo1.class new file mode 100644 index 000000000..fc09617ed Binary files /dev/null and b/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/bin/LambdaDemo1.class differ diff --git a/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/bin/LambdaDemo2.class b/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/bin/LambdaDemo2.class new file mode 100644 index 000000000..b4cd71bfc Binary files /dev/null and b/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/bin/LambdaDemo2.class differ diff --git a/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/bin/LambdaDemo3.class b/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/bin/LambdaDemo3.class new file mode 100644 index 000000000..a4790d21f Binary files /dev/null and b/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/bin/LambdaDemo3.class differ diff --git a/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/bin/LambdaDemo4.class b/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/bin/LambdaDemo4.class new file mode 100644 index 000000000..90bb1b926 Binary files /dev/null and b/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/bin/LambdaDemo4.class differ diff --git a/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/src/LambdaDemo1.java b/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/src/LambdaDemo1.java new file mode 100644 index 000000000..0f6e36c6f --- /dev/null +++ b/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/src/LambdaDemo1.java @@ -0,0 +1,34 @@ +import java.util.ArrayList; +import java.util.List; + +public class LambdaDemo1 +{ + + public static void main(String[] args) + { + + List nameList = new ArrayList<>(); + nameList.add("Peter"); + nameList.add("John"); + nameList.add("Juli"); + nameList.add("Stephan"); + + /* + * Before Java 8, Normal way to loop a list. + */ + for (String name : nameList) + { + System.out.println(name); + } + + System.out.println("------------------------------------"); + + /* + * In Java 8, we can loop a List with forEach + lambda + * expression or method reference. + */ + nameList.forEach(name -> System.out.println(name)); + + } + +} diff --git a/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/src/LambdaDemo2.java b/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/src/LambdaDemo2.java new file mode 100644 index 000000000..072e84aec --- /dev/null +++ b/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/src/LambdaDemo2.java @@ -0,0 +1,29 @@ +import java.util.ArrayList; +import java.util.List; + +public class LambdaDemo2 +{ + + public static void main(String[] args) + { + + List nameList = new ArrayList<>(); + nameList.add("Peter"); + nameList.add("John"); + nameList.add("Juli"); + nameList.add("Stephan"); + + /* + * In Java 8, we can loop a List with forEach + lambda + * expression or method reference. + */ + + nameList.forEach(name -> { + if ("John".equals(name)) + { + System.out.println("Hello " + name); + } + }); + } + +} diff --git a/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/src/LambdaDemo3.java b/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/src/LambdaDemo3.java new file mode 100644 index 000000000..2b17c1b6a --- /dev/null +++ b/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/src/LambdaDemo3.java @@ -0,0 +1,25 @@ +import java.util.ArrayList; +import java.util.List; + +public class LambdaDemo3 +{ + + public static void main(String[] args) + { + + List nameList = new ArrayList<>(); + nameList.add("Peter"); + nameList.add("John"); + nameList.add("Juli"); + nameList.add("Stephan"); + + /* + * In Java 8, we can loop a List with forEach + lambda + * expression or method reference. + */ + + //method reference + nameList.forEach(System.out::println); + } + +} diff --git a/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/src/LambdaDemo4.java b/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/src/LambdaDemo4.java new file mode 100644 index 000000000..4fbd88664 --- /dev/null +++ b/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo/src/LambdaDemo4.java @@ -0,0 +1,27 @@ +import java.util.ArrayList; +import java.util.List; + +public class LambdaDemo4 +{ + + public static void main(String[] args) + { + + List nameList = new ArrayList<>(); + nameList.add("Peter"); + nameList.add("John"); + nameList.add("Juli"); + nameList.add("Stephan"); + + /* + * In Java 8, we can loop a List with forEach + lambda + * expression or method reference. + */ + + //Stream and filter + nameList.stream() + .filter(name->name.contains("Juli")) + .forEach(System.out::println); + } + +} diff --git a/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo1_Output.txt b/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo1_Output.txt new file mode 100644 index 000000000..2409b100d --- /dev/null +++ b/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo1_Output.txt @@ -0,0 +1,9 @@ +Peter +John +Juli +Stephan +------------------------------------ +Peter +John +Juli +Stephan diff --git a/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo2_Output.txt b/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo2_Output.txt new file mode 100644 index 000000000..009ad52c0 --- /dev/null +++ b/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo2_Output.txt @@ -0,0 +1 @@ +Hello John diff --git a/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo3_Output.txt b/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo3_Output.txt new file mode 100644 index 000000000..5141b3f47 --- /dev/null +++ b/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo3_Output.txt @@ -0,0 +1,4 @@ +Peter +John +Juli +Stephan diff --git a/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo4_Output.txt b/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo4_Output.txt new file mode 100644 index 000000000..518b8912f --- /dev/null +++ b/BasicJava/LambdaDemo_list_foreach_app/LambdaDemo4_Output.txt @@ -0,0 +1 @@ +Juli diff --git a/BasicJava/LambdaDemo_list_foreach_person_app/LambdaDemo/.classpath b/BasicJava/LambdaDemo_list_foreach_person_app/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_list_foreach_person_app/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_list_foreach_person_app/LambdaDemo/.project b/BasicJava/LambdaDemo_list_foreach_person_app/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_list_foreach_person_app/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_list_foreach_person_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_list_foreach_person_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_list_foreach_person_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_list_foreach_person_app/LambdaDemo/bin/LambdaDemo.class b/BasicJava/LambdaDemo_list_foreach_person_app/LambdaDemo/bin/LambdaDemo.class new file mode 100644 index 000000000..4cdd191d2 Binary files /dev/null and b/BasicJava/LambdaDemo_list_foreach_person_app/LambdaDemo/bin/LambdaDemo.class differ diff --git a/BasicJava/LambdaDemo_list_foreach_person_app/LambdaDemo/bin/Person.class b/BasicJava/LambdaDemo_list_foreach_person_app/LambdaDemo/bin/Person.class new file mode 100644 index 000000000..943cff944 Binary files /dev/null and b/BasicJava/LambdaDemo_list_foreach_person_app/LambdaDemo/bin/Person.class differ diff --git a/BasicJava/LambdaDemo_list_foreach_person_app/LambdaDemo/src/LambdaDemo.java b/BasicJava/LambdaDemo_list_foreach_person_app/LambdaDemo/src/LambdaDemo.java new file mode 100644 index 000000000..e27f83213 --- /dev/null +++ b/BasicJava/LambdaDemo_list_foreach_person_app/LambdaDemo/src/LambdaDemo.java @@ -0,0 +1,39 @@ +import java.util.Arrays; +import java.util.List; + +public class LambdaDemo +{ + public static void main(String[] args) + { + + List personList = Arrays.asList( + new Person("Carla", 33), new Person("Balu", 32), + new Person("Bharth", 40), new Person("Ajay", 31)); + + + System.out.println("---------- With out lambda-----------------"); + /* + * Before JDK 8, With out lambda + */ + for (Person person : personList) + { + System.out.println(person); + } + + System.out.println("\n----------With lambda-----------------"); + + /* + * Now JDK 8 , With lambda + */ + personList.forEach(person -> System.out.println(person)); + + System.out.println("\n----------Method Reference-------------"); + + /* + * Method Reference + */ + personList.forEach(System.out::println); + + } + +} diff --git a/BasicJava/LambdaDemo_list_foreach_person_app/LambdaDemo/src/Person.java b/BasicJava/LambdaDemo_list_foreach_person_app/LambdaDemo/src/Person.java new file mode 100644 index 000000000..5c3924f59 --- /dev/null +++ b/BasicJava/LambdaDemo_list_foreach_person_app/LambdaDemo/src/Person.java @@ -0,0 +1,39 @@ +public class Person +{ + private String name; + private int age; + + public Person(String name, int age) + { + super(); + this.name = name; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + @Override + public String toString() + { + return "Person [name=" + name + ", age=" + age + "]"; + } + +} diff --git a/BasicJava/LambdaDemo_list_foreach_person_app/Output.txt b/BasicJava/LambdaDemo_list_foreach_person_app/Output.txt new file mode 100644 index 000000000..0f813666f --- /dev/null +++ b/BasicJava/LambdaDemo_list_foreach_person_app/Output.txt @@ -0,0 +1,17 @@ +---------- With out lambda----------------- +Person [name=Carla, age=33] +Person [name=Balu, age=32] +Person [name=Bharth, age=40] +Person [name=Ajay, age=31] + +----------With lambda----------------- +Person [name=Carla, age=33] +Person [name=Balu, age=32] +Person [name=Bharth, age=40] +Person [name=Ajay, age=31] + +----------Method Reference------------- +Person [name=Carla, age=33] +Person [name=Balu, age=32] +Person [name=Bharth, age=40] +Person [name=Ajay, age=31] diff --git a/BasicJava/LambdaDemo_map_foreach_app/LambdaDemo/.classpath b/BasicJava/LambdaDemo_map_foreach_app/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_map_foreach_app/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_map_foreach_app/LambdaDemo/.project b/BasicJava/LambdaDemo_map_foreach_app/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_map_foreach_app/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_map_foreach_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_map_foreach_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_map_foreach_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_map_foreach_app/LambdaDemo/bin/LambdaDemo1.class b/BasicJava/LambdaDemo_map_foreach_app/LambdaDemo/bin/LambdaDemo1.class new file mode 100644 index 000000000..8b94bc7ef Binary files /dev/null and b/BasicJava/LambdaDemo_map_foreach_app/LambdaDemo/bin/LambdaDemo1.class differ diff --git a/BasicJava/LambdaDemo_map_foreach_app/LambdaDemo/bin/LambdaDemo2.class b/BasicJava/LambdaDemo_map_foreach_app/LambdaDemo/bin/LambdaDemo2.class new file mode 100644 index 000000000..bdd1090dd Binary files /dev/null and b/BasicJava/LambdaDemo_map_foreach_app/LambdaDemo/bin/LambdaDemo2.class differ diff --git a/BasicJava/LambdaDemo_map_foreach_app/LambdaDemo/src/LambdaDemo1.java b/BasicJava/LambdaDemo_map_foreach_app/LambdaDemo/src/LambdaDemo1.java new file mode 100644 index 000000000..a94c5a7a6 --- /dev/null +++ b/BasicJava/LambdaDemo_map_foreach_app/LambdaDemo/src/LambdaDemo1.java @@ -0,0 +1,34 @@ +import java.util.LinkedHashMap; +import java.util.Map; + +public class LambdaDemo1 +{ + + public static void main(String[] args) + { + + Map map = new LinkedHashMap<>(); + map.put(1, "Peter"); + map.put(2, "John"); + map.put(3, "Juli"); + map.put(4, "Stephan"); + + /* + * Normal way to loop a Map.Before Java 8 + */ + for (Map.Entry entry : map.entrySet()) + { + System.out.println("key : " + entry.getKey() + ", value : " + + entry.getValue()); + } + + System.out.println("------------------------------------"); + + /* + * In Java 8, we can loop a Map with forEach + lambda expression. + */ + map.forEach((k, v) -> System.out.println("key : " + k + " value : " + v)); + + } + +} diff --git a/BasicJava/LambdaDemo_map_foreach_app/LambdaDemo/src/LambdaDemo2.java b/BasicJava/LambdaDemo_map_foreach_app/LambdaDemo/src/LambdaDemo2.java new file mode 100644 index 000000000..f3e265c19 --- /dev/null +++ b/BasicJava/LambdaDemo_map_foreach_app/LambdaDemo/src/LambdaDemo2.java @@ -0,0 +1,30 @@ +import java.util.LinkedHashMap; +import java.util.Map; + +public class LambdaDemo2 +{ + + public static void main(String[] args) + { + + Map map = new LinkedHashMap<>(); + map.put(1, "Peter"); + map.put(2, "John"); + map.put(3, "Juli"); + map.put(4, "Stephan"); + + /* + * In Java 8, we can loop a Map with forEach + lambda + * expression+multiple statements. + */ + + map.forEach((k, v) -> { + System.out.println("key : " + k + " value : " + v); + if ("John".equals(v)) + { + System.out.println("Hello John"); + } + }); + } + +} diff --git a/BasicJava/LambdaDemo_map_foreach_app/LambdaDemo1_Output.txt b/BasicJava/LambdaDemo_map_foreach_app/LambdaDemo1_Output.txt new file mode 100644 index 000000000..0b08d6875 --- /dev/null +++ b/BasicJava/LambdaDemo_map_foreach_app/LambdaDemo1_Output.txt @@ -0,0 +1,9 @@ +key : 1, value : Peter +key : 2, value : John +key : 3, value : Juli +key : 4, value : Stephan +------------------------------------ +key : 1 value : Peter +key : 2 value : John +key : 3 value : Juli +key : 4 value : Stephan diff --git a/BasicJava/LambdaDemo_map_foreach_app/LambdaDemo2_Output.txt b/BasicJava/LambdaDemo_map_foreach_app/LambdaDemo2_Output.txt new file mode 100644 index 000000000..9e12b4acc --- /dev/null +++ b/BasicJava/LambdaDemo_map_foreach_app/LambdaDemo2_Output.txt @@ -0,0 +1,5 @@ +key : 1 value : Peter +key : 2 value : John +Hello John +key : 3 value : Juli +key : 4 value : Stephan diff --git a/BasicJava/LambdaDemo_math_App/LambdaDemo/.classpath b/BasicJava/LambdaDemo_math_App/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_math_App/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_math_App/LambdaDemo/.project b/BasicJava/LambdaDemo_math_App/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_math_App/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_math_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_math_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_math_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_math_App/LambdaDemo/bin/LambdaDemo.class b/BasicJava/LambdaDemo_math_App/LambdaDemo/bin/LambdaDemo.class new file mode 100644 index 000000000..040cb622d Binary files /dev/null and b/BasicJava/LambdaDemo_math_App/LambdaDemo/bin/LambdaDemo.class differ diff --git a/BasicJava/LambdaDemo_math_App/LambdaDemo/bin/MathOperation.class b/BasicJava/LambdaDemo_math_App/LambdaDemo/bin/MathOperation.class new file mode 100644 index 000000000..6f477742a Binary files /dev/null and b/BasicJava/LambdaDemo_math_App/LambdaDemo/bin/MathOperation.class differ diff --git a/BasicJava/LambdaDemo_math_App/LambdaDemo/src/LambdaDemo.java b/BasicJava/LambdaDemo_math_App/LambdaDemo/src/LambdaDemo.java new file mode 100644 index 000000000..d05999ef6 --- /dev/null +++ b/BasicJava/LambdaDemo_math_App/LambdaDemo/src/LambdaDemo.java @@ -0,0 +1,43 @@ +@FunctionalInterface +interface MathOperation +{ + int operation(int a, int b); +} + +public class LambdaDemo +{ + + public static void main(String[] args) + { + + LambdaDemo lambdaDemo = new LambdaDemo(); + + // with type declaration + MathOperation addition = (int a, int b) -> a + b; + + // with out type declaration + MathOperation subtraction = (a, b) -> a - b; + + // with return statement along with curly braces + MathOperation multiplication = (int a, int b) -> { + return a * b; + }; + + // without return statement and without curly braces + MathOperation division = (int a, int b) -> a / b; + + System.out.println("10 + 5 = " + lambdaDemo.operate(10, 5, addition)); + + System.out.println("10 - 5 = " + lambdaDemo.operate(10, 5, subtraction)); + + System.out.println("10 x 5 = " + lambdaDemo.operate(10, 5, multiplication)); + + System.out.println("10 / 5 = " + lambdaDemo.operate(10, 5, division)); + } + + private int operate(int a, int b, MathOperation mathOperation) + { + return mathOperation.operation(a, b); + } + +} diff --git a/BasicJava/LambdaDemo_math_App/Output.txt b/BasicJava/LambdaDemo_math_App/Output.txt new file mode 100644 index 000000000..69b9c439c --- /dev/null +++ b/BasicJava/LambdaDemo_math_App/Output.txt @@ -0,0 +1,4 @@ +10 + 5 = 15 +10 - 5 = 5 +10 x 5 = 50 +10 / 5 = 2 diff --git a/BasicJava/LambdaDemo_method_accept_lambda_App/LambdaDemo/.classpath b/BasicJava/LambdaDemo_method_accept_lambda_App/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_method_accept_lambda_App/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_method_accept_lambda_App/LambdaDemo/.project b/BasicJava/LambdaDemo_method_accept_lambda_App/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_method_accept_lambda_App/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_method_accept_lambda_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_method_accept_lambda_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_method_accept_lambda_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_method_accept_lambda_App/LambdaDemo/bin/LambdaDemo.class b/BasicJava/LambdaDemo_method_accept_lambda_App/LambdaDemo/bin/LambdaDemo.class new file mode 100644 index 000000000..e5499920a Binary files /dev/null and b/BasicJava/LambdaDemo_method_accept_lambda_App/LambdaDemo/bin/LambdaDemo.class differ diff --git a/BasicJava/LambdaDemo_method_accept_lambda_App/LambdaDemo/bin/StringLengthLambda.class b/BasicJava/LambdaDemo_method_accept_lambda_App/LambdaDemo/bin/StringLengthLambda.class new file mode 100644 index 000000000..ba967f9fe Binary files /dev/null and b/BasicJava/LambdaDemo_method_accept_lambda_App/LambdaDemo/bin/StringLengthLambda.class differ diff --git a/BasicJava/LambdaDemo_method_accept_lambda_App/LambdaDemo/src/LambdaDemo.java b/BasicJava/LambdaDemo_method_accept_lambda_App/LambdaDemo/src/LambdaDemo.java new file mode 100644 index 000000000..d1824b5e9 --- /dev/null +++ b/BasicJava/LambdaDemo_method_accept_lambda_App/LambdaDemo/src/LambdaDemo.java @@ -0,0 +1,21 @@ +@FunctionalInterface +interface StringLengthLambda +{ + int getLength(String str); +} + +public class LambdaDemo +{ + + public static void main(String[] args) + { + printLambda(str -> str.length()); + } + + private static void printLambda(StringLengthLambda stringLengthLambda) + { + int length = stringLengthLambda.getLength("Welcome"); + System.out.println("length = " + length); + } + +} diff --git a/BasicJava/LambdaDemo_method_accept_lambda_App/Output.txt b/BasicJava/LambdaDemo_method_accept_lambda_App/Output.txt new file mode 100644 index 000000000..ba7867137 --- /dev/null +++ b/BasicJava/LambdaDemo_method_accept_lambda_App/Output.txt @@ -0,0 +1 @@ +length = 7 diff --git a/BasicJava/LambdaDemo_method_ref_constructor_app/LambdaDemo/.classpath b/BasicJava/LambdaDemo_method_ref_constructor_app/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_constructor_app/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_method_ref_constructor_app/LambdaDemo/.project b/BasicJava/LambdaDemo_method_ref_constructor_app/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_constructor_app/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_method_ref_constructor_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_method_ref_constructor_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_constructor_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_method_ref_constructor_app/LambdaDemo/bin/Message.class b/BasicJava/LambdaDemo_method_ref_constructor_app/LambdaDemo/bin/Message.class new file mode 100644 index 000000000..341c13d1d Binary files /dev/null and b/BasicJava/LambdaDemo_method_ref_constructor_app/LambdaDemo/bin/Message.class differ diff --git a/BasicJava/LambdaDemo_method_ref_constructor_app/LambdaDemo/bin/Messageable.class b/BasicJava/LambdaDemo_method_ref_constructor_app/LambdaDemo/bin/Messageable.class new file mode 100644 index 000000000..23d46a212 Binary files /dev/null and b/BasicJava/LambdaDemo_method_ref_constructor_app/LambdaDemo/bin/Messageable.class differ diff --git a/BasicJava/LambdaDemo_method_ref_constructor_app/LambdaDemo/bin/MethodReferenceDemo.class b/BasicJava/LambdaDemo_method_ref_constructor_app/LambdaDemo/bin/MethodReferenceDemo.class new file mode 100644 index 000000000..6b4506468 Binary files /dev/null and b/BasicJava/LambdaDemo_method_ref_constructor_app/LambdaDemo/bin/MethodReferenceDemo.class differ diff --git a/BasicJava/LambdaDemo_method_ref_constructor_app/LambdaDemo/src/MethodReferenceDemo.java b/BasicJava/LambdaDemo_method_ref_constructor_app/LambdaDemo/src/MethodReferenceDemo.java new file mode 100644 index 000000000..4755ec0ba --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_constructor_app/LambdaDemo/src/MethodReferenceDemo.java @@ -0,0 +1,28 @@ +/** + * + * We are using functional interface Messageable and referring constructor with + * the help of functional interface. + * + */ +@FunctionalInterface +interface Messageable +{ + Message getMessage(String msg); +} + +class Message +{ + public Message(String msg) + { + System.out.print(msg); + } +} + +public class MethodReferenceDemo +{ + public static void main(String[] args) + { + Messageable messageable = Message::new; + messageable.getMessage("Hello"); + } +} \ No newline at end of file diff --git a/BasicJava/LambdaDemo_method_ref_constructor_app/Output.txt b/BasicJava/LambdaDemo_method_ref_constructor_app/Output.txt new file mode 100644 index 000000000..5ab2f8a43 --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_constructor_app/Output.txt @@ -0,0 +1 @@ +Hello \ No newline at end of file diff --git a/BasicJava/LambdaDemo_method_ref_list_foreach_app/LambdaDemo/.classpath b/BasicJava/LambdaDemo_method_ref_list_foreach_app/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_list_foreach_app/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_method_ref_list_foreach_app/LambdaDemo/.project b/BasicJava/LambdaDemo_method_ref_list_foreach_app/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_list_foreach_app/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_method_ref_list_foreach_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_method_ref_list_foreach_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_list_foreach_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_method_ref_list_foreach_app/LambdaDemo/bin/LambdaDemo.class b/BasicJava/LambdaDemo_method_ref_list_foreach_app/LambdaDemo/bin/LambdaDemo.class new file mode 100644 index 000000000..f22820bf0 Binary files /dev/null and b/BasicJava/LambdaDemo_method_ref_list_foreach_app/LambdaDemo/bin/LambdaDemo.class differ diff --git a/BasicJava/LambdaDemo_method_ref_list_foreach_app/LambdaDemo/bin/MethodReferenceDemo.class b/BasicJava/LambdaDemo_method_ref_list_foreach_app/LambdaDemo/bin/MethodReferenceDemo.class new file mode 100644 index 000000000..d05a70462 Binary files /dev/null and b/BasicJava/LambdaDemo_method_ref_list_foreach_app/LambdaDemo/bin/MethodReferenceDemo.class differ diff --git a/BasicJava/LambdaDemo_method_ref_list_foreach_app/LambdaDemo/src/MethodReferenceDemo.java b/BasicJava/LambdaDemo_method_ref_list_foreach_app/LambdaDemo/src/MethodReferenceDemo.java new file mode 100644 index 000000000..5300a3a57 --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_list_foreach_app/LambdaDemo/src/MethodReferenceDemo.java @@ -0,0 +1,23 @@ +import java.util.ArrayList; +import java.util.List; + +public class MethodReferenceDemo +{ + public static void main(String[] args) + { + + List nameList = new ArrayList<>(); + nameList.add("Peter"); + nameList.add("John"); + nameList.add("Juli"); + nameList.add("Stephan"); + + nameList.forEach(name -> System.out.println(name)); + + System.out.println("------------------------"); + + // method reference + nameList.forEach(System.out::println); + } + +} diff --git a/BasicJava/LambdaDemo_method_ref_list_foreach_app/Output.txt b/BasicJava/LambdaDemo_method_ref_list_foreach_app/Output.txt new file mode 100644 index 000000000..4d05dc725 --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_list_foreach_app/Output.txt @@ -0,0 +1,9 @@ +Peter +John +Juli +Stephan +------------------------ +Peter +John +Juli +Stephan diff --git a/BasicJava/LambdaDemo_method_ref_nonstatic_Bifunction_app/LambdaDemo/.classpath b/BasicJava/LambdaDemo_method_ref_nonstatic_Bifunction_app/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_nonstatic_Bifunction_app/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_method_ref_nonstatic_Bifunction_app/LambdaDemo/.project b/BasicJava/LambdaDemo_method_ref_nonstatic_Bifunction_app/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_nonstatic_Bifunction_app/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_method_ref_nonstatic_Bifunction_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_method_ref_nonstatic_Bifunction_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_nonstatic_Bifunction_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_method_ref_nonstatic_Bifunction_app/LambdaDemo/bin/Arithmetic.class b/BasicJava/LambdaDemo_method_ref_nonstatic_Bifunction_app/LambdaDemo/bin/Arithmetic.class new file mode 100644 index 000000000..342193e4a Binary files /dev/null and b/BasicJava/LambdaDemo_method_ref_nonstatic_Bifunction_app/LambdaDemo/bin/Arithmetic.class differ diff --git a/BasicJava/LambdaDemo_method_ref_nonstatic_Bifunction_app/LambdaDemo/bin/MethodReferenceDemo.class b/BasicJava/LambdaDemo_method_ref_nonstatic_Bifunction_app/LambdaDemo/bin/MethodReferenceDemo.class new file mode 100644 index 000000000..f68da794c Binary files /dev/null and b/BasicJava/LambdaDemo_method_ref_nonstatic_Bifunction_app/LambdaDemo/bin/MethodReferenceDemo.class differ diff --git a/BasicJava/LambdaDemo_method_ref_nonstatic_Bifunction_app/LambdaDemo/src/MethodReferenceDemo.java b/BasicJava/LambdaDemo_method_ref_nonstatic_Bifunction_app/LambdaDemo/src/MethodReferenceDemo.java new file mode 100644 index 000000000..b5eabf518 --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_nonstatic_Bifunction_app/LambdaDemo/src/MethodReferenceDemo.java @@ -0,0 +1,27 @@ +import java.util.function.BiFunction; + +/** + * + * We are using predefined functional interface BiFunction and + * referring a non-static method add(int a, int b) to it's functional + * method apply(Integer t,Integer u). + * + */ + +class Arithmetic +{ + public int add(int a, int b) + { + return a + b; + } +} + +public class MethodReferenceDemo +{ + public static void main(String[] args) + { + BiFunction adder = new Arithmetic()::add; + int result = adder.apply(200, 200); + System.out.println(result); + } +} \ No newline at end of file diff --git a/BasicJava/LambdaDemo_method_ref_nonstatic_Bifunction_app/Output.txt b/BasicJava/LambdaDemo_method_ref_nonstatic_Bifunction_app/Output.txt new file mode 100644 index 000000000..d411bb7c1 --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_nonstatic_Bifunction_app/Output.txt @@ -0,0 +1 @@ +400 diff --git a/BasicJava/LambdaDemo_method_ref_nonstatic_dog_app/LambdaDemo/.classpath b/BasicJava/LambdaDemo_method_ref_nonstatic_dog_app/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_nonstatic_dog_app/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_method_ref_nonstatic_dog_app/LambdaDemo/.project b/BasicJava/LambdaDemo_method_ref_nonstatic_dog_app/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_nonstatic_dog_app/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_method_ref_nonstatic_dog_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_method_ref_nonstatic_dog_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_nonstatic_dog_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_method_ref_nonstatic_dog_app/LambdaDemo/bin/Dog.class b/BasicJava/LambdaDemo_method_ref_nonstatic_dog_app/LambdaDemo/bin/Dog.class new file mode 100644 index 000000000..e6e8c49bd Binary files /dev/null and b/BasicJava/LambdaDemo_method_ref_nonstatic_dog_app/LambdaDemo/bin/Dog.class differ diff --git a/BasicJava/LambdaDemo_method_ref_nonstatic_dog_app/LambdaDemo/bin/MethodReferenceDemo.class b/BasicJava/LambdaDemo_method_ref_nonstatic_dog_app/LambdaDemo/bin/MethodReferenceDemo.class new file mode 100644 index 000000000..53f0e1b2f Binary files /dev/null and b/BasicJava/LambdaDemo_method_ref_nonstatic_dog_app/LambdaDemo/bin/MethodReferenceDemo.class differ diff --git a/BasicJava/LambdaDemo_method_ref_nonstatic_dog_app/LambdaDemo/src/MethodReferenceDemo.java b/BasicJava/LambdaDemo_method_ref_nonstatic_dog_app/LambdaDemo/src/MethodReferenceDemo.java new file mode 100644 index 000000000..d16380ab6 --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_nonstatic_dog_app/LambdaDemo/src/MethodReferenceDemo.java @@ -0,0 +1,32 @@ +/** + * + * We have defined a functional interface Dog and referring a + * non-static method dogEating() to it's functional method eat(). + * + */ + +@FunctionalInterface +interface Dog +{ + void eat(); +} + +public class MethodReferenceDemo +{ + public void dogEating() + { + System.out.println("Dog is eating chicken."); + } + + public static void main(String[] args) + { + // Creating object + MethodReferenceDemo methodReferenceDemo = new MethodReferenceDemo(); + + // Referring non-static method using reference + Dog dog = methodReferenceDemo::dogEating; + + // Calling interface method + dog.eat(); + } +} \ No newline at end of file diff --git a/BasicJava/LambdaDemo_method_ref_nonstatic_dog_app/Output.txt b/BasicJava/LambdaDemo_method_ref_nonstatic_dog_app/Output.txt new file mode 100644 index 000000000..e0a58b080 --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_nonstatic_dog_app/Output.txt @@ -0,0 +1 @@ +Dog is eating chicken. diff --git a/BasicJava/LambdaDemo_method_ref_nonstatic_runnable_app/LambdaDemo/.classpath b/BasicJava/LambdaDemo_method_ref_nonstatic_runnable_app/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_nonstatic_runnable_app/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_method_ref_nonstatic_runnable_app/LambdaDemo/.project b/BasicJava/LambdaDemo_method_ref_nonstatic_runnable_app/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_nonstatic_runnable_app/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_method_ref_nonstatic_runnable_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_method_ref_nonstatic_runnable_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_nonstatic_runnable_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_method_ref_nonstatic_runnable_app/LambdaDemo/bin/MethodReferenceDemo.class b/BasicJava/LambdaDemo_method_ref_nonstatic_runnable_app/LambdaDemo/bin/MethodReferenceDemo.class new file mode 100644 index 000000000..a8928d697 Binary files /dev/null and b/BasicJava/LambdaDemo_method_ref_nonstatic_runnable_app/LambdaDemo/bin/MethodReferenceDemo.class differ diff --git a/BasicJava/LambdaDemo_method_ref_nonstatic_runnable_app/LambdaDemo/src/MethodReferenceDemo.java b/BasicJava/LambdaDemo_method_ref_nonstatic_runnable_app/LambdaDemo/src/MethodReferenceDemo.java new file mode 100644 index 000000000..9fb492eaf --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_nonstatic_runnable_app/LambdaDemo/src/MethodReferenceDemo.java @@ -0,0 +1,22 @@ +/** + * + * We are using predefined functional interface Runnable and referring + * a non-static method ThreadStatus() to it's functional method run(). + * + */ + +public class MethodReferenceDemo +{ + public void ThreadStatus() + { + System.out.println("Thread is running..."); + } + + public static void main(String[] args) + { + MethodReferenceDemo methodReferenceDemo = new MethodReferenceDemo(); + Runnable runnable = methodReferenceDemo::ThreadStatus; + Thread thread = new Thread(runnable); + thread.start(); + } +} \ No newline at end of file diff --git a/BasicJava/LambdaDemo_method_ref_nonstatic_runnable_app/Output.txt b/BasicJava/LambdaDemo_method_ref_nonstatic_runnable_app/Output.txt new file mode 100644 index 000000000..1a8759810 --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_nonstatic_runnable_app/Output.txt @@ -0,0 +1 @@ +Thread is running... diff --git a/BasicJava/LambdaDemo_method_ref_static_BiFunc_app/LambdaDemo/.classpath b/BasicJava/LambdaDemo_method_ref_static_BiFunc_app/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_static_BiFunc_app/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_method_ref_static_BiFunc_app/LambdaDemo/.project b/BasicJava/LambdaDemo_method_ref_static_BiFunc_app/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_static_BiFunc_app/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_method_ref_static_BiFunc_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_method_ref_static_BiFunc_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_static_BiFunc_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_method_ref_static_BiFunc_app/LambdaDemo/bin/Arithmetic.class b/BasicJava/LambdaDemo_method_ref_static_BiFunc_app/LambdaDemo/bin/Arithmetic.class new file mode 100644 index 000000000..97f501a02 Binary files /dev/null and b/BasicJava/LambdaDemo_method_ref_static_BiFunc_app/LambdaDemo/bin/Arithmetic.class differ diff --git a/BasicJava/LambdaDemo_method_ref_static_BiFunc_app/LambdaDemo/bin/MethodReferenceDemo.class b/BasicJava/LambdaDemo_method_ref_static_BiFunc_app/LambdaDemo/bin/MethodReferenceDemo.class new file mode 100644 index 000000000..835a8b536 Binary files /dev/null and b/BasicJava/LambdaDemo_method_ref_static_BiFunc_app/LambdaDemo/bin/MethodReferenceDemo.class differ diff --git a/BasicJava/LambdaDemo_method_ref_static_BiFunc_app/LambdaDemo/src/MethodReferenceDemo.java b/BasicJava/LambdaDemo_method_ref_static_BiFunc_app/LambdaDemo/src/MethodReferenceDemo.java new file mode 100644 index 000000000..8ac0736ad --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_static_BiFunc_app/LambdaDemo/src/MethodReferenceDemo.java @@ -0,0 +1,27 @@ +import java.util.function.BiFunction; + +/** + * + * We are using predefined functional interface BiFunction and + * referring a static method add(int a, int b) to it's functional + * method apply(Integer t,Integer u). + * + */ + +class Arithmetic +{ + public static int add(int a, int b) + { + return a + b; + } +} + +public class MethodReferenceDemo +{ + public static void main(String[] args) + { + BiFunction adder = Arithmetic::add; + int result = adder.apply(20, 20); + System.out.println(result); + } +} \ No newline at end of file diff --git a/BasicJava/LambdaDemo_method_ref_static_BiFunc_app/Output.txt b/BasicJava/LambdaDemo_method_ref_static_BiFunc_app/Output.txt new file mode 100644 index 000000000..425151f3a --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_static_BiFunc_app/Output.txt @@ -0,0 +1 @@ +40 diff --git a/BasicJava/LambdaDemo_method_ref_static_BiFunc_overload_app/LambdaDemo/.classpath b/BasicJava/LambdaDemo_method_ref_static_BiFunc_overload_app/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_static_BiFunc_overload_app/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_method_ref_static_BiFunc_overload_app/LambdaDemo/.project b/BasicJava/LambdaDemo_method_ref_static_BiFunc_overload_app/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_static_BiFunc_overload_app/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_method_ref_static_BiFunc_overload_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_method_ref_static_BiFunc_overload_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_static_BiFunc_overload_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_method_ref_static_BiFunc_overload_app/LambdaDemo/bin/Arithmetic.class b/BasicJava/LambdaDemo_method_ref_static_BiFunc_overload_app/LambdaDemo/bin/Arithmetic.class new file mode 100644 index 000000000..ef392887e Binary files /dev/null and b/BasicJava/LambdaDemo_method_ref_static_BiFunc_overload_app/LambdaDemo/bin/Arithmetic.class differ diff --git a/BasicJava/LambdaDemo_method_ref_static_BiFunc_overload_app/LambdaDemo/bin/MethodReferenceDemo.class b/BasicJava/LambdaDemo_method_ref_static_BiFunc_overload_app/LambdaDemo/bin/MethodReferenceDemo.class new file mode 100644 index 000000000..8e28a25b0 Binary files /dev/null and b/BasicJava/LambdaDemo_method_ref_static_BiFunc_overload_app/LambdaDemo/bin/MethodReferenceDemo.class differ diff --git a/BasicJava/LambdaDemo_method_ref_static_BiFunc_overload_app/LambdaDemo/src/MethodReferenceDemo.java b/BasicJava/LambdaDemo_method_ref_static_BiFunc_overload_app/LambdaDemo/src/MethodReferenceDemo.java new file mode 100644 index 000000000..09554b86e --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_static_BiFunc_overload_app/LambdaDemo/src/MethodReferenceDemo.java @@ -0,0 +1,46 @@ +import java.util.function.BiFunction; + +/** + * + * We can also override static methods by referring methods. In the + * following example, we have defined and overloaded three add + * methods. + * + */ + +class Arithmetic +{ + public static int add(int a, int b) + { + return a + b; + } + + public static float add(int a, float b) + { + return a + b; + } + + public static float add(float a, float b) + { + return a + b; + } +} + +public class MethodReferenceDemo +{ + public static void main(String[] args) + { + BiFunction adder1 = Arithmetic::add; + BiFunction adder2 = Arithmetic::add; + BiFunction adder3 = Arithmetic::add; + + int result1 = adder1.apply(10, 20); + System.out.println(result1); + + float result2 = adder2.apply(10, 20.3f); + System.out.println(result2); + + float result3 = adder3.apply(10.6f, 20.8f); + System.out.println(result3); + } +} \ No newline at end of file diff --git a/BasicJava/LambdaDemo_method_ref_static_BiFunc_overload_app/Output.txt b/BasicJava/LambdaDemo_method_ref_static_BiFunc_overload_app/Output.txt new file mode 100644 index 000000000..bed10b49a --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_static_BiFunc_overload_app/Output.txt @@ -0,0 +1,3 @@ +30 +30.3 +31.4 diff --git a/BasicJava/LambdaDemo_method_ref_static_Runnable_app/LambdaDemo/.classpath b/BasicJava/LambdaDemo_method_ref_static_Runnable_app/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_static_Runnable_app/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_method_ref_static_Runnable_app/LambdaDemo/.project b/BasicJava/LambdaDemo_method_ref_static_Runnable_app/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_static_Runnable_app/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_method_ref_static_Runnable_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_method_ref_static_Runnable_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_static_Runnable_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_method_ref_static_Runnable_app/LambdaDemo/bin/MethodReferenceDemo.class b/BasicJava/LambdaDemo_method_ref_static_Runnable_app/LambdaDemo/bin/MethodReferenceDemo.class new file mode 100644 index 000000000..181ad93c4 Binary files /dev/null and b/BasicJava/LambdaDemo_method_ref_static_Runnable_app/LambdaDemo/bin/MethodReferenceDemo.class differ diff --git a/BasicJava/LambdaDemo_method_ref_static_Runnable_app/LambdaDemo/src/MethodReferenceDemo.java b/BasicJava/LambdaDemo_method_ref_static_Runnable_app/LambdaDemo/src/MethodReferenceDemo.java new file mode 100644 index 000000000..ab2818e4c --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_static_Runnable_app/LambdaDemo/src/MethodReferenceDemo.java @@ -0,0 +1,21 @@ +/** + * + * We are using predefined functional interface Runnable and referring + * a static method ThreadStatus() to it's functional method run(). + * + */ + +public class MethodReferenceDemo +{ + public static void ThreadStatus() + { + System.out.println("Thread is running..."); + } + + public static void main(String[] args) + { + Runnable runnable = MethodReferenceDemo::ThreadStatus; + Thread thread = new Thread(runnable); + thread.start(); + } +} \ No newline at end of file diff --git a/BasicJava/LambdaDemo_method_ref_static_Runnable_app/Output.txt b/BasicJava/LambdaDemo_method_ref_static_Runnable_app/Output.txt new file mode 100644 index 000000000..1a8759810 --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_static_Runnable_app/Output.txt @@ -0,0 +1 @@ +Thread is running... diff --git a/BasicJava/LambdaDemo_method_ref_static_dog_app/LambdaDemo/.classpath b/BasicJava/LambdaDemo_method_ref_static_dog_app/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_static_dog_app/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_method_ref_static_dog_app/LambdaDemo/.project b/BasicJava/LambdaDemo_method_ref_static_dog_app/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_static_dog_app/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_method_ref_static_dog_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_method_ref_static_dog_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_static_dog_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_method_ref_static_dog_app/LambdaDemo/bin/Dog.class b/BasicJava/LambdaDemo_method_ref_static_dog_app/LambdaDemo/bin/Dog.class new file mode 100644 index 000000000..e6e8c49bd Binary files /dev/null and b/BasicJava/LambdaDemo_method_ref_static_dog_app/LambdaDemo/bin/Dog.class differ diff --git a/BasicJava/LambdaDemo_method_ref_static_dog_app/LambdaDemo/bin/MethodReferenceDemo.class b/BasicJava/LambdaDemo_method_ref_static_dog_app/LambdaDemo/bin/MethodReferenceDemo.class new file mode 100644 index 000000000..d8ffcc559 Binary files /dev/null and b/BasicJava/LambdaDemo_method_ref_static_dog_app/LambdaDemo/bin/MethodReferenceDemo.class differ diff --git a/BasicJava/LambdaDemo_method_ref_static_dog_app/LambdaDemo/src/MethodReferenceDemo.java b/BasicJava/LambdaDemo_method_ref_static_dog_app/LambdaDemo/src/MethodReferenceDemo.java new file mode 100644 index 000000000..41f60ba0c --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_static_dog_app/LambdaDemo/src/MethodReferenceDemo.java @@ -0,0 +1,28 @@ +/** + * + * We have defined a functional interface Dog and referring a + * static method dogEating() to it's functional method eat(). + * + */ + +@FunctionalInterface +interface Dog +{ + void eat(); +} + +public class MethodReferenceDemo +{ + public static void dogEating() + { + System.out.println("Dog is eating chicken."); + } + + public static void main(String[] args) + { + // Referring static method + Dog dog = MethodReferenceDemo::dogEating; + // Calling interface method + dog.eat(); + } +} \ No newline at end of file diff --git a/BasicJava/LambdaDemo_method_ref_static_dog_app/Output.txt b/BasicJava/LambdaDemo_method_ref_static_dog_app/Output.txt new file mode 100644 index 000000000..e0a58b080 --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_static_dog_app/Output.txt @@ -0,0 +1 @@ +Dog is eating chicken. diff --git a/BasicJava/LambdaDemo_method_ref_static_person_app/LambdaDemo/.classpath b/BasicJava/LambdaDemo_method_ref_static_person_app/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_static_person_app/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_method_ref_static_person_app/LambdaDemo/.project b/BasicJava/LambdaDemo_method_ref_static_person_app/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_static_person_app/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_method_ref_static_person_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_method_ref_static_person_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_static_person_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_method_ref_static_person_app/LambdaDemo/bin/MethodReferenceDemo.class b/BasicJava/LambdaDemo_method_ref_static_person_app/LambdaDemo/bin/MethodReferenceDemo.class new file mode 100644 index 000000000..ae415f42b Binary files /dev/null and b/BasicJava/LambdaDemo_method_ref_static_person_app/LambdaDemo/bin/MethodReferenceDemo.class differ diff --git a/BasicJava/LambdaDemo_method_ref_static_person_app/LambdaDemo/bin/Person.class b/BasicJava/LambdaDemo_method_ref_static_person_app/LambdaDemo/bin/Person.class new file mode 100644 index 000000000..812eb4abd Binary files /dev/null and b/BasicJava/LambdaDemo_method_ref_static_person_app/LambdaDemo/bin/Person.class differ diff --git a/BasicJava/LambdaDemo_method_ref_static_person_app/LambdaDemo/src/MethodReferenceDemo.java b/BasicJava/LambdaDemo_method_ref_static_person_app/LambdaDemo/src/MethodReferenceDemo.java new file mode 100644 index 000000000..c71536453 --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_static_person_app/LambdaDemo/src/MethodReferenceDemo.java @@ -0,0 +1,28 @@ +/** + * + * We have defined a functional interface person and referring a + * static method personWalking() to it's functional method walk(). + * + */ + +@FunctionalInterface +interface Person +{ + void walk(); +} + +public class MethodReferenceDemo +{ + public static void personWalking() + { + System.out.println("Walking on the road."); + } + + public static void main(String[] args) + { + // Referring static method + Person person = MethodReferenceDemo::personWalking; + // Calling interface method + person.walk(); + } +} \ No newline at end of file diff --git a/BasicJava/LambdaDemo_method_ref_static_person_app/Output.txt b/BasicJava/LambdaDemo_method_ref_static_person_app/Output.txt new file mode 100644 index 000000000..1a2f88911 --- /dev/null +++ b/BasicJava/LambdaDemo_method_ref_static_person_app/Output.txt @@ -0,0 +1 @@ +Walking on the road. diff --git a/BasicJava/LambdaDemo_multi_param_App/LambdaDemo/.classpath b/BasicJava/LambdaDemo_multi_param_App/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_multi_param_App/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_multi_param_App/LambdaDemo/.project b/BasicJava/LambdaDemo_multi_param_App/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_multi_param_App/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_multi_param_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_multi_param_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_multi_param_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_multi_param_App/LambdaDemo/bin/Dog.class b/BasicJava/LambdaDemo_multi_param_App/LambdaDemo/bin/Dog.class new file mode 100644 index 000000000..edf67eaea Binary files /dev/null and b/BasicJava/LambdaDemo_multi_param_App/LambdaDemo/bin/Dog.class differ diff --git a/BasicJava/LambdaDemo_multi_param_App/LambdaDemo/bin/LambdaDemo.class b/BasicJava/LambdaDemo_multi_param_App/LambdaDemo/bin/LambdaDemo.class new file mode 100644 index 000000000..16d0c94a2 Binary files /dev/null and b/BasicJava/LambdaDemo_multi_param_App/LambdaDemo/bin/LambdaDemo.class differ diff --git a/BasicJava/LambdaDemo_multi_param_App/LambdaDemo/src/LambdaDemo.java b/BasicJava/LambdaDemo_multi_param_App/LambdaDemo/src/LambdaDemo.java new file mode 100644 index 000000000..45be3303e --- /dev/null +++ b/BasicJava/LambdaDemo_multi_param_App/LambdaDemo/src/LambdaDemo.java @@ -0,0 +1,28 @@ +@FunctionalInterface +interface Dog +{ + public void eat(String foodName1, String foodName2); +} + +/** + * + * A lambda expression can have zero or any number of arguments. + * + */ +public class LambdaDemo +{ + + public static void main(String[] args) + { + /* + * Java Lambda Expression Example: Multiple Parameters. + */ + Dog dog = (foodName1, foodName2) -> + { + System.out.println( + "eating " + foodName1 + " and " + foodName2); + }; + dog.eat("Mutton", "Biscuit"); + } + +} diff --git a/BasicJava/LambdaDemo_multi_param_App/Output.txt b/BasicJava/LambdaDemo_multi_param_App/Output.txt new file mode 100644 index 000000000..5855f24cf --- /dev/null +++ b/BasicJava/LambdaDemo_multi_param_App/Output.txt @@ -0,0 +1 @@ +eating Mutton and Biscuit diff --git a/BasicJava/LambdaDemo_multi_statement_App/LambdaDemo/.classpath b/BasicJava/LambdaDemo_multi_statement_App/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_multi_statement_App/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_multi_statement_App/LambdaDemo/.project b/BasicJava/LambdaDemo_multi_statement_App/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_multi_statement_App/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_multi_statement_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_multi_statement_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_multi_statement_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_multi_statement_App/LambdaDemo/bin/LambdaDemo.class b/BasicJava/LambdaDemo_multi_statement_App/LambdaDemo/bin/LambdaDemo.class new file mode 100644 index 000000000..989d48faa Binary files /dev/null and b/BasicJava/LambdaDemo_multi_statement_App/LambdaDemo/bin/LambdaDemo.class differ diff --git a/BasicJava/LambdaDemo_multi_statement_App/LambdaDemo/bin/Message.class b/BasicJava/LambdaDemo_multi_statement_App/LambdaDemo/bin/Message.class new file mode 100644 index 000000000..8e71fc805 Binary files /dev/null and b/BasicJava/LambdaDemo_multi_statement_App/LambdaDemo/bin/Message.class differ diff --git a/BasicJava/LambdaDemo_multi_statement_App/LambdaDemo/src/LambdaDemo.java b/BasicJava/LambdaDemo_multi_statement_App/LambdaDemo/src/LambdaDemo.java new file mode 100644 index 000000000..284c3df48 --- /dev/null +++ b/BasicJava/LambdaDemo_multi_statement_App/LambdaDemo/src/LambdaDemo.java @@ -0,0 +1,27 @@ +@FunctionalInterface +interface Message +{ + String displayMessage(String strValue); +} + +/** + * Java Lambda Expression Example: Multiple Statements + * + */ +public class LambdaDemo +{ + + public static void main(String[] args) + { + /* + * We can pass multiple statements in lambda expression. + */ + Message msg = (strValue) -> { + String str1 = "Welcome to "; + String str2 = str1 + strValue; + return str2; + }; + System.out.println(msg.displayMessage("India.")); + } + +} diff --git a/BasicJava/LambdaDemo_multi_statement_App/Output.txt b/BasicJava/LambdaDemo_multi_statement_App/Output.txt new file mode 100644 index 000000000..a86c89cf2 --- /dev/null +++ b/BasicJava/LambdaDemo_multi_statement_App/Output.txt @@ -0,0 +1 @@ +Welcome to India. diff --git a/BasicJava/LambdaDemo_no_param_App/LambdaDemo/.classpath b/BasicJava/LambdaDemo_no_param_App/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_no_param_App/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_no_param_App/LambdaDemo/.project b/BasicJava/LambdaDemo_no_param_App/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_no_param_App/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_no_param_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_no_param_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_no_param_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_no_param_App/LambdaDemo/bin/Dog.class b/BasicJava/LambdaDemo_no_param_App/LambdaDemo/bin/Dog.class new file mode 100644 index 000000000..6c59912e7 Binary files /dev/null and b/BasicJava/LambdaDemo_no_param_App/LambdaDemo/bin/Dog.class differ diff --git a/BasicJava/LambdaDemo_no_param_App/LambdaDemo/bin/LambdaDemo.class b/BasicJava/LambdaDemo_no_param_App/LambdaDemo/bin/LambdaDemo.class new file mode 100644 index 000000000..a188ba6c2 Binary files /dev/null and b/BasicJava/LambdaDemo_no_param_App/LambdaDemo/bin/LambdaDemo.class differ diff --git a/BasicJava/LambdaDemo_no_param_App/LambdaDemo/src/LambdaDemo.java b/BasicJava/LambdaDemo_no_param_App/LambdaDemo/src/LambdaDemo.java new file mode 100644 index 000000000..85748e39e --- /dev/null +++ b/BasicJava/LambdaDemo_no_param_App/LambdaDemo/src/LambdaDemo.java @@ -0,0 +1,27 @@ +@FunctionalInterface +interface Dog +{ + public void eat(); +} + +/** + * + * A lambda expression can have zero or any number of arguments. + * + */ +public class LambdaDemo +{ + + public static void main(String[] args) + { + /* + * Java Lambda Expression Example: No Parameter. + */ + Dog dog = () -> + { + System.out.println("eating chicken"); + }; + dog.eat(); + } + +} diff --git a/BasicJava/LambdaDemo_no_param_App/Output.txt b/BasicJava/LambdaDemo_no_param_App/Output.txt new file mode 100644 index 000000000..f6c9f5c9a --- /dev/null +++ b/BasicJava/LambdaDemo_no_param_App/Output.txt @@ -0,0 +1 @@ +eating chicken diff --git a/BasicJava/LambdaDemo_one_param_App/LambdaDemo/.classpath b/BasicJava/LambdaDemo_one_param_App/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_one_param_App/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_one_param_App/LambdaDemo/.project b/BasicJava/LambdaDemo_one_param_App/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_one_param_App/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_one_param_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_one_param_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_one_param_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_one_param_App/LambdaDemo/bin/Dog.class b/BasicJava/LambdaDemo_one_param_App/LambdaDemo/bin/Dog.class new file mode 100644 index 000000000..ee84a8a2b Binary files /dev/null and b/BasicJava/LambdaDemo_one_param_App/LambdaDemo/bin/Dog.class differ diff --git a/BasicJava/LambdaDemo_one_param_App/LambdaDemo/bin/LambdaDemo.class b/BasicJava/LambdaDemo_one_param_App/LambdaDemo/bin/LambdaDemo.class new file mode 100644 index 000000000..0a70598aa Binary files /dev/null and b/BasicJava/LambdaDemo_one_param_App/LambdaDemo/bin/LambdaDemo.class differ diff --git a/BasicJava/LambdaDemo_one_param_App/LambdaDemo/src/LambdaDemo.java b/BasicJava/LambdaDemo_one_param_App/LambdaDemo/src/LambdaDemo.java new file mode 100644 index 000000000..e8497d318 --- /dev/null +++ b/BasicJava/LambdaDemo_one_param_App/LambdaDemo/src/LambdaDemo.java @@ -0,0 +1,27 @@ +@FunctionalInterface +interface Dog +{ + public void eat(String foodName); +} + +/** + * + * A lambda expression can have zero or any number of arguments. + * + */ +public class LambdaDemo +{ + + public static void main(String[] args) + { + /* + * Java Lambda Expression Example: Single Parameter. + */ + Dog dog = (foodName) -> + { + System.out.println("eating " + foodName); + }; + dog.eat("Mutton"); + } + +} diff --git a/BasicJava/LambdaDemo_one_param_App/Output.txt b/BasicJava/LambdaDemo_one_param_App/Output.txt new file mode 100644 index 000000000..2ac2aeac3 --- /dev/null +++ b/BasicJava/LambdaDemo_one_param_App/Output.txt @@ -0,0 +1 @@ +eating Mutton diff --git a/BasicJava/LambdaDemo_parenthesis_app/LambdaDemo/.classpath b/BasicJava/LambdaDemo_parenthesis_app/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_parenthesis_app/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_parenthesis_app/LambdaDemo/.project b/BasicJava/LambdaDemo_parenthesis_app/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_parenthesis_app/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_parenthesis_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_parenthesis_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_parenthesis_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_parenthesis_app/LambdaDemo/bin/GreetingService.class b/BasicJava/LambdaDemo_parenthesis_app/LambdaDemo/bin/GreetingService.class new file mode 100644 index 000000000..e5af5f211 Binary files /dev/null and b/BasicJava/LambdaDemo_parenthesis_app/LambdaDemo/bin/GreetingService.class differ diff --git a/BasicJava/LambdaDemo_parenthesis_app/LambdaDemo/bin/LambdaDemo.class b/BasicJava/LambdaDemo_parenthesis_app/LambdaDemo/bin/LambdaDemo.class new file mode 100644 index 000000000..260470419 Binary files /dev/null and b/BasicJava/LambdaDemo_parenthesis_app/LambdaDemo/bin/LambdaDemo.class differ diff --git a/BasicJava/LambdaDemo_parenthesis_app/LambdaDemo/src/LambdaDemo.java b/BasicJava/LambdaDemo_parenthesis_app/LambdaDemo/src/LambdaDemo.java new file mode 100644 index 000000000..fbce02d8e --- /dev/null +++ b/BasicJava/LambdaDemo_parenthesis_app/LambdaDemo/src/LambdaDemo.java @@ -0,0 +1,25 @@ +@FunctionalInterface +interface GreetingService +{ + void sayMessage(String message); +} + +public class LambdaDemo +{ + + public static void main(String[] args) + { + + // with parenthesis + GreetingService greetService1 = message -> + System.out.println("Hello " + message); + + // without parenthesis + GreetingService greetService2 = (message) -> + System.out.println("Hello " + message); + + greetService1.sayMessage("Peter"); + greetService2.sayMessage("John"); + } + +} diff --git a/BasicJava/LambdaDemo_parenthesis_app/Output.txt b/BasicJava/LambdaDemo_parenthesis_app/Output.txt new file mode 100644 index 000000000..6e3e7ee87 --- /dev/null +++ b/BasicJava/LambdaDemo_parenthesis_app/Output.txt @@ -0,0 +1,2 @@ +Hello Peter +Hello John diff --git a/BasicJava/LambdaDemo_predicate_App/LambdaDemo/.classpath b/BasicJava/LambdaDemo_predicate_App/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_predicate_App/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_predicate_App/LambdaDemo/.project b/BasicJava/LambdaDemo_predicate_App/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_predicate_App/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_predicate_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_predicate_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_predicate_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_predicate_App/LambdaDemo/bin/LambdaPredicateDemo.class b/BasicJava/LambdaDemo_predicate_App/LambdaDemo/bin/LambdaPredicateDemo.class new file mode 100644 index 000000000..00f0e1005 Binary files /dev/null and b/BasicJava/LambdaDemo_predicate_App/LambdaDemo/bin/LambdaPredicateDemo.class differ diff --git a/BasicJava/LambdaDemo_predicate_App/LambdaDemo/bin/Person.class b/BasicJava/LambdaDemo_predicate_App/LambdaDemo/bin/Person.class new file mode 100644 index 000000000..943cff944 Binary files /dev/null and b/BasicJava/LambdaDemo_predicate_App/LambdaDemo/bin/Person.class differ diff --git a/BasicJava/LambdaDemo_predicate_App/LambdaDemo/src/LambdaPredicateDemo.java b/BasicJava/LambdaDemo_predicate_App/LambdaDemo/src/LambdaPredicateDemo.java new file mode 100644 index 000000000..6d3a98ff6 --- /dev/null +++ b/BasicJava/LambdaDemo_predicate_App/LambdaDemo/src/LambdaPredicateDemo.java @@ -0,0 +1,39 @@ +import java.util.Arrays; +import java.util.List; +import java.util.function.Predicate; + +public class LambdaPredicateDemo +{ + public static void main(String[] args) + { + List personList = Arrays.asList( + new Person("Carla", 33), new Person("Balu", 32), + new Person("Bharth", 40), new Person("Ajay", 31)); + + System.out.println("------------Name Starts with B---------"); + + Predicate predicate = person -> person.getName().startsWith("B"); + + printNameBeginWith_B(personList, predicate); + + System.out.println("----------------------------------------"); + + } + + /* + * Method to print all people that have name begins with B. + */ + private static void printNameBeginWith_B(List personList, + Predicate predicate) + { + for (Person person : personList) + { + if (predicate.test(person)) + { + System.out.println(person); + } + } + + } + +} diff --git a/BasicJava/LambdaDemo_predicate_App/LambdaDemo/src/Person.java b/BasicJava/LambdaDemo_predicate_App/LambdaDemo/src/Person.java new file mode 100644 index 000000000..5c3924f59 --- /dev/null +++ b/BasicJava/LambdaDemo_predicate_App/LambdaDemo/src/Person.java @@ -0,0 +1,39 @@ +public class Person +{ + private String name; + private int age; + + public Person(String name, int age) + { + super(); + this.name = name; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + @Override + public String toString() + { + return "Person [name=" + name + ", age=" + age + "]"; + } + +} diff --git a/BasicJava/LambdaDemo_predicate_App/Output.txt b/BasicJava/LambdaDemo_predicate_App/Output.txt new file mode 100644 index 000000000..c5ebcd61a --- /dev/null +++ b/BasicJava/LambdaDemo_predicate_App/Output.txt @@ -0,0 +1,3 @@ +------------Name Starts with B--------- +Person [name=Balu, age=32] +Person [name=Bharth, age=40] diff --git a/BasicJava/LambdaDemo_product_sort_name_App/LambdaDemo/.classpath b/BasicJava/LambdaDemo_product_sort_name_App/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_product_sort_name_App/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_product_sort_name_App/LambdaDemo/.project b/BasicJava/LambdaDemo_product_sort_name_App/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_product_sort_name_App/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_product_sort_name_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_product_sort_name_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_product_sort_name_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_product_sort_name_App/LambdaDemo/bin/LambdaDemo.class b/BasicJava/LambdaDemo_product_sort_name_App/LambdaDemo/bin/LambdaDemo.class new file mode 100644 index 000000000..aff5f3196 Binary files /dev/null and b/BasicJava/LambdaDemo_product_sort_name_App/LambdaDemo/bin/LambdaDemo.class differ diff --git a/BasicJava/LambdaDemo_product_sort_name_App/LambdaDemo/bin/Product.class b/BasicJava/LambdaDemo_product_sort_name_App/LambdaDemo/bin/Product.class new file mode 100644 index 000000000..ee2818bad Binary files /dev/null and b/BasicJava/LambdaDemo_product_sort_name_App/LambdaDemo/bin/Product.class differ diff --git a/BasicJava/LambdaDemo_product_sort_name_App/LambdaDemo/src/LambdaDemo.java b/BasicJava/LambdaDemo_product_sort_name_App/LambdaDemo/src/LambdaDemo.java new file mode 100644 index 000000000..3bfc6c94d --- /dev/null +++ b/BasicJava/LambdaDemo_product_sort_name_App/LambdaDemo/src/LambdaDemo.java @@ -0,0 +1,44 @@ +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * Java Lambda Expression Example: Comparator + * + */ +public class LambdaDemo +{ + + public static void main(String[] args) + { + List list = new ArrayList(); + + // Adding Products + list.add(new Product(1, "Sony LED TV", 65000f)); + list.add(new Product(2, "Radio", 3000f)); + list.add(new Product(3, "Laptop", 150000f)); + + System.out.println("Before Sorting .... \n"); + + displayProductInfo(list); + + System.out.println("\nAfter Sorting ...\n"); + + // implementing lambda expression + Collections.sort(list, (p1, p2) -> { + return p1.getName().compareTo(p2.getName()); + }); + + displayProductInfo(list); + } + + private static void displayProductInfo(List list) + { + for (Product p : list) + { + System.out.println(p.getId() + " " + p.getName() + " " + + p.getPrice()); + } + } + +} diff --git a/BasicJava/LambdaDemo_product_sort_name_App/LambdaDemo/src/Product.java b/BasicJava/LambdaDemo_product_sort_name_App/LambdaDemo/src/Product.java new file mode 100644 index 000000000..0f9624db5 --- /dev/null +++ b/BasicJava/LambdaDemo_product_sort_name_App/LambdaDemo/src/Product.java @@ -0,0 +1,45 @@ +class Product +{ + private int id; + private String name; + private float price; + + public Product(int id, String name, float price) + { + super(); + this.id = id; + this.name = name; + this.price = price; + } + + public int getId() + { + return id; + } + + public void setId(int id) + { + this.id = id; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public float getPrice() + { + return price; + } + + public void setPrice(float price) + { + this.price = price; + } + +} \ No newline at end of file diff --git a/BasicJava/LambdaDemo_product_sort_name_App/Output.txt b/BasicJava/LambdaDemo_product_sort_name_App/Output.txt new file mode 100644 index 000000000..ed54cc8a1 --- /dev/null +++ b/BasicJava/LambdaDemo_product_sort_name_App/Output.txt @@ -0,0 +1,11 @@ +Before Sorting .... + +1 Sony LED TV 65000.0 +2 Radio 3000.0 +3 Laptop 150000.0 + +After Sorting ... + +3 Laptop 150000.0 +2 Radio 3000.0 +1 Sony LED TV 65000.0 diff --git a/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo/.classpath b/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo/.project b/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo/bin/LambdaDemo.class b/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo/bin/LambdaDemo.class new file mode 100644 index 000000000..44779d990 Binary files /dev/null and b/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo/bin/LambdaDemo.class differ diff --git a/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo/bin/NonLambdaDemo$1.class b/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo/bin/NonLambdaDemo$1.class new file mode 100644 index 000000000..5b50508f4 Binary files /dev/null and b/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo/bin/NonLambdaDemo$1.class differ diff --git a/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo/bin/NonLambdaDemo.class b/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo/bin/NonLambdaDemo.class new file mode 100644 index 000000000..da0864983 Binary files /dev/null and b/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo/bin/NonLambdaDemo.class differ diff --git a/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo/bin/Person.class b/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo/bin/Person.class new file mode 100644 index 000000000..943cff944 Binary files /dev/null and b/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo/bin/Person.class differ diff --git a/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo/src/LambdaDemo.java b/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo/src/LambdaDemo.java new file mode 100644 index 000000000..01e737f7b --- /dev/null +++ b/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo/src/LambdaDemo.java @@ -0,0 +1,53 @@ +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +/** + * JDK 8 + * + * With lambda expression how to sort the list of person by name. + * + */ + +public class LambdaDemo +{ + public static void main(String[] args) + { + List personList = Arrays.asList( + new Person("Carla", 33), new Person("Balu", 32), + new Person("Bharth", 40), new Person("Ajay", 31)); + + System.out.println("------------Before Sort by name---------"); + + printAll(personList); + + System.out.println("----------------------------------------"); + + /* + * Sort list by Name, with JDK 8 + */ + + Collections.sort(personList, + (p1, p2) -> p1.getName().compareTo(p2.getName())); + + + System.out.println("\n------------After Sort by name---------"); + /* + * Create a method that prints all elements in the list. + */ + + printAll(personList); + + System.out.println("----------------------------------------"); + + } + + private static void printAll(List personList) + { + for (Person person : personList) + { + System.out.println(person); + } + + } +} diff --git a/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo/src/NonLambdaDemo.java b/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo/src/NonLambdaDemo.java new file mode 100644 index 000000000..67c9abb22 --- /dev/null +++ b/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo/src/NonLambdaDemo.java @@ -0,0 +1,58 @@ +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +/** + * Before JDK 8 + * + * With out lambda expression how to sort the list of person by name + * + */ +public class NonLambdaDemo +{ + public static void main(String[] args) + { + List personList = Arrays.asList( + new Person("Carla", 33), new Person("Balu", 32), + new Person("Bharth", 40), new Person("Ajay", 31)); + + System.out.println("------------Before Sort by name---------"); + + printAll(personList); + + System.out.println("----------------------------------------"); + + /* + * Sort list by Name,Before JDK 8 + */ + + Collections.sort(personList, new Comparator() + { + @Override + public int compare(Person p1, Person p2) + { + return p1.getName().compareTo(p2.getName()); + } + }); + + System.out.println("\n------------After Sort by name---------"); + /* + * Create a method that prints all elements in the list. + */ + + printAll(personList); + + System.out.println("----------------------------------------"); + + } + + private static void printAll(List personList) + { + for (Person person : personList) + { + System.out.println(person); + } + + } +} diff --git a/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo/src/Person.java b/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo/src/Person.java new file mode 100644 index 000000000..5c3924f59 --- /dev/null +++ b/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo/src/Person.java @@ -0,0 +1,39 @@ +public class Person +{ + private String name; + private int age; + + public Person(String name, int age) + { + super(); + this.name = name; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + @Override + public String toString() + { + return "Person [name=" + name + ", age=" + age + "]"; + } + +} diff --git a/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo_Output.txt b/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo_Output.txt new file mode 100644 index 000000000..c1bc9c768 --- /dev/null +++ b/BasicJava/LambdaDemo_sort_pl_App/LambdaDemo_Output.txt @@ -0,0 +1,13 @@ +------------Before Sort by name--------- +Person [name=Carla, age=33] +Person [name=Balu, age=32] +Person [name=Bharth, age=40] +Person [name=Ajay, age=31] +---------------------------------------- + +------------After Sort by name--------- +Person [name=Ajay, age=31] +Person [name=Balu, age=32] +Person [name=Bharth, age=40] +Person [name=Carla, age=33] +---------------------------------------- diff --git a/BasicJava/LambdaDemo_sort_pl_App/NonLambdaDemo_Output.txt b/BasicJava/LambdaDemo_sort_pl_App/NonLambdaDemo_Output.txt new file mode 100644 index 000000000..c1bc9c768 --- /dev/null +++ b/BasicJava/LambdaDemo_sort_pl_App/NonLambdaDemo_Output.txt @@ -0,0 +1,13 @@ +------------Before Sort by name--------- +Person [name=Carla, age=33] +Person [name=Balu, age=32] +Person [name=Bharth, age=40] +Person [name=Ajay, age=31] +---------------------------------------- + +------------After Sort by name--------- +Person [name=Ajay, age=31] +Person [name=Balu, age=32] +Person [name=Bharth, age=40] +Person [name=Carla, age=33] +---------------------------------------- diff --git a/BasicJava/LambdaDemo_static_method_ref_less50_app/LambdaDemo/.classpath b/BasicJava/LambdaDemo_static_method_ref_less50_app/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_static_method_ref_less50_app/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_static_method_ref_less50_app/LambdaDemo/.project b/BasicJava/LambdaDemo_static_method_ref_less50_app/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_static_method_ref_less50_app/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_static_method_ref_less50_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_static_method_ref_less50_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_static_method_ref_less50_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_static_method_ref_less50_app/LambdaDemo/bin/LambdaDemo$1.class b/BasicJava/LambdaDemo_static_method_ref_less50_app/LambdaDemo/bin/LambdaDemo$1.class new file mode 100644 index 000000000..cffde115b Binary files /dev/null and b/BasicJava/LambdaDemo_static_method_ref_less50_app/LambdaDemo/bin/LambdaDemo$1.class differ diff --git a/BasicJava/LambdaDemo_static_method_ref_less50_app/LambdaDemo/bin/LambdaDemo.class b/BasicJava/LambdaDemo_static_method_ref_less50_app/LambdaDemo/bin/LambdaDemo.class new file mode 100644 index 000000000..2638b8bda Binary files /dev/null and b/BasicJava/LambdaDemo_static_method_ref_less50_app/LambdaDemo/bin/LambdaDemo.class differ diff --git a/BasicJava/LambdaDemo_static_method_ref_less50_app/LambdaDemo/bin/Numbers.class b/BasicJava/LambdaDemo_static_method_ref_less50_app/LambdaDemo/bin/Numbers.class new file mode 100644 index 000000000..2f8bde032 Binary files /dev/null and b/BasicJava/LambdaDemo_static_method_ref_less50_app/LambdaDemo/bin/Numbers.class differ diff --git a/BasicJava/LambdaDemo_static_method_ref_less50_app/LambdaDemo/src/LambdaDemo.java b/BasicJava/LambdaDemo_static_method_ref_less50_app/LambdaDemo/src/LambdaDemo.java new file mode 100644 index 000000000..6dae40943 --- /dev/null +++ b/BasicJava/LambdaDemo_static_method_ref_less50_app/LambdaDemo/src/LambdaDemo.java @@ -0,0 +1,32 @@ +import java.util.Arrays; +import java.util.List; +import java.util.function.Predicate; + +public class LambdaDemo +{ + public static void main(String[] args) + { + + List list = Arrays.asList(12, 55, 75, 88, 24, 40); + + // Using an anonymous class + List listOfLessthanfiftyNumbers = Numbers.findNumbers(list, new Predicate() + { + public boolean test(Integer i) + { + return Numbers.isLessThanFifty(i); + } + }); + + System.out.println("listOfLessthanfiftyNumbers - anonymous class = "+listOfLessthanfiftyNumbers); + + // Using a lambda expression + listOfLessthanfiftyNumbers = Numbers.findNumbers(list, (i) -> Numbers.isLessThanFifty(i)); + System.out.println("listOfLessthanfiftyNumbers - lambda expression = "+listOfLessthanfiftyNumbers); + + // Using a method reference + listOfLessthanfiftyNumbers = Numbers.findNumbers(list, Numbers::isLessThanFifty); + System.out.println("listOfLessthanfiftyNumbers - method reference = "+listOfLessthanfiftyNumbers); + } + +} diff --git a/BasicJava/LambdaDemo_static_method_ref_less50_app/LambdaDemo/src/Numbers.java b/BasicJava/LambdaDemo_static_method_ref_less50_app/LambdaDemo/src/Numbers.java new file mode 100644 index 000000000..aff2537cb --- /dev/null +++ b/BasicJava/LambdaDemo_static_method_ref_less50_app/LambdaDemo/src/Numbers.java @@ -0,0 +1,29 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.function.Predicate; + +class Numbers +{ + public static boolean isLessThanFifty(int number) + { + return number < 50; + } + + public static List findNumbers(List list, + Predicate p) + { + List newList = new ArrayList<>(); + for (Integer i : list) + { + /* + * test the number is less than 50 + * then add to the newList. + */ + if (p.test(i)) + { + newList.add(i); + } + } + return newList; + } +} \ No newline at end of file diff --git a/BasicJava/LambdaDemo_static_method_ref_less50_app/Output.txt b/BasicJava/LambdaDemo_static_method_ref_less50_app/Output.txt new file mode 100644 index 000000000..833c5bc40 --- /dev/null +++ b/BasicJava/LambdaDemo_static_method_ref_less50_app/Output.txt @@ -0,0 +1,3 @@ +listOfLessthanfiftyNumbers - anonymous class = [12, 24, 40] +listOfLessthanfiftyNumbers - lambda expression = [12, 24, 40] +listOfLessthanfiftyNumbers - method reference = [12, 24, 40] diff --git a/BasicJava/LambdaDemo_static_method_ref_more50_app/LambdaDemo/.classpath b/BasicJava/LambdaDemo_static_method_ref_more50_app/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_static_method_ref_more50_app/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_static_method_ref_more50_app/LambdaDemo/.project b/BasicJava/LambdaDemo_static_method_ref_more50_app/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_static_method_ref_more50_app/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_static_method_ref_more50_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_static_method_ref_more50_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_static_method_ref_more50_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_static_method_ref_more50_app/LambdaDemo/bin/LambdaDemo$1.class b/BasicJava/LambdaDemo_static_method_ref_more50_app/LambdaDemo/bin/LambdaDemo$1.class new file mode 100644 index 000000000..9cf16d347 Binary files /dev/null and b/BasicJava/LambdaDemo_static_method_ref_more50_app/LambdaDemo/bin/LambdaDemo$1.class differ diff --git a/BasicJava/LambdaDemo_static_method_ref_more50_app/LambdaDemo/bin/LambdaDemo.class b/BasicJava/LambdaDemo_static_method_ref_more50_app/LambdaDemo/bin/LambdaDemo.class new file mode 100644 index 000000000..81c3914c5 Binary files /dev/null and b/BasicJava/LambdaDemo_static_method_ref_more50_app/LambdaDemo/bin/LambdaDemo.class differ diff --git a/BasicJava/LambdaDemo_static_method_ref_more50_app/LambdaDemo/bin/Numbers.class b/BasicJava/LambdaDemo_static_method_ref_more50_app/LambdaDemo/bin/Numbers.class new file mode 100644 index 000000000..1328297a0 Binary files /dev/null and b/BasicJava/LambdaDemo_static_method_ref_more50_app/LambdaDemo/bin/Numbers.class differ diff --git a/BasicJava/LambdaDemo_static_method_ref_more50_app/LambdaDemo/src/LambdaDemo.java b/BasicJava/LambdaDemo_static_method_ref_more50_app/LambdaDemo/src/LambdaDemo.java new file mode 100644 index 000000000..c73f4dba5 --- /dev/null +++ b/BasicJava/LambdaDemo_static_method_ref_more50_app/LambdaDemo/src/LambdaDemo.java @@ -0,0 +1,32 @@ +import java.util.Arrays; +import java.util.List; +import java.util.function.BiPredicate; + +public class LambdaDemo +{ + public static void main(String[] args) + { + + List list = Arrays.asList(12, 5, 45, 18, 33, 24, 40); + + // Using an anonymous class + List listOfNumbers = Numbers.findNumbers(list, new BiPredicate() + { + public boolean test(Integer i1, Integer i2) + { + return Numbers.isMoreThanFifty(i1, i2); + } + }); + + System.out.println("listOfNumbers using a anonymous class = "+listOfNumbers); + + // Using a lambda expression + listOfNumbers =Numbers.findNumbers(list, (i1, i2) -> Numbers.isMoreThanFifty(i1, i2)); + System.out.println("listOfNumbers using a lambda expression = "+listOfNumbers); + + // Using a method reference + listOfNumbers = Numbers.findNumbers(list, Numbers::isMoreThanFifty); + System.out.println("listOfNumbers using a method reference = "+listOfNumbers); + } + +} diff --git a/BasicJava/LambdaDemo_static_method_ref_more50_app/LambdaDemo/src/Numbers.java b/BasicJava/LambdaDemo_static_method_ref_more50_app/LambdaDemo/src/Numbers.java new file mode 100644 index 000000000..f59cc1996 --- /dev/null +++ b/BasicJava/LambdaDemo_static_method_ref_more50_app/LambdaDemo/src/Numbers.java @@ -0,0 +1,25 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.function.BiPredicate; + +class Numbers +{ + public static boolean isMoreThanFifty(int n1, int n2) + { + return (n1 + n2) > 50; + } + + public static List findNumbers(List list, + BiPredicate p) + { + List newList = new ArrayList<>(); + for (Integer i : list) + { + if (p.test(i, i + 10)) + { + newList.add(i); + } + } + return newList; + } +} \ No newline at end of file diff --git a/BasicJava/LambdaDemo_static_method_ref_more50_app/Output.txt b/BasicJava/LambdaDemo_static_method_ref_more50_app/Output.txt new file mode 100644 index 000000000..920c0c59e --- /dev/null +++ b/BasicJava/LambdaDemo_static_method_ref_more50_app/Output.txt @@ -0,0 +1,3 @@ +listOfNumbers using a anonymous class = [45, 33, 24, 40] +listOfNumbers using a lambda expression = [45, 33, 24, 40] +listOfNumbers using a method reference = [45, 33, 24, 40] diff --git a/BasicJava/LambdaDemo_str_length_App/LambdaDemo/.classpath b/BasicJava/LambdaDemo_str_length_App/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_str_length_App/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_str_length_App/LambdaDemo/.project b/BasicJava/LambdaDemo_str_length_App/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_str_length_App/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_str_length_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_str_length_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_str_length_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_str_length_App/LambdaDemo/bin/LambdaDemo.class b/BasicJava/LambdaDemo_str_length_App/LambdaDemo/bin/LambdaDemo.class new file mode 100644 index 000000000..8f3b307be Binary files /dev/null and b/BasicJava/LambdaDemo_str_length_App/LambdaDemo/bin/LambdaDemo.class differ diff --git a/BasicJava/LambdaDemo_str_length_App/LambdaDemo/bin/StringLengthLambda.class b/BasicJava/LambdaDemo_str_length_App/LambdaDemo/bin/StringLengthLambda.class new file mode 100644 index 000000000..ba967f9fe Binary files /dev/null and b/BasicJava/LambdaDemo_str_length_App/LambdaDemo/bin/StringLengthLambda.class differ diff --git a/BasicJava/LambdaDemo_str_length_App/LambdaDemo/src/LambdaDemo.java b/BasicJava/LambdaDemo_str_length_App/LambdaDemo/src/LambdaDemo.java new file mode 100644 index 000000000..cd9fec199 --- /dev/null +++ b/BasicJava/LambdaDemo_str_length_App/LambdaDemo/src/LambdaDemo.java @@ -0,0 +1,17 @@ +@FunctionalInterface +interface StringLengthLambda +{ + int getLength(String str); +} + +public class LambdaDemo +{ + + public static void main(String[] args) + { + StringLengthLambda stringLengthLambda = (String str) -> str.length(); + int length = stringLengthLambda.getLength("Welcome"); + System.out.println("length = " + length); + } + +} diff --git a/BasicJava/LambdaDemo_str_length_App/Output.txt b/BasicJava/LambdaDemo_str_length_App/Output.txt new file mode 100644 index 000000000..ba7867137 --- /dev/null +++ b/BasicJava/LambdaDemo_str_length_App/Output.txt @@ -0,0 +1 @@ +length = 7 diff --git a/BasicJava/LambdaDemo_thread_create_App/LambdaDemo/.classpath b/BasicJava/LambdaDemo_thread_create_App/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_thread_create_App/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_thread_create_App/LambdaDemo/.project b/BasicJava/LambdaDemo_thread_create_App/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_thread_create_App/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_thread_create_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_thread_create_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_thread_create_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_thread_create_App/LambdaDemo/bin/LambdaDemo.class b/BasicJava/LambdaDemo_thread_create_App/LambdaDemo/bin/LambdaDemo.class new file mode 100644 index 000000000..8df89dda1 Binary files /dev/null and b/BasicJava/LambdaDemo_thread_create_App/LambdaDemo/bin/LambdaDemo.class differ diff --git a/BasicJava/LambdaDemo_thread_create_App/LambdaDemo/bin/NonLambdaDemo$1.class b/BasicJava/LambdaDemo_thread_create_App/LambdaDemo/bin/NonLambdaDemo$1.class new file mode 100644 index 000000000..e9f7cb9cf Binary files /dev/null and b/BasicJava/LambdaDemo_thread_create_App/LambdaDemo/bin/NonLambdaDemo$1.class differ diff --git a/BasicJava/LambdaDemo_thread_create_App/LambdaDemo/bin/NonLambdaDemo.class b/BasicJava/LambdaDemo_thread_create_App/LambdaDemo/bin/NonLambdaDemo.class new file mode 100644 index 000000000..9f3647b6e Binary files /dev/null and b/BasicJava/LambdaDemo_thread_create_App/LambdaDemo/bin/NonLambdaDemo.class differ diff --git a/BasicJava/LambdaDemo_thread_create_App/LambdaDemo/src/LambdaDemo.java b/BasicJava/LambdaDemo_thread_create_App/LambdaDemo/src/LambdaDemo.java new file mode 100644 index 000000000..16ade2bb8 --- /dev/null +++ b/BasicJava/LambdaDemo_thread_create_App/LambdaDemo/src/LambdaDemo.java @@ -0,0 +1,25 @@ +/** + * With JDK 8 + * + * Java Lambda Expression Example: Creating Thread + * + */ +public class LambdaDemo +{ + + public static void main(String[] args) + { + /* + * Thread Example with lambda. + * + * we are implementing run method by using lambda expression. + */ + + Runnable runnable = () -> { + System.out.println("Thread is running..."); + }; + Thread thread = new Thread(runnable); + thread.start(); + } + +} diff --git a/BasicJava/LambdaDemo_thread_create_App/LambdaDemo/src/NonLambdaDemo.java b/BasicJava/LambdaDemo_thread_create_App/LambdaDemo/src/NonLambdaDemo.java new file mode 100644 index 000000000..5a8695d7c --- /dev/null +++ b/BasicJava/LambdaDemo_thread_create_App/LambdaDemo/src/NonLambdaDemo.java @@ -0,0 +1,23 @@ +/** + * Before JDK 8 + * + */ +public class NonLambdaDemo +{ + + public static void main(String[] args) + { + // Thread Example without lambda + Runnable runnable = new Runnable() + { + @Override + public void run() + { + System.out.println("Thread is running..."); + } + }; + Thread thread = new Thread(runnable); + thread.start(); + } + +} diff --git a/BasicJava/LambdaDemo_thread_create_App/LambdaDemo_Output.txt b/BasicJava/LambdaDemo_thread_create_App/LambdaDemo_Output.txt new file mode 100644 index 000000000..1a8759810 --- /dev/null +++ b/BasicJava/LambdaDemo_thread_create_App/LambdaDemo_Output.txt @@ -0,0 +1 @@ +Thread is running... diff --git a/BasicJava/LambdaDemo_thread_create_App/NonLambdaDemo_Output.txt b/BasicJava/LambdaDemo_thread_create_App/NonLambdaDemo_Output.txt new file mode 100644 index 000000000..1a8759810 --- /dev/null +++ b/BasicJava/LambdaDemo_thread_create_App/NonLambdaDemo_Output.txt @@ -0,0 +1 @@ +Thread is running... diff --git a/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/.classpath b/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/.project b/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/bin/Developer.class b/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/bin/Developer.class new file mode 100644 index 000000000..fdeaab8b8 Binary files /dev/null and b/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/bin/Developer.class differ diff --git a/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/bin/LambdaDemo.class b/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/bin/LambdaDemo.class new file mode 100644 index 000000000..fb5552918 Binary files /dev/null and b/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/bin/LambdaDemo.class differ diff --git a/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/bin/NonLambdaDemo$1.class b/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/bin/NonLambdaDemo$1.class new file mode 100644 index 000000000..334c249ec Binary files /dev/null and b/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/bin/NonLambdaDemo$1.class differ diff --git a/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/bin/NonLambdaDemo$2.class b/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/bin/NonLambdaDemo$2.class new file mode 100644 index 000000000..902d16986 Binary files /dev/null and b/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/bin/NonLambdaDemo$2.class differ diff --git a/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/bin/NonLambdaDemo.class b/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/bin/NonLambdaDemo.class new file mode 100644 index 000000000..7b4735040 Binary files /dev/null and b/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/bin/NonLambdaDemo.class differ diff --git a/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/src/Developer.java b/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/src/Developer.java new file mode 100644 index 000000000..a32ea868d --- /dev/null +++ b/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/src/Developer.java @@ -0,0 +1,39 @@ +public class Developer +{ + private String name; + private int age; + + public Developer(String name, int age) + { + super(); + this.name = name; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + @Override + public String toString() + { + return "Developer [name=" + name + ", age=" + age + "]"; + } + +} diff --git a/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/src/LambdaDemo.java b/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/src/LambdaDemo.java new file mode 100644 index 000000000..65cc755a4 --- /dev/null +++ b/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/src/LambdaDemo.java @@ -0,0 +1,49 @@ +import java.util.ArrayList; +import java.util.List; + +/** + * Sort with Lambda,With JDK 8 + */ +public class LambdaDemo +{ + public static void main(String[] args) + { + + List developerList = getDevelopers(); + + System.out.println("-----------Before Sort-----------"); + for (Developer developer : developerList) + { + System.out.println(developer); + } + + System.out.println("\n-----------After Sort by Age------------"); + // lambda here... + developerList.sort((Developer o1, Developer o2) -> o1.getAge() - o2.getAge()); + + // java 8 only, lambda also, to print the List + developerList.forEach((developer) -> System.out.println(developer)); + + System.out.println("\n-----------After Sort by Name------------"); + // lambda + developerList.sort((Developer o1, Developer o2) -> o1.getName().compareTo(o2.getName())); + + // java 8 only, lambda also, to print the List + developerList.forEach((developer) -> System.out.println(developer)); + + } + + private static List getDevelopers() + { + + List developerList = new ArrayList(); + + developerList.add(new Developer("Peter", 33)); + developerList.add(new Developer("John", 22)); + developerList.add(new Developer("Ram", 15)); + developerList.add(new Developer("Steve", 55)); + + return developerList; + + } +} diff --git a/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/src/NonLambdaDemo.java b/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/src/NonLambdaDemo.java new file mode 100644 index 000000000..4ed3e593d --- /dev/null +++ b/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo/src/NonLambdaDemo.java @@ -0,0 +1,68 @@ +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +/** + * Sort without Lambda,Before JDK 8 + */ +public class NonLambdaDemo +{ + public static void main(String[] args) + { + + List developerList = getDevelopers(); + + System.out.println("-----------Before Sort-----------"); + printDeveloperInfo(developerList); + + // sort by age + Collections.sort(developerList, new Comparator() + { + @Override + public int compare(Developer o1, Developer o2) + { + return o1.getAge() - o2.getAge(); + } + }); + + System.out.println("\n-----------After Sort by Age------------"); + printDeveloperInfo(developerList); + + // sort by name + Collections.sort(developerList, new Comparator() + { + @Override + public int compare(Developer o1, Developer o2) + { + return o1.getName().compareTo(o2.getName()); + } + }); + + System.out.println("\n-----------After Sort by Name------------"); + printDeveloperInfo(developerList); + + } + + private static void printDeveloperInfo(List developerList) + { + for (Developer developer : developerList) + { + System.out.println(developer); + } + } + + private static List getDevelopers() + { + + List developerList = new ArrayList(); + + developerList.add(new Developer("Peter", 33)); + developerList.add(new Developer("John", 22)); + developerList.add(new Developer("Ram", 15)); + developerList.add(new Developer("Steve", 55)); + + return developerList; + + } +} diff --git a/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo_Output.txt b/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo_Output.txt new file mode 100644 index 000000000..6c1f588fd --- /dev/null +++ b/BasicJava/LambdaDemo_with_comparator_app/LambdaDemo_Output.txt @@ -0,0 +1,17 @@ +-----------Before Sort----------- +Developer [name=Peter, age=33] +Developer [name=John, age=22] +Developer [name=Ram, age=15] +Developer [name=Steve, age=55] + +-----------After Sort by Age------------ +Developer [name=Ram, age=15] +Developer [name=John, age=22] +Developer [name=Peter, age=33] +Developer [name=Steve, age=55] + +-----------After Sort by Name------------ +Developer [name=John, age=22] +Developer [name=Peter, age=33] +Developer [name=Ram, age=15] +Developer [name=Steve, age=55] diff --git a/BasicJava/LambdaDemo_with_comparator_app/NonLambdaDemo_Output.txt b/BasicJava/LambdaDemo_with_comparator_app/NonLambdaDemo_Output.txt new file mode 100644 index 000000000..6c1f588fd --- /dev/null +++ b/BasicJava/LambdaDemo_with_comparator_app/NonLambdaDemo_Output.txt @@ -0,0 +1,17 @@ +-----------Before Sort----------- +Developer [name=Peter, age=33] +Developer [name=John, age=22] +Developer [name=Ram, age=15] +Developer [name=Steve, age=55] + +-----------After Sort by Age------------ +Developer [name=Ram, age=15] +Developer [name=John, age=22] +Developer [name=Peter, age=33] +Developer [name=Steve, age=55] + +-----------After Sort by Name------------ +Developer [name=John, age=22] +Developer [name=Peter, age=33] +Developer [name=Ram, age=15] +Developer [name=Steve, age=55] diff --git a/BasicJava/LambdaDemo_with_return_App/LambdaDemo/.classpath b/BasicJava/LambdaDemo_with_return_App/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_with_return_App/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_with_return_App/LambdaDemo/.project b/BasicJava/LambdaDemo_with_return_App/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_with_return_App/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_with_return_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_with_return_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_with_return_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_with_return_App/LambdaDemo/bin/Add.class b/BasicJava/LambdaDemo_with_return_App/LambdaDemo/bin/Add.class new file mode 100644 index 000000000..ad4220580 Binary files /dev/null and b/BasicJava/LambdaDemo_with_return_App/LambdaDemo/bin/Add.class differ diff --git a/BasicJava/LambdaDemo_with_return_App/LambdaDemo/bin/LambdaDemo.class b/BasicJava/LambdaDemo_with_return_App/LambdaDemo/bin/LambdaDemo.class new file mode 100644 index 000000000..8e97a7e24 Binary files /dev/null and b/BasicJava/LambdaDemo_with_return_App/LambdaDemo/bin/LambdaDemo.class differ diff --git a/BasicJava/LambdaDemo_with_return_App/LambdaDemo/src/LambdaDemo.java b/BasicJava/LambdaDemo_with_return_App/LambdaDemo/src/LambdaDemo.java new file mode 100644 index 000000000..bb23b3890 --- /dev/null +++ b/BasicJava/LambdaDemo_with_return_App/LambdaDemo/src/LambdaDemo.java @@ -0,0 +1,31 @@ +@FunctionalInterface +interface Add +{ + int addition(int a, int b); +} + +/** + * + * You must use return keyword when lambda expression contains + * multiple statements. + * + * Java Lambda Expression Example: With return keyword + * + */ +public class LambdaDemo +{ + + public static void main(String[] args) + { + // Lambda expression with return keyword. + Add add = (int a, int b) -> + { + int sum = a + b; + return sum; + }; + + int sum = add.addition(13, 53); + System.out.println("sum = " + sum); + } + +} diff --git a/BasicJava/LambdaDemo_with_return_App/Output.txt b/BasicJava/LambdaDemo_with_return_App/Output.txt new file mode 100644 index 000000000..020e40d0c --- /dev/null +++ b/BasicJava/LambdaDemo_with_return_App/Output.txt @@ -0,0 +1 @@ +sum = 66 diff --git a/BasicJava/LambdaDemo_without_return_App/LambdaDemo/.classpath b/BasicJava/LambdaDemo_without_return_App/LambdaDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LambdaDemo_without_return_App/LambdaDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LambdaDemo_without_return_App/LambdaDemo/.project b/BasicJava/LambdaDemo_without_return_App/LambdaDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/LambdaDemo_without_return_App/LambdaDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LambdaDemo_without_return_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LambdaDemo_without_return_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LambdaDemo_without_return_App/LambdaDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LambdaDemo_without_return_App/LambdaDemo/bin/Add.class b/BasicJava/LambdaDemo_without_return_App/LambdaDemo/bin/Add.class new file mode 100644 index 000000000..ad4220580 Binary files /dev/null and b/BasicJava/LambdaDemo_without_return_App/LambdaDemo/bin/Add.class differ diff --git a/BasicJava/LambdaDemo_without_return_App/LambdaDemo/bin/LambdaDemo.class b/BasicJava/LambdaDemo_without_return_App/LambdaDemo/bin/LambdaDemo.class new file mode 100644 index 000000000..c89cdf85c Binary files /dev/null and b/BasicJava/LambdaDemo_without_return_App/LambdaDemo/bin/LambdaDemo.class differ diff --git a/BasicJava/LambdaDemo_without_return_App/LambdaDemo/src/LambdaDemo.java b/BasicJava/LambdaDemo_without_return_App/LambdaDemo/src/LambdaDemo.java new file mode 100644 index 000000000..27bc8c013 --- /dev/null +++ b/BasicJava/LambdaDemo_without_return_App/LambdaDemo/src/LambdaDemo.java @@ -0,0 +1,27 @@ +@FunctionalInterface +interface Add +{ + int addition(int a, int b); +} + +/** + * + * In Java lambda expression, if there is only one statement, you may + * or may not use return keyword. + * + * Java Lambda Expression Example: Without return keyword + * + */ +public class LambdaDemo +{ + + public static void main(String[] args) + { + // Lambda expression without return keyword. + Add add = (a, b) -> (a + b); + + int sum = add.addition(10, 20); + System.out.println("sum = " + sum); + } + +} diff --git a/BasicJava/LambdaDemo_without_return_App/Output.txt b/BasicJava/LambdaDemo_without_return_App/Output.txt new file mode 100644 index 000000000..a63ff4875 --- /dev/null +++ b/BasicJava/LambdaDemo_without_return_App/Output.txt @@ -0,0 +1 @@ +sum = 30 diff --git a/BasicJava/LocalDateDemo_Intro/LocalDateDemo/.classpath b/BasicJava/LocalDateDemo_Intro/LocalDateDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalDateDemo_Intro/LocalDateDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalDateDemo_Intro/LocalDateDemo/.project b/BasicJava/LocalDateDemo_Intro/LocalDateDemo/.project new file mode 100644 index 000000000..b83b03f89 --- /dev/null +++ b/BasicJava/LocalDateDemo_Intro/LocalDateDemo/.project @@ -0,0 +1,17 @@ + + + LocalDateDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalDateDemo_Intro/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalDateDemo_Intro/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalDateDemo_Intro/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalDateDemo_Intro/LocalDateDemo/bin/LocalDateDemo1.class b/BasicJava/LocalDateDemo_Intro/LocalDateDemo/bin/LocalDateDemo1.class new file mode 100644 index 000000000..9c662c8cf Binary files /dev/null and b/BasicJava/LocalDateDemo_Intro/LocalDateDemo/bin/LocalDateDemo1.class differ diff --git a/BasicJava/LocalDateDemo_Intro/LocalDateDemo/bin/LocalDateDemo2.class b/BasicJava/LocalDateDemo_Intro/LocalDateDemo/bin/LocalDateDemo2.class new file mode 100644 index 000000000..9229b61b7 Binary files /dev/null and b/BasicJava/LocalDateDemo_Intro/LocalDateDemo/bin/LocalDateDemo2.class differ diff --git a/BasicJava/LocalDateDemo_Intro/LocalDateDemo/bin/LocalDateDemo3.class b/BasicJava/LocalDateDemo_Intro/LocalDateDemo/bin/LocalDateDemo3.class new file mode 100644 index 000000000..6c293b9b3 Binary files /dev/null and b/BasicJava/LocalDateDemo_Intro/LocalDateDemo/bin/LocalDateDemo3.class differ diff --git a/BasicJava/LocalDateDemo_Intro/LocalDateDemo/src/LocalDateDemo1.java b/BasicJava/LocalDateDemo_Intro/LocalDateDemo/src/LocalDateDemo1.java new file mode 100644 index 000000000..a6c49974b --- /dev/null +++ b/BasicJava/LocalDateDemo_Intro/LocalDateDemo/src/LocalDateDemo1.java @@ -0,0 +1,21 @@ +import java.time.LocalDate; + +public class LocalDateDemo1 +{ + + public static void main(String[] args) + { + /* + * Returns:the current date using the system clock and default + * time-zone, not null + */ + LocalDate localDate = LocalDate.now(); + System.out.println(localDate); + System.out.println("Year = " + localDate.getYear()); + System.out.println("Month = " + localDate.getMonthValue()); + System.out.println("DayOfMonth = " + localDate.getDayOfMonth()); + System.out.println("DayOfWeek = " + localDate.getDayOfWeek()); + + } + +} diff --git a/BasicJava/LocalDateDemo_Intro/LocalDateDemo/src/LocalDateDemo2.java b/BasicJava/LocalDateDemo_Intro/LocalDateDemo/src/LocalDateDemo2.java new file mode 100644 index 000000000..883d2b33b --- /dev/null +++ b/BasicJava/LocalDateDemo_Intro/LocalDateDemo/src/LocalDateDemo2.java @@ -0,0 +1,25 @@ +import java.time.LocalDate; + +public class LocalDateDemo2 +{ + + public static void main(String[] args) + { + /* + * Parameters: + * + * year - the year to represent, from MIN_YEAR to MAX_YEAR + * + * month - the month-of-year to represent, from 1 (January) to + * 12 (December) + * + * dayOfMonth - the day-of-month to represent, from 1 to 31 + * + * Returns:the local date, not null + */ + LocalDate localDate = LocalDate.of(2027, 7, 25); + System.out.println(localDate); + + } + +} diff --git a/BasicJava/LocalDateDemo_Intro/LocalDateDemo/src/LocalDateDemo3.java b/BasicJava/LocalDateDemo_Intro/LocalDateDemo/src/LocalDateDemo3.java new file mode 100644 index 000000000..8e8b19d95 --- /dev/null +++ b/BasicJava/LocalDateDemo_Intro/LocalDateDemo/src/LocalDateDemo3.java @@ -0,0 +1,23 @@ +import java.time.LocalDate; + +public class LocalDateDemo3 +{ + + public static void main(String[] args) + { + /* + * Parameters: + * + * text - the text to parse such as "2007-12-03", not null + * + * Returns: + * + * the parsed local date, not null + * + */ + LocalDate localDate = LocalDate.parse("2007-12-03"); + System.out.println(localDate); + + } + +} diff --git a/BasicJava/LocalDateDemo_Intro/LocalDateDemo1_Output.txt b/BasicJava/LocalDateDemo_Intro/LocalDateDemo1_Output.txt new file mode 100644 index 000000000..801a4e4bb --- /dev/null +++ b/BasicJava/LocalDateDemo_Intro/LocalDateDemo1_Output.txt @@ -0,0 +1,5 @@ +2018-01-03 +Year = 2018 +Month = 1 +DayOfMonth = 3 +DayOfWeek = WEDNESDAY diff --git a/BasicJava/LocalDateDemo_Intro/LocalDateDemo2_Output.txt b/BasicJava/LocalDateDemo_Intro/LocalDateDemo2_Output.txt new file mode 100644 index 000000000..1b4c162ac --- /dev/null +++ b/BasicJava/LocalDateDemo_Intro/LocalDateDemo2_Output.txt @@ -0,0 +1 @@ +2027-07-25 diff --git a/BasicJava/LocalDateDemo_Intro/LocalDateDemo3_Output.txt b/BasicJava/LocalDateDemo_Intro/LocalDateDemo3_Output.txt new file mode 100644 index 000000000..b70104032 --- /dev/null +++ b/BasicJava/LocalDateDemo_Intro/LocalDateDemo3_Output.txt @@ -0,0 +1 @@ +2007-12-03 diff --git a/BasicJava/LocalDateDemo_format/LocalDateDemo/.classpath b/BasicJava/LocalDateDemo_format/LocalDateDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalDateDemo_format/LocalDateDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalDateDemo_format/LocalDateDemo/.project b/BasicJava/LocalDateDemo_format/LocalDateDemo/.project new file mode 100644 index 000000000..b83b03f89 --- /dev/null +++ b/BasicJava/LocalDateDemo_format/LocalDateDemo/.project @@ -0,0 +1,17 @@ + + + LocalDateDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalDateDemo_format/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalDateDemo_format/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalDateDemo_format/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalDateDemo_format/LocalDateDemo/bin/LocalDateDemo.class b/BasicJava/LocalDateDemo_format/LocalDateDemo/bin/LocalDateDemo.class new file mode 100644 index 000000000..9a13bea29 Binary files /dev/null and b/BasicJava/LocalDateDemo_format/LocalDateDemo/bin/LocalDateDemo.class differ diff --git a/BasicJava/LocalDateDemo_format/LocalDateDemo/src/LocalDateDemo.java b/BasicJava/LocalDateDemo_format/LocalDateDemo/src/LocalDateDemo.java new file mode 100644 index 000000000..c0e61b708 --- /dev/null +++ b/BasicJava/LocalDateDemo_format/LocalDateDemo/src/LocalDateDemo.java @@ -0,0 +1,38 @@ +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; + +public class LocalDateDemo +{ + + public static void main(String[] args) + { + LocalDate localDate = LocalDate.parse("2020-12-23"); + System.out.println(localDate); + + /* + * Parameters: + * + * pattern - the pattern to use, not null + * + * Returns: + * + * the formatter based on the pattern, not null + */ + DateTimeFormatter dateTimeFormatter = DateTimeFormatter + .ofPattern("dd/MM/YYYY"); + + /* + * Parameters: + * + * formatter - the formatter to use, not null + * + * Returns: + * + * the formatted date string, not null + */ + + String formatedDate = localDate.format(dateTimeFormatter); + System.out.println(formatedDate); + } + +} diff --git a/BasicJava/LocalDateDemo_format/Output.txt b/BasicJava/LocalDateDemo_format/Output.txt new file mode 100644 index 000000000..2718ba236 --- /dev/null +++ b/BasicJava/LocalDateDemo_format/Output.txt @@ -0,0 +1,2 @@ +2020-12-23 +23/12/2020 diff --git a/BasicJava/LocalDateDemo_get/LocalDateDemo/.classpath b/BasicJava/LocalDateDemo_get/LocalDateDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalDateDemo_get/LocalDateDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalDateDemo_get/LocalDateDemo/.project b/BasicJava/LocalDateDemo_get/LocalDateDemo/.project new file mode 100644 index 000000000..b83b03f89 --- /dev/null +++ b/BasicJava/LocalDateDemo_get/LocalDateDemo/.project @@ -0,0 +1,17 @@ + + + LocalDateDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalDateDemo_get/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalDateDemo_get/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalDateDemo_get/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalDateDemo_get/LocalDateDemo/bin/LocalDateDemo.class b/BasicJava/LocalDateDemo_get/LocalDateDemo/bin/LocalDateDemo.class new file mode 100644 index 000000000..056ad8354 Binary files /dev/null and b/BasicJava/LocalDateDemo_get/LocalDateDemo/bin/LocalDateDemo.class differ diff --git a/BasicJava/LocalDateDemo_get/LocalDateDemo/src/LocalDateDemo.java b/BasicJava/LocalDateDemo_get/LocalDateDemo/src/LocalDateDemo.java new file mode 100644 index 000000000..44bd156a4 --- /dev/null +++ b/BasicJava/LocalDateDemo_get/LocalDateDemo/src/LocalDateDemo.java @@ -0,0 +1,34 @@ +import java.time.LocalDate; +import java.time.temporal.ChronoField; + +public class LocalDateDemo +{ + + public static void main(String[] args) + { + LocalDate date = LocalDate.parse("2017-11-23"); + System.out.println(date); + + /* + * Parameters: + * + * field - the field to get, not null + * + * Returns: + * + * the value for the field + */ + + int year = date.get(ChronoField.YEAR); + System.out.println("year = "+year); + + int month = date.get(ChronoField.MONTH_OF_YEAR); + System.out.println("month of year = "+month); + + int dayOfTheMonth = date.get(ChronoField.DAY_OF_MONTH); + System.out.println("dayOfTheMonth = "+dayOfTheMonth); + + + } + +} diff --git a/BasicJava/LocalDateDemo_get/Output.txt b/BasicJava/LocalDateDemo_get/Output.txt new file mode 100644 index 000000000..8e14de713 --- /dev/null +++ b/BasicJava/LocalDateDemo_get/Output.txt @@ -0,0 +1,4 @@ +2017-11-23 +year = 2017 +month of year = 11 +dayOfTheMonth = 23 diff --git a/BasicJava/LocalDateDemo_getEra/LocalDateDemo/.classpath b/BasicJava/LocalDateDemo_getEra/LocalDateDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalDateDemo_getEra/LocalDateDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalDateDemo_getEra/LocalDateDemo/.project b/BasicJava/LocalDateDemo_getEra/LocalDateDemo/.project new file mode 100644 index 000000000..b83b03f89 --- /dev/null +++ b/BasicJava/LocalDateDemo_getEra/LocalDateDemo/.project @@ -0,0 +1,17 @@ + + + LocalDateDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalDateDemo_getEra/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalDateDemo_getEra/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalDateDemo_getEra/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalDateDemo_getEra/LocalDateDemo/bin/LocalDateDemo.class b/BasicJava/LocalDateDemo_getEra/LocalDateDemo/bin/LocalDateDemo.class new file mode 100644 index 000000000..0c616f2fb Binary files /dev/null and b/BasicJava/LocalDateDemo_getEra/LocalDateDemo/bin/LocalDateDemo.class differ diff --git a/BasicJava/LocalDateDemo_getEra/LocalDateDemo/src/LocalDateDemo.java b/BasicJava/LocalDateDemo_getEra/LocalDateDemo/src/LocalDateDemo.java new file mode 100644 index 000000000..03ea3097c --- /dev/null +++ b/BasicJava/LocalDateDemo_getEra/LocalDateDemo/src/LocalDateDemo.java @@ -0,0 +1,19 @@ +import java.time.LocalDate; +import java.time.chrono.Era; + +public class LocalDateDemo +{ + + public static void main(String[] args) + { + LocalDate date = LocalDate.parse("2017-11-23"); + + /* + * Returns:the IsoChronology era constant applicable at this + * date, not null + */ + Era era = date.getEra(); + System.out.println(era); + } + +} diff --git a/BasicJava/LocalDateDemo_getEra/Output.txt b/BasicJava/LocalDateDemo_getEra/Output.txt new file mode 100644 index 000000000..ba1341353 --- /dev/null +++ b/BasicJava/LocalDateDemo_getEra/Output.txt @@ -0,0 +1 @@ +CE diff --git a/BasicJava/LocalDateDemo_isAfter_before_equal/LocalDateDemo/.classpath b/BasicJava/LocalDateDemo_isAfter_before_equal/LocalDateDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalDateDemo_isAfter_before_equal/LocalDateDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalDateDemo_isAfter_before_equal/LocalDateDemo/.project b/BasicJava/LocalDateDemo_isAfter_before_equal/LocalDateDemo/.project new file mode 100644 index 000000000..b83b03f89 --- /dev/null +++ b/BasicJava/LocalDateDemo_isAfter_before_equal/LocalDateDemo/.project @@ -0,0 +1,17 @@ + + + LocalDateDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalDateDemo_isAfter_before_equal/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalDateDemo_isAfter_before_equal/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalDateDemo_isAfter_before_equal/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalDateDemo_isAfter_before_equal/LocalDateDemo/bin/LocalDateDemo.class b/BasicJava/LocalDateDemo_isAfter_before_equal/LocalDateDemo/bin/LocalDateDemo.class new file mode 100644 index 000000000..07d0eebaa Binary files /dev/null and b/BasicJava/LocalDateDemo_isAfter_before_equal/LocalDateDemo/bin/LocalDateDemo.class differ diff --git a/BasicJava/LocalDateDemo_isAfter_before_equal/LocalDateDemo/src/LocalDateDemo.java b/BasicJava/LocalDateDemo_isAfter_before_equal/LocalDateDemo/src/LocalDateDemo.java new file mode 100644 index 000000000..92676513b --- /dev/null +++ b/BasicJava/LocalDateDemo_isAfter_before_equal/LocalDateDemo/src/LocalDateDemo.java @@ -0,0 +1,31 @@ +import java.time.LocalDate; + +public class LocalDateDemo +{ + + public static void main(String[] args) + { + LocalDate date1 = LocalDate.parse("2018-07-03"); + System.out.println("date1= "+date1); + + LocalDate date2 = LocalDate.parse("2017-03-03"); + System.out.println("date2= "+date2); + + /* + * Returns:true if this date is after the specified date + */ + System.out.println(date1.isAfter(date2)); + + /* + * Returns:true if this date is before the specified date + */ + System.out.println(date1.isBefore(date2)); + + /* + * Returns:true if this date is equal to the specified date + */ + System.out.println(date1.isEqual(date2)); + + } + +} diff --git a/BasicJava/LocalDateDemo_isAfter_before_equal/Output.txt b/BasicJava/LocalDateDemo_isAfter_before_equal/Output.txt new file mode 100644 index 000000000..def6e06ff --- /dev/null +++ b/BasicJava/LocalDateDemo_isAfter_before_equal/Output.txt @@ -0,0 +1,5 @@ +date1= 2018-07-03 +date2= 2017-03-03 +true +false +false diff --git a/BasicJava/LocalDateDemo_isLeapYear/LocalDateDemo/.classpath b/BasicJava/LocalDateDemo_isLeapYear/LocalDateDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalDateDemo_isLeapYear/LocalDateDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalDateDemo_isLeapYear/LocalDateDemo/.project b/BasicJava/LocalDateDemo_isLeapYear/LocalDateDemo/.project new file mode 100644 index 000000000..b83b03f89 --- /dev/null +++ b/BasicJava/LocalDateDemo_isLeapYear/LocalDateDemo/.project @@ -0,0 +1,17 @@ + + + LocalDateDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalDateDemo_isLeapYear/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalDateDemo_isLeapYear/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalDateDemo_isLeapYear/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalDateDemo_isLeapYear/LocalDateDemo/bin/LocalDateDemo.class b/BasicJava/LocalDateDemo_isLeapYear/LocalDateDemo/bin/LocalDateDemo.class new file mode 100644 index 000000000..b5bbeccc3 Binary files /dev/null and b/BasicJava/LocalDateDemo_isLeapYear/LocalDateDemo/bin/LocalDateDemo.class differ diff --git a/BasicJava/LocalDateDemo_isLeapYear/LocalDateDemo/src/LocalDateDemo.java b/BasicJava/LocalDateDemo_isLeapYear/LocalDateDemo/src/LocalDateDemo.java new file mode 100644 index 000000000..a8ddbbecb --- /dev/null +++ b/BasicJava/LocalDateDemo_isLeapYear/LocalDateDemo/src/LocalDateDemo.java @@ -0,0 +1,19 @@ +import java.time.LocalDate; + +public class LocalDateDemo +{ + + public static void main(String[] args) + { + LocalDate date1 = LocalDate.of(2017, 9, 25); + + /* + * Returns:true if the year is leap, false otherwise + */ + System.out.println(date1.isLeapYear()); + + LocalDate date2 = LocalDate.of(2020, 9, 25); + System.out.println(date2.isLeapYear()); + } + +} diff --git a/BasicJava/LocalDateDemo_isLeapYear/Output.txt b/BasicJava/LocalDateDemo_isLeapYear/Output.txt new file mode 100644 index 000000000..1d474d525 --- /dev/null +++ b/BasicJava/LocalDateDemo_isLeapYear/Output.txt @@ -0,0 +1,2 @@ +false +true diff --git a/BasicJava/LocalDateDemo_minus_plus_month_year/LocalDateDemo/.classpath b/BasicJava/LocalDateDemo_minus_plus_month_year/LocalDateDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalDateDemo_minus_plus_month_year/LocalDateDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalDateDemo_minus_plus_month_year/LocalDateDemo/.project b/BasicJava/LocalDateDemo_minus_plus_month_year/LocalDateDemo/.project new file mode 100644 index 000000000..b83b03f89 --- /dev/null +++ b/BasicJava/LocalDateDemo_minus_plus_month_year/LocalDateDemo/.project @@ -0,0 +1,17 @@ + + + LocalDateDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalDateDemo_minus_plus_month_year/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalDateDemo_minus_plus_month_year/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalDateDemo_minus_plus_month_year/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalDateDemo_minus_plus_month_year/LocalDateDemo/bin/LocalDateDemo1.class b/BasicJava/LocalDateDemo_minus_plus_month_year/LocalDateDemo/bin/LocalDateDemo1.class new file mode 100644 index 000000000..d5c7f08b2 Binary files /dev/null and b/BasicJava/LocalDateDemo_minus_plus_month_year/LocalDateDemo/bin/LocalDateDemo1.class differ diff --git a/BasicJava/LocalDateDemo_minus_plus_month_year/LocalDateDemo/bin/LocalDateDemo2.class b/BasicJava/LocalDateDemo_minus_plus_month_year/LocalDateDemo/bin/LocalDateDemo2.class new file mode 100644 index 000000000..fab3aeb13 Binary files /dev/null and b/BasicJava/LocalDateDemo_minus_plus_month_year/LocalDateDemo/bin/LocalDateDemo2.class differ diff --git a/BasicJava/LocalDateDemo_minus_plus_month_year/LocalDateDemo/src/LocalDateDemo1.java b/BasicJava/LocalDateDemo_minus_plus_month_year/LocalDateDemo/src/LocalDateDemo1.java new file mode 100644 index 000000000..a39fbe785 --- /dev/null +++ b/BasicJava/LocalDateDemo_minus_plus_month_year/LocalDateDemo/src/LocalDateDemo1.java @@ -0,0 +1,34 @@ +import java.time.LocalDate; + +public class LocalDateDemo1 +{ + + public static void main(String[] args) + { + LocalDate date = LocalDate.now(); + System.out.println("date = " + date); + + /* + * Parameters: + * + * monthsToSubtract - the months to subtract, may be negative + * + * Returns:a LocalDate based on this date with the months + * subtracted, not null + */ + LocalDate dateAfterMonthChanged = date.minusMonths(2); + System.out.println("dateAfterMonthChanged = " + dateAfterMonthChanged); + + /* + * Parameters: + * + * yearsToSubtract - the years to subtract, may be negative + * + * Returns:a LocalDate based on this date with the years + * subtracted, not null + */ + LocalDate dateAfterYearChanged = date.minusYears(3); + System.out.println("dateAfterYearChanged = " + dateAfterYearChanged); + } + +} diff --git a/BasicJava/LocalDateDemo_minus_plus_month_year/LocalDateDemo/src/LocalDateDemo2.java b/BasicJava/LocalDateDemo_minus_plus_month_year/LocalDateDemo/src/LocalDateDemo2.java new file mode 100644 index 000000000..355bf36ff --- /dev/null +++ b/BasicJava/LocalDateDemo_minus_plus_month_year/LocalDateDemo/src/LocalDateDemo2.java @@ -0,0 +1,35 @@ +import java.time.LocalDate; + +public class LocalDateDemo2 +{ + + public static void main(String[] args) + { + LocalDate date = LocalDate.now(); + System.out.println("date = " + date); + + /* + * Parameters: + * + * monthsToAdd - the months to add, may be negative + * + * Returns:a LocalDate based on this date with the months + * added, not null + */ + LocalDate dateAfterMonthChanged = date.plusMonths(2); + System.out.println("dateAfterMonthChanged = " + dateAfterMonthChanged); + + /* + * Parameters: + * + * yearsToAdd - the years to add, may be negative + * + * Returns:a LocalDate based on this date with the years + * added, not null + */ + + LocalDate dateAfterYearChanged = date.plusYears(5); + System.out.println("dateAfterYearChanged = " + dateAfterYearChanged); + } + +} diff --git a/BasicJava/LocalDateDemo_minus_plus_month_year/LocalDateDemo1_Output.txt b/BasicJava/LocalDateDemo_minus_plus_month_year/LocalDateDemo1_Output.txt new file mode 100644 index 000000000..6984b4406 --- /dev/null +++ b/BasicJava/LocalDateDemo_minus_plus_month_year/LocalDateDemo1_Output.txt @@ -0,0 +1,3 @@ +date = 2018-01-04 +dateAfterMonthChanged = 2017-11-04 +dateAfterYearChanged = 2015-01-04 diff --git a/BasicJava/LocalDateDemo_minus_plus_month_year/LocalDateDemo2_Output.txt b/BasicJava/LocalDateDemo_minus_plus_month_year/LocalDateDemo2_Output.txt new file mode 100644 index 000000000..3aa2296ab --- /dev/null +++ b/BasicJava/LocalDateDemo_minus_plus_month_year/LocalDateDemo2_Output.txt @@ -0,0 +1,3 @@ +date = 2018-01-04 +dateAfterMonthChanged = 2018-03-04 +dateAfterYearChanged = 2023-01-04 diff --git a/BasicJava/LocalDateDemo_minus_plus_weeks/LocalDateDemo/.classpath b/BasicJava/LocalDateDemo_minus_plus_weeks/LocalDateDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalDateDemo_minus_plus_weeks/LocalDateDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalDateDemo_minus_plus_weeks/LocalDateDemo/.project b/BasicJava/LocalDateDemo_minus_plus_weeks/LocalDateDemo/.project new file mode 100644 index 000000000..b83b03f89 --- /dev/null +++ b/BasicJava/LocalDateDemo_minus_plus_weeks/LocalDateDemo/.project @@ -0,0 +1,17 @@ + + + LocalDateDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalDateDemo_minus_plus_weeks/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalDateDemo_minus_plus_weeks/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalDateDemo_minus_plus_weeks/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalDateDemo_minus_plus_weeks/LocalDateDemo/bin/LocalDateDemo1.class b/BasicJava/LocalDateDemo_minus_plus_weeks/LocalDateDemo/bin/LocalDateDemo1.class new file mode 100644 index 000000000..29cce6213 Binary files /dev/null and b/BasicJava/LocalDateDemo_minus_plus_weeks/LocalDateDemo/bin/LocalDateDemo1.class differ diff --git a/BasicJava/LocalDateDemo_minus_plus_weeks/LocalDateDemo/bin/LocalDateDemo2.class b/BasicJava/LocalDateDemo_minus_plus_weeks/LocalDateDemo/bin/LocalDateDemo2.class new file mode 100644 index 000000000..fb6044183 Binary files /dev/null and b/BasicJava/LocalDateDemo_minus_plus_weeks/LocalDateDemo/bin/LocalDateDemo2.class differ diff --git a/BasicJava/LocalDateDemo_minus_plus_weeks/LocalDateDemo/src/LocalDateDemo1.java b/BasicJava/LocalDateDemo_minus_plus_weeks/LocalDateDemo/src/LocalDateDemo1.java new file mode 100644 index 000000000..ff0f5fc96 --- /dev/null +++ b/BasicJava/LocalDateDemo_minus_plus_weeks/LocalDateDemo/src/LocalDateDemo1.java @@ -0,0 +1,23 @@ +import java.time.LocalDate; + +public class LocalDateDemo1 +{ + + public static void main(String[] args) + { + LocalDate currentDate = LocalDate.now(); + System.out.println("currentDate = " + currentDate); + + /* + * Parameters: + * + * weeksToSubtract - the weeks to subtract, may be negative + * + * Returns:a LocalDate based on this date with the weeks + * subtracted, not null + */ + LocalDate dateAfterWeekChanged = currentDate.minusWeeks(2); + System.out.println("dateAfterWeekChanged = " + dateAfterWeekChanged); + } + +} diff --git a/BasicJava/LocalDateDemo_minus_plus_weeks/LocalDateDemo/src/LocalDateDemo2.java b/BasicJava/LocalDateDemo_minus_plus_weeks/LocalDateDemo/src/LocalDateDemo2.java new file mode 100644 index 000000000..f4860c299 --- /dev/null +++ b/BasicJava/LocalDateDemo_minus_plus_weeks/LocalDateDemo/src/LocalDateDemo2.java @@ -0,0 +1,27 @@ +import java.time.LocalDate; + +public class LocalDateDemo2 +{ + + public static void main(String[] args) + { + /* + * Obtains an instance of LocalDate from a text string such as + * 2007-12-03 + */ + LocalDate currentDate = LocalDate.now(); + System.out.println("currentDate = " + currentDate); + + /* + * Parameters: + * + * weeksToAdd - the weeks to add, may be negative + * + * Returns:a LocalDate based on this date with the weeks + * added, not null + */ + LocalDate dateAfterWeekChanged = currentDate.plusWeeks(3); + System.out.println("dateAfterWeekChanged = " + dateAfterWeekChanged); + } + +} diff --git a/BasicJava/LocalDateDemo_minus_plus_weeks/LocalDateDemo1_Output.txt b/BasicJava/LocalDateDemo_minus_plus_weeks/LocalDateDemo1_Output.txt new file mode 100644 index 000000000..d6e035a07 --- /dev/null +++ b/BasicJava/LocalDateDemo_minus_plus_weeks/LocalDateDemo1_Output.txt @@ -0,0 +1,2 @@ +currentDate = 2018-01-05 +dateAfterWeekChanged = 2017-12-22 diff --git a/BasicJava/LocalDateDemo_minus_plus_weeks/LocalDateDemo2_Output.txt b/BasicJava/LocalDateDemo_minus_plus_weeks/LocalDateDemo2_Output.txt new file mode 100644 index 000000000..9964adaf1 --- /dev/null +++ b/BasicJava/LocalDateDemo_minus_plus_weeks/LocalDateDemo2_Output.txt @@ -0,0 +1,2 @@ +currentDate = 2018-01-05 +dateAfterWeekChanged = 2018-01-26 diff --git a/BasicJava/LocalDateDemo_now_methods/LocalDateDemo/.classpath b/BasicJava/LocalDateDemo_now_methods/LocalDateDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalDateDemo_now_methods/LocalDateDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalDateDemo_now_methods/LocalDateDemo/.project b/BasicJava/LocalDateDemo_now_methods/LocalDateDemo/.project new file mode 100644 index 000000000..b83b03f89 --- /dev/null +++ b/BasicJava/LocalDateDemo_now_methods/LocalDateDemo/.project @@ -0,0 +1,17 @@ + + + LocalDateDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalDateDemo_now_methods/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalDateDemo_now_methods/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalDateDemo_now_methods/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalDateDemo_now_methods/LocalDateDemo/bin/LocalDateDemo.class b/BasicJava/LocalDateDemo_now_methods/LocalDateDemo/bin/LocalDateDemo.class new file mode 100644 index 000000000..5955080ea Binary files /dev/null and b/BasicJava/LocalDateDemo_now_methods/LocalDateDemo/bin/LocalDateDemo.class differ diff --git a/BasicJava/LocalDateDemo_now_methods/LocalDateDemo/src/LocalDateDemo.java b/BasicJava/LocalDateDemo_now_methods/LocalDateDemo/src/LocalDateDemo.java new file mode 100644 index 000000000..9f2f52fba --- /dev/null +++ b/BasicJava/LocalDateDemo_now_methods/LocalDateDemo/src/LocalDateDemo.java @@ -0,0 +1,40 @@ +import java.time.Clock; +import java.time.LocalDate; +import java.time.ZoneId; + +public class LocalDateDemo +{ + public static void main(String[] args) + { + /* + * Returns:the current date using the system clock and default + * time-zone, not null + */ + LocalDate date1 = LocalDate.now(); + System.out.println(date1); + + Clock clock = Clock.systemUTC(); + /* + * Parameters: + * + * clock - the clock to use, not null + * + * Returns:the current date, not null + */ + + LocalDate date2 = LocalDate.now(clock); + System.out.println(date2); + + ZoneId zoneId = ZoneId.systemDefault(); + /* + * Parameters: + * + * zone - the zone ID to use, not null + * + * Returns:the current date using the system clock, not null + */ + LocalDate date3 = LocalDate.now(zoneId); + System.out.println(date3); + } + +} diff --git a/BasicJava/LocalDateDemo_now_methods/Output.txt b/BasicJava/LocalDateDemo_now_methods/Output.txt new file mode 100644 index 000000000..b61529407 --- /dev/null +++ b/BasicJava/LocalDateDemo_now_methods/Output.txt @@ -0,0 +1,3 @@ +2018-01-07 +2018-01-07 +2018-01-07 diff --git a/BasicJava/LocalDateDemo_plus_minus_days/LocalDateDemo/.classpath b/BasicJava/LocalDateDemo_plus_minus_days/LocalDateDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalDateDemo_plus_minus_days/LocalDateDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalDateDemo_plus_minus_days/LocalDateDemo/.project b/BasicJava/LocalDateDemo_plus_minus_days/LocalDateDemo/.project new file mode 100644 index 000000000..b83b03f89 --- /dev/null +++ b/BasicJava/LocalDateDemo_plus_minus_days/LocalDateDemo/.project @@ -0,0 +1,17 @@ + + + LocalDateDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalDateDemo_plus_minus_days/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalDateDemo_plus_minus_days/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalDateDemo_plus_minus_days/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalDateDemo_plus_minus_days/LocalDateDemo/bin/LocalDateDemo.class b/BasicJava/LocalDateDemo_plus_minus_days/LocalDateDemo/bin/LocalDateDemo.class new file mode 100644 index 000000000..5db8a9fc3 Binary files /dev/null and b/BasicJava/LocalDateDemo_plus_minus_days/LocalDateDemo/bin/LocalDateDemo.class differ diff --git a/BasicJava/LocalDateDemo_plus_minus_days/LocalDateDemo/src/LocalDateDemo.java b/BasicJava/LocalDateDemo_plus_minus_days/LocalDateDemo/src/LocalDateDemo.java new file mode 100644 index 000000000..af5e02ef6 --- /dev/null +++ b/BasicJava/LocalDateDemo_plus_minus_days/LocalDateDemo/src/LocalDateDemo.java @@ -0,0 +1,39 @@ +import java.time.LocalDate; + +public class LocalDateDemo +{ + + public static void main(String[] args) + { + /* + * Returns:the current date using the system clock and default + * time-zone, not null + */ + LocalDate todayDate = LocalDate.now(); + System.out.println("Today date = " + todayDate); + + /* + * Parameters: + * + * daysToSubtract - the days to subtract, may be negative + * + * Returns:a LocalDate based on this date with the days + * subtracted, not null + */ + LocalDate yesterdayDate = todayDate.minusDays(1); + System.out.println("Yesterday date = " + yesterdayDate); + + /* + * Parameters: + * + * daysToAdd - the days to add, may be negative + * + * Returns:a LocalDate based on this date with the days added, + * not null + * + */ + LocalDate tomorrowDate = todayDate.plusDays(1); + System.out.println("Tommorow date = " + tomorrowDate); + } + +} diff --git a/BasicJava/LocalDateDemo_plus_minus_days/Output.txt b/BasicJava/LocalDateDemo_plus_minus_days/Output.txt new file mode 100644 index 000000000..e2789b443 --- /dev/null +++ b/BasicJava/LocalDateDemo_plus_minus_days/Output.txt @@ -0,0 +1,3 @@ +Today date = 2018-01-03 +Yesterday date = 2018-01-02 +Tommorow date = 2018-01-04 diff --git a/BasicJava/LocalDateDemo_range/LocalDateDemo/.classpath b/BasicJava/LocalDateDemo_range/LocalDateDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalDateDemo_range/LocalDateDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalDateDemo_range/LocalDateDemo/.project b/BasicJava/LocalDateDemo_range/LocalDateDemo/.project new file mode 100644 index 000000000..b83b03f89 --- /dev/null +++ b/BasicJava/LocalDateDemo_range/LocalDateDemo/.project @@ -0,0 +1,17 @@ + + + LocalDateDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalDateDemo_range/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalDateDemo_range/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalDateDemo_range/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalDateDemo_range/LocalDateDemo/bin/LocalDateDemo.class b/BasicJava/LocalDateDemo_range/LocalDateDemo/bin/LocalDateDemo.class new file mode 100644 index 000000000..596ead5ca Binary files /dev/null and b/BasicJava/LocalDateDemo_range/LocalDateDemo/bin/LocalDateDemo.class differ diff --git a/BasicJava/LocalDateDemo_range/LocalDateDemo/src/LocalDateDemo.java b/BasicJava/LocalDateDemo_range/LocalDateDemo/src/LocalDateDemo.java new file mode 100644 index 000000000..2ffc1ce02 --- /dev/null +++ b/BasicJava/LocalDateDemo_range/LocalDateDemo/src/LocalDateDemo.java @@ -0,0 +1,42 @@ +import java.time.LocalDate; +import java.time.temporal.ChronoField; +import java.time.temporal.ValueRange; + +public class LocalDateDemo +{ + + public static void main(String[] args) + { + LocalDate date = LocalDate.parse("2017-12-03"); + + /* + * Parameters: + * + * field - the field to query the range for, not null + * + * Returns: + * + * the range of valid values for the field, not null + */ + ValueRange dayOfMonthRange = date.range(ChronoField.DAY_OF_MONTH); + System.out.println("dayOfMonthRange = "+dayOfMonthRange); + System.out.println("Max DayOfMonth = "+ dayOfMonthRange.getMaximum()); + System.out.println("Min DayOfMonth = "+ dayOfMonthRange.getMinimum()); + + System.out.println("--------------------------"); + + ValueRange monthOfYearRange = date.range(ChronoField.MONTH_OF_YEAR); + System.out.println("monthOfYearRange = "+monthOfYearRange); + System.out.println("Max MonthOfYear = "+ monthOfYearRange.getMaximum()); + System.out.println("Min MonthOfYear = "+ monthOfYearRange.getMinimum()); + + System.out.println("--------------------------"); + + ValueRange dayOfYearRange = date.range(ChronoField.DAY_OF_YEAR); + System.out.println("dayOfYearRange = "+dayOfYearRange); + System.out.println("Max DayOfYear = "+ dayOfYearRange.getMaximum()); + System.out.println("Min DayOfYear = "+ dayOfYearRange.getMinimum()); + + } + +} diff --git a/BasicJava/LocalDateDemo_range/Output.txt b/BasicJava/LocalDateDemo_range/Output.txt new file mode 100644 index 000000000..3546b0673 --- /dev/null +++ b/BasicJava/LocalDateDemo_range/Output.txt @@ -0,0 +1,11 @@ +dayOfMonthRange = 1 - 31 +Max DayOfMonth = 31 +Min DayOfMonth = 1 +-------------------------- +monthOfYearRange = 1 - 12 +Max MonthOfYear = 12 +Min MonthOfYear = 1 +-------------------------- +dayOfYearRange = 1 - 365 +Max DayOfYear = 365 +Min DayOfYear = 1 diff --git a/BasicJava/LocalDateDemo_with/LocalDateDemo/.classpath b/BasicJava/LocalDateDemo_with/LocalDateDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalDateDemo_with/LocalDateDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalDateDemo_with/LocalDateDemo/.project b/BasicJava/LocalDateDemo_with/LocalDateDemo/.project new file mode 100644 index 000000000..b83b03f89 --- /dev/null +++ b/BasicJava/LocalDateDemo_with/LocalDateDemo/.project @@ -0,0 +1,17 @@ + + + LocalDateDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalDateDemo_with/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalDateDemo_with/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalDateDemo_with/LocalDateDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalDateDemo_with/LocalDateDemo/bin/LocalDateDemo.class b/BasicJava/LocalDateDemo_with/LocalDateDemo/bin/LocalDateDemo.class new file mode 100644 index 000000000..2e1b8d5d3 Binary files /dev/null and b/BasicJava/LocalDateDemo_with/LocalDateDemo/bin/LocalDateDemo.class differ diff --git a/BasicJava/LocalDateDemo_with/LocalDateDemo/src/LocalDateDemo.java b/BasicJava/LocalDateDemo_with/LocalDateDemo/src/LocalDateDemo.java new file mode 100644 index 000000000..610704322 --- /dev/null +++ b/BasicJava/LocalDateDemo_with/LocalDateDemo/src/LocalDateDemo.java @@ -0,0 +1,49 @@ +import java.time.LocalDate; + +public class LocalDateDemo +{ + + public static void main(String[] args) + { + LocalDate date = LocalDate.now(); + System.out.println("date = " + date); + + /* + * Parameters: + * + * dayOfMonth - the day-of-month to set in the result, from 1 + * to 28-31 + * + * Returns:a LocalDate based on this date with the requested + * day, not null + */ + LocalDate dateAfterDayChanged = date.withDayOfMonth(30); + System.out.println("dateAfterDayChanged = " + dateAfterDayChanged); + + /* + * Parameters: + * + * month - the month-of-year to set in the result, from 1 + * (January) to 12 (December) + * + * Returns:a LocalDate based on this date with the requested + * month, not null + */ + LocalDate dateAfterMonthChanged = date.withMonth(2); + System.out.println("dateAfterMonthChanged = " + dateAfterMonthChanged); + + /* + * Parameters: + * + * year - the year to set in the result, from MIN_YEAR to + * MAX_YEAR + * + * Returns:a LocalDate based on this date with the requested + * year, not null + */ + LocalDate dateAfterYearChanged = date.withYear(2050); + System.out.println("dateAfterYearChanged = " + dateAfterYearChanged); + + } + +} diff --git a/BasicJava/LocalDateDemo_with/Output.txt b/BasicJava/LocalDateDemo_with/Output.txt new file mode 100644 index 000000000..483c8c2d4 --- /dev/null +++ b/BasicJava/LocalDateDemo_with/Output.txt @@ -0,0 +1,4 @@ +date = 2018-01-05 +dateAfterDayChanged = 2018-01-30 +dateAfterMonthChanged = 2018-02-05 +dateAfterYearChanged = 2050-01-05 diff --git a/BasicJava/LocalDateTimeDemo_Intro/LocalDateTimeDemo/.classpath b/BasicJava/LocalDateTimeDemo_Intro/LocalDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_Intro/LocalDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalDateTimeDemo_Intro/LocalDateTimeDemo/.project b/BasicJava/LocalDateTimeDemo_Intro/LocalDateTimeDemo/.project new file mode 100644 index 000000000..f1fb898ca --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_Intro/LocalDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + LocalDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalDateTimeDemo_Intro/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalDateTimeDemo_Intro/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_Intro/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalDateTimeDemo_Intro/LocalDateTimeDemo/bin/LocalDateTimeDemo.class b/BasicJava/LocalDateTimeDemo_Intro/LocalDateTimeDemo/bin/LocalDateTimeDemo.class new file mode 100644 index 000000000..9529729ab Binary files /dev/null and b/BasicJava/LocalDateTimeDemo_Intro/LocalDateTimeDemo/bin/LocalDateTimeDemo.class differ diff --git a/BasicJava/LocalDateTimeDemo_Intro/LocalDateTimeDemo/src/LocalDateTimeDemo.java b/BasicJava/LocalDateTimeDemo_Intro/LocalDateTimeDemo/src/LocalDateTimeDemo.java new file mode 100644 index 000000000..1c642e98a --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_Intro/LocalDateTimeDemo/src/LocalDateTimeDemo.java @@ -0,0 +1,18 @@ +import java.time.LocalDateTime; + +public class LocalDateTimeDemo +{ + + public static void main(String[] args) + { + /* + * Returns: + * + * the current date-time using the system clock and + * default time-zone, not null + */ + LocalDateTime localDateTime = LocalDateTime.now(); + System.out.println(localDateTime); + } + +} diff --git a/BasicJava/LocalDateTimeDemo_Intro/Output.txt b/BasicJava/LocalDateTimeDemo_Intro/Output.txt new file mode 100644 index 000000000..fe9580505 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_Intro/Output.txt @@ -0,0 +1 @@ +2018-01-12T09:32:49.274 diff --git a/BasicJava/LocalDateTimeDemo_atOffset/LocalDateTimeDemo/.classpath b/BasicJava/LocalDateTimeDemo_atOffset/LocalDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_atOffset/LocalDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalDateTimeDemo_atOffset/LocalDateTimeDemo/.project b/BasicJava/LocalDateTimeDemo_atOffset/LocalDateTimeDemo/.project new file mode 100644 index 000000000..f1fb898ca --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_atOffset/LocalDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + LocalDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalDateTimeDemo_atOffset/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalDateTimeDemo_atOffset/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_atOffset/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalDateTimeDemo_atOffset/LocalDateTimeDemo/bin/LocalDateTimeDemo.class b/BasicJava/LocalDateTimeDemo_atOffset/LocalDateTimeDemo/bin/LocalDateTimeDemo.class new file mode 100644 index 000000000..8188ed7ad Binary files /dev/null and b/BasicJava/LocalDateTimeDemo_atOffset/LocalDateTimeDemo/bin/LocalDateTimeDemo.class differ diff --git a/BasicJava/LocalDateTimeDemo_atOffset/LocalDateTimeDemo/src/LocalDateTimeDemo.java b/BasicJava/LocalDateTimeDemo_atOffset/LocalDateTimeDemo/src/LocalDateTimeDemo.java new file mode 100644 index 000000000..755fb97d0 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_atOffset/LocalDateTimeDemo/src/LocalDateTimeDemo.java @@ -0,0 +1,30 @@ +import java.time.LocalDateTime; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; + +public class LocalDateTimeDemo +{ + + public static void main(String[] args) + { + LocalDateTime localDateTime = LocalDateTime + .parse("2017-02-03T12:30:30"); + System.out.println("localDateTime = "+localDateTime); + + ZoneOffset zoneOffset = ZoneOffset.ofHours(5); + System.out.println("zoneOffset = "+zoneOffset); + /* + * Parameters: + * + * offset - the offset to combine with, not null + * + * Returns: + * + * the offset date-time formed from this date-time and the + * specified offset, not null + */ + OffsetDateTime offsetDateTime = localDateTime.atOffset(zoneOffset); + System.out.println("offsetDateTime = "+offsetDateTime); + } + +} diff --git a/BasicJava/LocalDateTimeDemo_atOffset/Output.txt b/BasicJava/LocalDateTimeDemo_atOffset/Output.txt new file mode 100644 index 000000000..d797ced92 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_atOffset/Output.txt @@ -0,0 +1,3 @@ +localDateTime = 2017-02-03T12:30:30 +zoneOffset = +05:00 +offsetDateTime = 2017-02-03T12:30:30+05:00 diff --git a/BasicJava/LocalDateTimeDemo_atZone/LocalDateTimeDemo/.classpath b/BasicJava/LocalDateTimeDemo_atZone/LocalDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_atZone/LocalDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalDateTimeDemo_atZone/LocalDateTimeDemo/.project b/BasicJava/LocalDateTimeDemo_atZone/LocalDateTimeDemo/.project new file mode 100644 index 000000000..f1fb898ca --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_atZone/LocalDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + LocalDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalDateTimeDemo_atZone/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalDateTimeDemo_atZone/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_atZone/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalDateTimeDemo_atZone/LocalDateTimeDemo/bin/LocalDateTimeDemo.class b/BasicJava/LocalDateTimeDemo_atZone/LocalDateTimeDemo/bin/LocalDateTimeDemo.class new file mode 100644 index 000000000..fc10b74f0 Binary files /dev/null and b/BasicJava/LocalDateTimeDemo_atZone/LocalDateTimeDemo/bin/LocalDateTimeDemo.class differ diff --git a/BasicJava/LocalDateTimeDemo_atZone/LocalDateTimeDemo/src/LocalDateTimeDemo.java b/BasicJava/LocalDateTimeDemo_atZone/LocalDateTimeDemo/src/LocalDateTimeDemo.java new file mode 100644 index 000000000..75e50b732 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_atZone/LocalDateTimeDemo/src/LocalDateTimeDemo.java @@ -0,0 +1,33 @@ +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; + +public class LocalDateTimeDemo +{ + + public static void main(String[] args) + { + LocalDateTime localDateTime = LocalDateTime + .parse("2017-05-03T12:30:30"); + + System.out.println(localDateTime); + + ZoneId zoneId = ZoneId.systemDefault(); + System.out.println("zoneId = "+zoneId); + + /* + * Parameters: + * + * zone - the time-zone to use, not null + * + * Returns: + * + * the zoned date-time formed from this date-time, not null + */ + ZonedDateTime zonedDateTime = localDateTime.atZone(zoneId); + + System.out.println(zonedDateTime); + + } + +} diff --git a/BasicJava/LocalDateTimeDemo_atZone/Output.txt b/BasicJava/LocalDateTimeDemo_atZone/Output.txt new file mode 100644 index 000000000..5d69944c6 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_atZone/Output.txt @@ -0,0 +1,3 @@ +2017-05-03T12:30:30 +zoneId = Asia/Calcutta +2017-05-03T12:30:30+05:30[Asia/Calcutta] diff --git a/BasicJava/LocalDateTimeDemo_equal_after_before/LocalDateTimeDemo/.classpath b/BasicJava/LocalDateTimeDemo_equal_after_before/LocalDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_equal_after_before/LocalDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalDateTimeDemo_equal_after_before/LocalDateTimeDemo/.project b/BasicJava/LocalDateTimeDemo_equal_after_before/LocalDateTimeDemo/.project new file mode 100644 index 000000000..f1fb898ca --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_equal_after_before/LocalDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + LocalDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalDateTimeDemo_equal_after_before/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalDateTimeDemo_equal_after_before/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_equal_after_before/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalDateTimeDemo_equal_after_before/LocalDateTimeDemo/bin/LocalDateTimeDemo.class b/BasicJava/LocalDateTimeDemo_equal_after_before/LocalDateTimeDemo/bin/LocalDateTimeDemo.class new file mode 100644 index 000000000..720786a14 Binary files /dev/null and b/BasicJava/LocalDateTimeDemo_equal_after_before/LocalDateTimeDemo/bin/LocalDateTimeDemo.class differ diff --git a/BasicJava/LocalDateTimeDemo_equal_after_before/LocalDateTimeDemo/src/LocalDateTimeDemo.java b/BasicJava/LocalDateTimeDemo_equal_after_before/LocalDateTimeDemo/src/LocalDateTimeDemo.java new file mode 100644 index 000000000..962e0c8c9 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_equal_after_before/LocalDateTimeDemo/src/LocalDateTimeDemo.java @@ -0,0 +1,36 @@ +import java.time.LocalDateTime; + +public class LocalDateTimeDemo +{ + + public static void main(String[] args) + { + LocalDateTime localDateTime1 = LocalDateTime + .parse("2016-02-03T12:30:30"); + System.out.println("localDateTime1 = "+localDateTime1); + + LocalDateTime localDateTime2 = LocalDateTime + .parse("2017-03-03T12:30:30"); + + System.out.println("localDateTime2 = "+localDateTime2); + + /* + * Returns:true if this is equal to the other date-time + */ + System.out.println(localDateTime1.equals(localDateTime2)); + + /* + * Returns:true if this date-time is after the specified + * date-time + */ + System.out.println(localDateTime1.isAfter(localDateTime2)); + + /* + * Returns:true if this date-time is before the specified + * date-time + */ + + System.out.println(localDateTime1.isBefore(localDateTime2)); + } + +} diff --git a/BasicJava/LocalDateTimeDemo_equal_after_before/Output.txt b/BasicJava/LocalDateTimeDemo_equal_after_before/Output.txt new file mode 100644 index 000000000..49a8ca462 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_equal_after_before/Output.txt @@ -0,0 +1,5 @@ +localDateTime1 = 2016-02-03T12:30:30 +localDateTime2 = 2017-03-03T12:30:30 +false +false +true diff --git a/BasicJava/LocalDateTimeDemo_format_datetimeformatter/LocalDateTimeDemo/.classpath b/BasicJava/LocalDateTimeDemo_format_datetimeformatter/LocalDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_format_datetimeformatter/LocalDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalDateTimeDemo_format_datetimeformatter/LocalDateTimeDemo/.project b/BasicJava/LocalDateTimeDemo_format_datetimeformatter/LocalDateTimeDemo/.project new file mode 100644 index 000000000..f1fb898ca --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_format_datetimeformatter/LocalDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + LocalDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalDateTimeDemo_format_datetimeformatter/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalDateTimeDemo_format_datetimeformatter/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_format_datetimeformatter/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalDateTimeDemo_format_datetimeformatter/LocalDateTimeDemo/bin/LocalDateTimeDemo.class b/BasicJava/LocalDateTimeDemo_format_datetimeformatter/LocalDateTimeDemo/bin/LocalDateTimeDemo.class new file mode 100644 index 000000000..f52c70b68 Binary files /dev/null and b/BasicJava/LocalDateTimeDemo_format_datetimeformatter/LocalDateTimeDemo/bin/LocalDateTimeDemo.class differ diff --git a/BasicJava/LocalDateTimeDemo_format_datetimeformatter/LocalDateTimeDemo/src/LocalDateTimeDemo.java b/BasicJava/LocalDateTimeDemo_format_datetimeformatter/LocalDateTimeDemo/src/LocalDateTimeDemo.java new file mode 100644 index 000000000..dce6b6545 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_format_datetimeformatter/LocalDateTimeDemo/src/LocalDateTimeDemo.java @@ -0,0 +1,40 @@ +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; + +public class LocalDateTimeDemo +{ + + public static void main(String[] args) + { + LocalDateTime localDateTime = LocalDateTime.now(); + System.out.println("Before Formatting = " + localDateTime); + + /* + * Parameters: + * + * pattern - the pattern to use, not null + * + * Returns: + * + * the formatter based on the pattern, not null + * + */ + + DateTimeFormatter dateTimeFormatter = DateTimeFormatter + .ofPattern("dd-MM-yyyy HH:mm:ss"); + + /* + * Parameters: + * + * formatter - the formatter to use, not null + * + * Returns: + * + * the formatted date-time string, not null + * + */ + String formatDateTime = localDateTime.format(dateTimeFormatter); + System.out.println("After Formatting = " + formatDateTime); + } + +} diff --git a/BasicJava/LocalDateTimeDemo_format_datetimeformatter/Output.txt b/BasicJava/LocalDateTimeDemo_format_datetimeformatter/Output.txt new file mode 100644 index 000000000..96c689231 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_format_datetimeformatter/Output.txt @@ -0,0 +1,2 @@ +Before Formatting = 2018-01-17T10:09:54.188 +After Formatting = 17-01-2018 10:09:54 diff --git a/BasicJava/LocalDateTimeDemo_format_how/LocalDateTimeDemo/.classpath b/BasicJava/LocalDateTimeDemo_format_how/LocalDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_format_how/LocalDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalDateTimeDemo_format_how/LocalDateTimeDemo/.project b/BasicJava/LocalDateTimeDemo_format_how/LocalDateTimeDemo/.project new file mode 100644 index 000000000..f1fb898ca --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_format_how/LocalDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + LocalDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalDateTimeDemo_format_how/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalDateTimeDemo_format_how/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_format_how/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalDateTimeDemo_format_how/LocalDateTimeDemo/bin/LocalDateTimeDemo.class b/BasicJava/LocalDateTimeDemo_format_how/LocalDateTimeDemo/bin/LocalDateTimeDemo.class new file mode 100644 index 000000000..9e006a090 Binary files /dev/null and b/BasicJava/LocalDateTimeDemo_format_how/LocalDateTimeDemo/bin/LocalDateTimeDemo.class differ diff --git a/BasicJava/LocalDateTimeDemo_format_how/LocalDateTimeDemo/src/LocalDateTimeDemo.java b/BasicJava/LocalDateTimeDemo_format_how/LocalDateTimeDemo/src/LocalDateTimeDemo.java new file mode 100644 index 000000000..0800a73eb --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_format_how/LocalDateTimeDemo/src/LocalDateTimeDemo.java @@ -0,0 +1,29 @@ +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; + +public class LocalDateTimeDemo +{ + + public static void main(String[] args) + { + LocalDateTime localDateTime = LocalDateTime + .parse("2017-02-03T12:30:30"); + System.out.println(localDateTime); + + + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ISO_DATE; + /* + * Parameters: + * + * temporal - the temporal object to format, not null + * + * Returns: + * + * the formatted string, not null + */ + + String formatedStrDate = dateTimeFormatter.format(localDateTime); + System.out.println(formatedStrDate); + } + +} diff --git a/BasicJava/LocalDateTimeDemo_format_how/Output.txt b/BasicJava/LocalDateTimeDemo_format_how/Output.txt new file mode 100644 index 000000000..33b538187 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_format_how/Output.txt @@ -0,0 +1,2 @@ +2017-02-03T12:30:30 +2017-02-03 diff --git a/BasicJava/LocalDateTimeDemo_get_Temporalfield/LocalDateTimeDemo/.classpath b/BasicJava/LocalDateTimeDemo_get_Temporalfield/LocalDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_get_Temporalfield/LocalDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalDateTimeDemo_get_Temporalfield/LocalDateTimeDemo/.project b/BasicJava/LocalDateTimeDemo_get_Temporalfield/LocalDateTimeDemo/.project new file mode 100644 index 000000000..f1fb898ca --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_get_Temporalfield/LocalDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + LocalDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalDateTimeDemo_get_Temporalfield/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalDateTimeDemo_get_Temporalfield/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_get_Temporalfield/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalDateTimeDemo_get_Temporalfield/LocalDateTimeDemo/bin/LocalDateTimeDemo.class b/BasicJava/LocalDateTimeDemo_get_Temporalfield/LocalDateTimeDemo/bin/LocalDateTimeDemo.class new file mode 100644 index 000000000..447b3f1f2 Binary files /dev/null and b/BasicJava/LocalDateTimeDemo_get_Temporalfield/LocalDateTimeDemo/bin/LocalDateTimeDemo.class differ diff --git a/BasicJava/LocalDateTimeDemo_get_Temporalfield/LocalDateTimeDemo/src/LocalDateTimeDemo.java b/BasicJava/LocalDateTimeDemo_get_Temporalfield/LocalDateTimeDemo/src/LocalDateTimeDemo.java new file mode 100644 index 000000000..8add2456d --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_get_Temporalfield/LocalDateTimeDemo/src/LocalDateTimeDemo.java @@ -0,0 +1,38 @@ +import java.time.LocalDateTime; +import java.time.temporal.ChronoField; + +public class LocalDateTimeDemo +{ + + public static void main(String[] args) + { + LocalDateTime currentDateTime = LocalDateTime.now(); + System.out.println(currentDateTime); + + /* + * Parameters: + * + * field - the field to get, not null + * + * Returns: + * + * the value for the field + * + */ + System.out.println("DAY_OF_WEEK = " + + currentDateTime.get(ChronoField.DAY_OF_WEEK)); + + System.out.println("DAY_OF_YEAR = " + + currentDateTime.get(ChronoField.DAY_OF_YEAR)); + + System.out.println("DAY_OF_MONTH = " + + currentDateTime.get(ChronoField.DAY_OF_MONTH)); + + System.out.println("HOUR_OF_DAY = " + + currentDateTime.get(ChronoField.HOUR_OF_DAY)); + + System.out.println("MINUTE_OF_DAY = " + + currentDateTime.get(ChronoField.MINUTE_OF_DAY)); + } + +} diff --git a/BasicJava/LocalDateTimeDemo_get_Temporalfield/Output.txt b/BasicJava/LocalDateTimeDemo_get_Temporalfield/Output.txt new file mode 100644 index 000000000..ec127a115 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_get_Temporalfield/Output.txt @@ -0,0 +1,6 @@ +2018-01-12T09:47:30.097 +DAY_OF_WEEK = 5 +DAY_OF_YEAR = 12 +DAY_OF_MONTH = 12 +HOUR_OF_DAY = 9 +MINUTE_OF_DAY = 587 diff --git a/BasicJava/LocalDateTimeDemo_minus/LocalDateTimeDemo/.classpath b/BasicJava/LocalDateTimeDemo_minus/LocalDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_minus/LocalDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalDateTimeDemo_minus/LocalDateTimeDemo/.project b/BasicJava/LocalDateTimeDemo_minus/LocalDateTimeDemo/.project new file mode 100644 index 000000000..f1fb898ca --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_minus/LocalDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + LocalDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalDateTimeDemo_minus/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalDateTimeDemo_minus/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_minus/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalDateTimeDemo_minus/LocalDateTimeDemo/bin/LocalDateTimeDemo.class b/BasicJava/LocalDateTimeDemo_minus/LocalDateTimeDemo/bin/LocalDateTimeDemo.class new file mode 100644 index 000000000..78e84dff0 Binary files /dev/null and b/BasicJava/LocalDateTimeDemo_minus/LocalDateTimeDemo/bin/LocalDateTimeDemo.class differ diff --git a/BasicJava/LocalDateTimeDemo_minus/LocalDateTimeDemo/src/LocalDateTimeDemo.java b/BasicJava/LocalDateTimeDemo_minus/LocalDateTimeDemo/src/LocalDateTimeDemo.java new file mode 100644 index 000000000..41b44b5c5 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_minus/LocalDateTimeDemo/src/LocalDateTimeDemo.java @@ -0,0 +1,37 @@ +import java.time.LocalDateTime; + +public class LocalDateTimeDemo +{ + + public static void main(String[] args) + { + LocalDateTime localDateTime1 = LocalDateTime.now(); + System.out.println("Current date and Time = " + localDateTime1); + + LocalDateTime localDateTime2 = localDateTime1.minusYears(2); + System.out.println("\nYear changed = " + localDateTime2); + + LocalDateTime localDateTime3 = localDateTime2.minusMonths(3); + System.out.println("Month changed = " + localDateTime3); + + LocalDateTime localDateTime4 = localDateTime3.minusDays(5); + System.out.println("Day changed = " + localDateTime4); + + LocalDateTime localDateTime5 = localDateTime4.minusHours(1); + System.out.println("Hour changed = " + localDateTime5); + + LocalDateTime localDateTime6 = localDateTime5.minusMinutes(10); + System.out.println("Min changed = " + localDateTime6); + + LocalDateTime localDateTime7 = localDateTime6.minusSeconds(20); + System.out.println("Sec changed = " + localDateTime7); + + LocalDateTime localDateTime8 = localDateTime7.minusNanos(50); + System.out.println("NanoSec changed = " + localDateTime8); + + LocalDateTime localDateTime9 = localDateTime8.minusWeeks(3); + System.out.println("Week changed = " + localDateTime9); + + } + +} diff --git a/BasicJava/LocalDateTimeDemo_minus/Output.txt b/BasicJava/LocalDateTimeDemo_minus/Output.txt new file mode 100644 index 000000000..9b12647e9 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_minus/Output.txt @@ -0,0 +1,10 @@ +Current date and Time = 2018-01-13T08:30:09.954 + +Year changed = 2016-01-13T08:30:09.954 +Month changed = 2015-10-13T08:30:09.954 +Day changed = 2015-10-08T08:30:09.954 +Hour changed = 2015-10-08T07:30:09.954 +Min changed = 2015-10-08T07:20:09.954 +Sec changed = 2015-10-08T07:19:49.954 +NanoSec changed = 2015-10-08T07:19:49.953999950 +Week changed = 2015-09-17T07:19:49.953999950 diff --git a/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo/.classpath b/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo/.project b/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo/.project new file mode 100644 index 000000000..f1fb898ca --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + LocalDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo/bin/LocalDateTimeDemo1.class b/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo/bin/LocalDateTimeDemo1.class new file mode 100644 index 000000000..3cfa0de0d Binary files /dev/null and b/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo/bin/LocalDateTimeDemo1.class differ diff --git a/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo/bin/LocalDateTimeDemo2.class b/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo/bin/LocalDateTimeDemo2.class new file mode 100644 index 000000000..20b67e1a3 Binary files /dev/null and b/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo/bin/LocalDateTimeDemo2.class differ diff --git a/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo/bin/LocalDateTimeDemo3.class b/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo/bin/LocalDateTimeDemo3.class new file mode 100644 index 000000000..3fe3ec9d4 Binary files /dev/null and b/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo/bin/LocalDateTimeDemo3.class differ diff --git a/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo/src/LocalDateTimeDemo1.java b/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo/src/LocalDateTimeDemo1.java new file mode 100644 index 000000000..220739a69 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo/src/LocalDateTimeDemo1.java @@ -0,0 +1,33 @@ +import java.time.LocalDateTime; +import java.time.Month; + +public class LocalDateTimeDemo1 +{ + + public static void main(String[] args) + { + /* + * Parameters: + * + * year - the year to represent, from MIN_YEAR to MAX_YEAR + * + * month - the month-of-year to represent, not null + * + * dayOfMonth - the day-of-month to represent, from 1 to 31 + * + * hour - the hour-of-day to represent, from 0 to 23 + * + * minute - the minute-of-hour to represent, from 0 to 59 + * + * Returns: + * + * the local date-time, not null + */ + + LocalDateTime localDateTime = LocalDateTime.of(2020, Month.MARCH, 30, 6, + 30); + System.out.println(localDateTime); + + } + +} diff --git a/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo/src/LocalDateTimeDemo2.java b/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo/src/LocalDateTimeDemo2.java new file mode 100644 index 000000000..f92e58ded --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo/src/LocalDateTimeDemo2.java @@ -0,0 +1,35 @@ +import java.time.LocalDateTime; +import java.time.Month; + +public class LocalDateTimeDemo2 +{ + + public static void main(String[] args) + { + /* + * Parameters: + * + * year - the year to represent, from MIN_YEAR to MAX_YEAR + * + * month - the month-of-year to represent, not null + * + * dayOfMonth - the day-of-month to represent, from 1 to 31 + * + * hour - the hour-of-day to represent, from 0 to 23 + * + * minute - the minute-of-hour to represent, from 0 to 59 + * + * second - the second-of-minute to represent, from 0 to 59 + * + * Returns: + * + * the local date-time, not null + */ + + LocalDateTime localDateTime = LocalDateTime.of(2020, Month.MARCH, 30, + 6, 30, 59); + System.out.println(localDateTime); + + } + +} diff --git a/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo/src/LocalDateTimeDemo3.java b/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo/src/LocalDateTimeDemo3.java new file mode 100644 index 000000000..262aa5021 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo/src/LocalDateTimeDemo3.java @@ -0,0 +1,36 @@ +import java.time.LocalDateTime; +import java.time.Month; + +public class LocalDateTimeDemo3 +{ + + public static void main(String[] args) + { + /* + * Parameters: + * + * year - the year to represent, from MIN_YEAR to MAX_YEAR + * + * month - the month-of-year to represent, not null + * + * dayOfMonth - the day-of-month to represent, from 1 to 31 + * + * hour - the hour-of-day to represent, from 0 to 23 + * + * minute - the minute-of-hour to represent, from 0 to 59 + * + * second - the second-of-minute to represent, from 0 to 59 + * + * nanoOfSecond - the nano-of-second to represent, from 0 to + * 999,999,999 + * + * Returns:the local date-time, not null + */ + + LocalDateTime localDateTime = LocalDateTime.of(2020, Month.MARCH, 30, + 6, 30, 59, 600); + System.out.println(localDateTime); + + } + +} diff --git a/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo1_Output.txt b/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo1_Output.txt new file mode 100644 index 000000000..42f1724d3 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo1_Output.txt @@ -0,0 +1 @@ +2020-03-30T06:30 diff --git a/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo2_Output.txt b/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo2_Output.txt new file mode 100644 index 000000000..b7b0696d0 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo2_Output.txt @@ -0,0 +1 @@ +2020-03-30T06:30:59 diff --git a/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo3_Output.txt b/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo3_Output.txt new file mode 100644 index 000000000..ce2cbfe1d --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_of/LocalDateTimeDemo3_Output.txt @@ -0,0 +1 @@ +2020-03-30T06:30:59.000000600 diff --git a/BasicJava/LocalDateTimeDemo_ofInstant/LocalDateTimeDemo/.classpath b/BasicJava/LocalDateTimeDemo_ofInstant/LocalDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_ofInstant/LocalDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalDateTimeDemo_ofInstant/LocalDateTimeDemo/.project b/BasicJava/LocalDateTimeDemo_ofInstant/LocalDateTimeDemo/.project new file mode 100644 index 000000000..f1fb898ca --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_ofInstant/LocalDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + LocalDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalDateTimeDemo_ofInstant/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalDateTimeDemo_ofInstant/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_ofInstant/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalDateTimeDemo_ofInstant/LocalDateTimeDemo/bin/LocalDateTimeDemo.class b/BasicJava/LocalDateTimeDemo_ofInstant/LocalDateTimeDemo/bin/LocalDateTimeDemo.class new file mode 100644 index 000000000..318ced109 Binary files /dev/null and b/BasicJava/LocalDateTimeDemo_ofInstant/LocalDateTimeDemo/bin/LocalDateTimeDemo.class differ diff --git a/BasicJava/LocalDateTimeDemo_ofInstant/LocalDateTimeDemo/src/LocalDateTimeDemo.java b/BasicJava/LocalDateTimeDemo_ofInstant/LocalDateTimeDemo/src/LocalDateTimeDemo.java new file mode 100644 index 000000000..839de51da --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_ofInstant/LocalDateTimeDemo/src/LocalDateTimeDemo.java @@ -0,0 +1,30 @@ +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; + +public class LocalDateTimeDemo +{ + + public static void main(String[] args) + { + + Instant instant = Instant.now(); + System.out.println("instant = "+instant); + + ZoneId zoneId = ZoneId.systemDefault(); + System.out.println("zoneId = "+zoneId); + /* + * Parameters: + * + * instant - the instant to create the date-time from, not + * null + * + * zone - the time-zone, which may be an offset, not null + * + * Returns:the local date-time, not null + */ + LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, zoneId); + System.out.println("localDateTime = "+localDateTime); + } + +} diff --git a/BasicJava/LocalDateTimeDemo_ofInstant/Output.txt b/BasicJava/LocalDateTimeDemo_ofInstant/Output.txt new file mode 100644 index 000000000..df6063554 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_ofInstant/Output.txt @@ -0,0 +1,3 @@ +instant = 2018-01-16T04:49:52.570Z +zoneId = Asia/Calcutta +localDateTime = 2018-01-16T10:19:52.570 diff --git a/BasicJava/LocalDateTimeDemo_parse/LocalDateTimeDemo/.classpath b/BasicJava/LocalDateTimeDemo_parse/LocalDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_parse/LocalDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalDateTimeDemo_parse/LocalDateTimeDemo/.project b/BasicJava/LocalDateTimeDemo_parse/LocalDateTimeDemo/.project new file mode 100644 index 000000000..f1fb898ca --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_parse/LocalDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + LocalDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalDateTimeDemo_parse/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalDateTimeDemo_parse/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_parse/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalDateTimeDemo_parse/LocalDateTimeDemo/bin/LocalDateTimeDemo1.class b/BasicJava/LocalDateTimeDemo_parse/LocalDateTimeDemo/bin/LocalDateTimeDemo1.class new file mode 100644 index 000000000..2804e2f73 Binary files /dev/null and b/BasicJava/LocalDateTimeDemo_parse/LocalDateTimeDemo/bin/LocalDateTimeDemo1.class differ diff --git a/BasicJava/LocalDateTimeDemo_parse/LocalDateTimeDemo/bin/LocalDateTimeDemo2.class b/BasicJava/LocalDateTimeDemo_parse/LocalDateTimeDemo/bin/LocalDateTimeDemo2.class new file mode 100644 index 000000000..df942ccb3 Binary files /dev/null and b/BasicJava/LocalDateTimeDemo_parse/LocalDateTimeDemo/bin/LocalDateTimeDemo2.class differ diff --git a/BasicJava/LocalDateTimeDemo_parse/LocalDateTimeDemo/src/LocalDateTimeDemo1.java b/BasicJava/LocalDateTimeDemo_parse/LocalDateTimeDemo/src/LocalDateTimeDemo1.java new file mode 100644 index 000000000..4a73ac4a9 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_parse/LocalDateTimeDemo/src/LocalDateTimeDemo1.java @@ -0,0 +1,24 @@ +import java.time.LocalDateTime; + +public class LocalDateTimeDemo1 +{ + + public static void main(String[] args) + { + + String strDate = "2020-02-03T10:15:30"; + /* + * Parameters: + * + * text - the text to parse such as "2007-12-03T10:15:30", not + * null + * + * Returns:the parsed local date-time, not null + */ + LocalDateTime localDateTime = LocalDateTime.parse(strDate); + + System.out.println(localDateTime); + + } + +} diff --git a/BasicJava/LocalDateTimeDemo_parse/LocalDateTimeDemo/src/LocalDateTimeDemo2.java b/BasicJava/LocalDateTimeDemo_parse/LocalDateTimeDemo/src/LocalDateTimeDemo2.java new file mode 100644 index 000000000..84aa3da10 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_parse/LocalDateTimeDemo/src/LocalDateTimeDemo2.java @@ -0,0 +1,31 @@ +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; + +public class LocalDateTimeDemo2 +{ + + public static void main(String[] args) + { + + String strDate = "2017-12-03T10:15:30+01:00"; + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ISO_DATE_TIME; + + /* + * Parameters: + * + * text - the text to parse, not null + * + * formatter - the formatter to use, not null + * + * Returns: + * + * the parsed local date-time, not null + */ + + LocalDateTime localDateTime = LocalDateTime.parse(strDate, + dateTimeFormatter); + + System.out.println(localDateTime); + } + +} diff --git a/BasicJava/LocalDateTimeDemo_parse/LocalDateTimeDemo1_Output.txt b/BasicJava/LocalDateTimeDemo_parse/LocalDateTimeDemo1_Output.txt new file mode 100644 index 000000000..723b3561b --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_parse/LocalDateTimeDemo1_Output.txt @@ -0,0 +1 @@ +2020-02-03T10:15:30 diff --git a/BasicJava/LocalDateTimeDemo_parse/LocalDateTimeDemo2_Output.txt b/BasicJava/LocalDateTimeDemo_parse/LocalDateTimeDemo2_Output.txt new file mode 100644 index 000000000..5e4d64b45 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_parse/LocalDateTimeDemo2_Output.txt @@ -0,0 +1 @@ +2017-12-03T10:15:30 diff --git a/BasicJava/LocalDateTimeDemo_plus/LocalDateTimeDemo/.classpath b/BasicJava/LocalDateTimeDemo_plus/LocalDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_plus/LocalDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalDateTimeDemo_plus/LocalDateTimeDemo/.project b/BasicJava/LocalDateTimeDemo_plus/LocalDateTimeDemo/.project new file mode 100644 index 000000000..f1fb898ca --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_plus/LocalDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + LocalDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalDateTimeDemo_plus/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalDateTimeDemo_plus/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_plus/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalDateTimeDemo_plus/LocalDateTimeDemo/bin/LocalDateTimeDemo.class b/BasicJava/LocalDateTimeDemo_plus/LocalDateTimeDemo/bin/LocalDateTimeDemo.class new file mode 100644 index 000000000..4f16d8022 Binary files /dev/null and b/BasicJava/LocalDateTimeDemo_plus/LocalDateTimeDemo/bin/LocalDateTimeDemo.class differ diff --git a/BasicJava/LocalDateTimeDemo_plus/LocalDateTimeDemo/src/LocalDateTimeDemo.java b/BasicJava/LocalDateTimeDemo_plus/LocalDateTimeDemo/src/LocalDateTimeDemo.java new file mode 100644 index 000000000..3241da5dd --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_plus/LocalDateTimeDemo/src/LocalDateTimeDemo.java @@ -0,0 +1,36 @@ +import java.time.LocalDateTime; + +public class LocalDateTimeDemo +{ + + public static void main(String[] args) + { + LocalDateTime localDateTime1 = LocalDateTime.now(); + System.out.println("Current date and Time = "+localDateTime1); + + LocalDateTime localDateTime2 = localDateTime1.plusYears(2); + System.out.println("\nYear changed = "+localDateTime2); + + LocalDateTime localDateTime3 = localDateTime2.plusMonths(3); + System.out.println("Month changed = "+localDateTime3); + + LocalDateTime localDateTime4 = localDateTime3.plusDays(5); + System.out.println("Day changed = "+localDateTime4); + + LocalDateTime localDateTime5 = localDateTime4.plusHours(1); + System.out.println("Hour changed = "+localDateTime5); + + LocalDateTime localDateTime6 = localDateTime5.plusMinutes(10); + System.out.println("Min changed = "+localDateTime6); + + LocalDateTime localDateTime7 = localDateTime6.plusSeconds(20); + System.out.println("Sec changed = "+localDateTime7); + + LocalDateTime localDateTime8 = localDateTime7.plusNanos(50); + System.out.println("NanoSec changed = "+localDateTime8); + + LocalDateTime localDateTime9 = localDateTime8.plusWeeks(3); + System.out.println("Week changed = "+localDateTime9); + } + +} diff --git a/BasicJava/LocalDateTimeDemo_plus/Output.txt b/BasicJava/LocalDateTimeDemo_plus/Output.txt new file mode 100644 index 000000000..4adccd8a5 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_plus/Output.txt @@ -0,0 +1,10 @@ +Current date and Time = 2018-01-15T09:07:10.128 + +Year changed = 2020-01-15T09:07:10.128 +Month changed = 2020-04-15T09:07:10.128 +Day changed = 2020-04-20T09:07:10.128 +Hour changed = 2020-04-20T10:07:10.128 +Min changed = 2020-04-20T10:17:10.128 +Sec changed = 2020-04-20T10:17:30.128 +NanoSec changed = 2020-04-20T10:17:30.128000050 +Week changed = 2020-05-11T10:17:30.128000050 diff --git a/BasicJava/LocalDateTimeDemo_plus_minus_unit/LocalDateTimeDemo/.classpath b/BasicJava/LocalDateTimeDemo_plus_minus_unit/LocalDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_plus_minus_unit/LocalDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalDateTimeDemo_plus_minus_unit/LocalDateTimeDemo/.project b/BasicJava/LocalDateTimeDemo_plus_minus_unit/LocalDateTimeDemo/.project new file mode 100644 index 000000000..f1fb898ca --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_plus_minus_unit/LocalDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + LocalDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalDateTimeDemo_plus_minus_unit/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalDateTimeDemo_plus_minus_unit/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_plus_minus_unit/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalDateTimeDemo_plus_minus_unit/LocalDateTimeDemo/bin/LocalDateTimeDemo.class b/BasicJava/LocalDateTimeDemo_plus_minus_unit/LocalDateTimeDemo/bin/LocalDateTimeDemo.class new file mode 100644 index 000000000..ba9fac48e Binary files /dev/null and b/BasicJava/LocalDateTimeDemo_plus_minus_unit/LocalDateTimeDemo/bin/LocalDateTimeDemo.class differ diff --git a/BasicJava/LocalDateTimeDemo_plus_minus_unit/LocalDateTimeDemo/src/LocalDateTimeDemo.java b/BasicJava/LocalDateTimeDemo_plus_minus_unit/LocalDateTimeDemo/src/LocalDateTimeDemo.java new file mode 100644 index 000000000..470d12b4c --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_plus_minus_unit/LocalDateTimeDemo/src/LocalDateTimeDemo.java @@ -0,0 +1,48 @@ +import java.time.LocalDateTime; +import java.time.temporal.ChronoUnit; + +public class LocalDateTimeDemo +{ + + public static void main(String[] args) + { + LocalDateTime currentDatetime = LocalDateTime.now(); + System.out.println("currentDatetime= " + currentDatetime); + + /* + * Parameters: + * + * amountToAdd - the amount of the unit to add to the result, + * may be negative + * + * unit - the unit of the amount to add, not null + * + * Returns: + * + * a LocalDateTime based on this date-time with the specified + * amount added, not null + */ + LocalDateTime localDateTime2 = currentDatetime.plus(5, + ChronoUnit.MONTHS); + System.out.println("Month Added = " + localDateTime2); + + /* + * Parameters: + * + * amountToSubtract - the amount of the unit to subtract from + * the result, may be negative + * + * unit - the unit of the amount to subtract, not null + * + * Returns: + * + * a LocalDateTime based on this date-time with the specified + * amount subtracted, not null + */ + + LocalDateTime localDateTime3 = currentDatetime.minus(5, + ChronoUnit.YEARS); + System.out.println("Years reduced = " + localDateTime3); + } + +} diff --git a/BasicJava/LocalDateTimeDemo_plus_minus_unit/Output.txt b/BasicJava/LocalDateTimeDemo_plus_minus_unit/Output.txt new file mode 100644 index 000000000..de8a0664b --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_plus_minus_unit/Output.txt @@ -0,0 +1,3 @@ +currentDatetime= 2018-01-16T09:44:12.673 +Month Added = 2018-06-16T09:44:12.673 +Years reduced = 2013-01-16T09:44:12.673 diff --git a/BasicJava/LocalDateTimeDemo_range/LocalDateTimeDemo/.classpath b/BasicJava/LocalDateTimeDemo_range/LocalDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_range/LocalDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalDateTimeDemo_range/LocalDateTimeDemo/.project b/BasicJava/LocalDateTimeDemo_range/LocalDateTimeDemo/.project new file mode 100644 index 000000000..f1fb898ca --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_range/LocalDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + LocalDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalDateTimeDemo_range/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalDateTimeDemo_range/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_range/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalDateTimeDemo_range/LocalDateTimeDemo/bin/LocalDateTimeDemo.class b/BasicJava/LocalDateTimeDemo_range/LocalDateTimeDemo/bin/LocalDateTimeDemo.class new file mode 100644 index 000000000..49641fbbb Binary files /dev/null and b/BasicJava/LocalDateTimeDemo_range/LocalDateTimeDemo/bin/LocalDateTimeDemo.class differ diff --git a/BasicJava/LocalDateTimeDemo_range/LocalDateTimeDemo/src/LocalDateTimeDemo.java b/BasicJava/LocalDateTimeDemo_range/LocalDateTimeDemo/src/LocalDateTimeDemo.java new file mode 100644 index 000000000..ce395f12d --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_range/LocalDateTimeDemo/src/LocalDateTimeDemo.java @@ -0,0 +1,37 @@ +import java.time.LocalDateTime; +import java.time.temporal.ChronoField; +import java.time.temporal.ValueRange; + +public class LocalDateTimeDemo +{ + + public static void main(String[] args) + { + LocalDateTime localDateTime = LocalDateTime + .parse("2018-12-03T10:15:30"); + + /* + * Parameters: + * + * field - the field to query the range for, not null + * + * Returns: + * + * the range of valid values for the field, not null + */ + ValueRange valueRange = localDateTime.range(ChronoField.DAY_OF_YEAR); + + System.out.println("Range : " + valueRange); + System.out.println("Min : " + valueRange.getMinimum()); + System.out.println("Max : " + valueRange.getMaximum()); + + System.out.println("--------------------------------"); + + valueRange = localDateTime.range(ChronoField.MONTH_OF_YEAR); + + System.out.println("Range : " + valueRange); + System.out.println("Min : " + valueRange.getMinimum()); + System.out.println("Max : " + valueRange.getMaximum()); + } + +} diff --git a/BasicJava/LocalDateTimeDemo_range/Output.txt b/BasicJava/LocalDateTimeDemo_range/Output.txt new file mode 100644 index 000000000..12d260ce9 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_range/Output.txt @@ -0,0 +1,7 @@ +Range : 1 - 365 +Min : 1 +Max : 365 +-------------------------------- +Range : 1 - 12 +Min : 1 +Max : 12 diff --git a/BasicJava/LocalDateTimeDemo_toLocaldate_time/LocalDateTimeDemo/.classpath b/BasicJava/LocalDateTimeDemo_toLocaldate_time/LocalDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_toLocaldate_time/LocalDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalDateTimeDemo_toLocaldate_time/LocalDateTimeDemo/.project b/BasicJava/LocalDateTimeDemo_toLocaldate_time/LocalDateTimeDemo/.project new file mode 100644 index 000000000..f1fb898ca --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_toLocaldate_time/LocalDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + LocalDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalDateTimeDemo_toLocaldate_time/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalDateTimeDemo_toLocaldate_time/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_toLocaldate_time/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalDateTimeDemo_toLocaldate_time/LocalDateTimeDemo/bin/LocalDateTimeDemo.class b/BasicJava/LocalDateTimeDemo_toLocaldate_time/LocalDateTimeDemo/bin/LocalDateTimeDemo.class new file mode 100644 index 000000000..654e2b5b6 Binary files /dev/null and b/BasicJava/LocalDateTimeDemo_toLocaldate_time/LocalDateTimeDemo/bin/LocalDateTimeDemo.class differ diff --git a/BasicJava/LocalDateTimeDemo_toLocaldate_time/LocalDateTimeDemo/src/LocalDateTimeDemo.java b/BasicJava/LocalDateTimeDemo_toLocaldate_time/LocalDateTimeDemo/src/LocalDateTimeDemo.java new file mode 100644 index 000000000..dff7e3822 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_toLocaldate_time/LocalDateTimeDemo/src/LocalDateTimeDemo.java @@ -0,0 +1,28 @@ +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; + +public class LocalDateTimeDemo +{ + + public static void main(String[] args) + { + LocalDateTime localDateTime = LocalDateTime.now(); + System.out.println("localDateTime = " + localDateTime); + + + /* + * Returns the date part of this date-time, not null. + */ + LocalDate localDate = localDateTime.toLocalDate(); + System.out.println("localDate = " + localDate); + + /* + * Returns the time part of this date-time, not null. + */ + LocalTime localTime = localDateTime.toLocalTime(); + System.out.println("localTime = " + localTime); + + } + +} diff --git a/BasicJava/LocalDateTimeDemo_toLocaldate_time/Output.txt b/BasicJava/LocalDateTimeDemo_toLocaldate_time/Output.txt new file mode 100644 index 000000000..5b202f8d3 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_toLocaldate_time/Output.txt @@ -0,0 +1,3 @@ +localDateTime = 2018-01-17T09:41:13.709 +localDate = 2018-01-17 +localTime = 09:41:13.709 diff --git a/BasicJava/LocalDateTimeDemo_truncatedto/LocalDateTimeDemo/.classpath b/BasicJava/LocalDateTimeDemo_truncatedto/LocalDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_truncatedto/LocalDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalDateTimeDemo_truncatedto/LocalDateTimeDemo/.project b/BasicJava/LocalDateTimeDemo_truncatedto/LocalDateTimeDemo/.project new file mode 100644 index 000000000..f1fb898ca --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_truncatedto/LocalDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + LocalDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalDateTimeDemo_truncatedto/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalDateTimeDemo_truncatedto/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_truncatedto/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalDateTimeDemo_truncatedto/LocalDateTimeDemo/bin/LocalDateTimeDemo.class b/BasicJava/LocalDateTimeDemo_truncatedto/LocalDateTimeDemo/bin/LocalDateTimeDemo.class new file mode 100644 index 000000000..35d1c6e78 Binary files /dev/null and b/BasicJava/LocalDateTimeDemo_truncatedto/LocalDateTimeDemo/bin/LocalDateTimeDemo.class differ diff --git a/BasicJava/LocalDateTimeDemo_truncatedto/LocalDateTimeDemo/src/LocalDateTimeDemo.java b/BasicJava/LocalDateTimeDemo_truncatedto/LocalDateTimeDemo/src/LocalDateTimeDemo.java new file mode 100644 index 000000000..e6e95a333 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_truncatedto/LocalDateTimeDemo/src/LocalDateTimeDemo.java @@ -0,0 +1,29 @@ +import java.time.LocalDateTime; +import java.time.temporal.ChronoUnit; + +public class LocalDateTimeDemo +{ + + public static void main(String[] args) + { + LocalDateTime localDateTime1 = LocalDateTime.now(); + System.out.println(localDateTime1); + + /* + * Parameters: + * + * unit - the unit to truncate to, not null + * + * Returns: + * + * a LocalDateTime based on this date-time with the + * time truncated, not null + */ + LocalDateTime localDateTime2 = localDateTime1 + .truncatedTo(ChronoUnit.DAYS); + + System.out.println(localDateTime2); + + } + +} diff --git a/BasicJava/LocalDateTimeDemo_truncatedto/Output.txt b/BasicJava/LocalDateTimeDemo_truncatedto/Output.txt new file mode 100644 index 000000000..478897c8f --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_truncatedto/Output.txt @@ -0,0 +1,2 @@ +2018-01-17T09:54:07.362 +2018-01-17T00:00 diff --git a/BasicJava/LocalDateTimeDemo_with/LocalDateTimeDemo/.classpath b/BasicJava/LocalDateTimeDemo_with/LocalDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_with/LocalDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalDateTimeDemo_with/LocalDateTimeDemo/.project b/BasicJava/LocalDateTimeDemo_with/LocalDateTimeDemo/.project new file mode 100644 index 000000000..f1fb898ca --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_with/LocalDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + LocalDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalDateTimeDemo_with/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalDateTimeDemo_with/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_with/LocalDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalDateTimeDemo_with/LocalDateTimeDemo/bin/LocalDateTimeDemo.class b/BasicJava/LocalDateTimeDemo_with/LocalDateTimeDemo/bin/LocalDateTimeDemo.class new file mode 100644 index 000000000..69b2f56a4 Binary files /dev/null and b/BasicJava/LocalDateTimeDemo_with/LocalDateTimeDemo/bin/LocalDateTimeDemo.class differ diff --git a/BasicJava/LocalDateTimeDemo_with/LocalDateTimeDemo/src/LocalDateTimeDemo.java b/BasicJava/LocalDateTimeDemo_with/LocalDateTimeDemo/src/LocalDateTimeDemo.java new file mode 100644 index 000000000..27eaa7e77 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_with/LocalDateTimeDemo/src/LocalDateTimeDemo.java @@ -0,0 +1,34 @@ +import java.time.LocalDateTime; + +public class LocalDateTimeDemo +{ + + public static void main(String[] args) + { + LocalDateTime localDateTime1 = LocalDateTime.parse("2017-01-03T20:25:30"); + System.out.println("date and Time = "+localDateTime1); + + LocalDateTime localDateTime2 = localDateTime1.withYear(2018); + System.out.println("\nYear changed = "+localDateTime2); + + LocalDateTime localDateTime3 = localDateTime2.withMonth(10); + System.out.println("Month changed = "+localDateTime3); + + LocalDateTime localDateTime4 = localDateTime3.withDayOfMonth(25); + System.out.println("Day changed = "+localDateTime4); + + LocalDateTime localDateTime5 = localDateTime4.withHour(1); + System.out.println("Hour changed = "+localDateTime5); + + LocalDateTime localDateTime6 = localDateTime5.withMinute(10); + System.out.println("Min changed = "+localDateTime6); + + LocalDateTime localDateTime7 = localDateTime6.withSecond(20); + System.out.println("Sec changed = "+localDateTime7); + + LocalDateTime localDateTime8 = localDateTime7.withNano(50); + System.out.println("NanoSec changed = "+localDateTime8); + + } + +} diff --git a/BasicJava/LocalDateTimeDemo_with/Output.txt b/BasicJava/LocalDateTimeDemo_with/Output.txt new file mode 100644 index 000000000..504ef6404 --- /dev/null +++ b/BasicJava/LocalDateTimeDemo_with/Output.txt @@ -0,0 +1,9 @@ +date and Time = 2017-01-03T20:25:30 + +Year changed = 2018-01-03T20:25:30 +Month changed = 2018-10-03T20:25:30 +Day changed = 2018-10-25T20:25:30 +Hour changed = 2018-10-25T01:25:30 +Min changed = 2018-10-25T01:10:30 +Sec changed = 2018-10-25T01:10:20 +NanoSec changed = 2018-10-25T01:10:20.000000050 diff --git a/BasicJava/LocalTimeDemo_Intro/LocalTimeDemo/.classpath b/BasicJava/LocalTimeDemo_Intro/LocalTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalTimeDemo_Intro/LocalTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalTimeDemo_Intro/LocalTimeDemo/.project b/BasicJava/LocalTimeDemo_Intro/LocalTimeDemo/.project new file mode 100644 index 000000000..7b8fa740f --- /dev/null +++ b/BasicJava/LocalTimeDemo_Intro/LocalTimeDemo/.project @@ -0,0 +1,17 @@ + + + LocalTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalTimeDemo_Intro/LocalTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalTimeDemo_Intro/LocalTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalTimeDemo_Intro/LocalTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalTimeDemo_Intro/LocalTimeDemo/bin/LocalTimeDemo.class b/BasicJava/LocalTimeDemo_Intro/LocalTimeDemo/bin/LocalTimeDemo.class new file mode 100644 index 000000000..ee2a29919 Binary files /dev/null and b/BasicJava/LocalTimeDemo_Intro/LocalTimeDemo/bin/LocalTimeDemo.class differ diff --git a/BasicJava/LocalTimeDemo_Intro/LocalTimeDemo/src/LocalTimeDemo.java b/BasicJava/LocalTimeDemo_Intro/LocalTimeDemo/src/LocalTimeDemo.java new file mode 100644 index 000000000..685b4532c --- /dev/null +++ b/BasicJava/LocalTimeDemo_Intro/LocalTimeDemo/src/LocalTimeDemo.java @@ -0,0 +1,20 @@ +import java.time.LocalTime; + +public class LocalTimeDemo +{ + + public static void main(String[] args) + { + /* + * Returns:the current time using the system clock and default + * time-zone, not null + */ + LocalTime time = LocalTime.now(); + System.out.println(time); + System.out.println("Hour = "+time.getHour()); + System.out.println("Min = "+time.getMinute()); + System.out.println("Seonds = "+time.getSecond()); + System.out.println("Nano = "+time.getNano()); + } + +} diff --git a/BasicJava/LocalTimeDemo_Intro/Output.txt b/BasicJava/LocalTimeDemo_Intro/Output.txt new file mode 100644 index 000000000..6c9d30747 --- /dev/null +++ b/BasicJava/LocalTimeDemo_Intro/Output.txt @@ -0,0 +1,5 @@ +09:42:52.761 +Hour = 9 +Min = 42 +Seonds = 52 +Nano = 761000000 diff --git a/BasicJava/LocalTimeDemo_atDate/LocalTimeDemo/.classpath b/BasicJava/LocalTimeDemo_atDate/LocalTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalTimeDemo_atDate/LocalTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalTimeDemo_atDate/LocalTimeDemo/.project b/BasicJava/LocalTimeDemo_atDate/LocalTimeDemo/.project new file mode 100644 index 000000000..7b8fa740f --- /dev/null +++ b/BasicJava/LocalTimeDemo_atDate/LocalTimeDemo/.project @@ -0,0 +1,17 @@ + + + LocalTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalTimeDemo_atDate/LocalTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalTimeDemo_atDate/LocalTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalTimeDemo_atDate/LocalTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalTimeDemo_atDate/LocalTimeDemo/bin/LocalTimeDemo.class b/BasicJava/LocalTimeDemo_atDate/LocalTimeDemo/bin/LocalTimeDemo.class new file mode 100644 index 000000000..e26cc01ea Binary files /dev/null and b/BasicJava/LocalTimeDemo_atDate/LocalTimeDemo/bin/LocalTimeDemo.class differ diff --git a/BasicJava/LocalTimeDemo_atDate/LocalTimeDemo/src/LocalTimeDemo.java b/BasicJava/LocalTimeDemo_atDate/LocalTimeDemo/src/LocalTimeDemo.java new file mode 100644 index 000000000..aef0badfb --- /dev/null +++ b/BasicJava/LocalTimeDemo_atDate/LocalTimeDemo/src/LocalTimeDemo.java @@ -0,0 +1,31 @@ +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; + +public class LocalTimeDemo +{ + + public static void main(String[] args) + { + LocalDate localDate = LocalDate.now(); + System.out.println(localDate); + + LocalTime localTime = LocalTime.parse("12:30:30"); + System.out.println(localTime); + + /* + * Parameters: + * + * date - the date to combine with, not null + * + * Returns: + * + * the local date-time formed from this time and the specified + * date, not null + */ + + LocalDateTime localDatetime = localTime.atDate(localDate); + System.out.println(localDatetime); + } + +} diff --git a/BasicJava/LocalTimeDemo_atDate/Output.txt b/BasicJava/LocalTimeDemo_atDate/Output.txt new file mode 100644 index 000000000..08a6dd3f0 --- /dev/null +++ b/BasicJava/LocalTimeDemo_atDate/Output.txt @@ -0,0 +1,3 @@ +2018-01-09 +12:30:30 +2018-01-09T12:30:30 diff --git a/BasicJava/LocalTimeDemo_compareTo_equals/LocalTimeDemo/.classpath b/BasicJava/LocalTimeDemo_compareTo_equals/LocalTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalTimeDemo_compareTo_equals/LocalTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalTimeDemo_compareTo_equals/LocalTimeDemo/.project b/BasicJava/LocalTimeDemo_compareTo_equals/LocalTimeDemo/.project new file mode 100644 index 000000000..7b8fa740f --- /dev/null +++ b/BasicJava/LocalTimeDemo_compareTo_equals/LocalTimeDemo/.project @@ -0,0 +1,17 @@ + + + LocalTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalTimeDemo_compareTo_equals/LocalTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalTimeDemo_compareTo_equals/LocalTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalTimeDemo_compareTo_equals/LocalTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalTimeDemo_compareTo_equals/LocalTimeDemo/bin/LocalTimeDemo1.class b/BasicJava/LocalTimeDemo_compareTo_equals/LocalTimeDemo/bin/LocalTimeDemo1.class new file mode 100644 index 000000000..5eeed2bfb Binary files /dev/null and b/BasicJava/LocalTimeDemo_compareTo_equals/LocalTimeDemo/bin/LocalTimeDemo1.class differ diff --git a/BasicJava/LocalTimeDemo_compareTo_equals/LocalTimeDemo/bin/LocalTimeDemo2.class b/BasicJava/LocalTimeDemo_compareTo_equals/LocalTimeDemo/bin/LocalTimeDemo2.class new file mode 100644 index 000000000..aa99efd6c Binary files /dev/null and b/BasicJava/LocalTimeDemo_compareTo_equals/LocalTimeDemo/bin/LocalTimeDemo2.class differ diff --git a/BasicJava/LocalTimeDemo_compareTo_equals/LocalTimeDemo/src/LocalTimeDemo1.java b/BasicJava/LocalTimeDemo_compareTo_equals/LocalTimeDemo/src/LocalTimeDemo1.java new file mode 100644 index 000000000..b303d383e --- /dev/null +++ b/BasicJava/LocalTimeDemo_compareTo_equals/LocalTimeDemo/src/LocalTimeDemo1.java @@ -0,0 +1,28 @@ +import java.time.LocalTime; + +public class LocalTimeDemo1 +{ + + public static void main(String[] args) + { + LocalTime time1 = LocalTime.parse("05:30:30"); + System.out.println(time1); + + LocalTime time2 = LocalTime.parse("06:35:30"); + System.out.println(time2); + + /* + * Parameters: + * + * other - the other time to compare to, not null + * + * Returns:the comparator value, negative if less, positive if + * greater + */ + + int value = time1.compareTo(time2); + + System.out.println(value); + } + +} diff --git a/BasicJava/LocalTimeDemo_compareTo_equals/LocalTimeDemo/src/LocalTimeDemo2.java b/BasicJava/LocalTimeDemo_compareTo_equals/LocalTimeDemo/src/LocalTimeDemo2.java new file mode 100644 index 000000000..eaf27bbba --- /dev/null +++ b/BasicJava/LocalTimeDemo_compareTo_equals/LocalTimeDemo/src/LocalTimeDemo2.java @@ -0,0 +1,27 @@ +import java.time.LocalTime; + +public class LocalTimeDemo2 +{ + + public static void main(String[] args) + { + LocalTime time1 = LocalTime.parse("05:30:30"); + System.out.println(time1); + + LocalTime time2 = LocalTime.parse("05:30:30"); + System.out.println(time2); + + /* + * Parameters: + * + * obj - the object to check, null returns false + * + * Returns:true if this is equal to the other time + */ + + boolean value = time1.equals(time2); + + System.out.println(value); + } + +} diff --git a/BasicJava/LocalTimeDemo_compareTo_equals/LocalTimeDemo1_Output.txt b/BasicJava/LocalTimeDemo_compareTo_equals/LocalTimeDemo1_Output.txt new file mode 100644 index 000000000..fc3e2ecc3 --- /dev/null +++ b/BasicJava/LocalTimeDemo_compareTo_equals/LocalTimeDemo1_Output.txt @@ -0,0 +1,3 @@ +05:30:30 +06:35:30 +-1 diff --git a/BasicJava/LocalTimeDemo_compareTo_equals/LocalTimeDemo2_Output.txt b/BasicJava/LocalTimeDemo_compareTo_equals/LocalTimeDemo2_Output.txt new file mode 100644 index 000000000..e6934a99a --- /dev/null +++ b/BasicJava/LocalTimeDemo_compareTo_equals/LocalTimeDemo2_Output.txt @@ -0,0 +1,3 @@ +05:30:30 +05:30:30 +true diff --git a/BasicJava/LocalTimeDemo_minus_plus/LocalTimeDemo/.classpath b/BasicJava/LocalTimeDemo_minus_plus/LocalTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalTimeDemo_minus_plus/LocalTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalTimeDemo_minus_plus/LocalTimeDemo/.project b/BasicJava/LocalTimeDemo_minus_plus/LocalTimeDemo/.project new file mode 100644 index 000000000..7b8fa740f --- /dev/null +++ b/BasicJava/LocalTimeDemo_minus_plus/LocalTimeDemo/.project @@ -0,0 +1,17 @@ + + + LocalTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalTimeDemo_minus_plus/LocalTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalTimeDemo_minus_plus/LocalTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalTimeDemo_minus_plus/LocalTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalTimeDemo_minus_plus/LocalTimeDemo/bin/LocalTimeDemo1.class b/BasicJava/LocalTimeDemo_minus_plus/LocalTimeDemo/bin/LocalTimeDemo1.class new file mode 100644 index 000000000..3cc9ff3b1 Binary files /dev/null and b/BasicJava/LocalTimeDemo_minus_plus/LocalTimeDemo/bin/LocalTimeDemo1.class differ diff --git a/BasicJava/LocalTimeDemo_minus_plus/LocalTimeDemo/bin/LocalTimeDemo2.class b/BasicJava/LocalTimeDemo_minus_plus/LocalTimeDemo/bin/LocalTimeDemo2.class new file mode 100644 index 000000000..073348ed4 Binary files /dev/null and b/BasicJava/LocalTimeDemo_minus_plus/LocalTimeDemo/bin/LocalTimeDemo2.class differ diff --git a/BasicJava/LocalTimeDemo_minus_plus/LocalTimeDemo/src/LocalTimeDemo1.java b/BasicJava/LocalTimeDemo_minus_plus/LocalTimeDemo/src/LocalTimeDemo1.java new file mode 100644 index 000000000..a8d05b69e --- /dev/null +++ b/BasicJava/LocalTimeDemo_minus_plus/LocalTimeDemo/src/LocalTimeDemo1.java @@ -0,0 +1,52 @@ +import java.time.LocalTime; + +public class LocalTimeDemo1 +{ + + public static void main(String[] args) + { + LocalTime time1 = LocalTime.now(); + System.out.println("time1 = " + time1); + /* + * Parameters: + * + * hoursToSubtract - the hours to subtract, may be negative + * + * Returns: + * + * a LocalTime based on this time with the hours subtracted, + * not null + */ + LocalTime time2 = time1.minusHours(2); + System.out.println("Hours Changed = " + time2); + + /* + * Parameters: + * + * minutesToSubtract - the minutes to subtract, may be + * negative + * + * Returns: + * + * a LocalTime based on this time with the minutes subtracted, + * not null + */ + LocalTime time3 = time1.minusMinutes(30); + System.out.println("Min Changed = " + time3); + + /* + * Parameters: + * + * secondsToSubtract - the seconds to subtract, may be + * negative + * + * Returns: + * + * a LocalTime based on this time with the seconds subtracted, + * not null + */ + LocalTime time4 = time1.minusSeconds(10); + System.out.println("Sec Changed = " + time4); + } + +} diff --git a/BasicJava/LocalTimeDemo_minus_plus/LocalTimeDemo/src/LocalTimeDemo2.java b/BasicJava/LocalTimeDemo_minus_plus/LocalTimeDemo/src/LocalTimeDemo2.java new file mode 100644 index 000000000..fa4eb1315 --- /dev/null +++ b/BasicJava/LocalTimeDemo_minus_plus/LocalTimeDemo/src/LocalTimeDemo2.java @@ -0,0 +1,51 @@ +import java.time.LocalTime; + +public class LocalTimeDemo2 +{ + + public static void main(String[] args) + { + LocalTime time1 = LocalTime.now(); + System.out.println("time1 = " + time1); + + /* + * Parameters: + * + * hoursToAdd - the hours to add, may be negative + * + * Returns: + * + * a LocalTime based on this time with the hours added, not + * null + */ + LocalTime time2 = time1.plusHours(2); + System.out.println("Hours Changed = " + time2); + + /* + * Parameters: + * + * minutesToAdd - the minutes to add, may be negative + * + * Returns: + * + * a LocalTime based on this time with the minutes added, not + * null + */ + LocalTime time3 = time1.plusMinutes(30); + System.out.println("Min Changed = " + time3); + + /* + * Parameters: + * + * secondstoAdd - the seconds to add, may be negative + * + * Returns: + * + * a LocalTime based on this time with the seconds added, not + * null + */ + LocalTime time4 = time1.plusSeconds(10); + System.out.println("Sec Changed = " + time4); + } + +} diff --git a/BasicJava/LocalTimeDemo_minus_plus/LocalTimeDemo1_Output.txt b/BasicJava/LocalTimeDemo_minus_plus/LocalTimeDemo1_Output.txt new file mode 100644 index 000000000..0a6355d36 --- /dev/null +++ b/BasicJava/LocalTimeDemo_minus_plus/LocalTimeDemo1_Output.txt @@ -0,0 +1,4 @@ +time1 = 10:20:19.209 +Hours Changed = 08:20:19.209 +Min Changed = 09:50:19.209 +Sec Changed = 10:20:09.209 diff --git a/BasicJava/LocalTimeDemo_minus_plus/LocalTimeDemo2_Output.txt b/BasicJava/LocalTimeDemo_minus_plus/LocalTimeDemo2_Output.txt new file mode 100644 index 000000000..45c0609c6 --- /dev/null +++ b/BasicJava/LocalTimeDemo_minus_plus/LocalTimeDemo2_Output.txt @@ -0,0 +1,4 @@ +time1 = 10:20:27.107 +Hours Changed = 12:20:27.107 +Min Changed = 10:50:27.107 +Sec Changed = 10:20:37.107 diff --git a/BasicJava/LocalTimeDemo_now_methods/LocalTimeDemo/.classpath b/BasicJava/LocalTimeDemo_now_methods/LocalTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalTimeDemo_now_methods/LocalTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalTimeDemo_now_methods/LocalTimeDemo/.project b/BasicJava/LocalTimeDemo_now_methods/LocalTimeDemo/.project new file mode 100644 index 000000000..7b8fa740f --- /dev/null +++ b/BasicJava/LocalTimeDemo_now_methods/LocalTimeDemo/.project @@ -0,0 +1,17 @@ + + + LocalTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalTimeDemo_now_methods/LocalTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalTimeDemo_now_methods/LocalTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalTimeDemo_now_methods/LocalTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalTimeDemo_now_methods/LocalTimeDemo/bin/LocalTimeDemo1.class b/BasicJava/LocalTimeDemo_now_methods/LocalTimeDemo/bin/LocalTimeDemo1.class new file mode 100644 index 000000000..63ab53825 Binary files /dev/null and b/BasicJava/LocalTimeDemo_now_methods/LocalTimeDemo/bin/LocalTimeDemo1.class differ diff --git a/BasicJava/LocalTimeDemo_now_methods/LocalTimeDemo/bin/LocalTimeDemo2.class b/BasicJava/LocalTimeDemo_now_methods/LocalTimeDemo/bin/LocalTimeDemo2.class new file mode 100644 index 000000000..25b81ccf4 Binary files /dev/null and b/BasicJava/LocalTimeDemo_now_methods/LocalTimeDemo/bin/LocalTimeDemo2.class differ diff --git a/BasicJava/LocalTimeDemo_now_methods/LocalTimeDemo/src/LocalTimeDemo1.java b/BasicJava/LocalTimeDemo_now_methods/LocalTimeDemo/src/LocalTimeDemo1.java new file mode 100644 index 000000000..fadd136c9 --- /dev/null +++ b/BasicJava/LocalTimeDemo_now_methods/LocalTimeDemo/src/LocalTimeDemo1.java @@ -0,0 +1,24 @@ +import java.time.Clock; +import java.time.LocalTime; + +public class LocalTimeDemo1 +{ + + public static void main(String[] args) + { + Clock clock = Clock.systemUTC(); + + /* + * Parameters: + * + * clock - the clock to use, not null + * + * Returns: + * + * the current time, not null + */ + LocalTime time = LocalTime.now(clock); + System.out.println(time); + } + +} diff --git a/BasicJava/LocalTimeDemo_now_methods/LocalTimeDemo/src/LocalTimeDemo2.java b/BasicJava/LocalTimeDemo_now_methods/LocalTimeDemo/src/LocalTimeDemo2.java new file mode 100644 index 000000000..bf2ddb611 --- /dev/null +++ b/BasicJava/LocalTimeDemo_now_methods/LocalTimeDemo/src/LocalTimeDemo2.java @@ -0,0 +1,25 @@ +import java.time.LocalTime; +import java.time.ZoneId; + +public class LocalTimeDemo2 +{ + + public static void main(String[] args) + { + ZoneId zoneId = ZoneId.systemDefault(); + System.out.println(zoneId); + + /* + * Parameters: + * + * zone - the zone ID to use, not null + * + * Returns: + * + * the current time using the system clock, not null + */ + LocalTime time = LocalTime.now(zoneId); + System.out.println(time); + } + +} diff --git a/BasicJava/LocalTimeDemo_now_methods/LocalTimeDemo1_Output.txt b/BasicJava/LocalTimeDemo_now_methods/LocalTimeDemo1_Output.txt new file mode 100644 index 000000000..ba900a1ab --- /dev/null +++ b/BasicJava/LocalTimeDemo_now_methods/LocalTimeDemo1_Output.txt @@ -0,0 +1 @@ +04:59:41.320 diff --git a/BasicJava/LocalTimeDemo_now_methods/LocalTimeDemo2_Output.txt b/BasicJava/LocalTimeDemo_now_methods/LocalTimeDemo2_Output.txt new file mode 100644 index 000000000..c58a4dea4 --- /dev/null +++ b/BasicJava/LocalTimeDemo_now_methods/LocalTimeDemo2_Output.txt @@ -0,0 +1,2 @@ +Asia/Calcutta +10:29:51.536 diff --git a/BasicJava/LocalTimeDemo_now_zoneId/LocalTimeDemo/.classpath b/BasicJava/LocalTimeDemo_now_zoneId/LocalTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalTimeDemo_now_zoneId/LocalTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalTimeDemo_now_zoneId/LocalTimeDemo/.project b/BasicJava/LocalTimeDemo_now_zoneId/LocalTimeDemo/.project new file mode 100644 index 000000000..7b8fa740f --- /dev/null +++ b/BasicJava/LocalTimeDemo_now_zoneId/LocalTimeDemo/.project @@ -0,0 +1,17 @@ + + + LocalTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalTimeDemo_now_zoneId/LocalTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalTimeDemo_now_zoneId/LocalTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalTimeDemo_now_zoneId/LocalTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalTimeDemo_now_zoneId/LocalTimeDemo/bin/LocalTimeDemo.class b/BasicJava/LocalTimeDemo_now_zoneId/LocalTimeDemo/bin/LocalTimeDemo.class new file mode 100644 index 000000000..85d36420b Binary files /dev/null and b/BasicJava/LocalTimeDemo_now_zoneId/LocalTimeDemo/bin/LocalTimeDemo.class differ diff --git a/BasicJava/LocalTimeDemo_now_zoneId/LocalTimeDemo/src/LocalTimeDemo.java b/BasicJava/LocalTimeDemo_now_zoneId/LocalTimeDemo/src/LocalTimeDemo.java new file mode 100644 index 000000000..7f567d9c3 --- /dev/null +++ b/BasicJava/LocalTimeDemo_now_zoneId/LocalTimeDemo/src/LocalTimeDemo.java @@ -0,0 +1,35 @@ +import java.time.LocalTime; +import java.time.ZoneId; +import java.time.temporal.ChronoUnit; + +public class LocalTimeDemo +{ + + public static void main(String[] args) + { + ZoneId zoneId1 = ZoneId.of("Asia/Kolkata"); + + /* + * Parameters: + * + * zone - the zone ID to use, not null + * + * Returns: + * + * the current time using the system clock, not null + */ + LocalTime indiaTime = LocalTime.now(zoneId1); + System.out.println("indiaTime = " + indiaTime); + + ZoneId zoneId2 = ZoneId.of("Asia/Bangkok"); + LocalTime bangkokTime = LocalTime.now(zoneId2); + System.out.println("bangkokTime = " + bangkokTime); + + long hours = ChronoUnit.HOURS.between(indiaTime, bangkokTime); + System.out.println("\nHours between two Time Zone = " + hours); + + long minutes = ChronoUnit.MINUTES.between(indiaTime, bangkokTime); + System.out.println("Minutes between two time zone = " + minutes); + } + +} diff --git a/BasicJava/LocalTimeDemo_now_zoneId/Output.txt b/BasicJava/LocalTimeDemo_now_zoneId/Output.txt new file mode 100644 index 000000000..f1500eec4 --- /dev/null +++ b/BasicJava/LocalTimeDemo_now_zoneId/Output.txt @@ -0,0 +1,5 @@ +indiaTime = 09:22:58.690 +bangkokTime = 10:53:24.641 + +Hours between two Time Zone = 1 +Minutes between two time zone = 90 diff --git a/BasicJava/LocalTimeDemo_of/LocalTimeDemo/.classpath b/BasicJava/LocalTimeDemo_of/LocalTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/LocalTimeDemo_of/LocalTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/LocalTimeDemo_of/LocalTimeDemo/.project b/BasicJava/LocalTimeDemo_of/LocalTimeDemo/.project new file mode 100644 index 000000000..7b8fa740f --- /dev/null +++ b/BasicJava/LocalTimeDemo_of/LocalTimeDemo/.project @@ -0,0 +1,17 @@ + + + LocalTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/LocalTimeDemo_of/LocalTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/LocalTimeDemo_of/LocalTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/LocalTimeDemo_of/LocalTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/LocalTimeDemo_of/LocalTimeDemo/bin/LocalTimeDemo.class b/BasicJava/LocalTimeDemo_of/LocalTimeDemo/bin/LocalTimeDemo.class new file mode 100644 index 000000000..6efe6ee2c Binary files /dev/null and b/BasicJava/LocalTimeDemo_of/LocalTimeDemo/bin/LocalTimeDemo.class differ diff --git a/BasicJava/LocalTimeDemo_of/LocalTimeDemo/src/LocalTimeDemo.java b/BasicJava/LocalTimeDemo_of/LocalTimeDemo/src/LocalTimeDemo.java new file mode 100644 index 000000000..36a460f68 --- /dev/null +++ b/BasicJava/LocalTimeDemo_of/LocalTimeDemo/src/LocalTimeDemo.java @@ -0,0 +1,23 @@ +import java.time.LocalTime; + +public class LocalTimeDemo +{ + + public static void main(String[] args) + { + /* + * Parameters: + * + * hour - the hour-of-day to represent, from 0 to 23 + * + * minute - the minute-of-hour to represent, from 0 to 59 + * + * second - the second-of-minute to represent, from 0 to 59 + * + * Returns:the local time, not null + */ + LocalTime time = LocalTime.of(8, 53, 56); + System.out.println(time); + } + +} diff --git a/BasicJava/LocalTimeDemo_of/Output.txt b/BasicJava/LocalTimeDemo_of/Output.txt new file mode 100644 index 000000000..bc9dcb09c --- /dev/null +++ b/BasicJava/LocalTimeDemo_of/Output.txt @@ -0,0 +1 @@ +08:53:56 diff --git a/BasicJava/MonthDayDemo_Intro/MonthDayDemo/.classpath b/BasicJava/MonthDayDemo_Intro/MonthDayDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/MonthDayDemo_Intro/MonthDayDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/MonthDayDemo_Intro/MonthDayDemo/.project b/BasicJava/MonthDayDemo_Intro/MonthDayDemo/.project new file mode 100644 index 000000000..38ae1b32b --- /dev/null +++ b/BasicJava/MonthDayDemo_Intro/MonthDayDemo/.project @@ -0,0 +1,17 @@ + + + MonthDayDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/MonthDayDemo_Intro/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/MonthDayDemo_Intro/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/MonthDayDemo_Intro/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/MonthDayDemo_Intro/MonthDayDemo/bin/MonthDayDemo.class b/BasicJava/MonthDayDemo_Intro/MonthDayDemo/bin/MonthDayDemo.class new file mode 100644 index 000000000..e76feb008 Binary files /dev/null and b/BasicJava/MonthDayDemo_Intro/MonthDayDemo/bin/MonthDayDemo.class differ diff --git a/BasicJava/MonthDayDemo_Intro/MonthDayDemo/src/MonthDayDemo.java b/BasicJava/MonthDayDemo_Intro/MonthDayDemo/src/MonthDayDemo.java new file mode 100644 index 000000000..5d7896541 --- /dev/null +++ b/BasicJava/MonthDayDemo_Intro/MonthDayDemo/src/MonthDayDemo.java @@ -0,0 +1,32 @@ +import java.time.MonthDay; + +public class MonthDayDemo +{ + + public static void main(String[] args) + { + + /* + * Returns: + * + * the current month-day using the system clock and + * default time-zone, not null + */ + MonthDay currentMonthDay = MonthDay.now(); + System.out.println(currentMonthDay); + + /* + * Parameters: + * + * text - the text to parse such as "--12-03", not null + * + * Returns: + * + * the parsed month-day, not null + */ + + MonthDay monthDay = MonthDay.parse("--03-30"); + System.out.println(monthDay); + } + +} diff --git a/BasicJava/MonthDayDemo_Intro/Output.txt b/BasicJava/MonthDayDemo_Intro/Output.txt new file mode 100644 index 000000000..85ce53f71 --- /dev/null +++ b/BasicJava/MonthDayDemo_Intro/Output.txt @@ -0,0 +1,2 @@ +--01-18 +--03-30 diff --git a/BasicJava/MonthDayDemo_atYear/MonthDayDemo/.classpath b/BasicJava/MonthDayDemo_atYear/MonthDayDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/MonthDayDemo_atYear/MonthDayDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/MonthDayDemo_atYear/MonthDayDemo/.project b/BasicJava/MonthDayDemo_atYear/MonthDayDemo/.project new file mode 100644 index 000000000..38ae1b32b --- /dev/null +++ b/BasicJava/MonthDayDemo_atYear/MonthDayDemo/.project @@ -0,0 +1,17 @@ + + + MonthDayDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/MonthDayDemo_atYear/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/MonthDayDemo_atYear/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/MonthDayDemo_atYear/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/MonthDayDemo_atYear/MonthDayDemo/bin/MonthDayDemo.class b/BasicJava/MonthDayDemo_atYear/MonthDayDemo/bin/MonthDayDemo.class new file mode 100644 index 000000000..4683dccbe Binary files /dev/null and b/BasicJava/MonthDayDemo_atYear/MonthDayDemo/bin/MonthDayDemo.class differ diff --git a/BasicJava/MonthDayDemo_atYear/MonthDayDemo/src/MonthDayDemo.java b/BasicJava/MonthDayDemo_atYear/MonthDayDemo/src/MonthDayDemo.java new file mode 100644 index 000000000..533a768e1 --- /dev/null +++ b/BasicJava/MonthDayDemo_atYear/MonthDayDemo/src/MonthDayDemo.java @@ -0,0 +1,25 @@ +import java.time.LocalDate; +import java.time.MonthDay; + +public class MonthDayDemo +{ + + public static void main(String[] args) + { + MonthDay monthDay = MonthDay.now(); + System.out.println(monthDay); + + /* + * Parameters: + * + * year - the year to use, from MIN_YEAR to MAX_YEAR + * + * Returns: + * + * the local date formed from this month-day and the + * specified year, not null + */ + LocalDate localDate = monthDay.atYear(2013); + System.out.println(localDate); + } +} diff --git a/BasicJava/MonthDayDemo_atYear/Output.txt b/BasicJava/MonthDayDemo_atYear/Output.txt new file mode 100644 index 000000000..1fccc06db --- /dev/null +++ b/BasicJava/MonthDayDemo_atYear/Output.txt @@ -0,0 +1,2 @@ +--01-18 +2013-01-18 diff --git a/BasicJava/MonthDayDemo_format/MonthDayDemo/.classpath b/BasicJava/MonthDayDemo_format/MonthDayDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/MonthDayDemo_format/MonthDayDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/MonthDayDemo_format/MonthDayDemo/.project b/BasicJava/MonthDayDemo_format/MonthDayDemo/.project new file mode 100644 index 000000000..38ae1b32b --- /dev/null +++ b/BasicJava/MonthDayDemo_format/MonthDayDemo/.project @@ -0,0 +1,17 @@ + + + MonthDayDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/MonthDayDemo_format/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/MonthDayDemo_format/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/MonthDayDemo_format/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/MonthDayDemo_format/MonthDayDemo/bin/MonthDayDemo.class b/BasicJava/MonthDayDemo_format/MonthDayDemo/bin/MonthDayDemo.class new file mode 100644 index 000000000..ce80bea58 Binary files /dev/null and b/BasicJava/MonthDayDemo_format/MonthDayDemo/bin/MonthDayDemo.class differ diff --git a/BasicJava/MonthDayDemo_format/MonthDayDemo/src/MonthDayDemo.java b/BasicJava/MonthDayDemo_format/MonthDayDemo/src/MonthDayDemo.java new file mode 100644 index 000000000..0333bee8e --- /dev/null +++ b/BasicJava/MonthDayDemo_format/MonthDayDemo/src/MonthDayDemo.java @@ -0,0 +1,36 @@ +import java.time.MonthDay; +import java.time.format.DateTimeFormatter; + +public class MonthDayDemo +{ + + public static void main(String[] args) + { + MonthDay monthDay = MonthDay.parse("--12-30"); + System.out.println(monthDay); + + /* + * Parameters: + * + * pattern - the pattern to use, not null + * + * Returns: + * + * the formatter based on the pattern, not null + * + */ + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("--MM"); + + /* + * Parameters: + * + * formatter - the formatter to use, not null + * + * Returns:the formatted month-day string, not null + */ + + String formatedValue = monthDay.format(formatter); + System.out.println(formatedValue); + } + +} diff --git a/BasicJava/MonthDayDemo_format/Output.txt b/BasicJava/MonthDayDemo_format/Output.txt new file mode 100644 index 000000000..8f9937a74 --- /dev/null +++ b/BasicJava/MonthDayDemo_format/Output.txt @@ -0,0 +1,2 @@ +--12-30 +--12 diff --git a/BasicJava/MonthDayDemo_from/MonthDayDemo/.classpath b/BasicJava/MonthDayDemo_from/MonthDayDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/MonthDayDemo_from/MonthDayDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/MonthDayDemo_from/MonthDayDemo/.project b/BasicJava/MonthDayDemo_from/MonthDayDemo/.project new file mode 100644 index 000000000..38ae1b32b --- /dev/null +++ b/BasicJava/MonthDayDemo_from/MonthDayDemo/.project @@ -0,0 +1,17 @@ + + + MonthDayDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/MonthDayDemo_from/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/MonthDayDemo_from/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/MonthDayDemo_from/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/MonthDayDemo_from/MonthDayDemo/bin/MonthDayDemo.class b/BasicJava/MonthDayDemo_from/MonthDayDemo/bin/MonthDayDemo.class new file mode 100644 index 000000000..360042fc2 Binary files /dev/null and b/BasicJava/MonthDayDemo_from/MonthDayDemo/bin/MonthDayDemo.class differ diff --git a/BasicJava/MonthDayDemo_from/MonthDayDemo/src/MonthDayDemo.java b/BasicJava/MonthDayDemo_from/MonthDayDemo/src/MonthDayDemo.java new file mode 100644 index 000000000..8ac141bde --- /dev/null +++ b/BasicJava/MonthDayDemo_from/MonthDayDemo/src/MonthDayDemo.java @@ -0,0 +1,23 @@ +import java.time.MonthDay; +import java.time.ZonedDateTime; + +public class MonthDayDemo +{ + + public static void main(String[] args) + { + + ZonedDateTime zonedDateTime = ZonedDateTime.now(); + System.out.println(zonedDateTime); + /* + * Parameters: + * + * temporal - the temporal object to convert, not null + * + * Returns:the month-day, not null + */ + MonthDay monthDay = MonthDay.from(zonedDateTime); + System.out.println(monthDay); + } + +} diff --git a/BasicJava/MonthDayDemo_from/Output.txt b/BasicJava/MonthDayDemo_from/Output.txt new file mode 100644 index 000000000..578b830ef --- /dev/null +++ b/BasicJava/MonthDayDemo_from/Output.txt @@ -0,0 +1,2 @@ +2018-01-19T09:18:45.949+05:30[Asia/Calcutta] +--01-19 diff --git a/BasicJava/MonthDayDemo_get_field/MonthDayDemo/.classpath b/BasicJava/MonthDayDemo_get_field/MonthDayDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/MonthDayDemo_get_field/MonthDayDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/MonthDayDemo_get_field/MonthDayDemo/.project b/BasicJava/MonthDayDemo_get_field/MonthDayDemo/.project new file mode 100644 index 000000000..38ae1b32b --- /dev/null +++ b/BasicJava/MonthDayDemo_get_field/MonthDayDemo/.project @@ -0,0 +1,17 @@ + + + MonthDayDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/MonthDayDemo_get_field/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/MonthDayDemo_get_field/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/MonthDayDemo_get_field/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/MonthDayDemo_get_field/MonthDayDemo/bin/MonthDayDemo.class b/BasicJava/MonthDayDemo_get_field/MonthDayDemo/bin/MonthDayDemo.class new file mode 100644 index 000000000..ce17772b6 Binary files /dev/null and b/BasicJava/MonthDayDemo_get_field/MonthDayDemo/bin/MonthDayDemo.class differ diff --git a/BasicJava/MonthDayDemo_get_field/MonthDayDemo/src/MonthDayDemo.java b/BasicJava/MonthDayDemo_get_field/MonthDayDemo/src/MonthDayDemo.java new file mode 100644 index 000000000..8244723de --- /dev/null +++ b/BasicJava/MonthDayDemo_get_field/MonthDayDemo/src/MonthDayDemo.java @@ -0,0 +1,30 @@ +import java.time.MonthDay; +import java.time.temporal.ChronoField; + +public class MonthDayDemo +{ + + public static void main(String[] args) + { + MonthDay monthDay = MonthDay.now(); + System.out.println(monthDay); + + /* + * Parameters: + * + * field - the field to get, not null + * + * Returns: + * + * the value for the field + */ + + int monthOfYear = monthDay.get(ChronoField.MONTH_OF_YEAR); + System.out.println("monthOfYear = " + monthOfYear); + + int dayOfMonth = monthDay.get(ChronoField.DAY_OF_MONTH); + System.out.println("dayOfMonth = " + dayOfMonth); + + } + +} diff --git a/BasicJava/MonthDayDemo_get_field/Output.txt b/BasicJava/MonthDayDemo_get_field/Output.txt new file mode 100644 index 000000000..67a287437 --- /dev/null +++ b/BasicJava/MonthDayDemo_get_field/Output.txt @@ -0,0 +1,3 @@ +--01-19 +monthOfYear = 1 +dayOfMonth = 19 diff --git a/BasicJava/MonthDayDemo_getmonth_day/MonthDayDemo/.classpath b/BasicJava/MonthDayDemo_getmonth_day/MonthDayDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/MonthDayDemo_getmonth_day/MonthDayDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/MonthDayDemo_getmonth_day/MonthDayDemo/.project b/BasicJava/MonthDayDemo_getmonth_day/MonthDayDemo/.project new file mode 100644 index 000000000..38ae1b32b --- /dev/null +++ b/BasicJava/MonthDayDemo_getmonth_day/MonthDayDemo/.project @@ -0,0 +1,17 @@ + + + MonthDayDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/MonthDayDemo_getmonth_day/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/MonthDayDemo_getmonth_day/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/MonthDayDemo_getmonth_day/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/MonthDayDemo_getmonth_day/MonthDayDemo/bin/MonthDayDemo.class b/BasicJava/MonthDayDemo_getmonth_day/MonthDayDemo/bin/MonthDayDemo.class new file mode 100644 index 000000000..a619e6e57 Binary files /dev/null and b/BasicJava/MonthDayDemo_getmonth_day/MonthDayDemo/bin/MonthDayDemo.class differ diff --git a/BasicJava/MonthDayDemo_getmonth_day/MonthDayDemo/src/MonthDayDemo.java b/BasicJava/MonthDayDemo_getmonth_day/MonthDayDemo/src/MonthDayDemo.java new file mode 100644 index 000000000..c55e40b90 --- /dev/null +++ b/BasicJava/MonthDayDemo_getmonth_day/MonthDayDemo/src/MonthDayDemo.java @@ -0,0 +1,37 @@ +import java.time.Month; +import java.time.MonthDay; + +public class MonthDayDemo +{ + + public static void main(String[] args) + { + /* + * Returns:the current month-day using the system clock and + * default time-zone, not null + */ + MonthDay monthDay = MonthDay.now(); + System.out.println("monthDay = " + monthDay); + + /* + * Returns:the day-of-month, from 1 to 31 + */ + int dayOfTheMonth = monthDay.getDayOfMonth(); + System.out.println("dayOfTheMonth = " + dayOfTheMonth); + + /* + * Returns:the month-of-year, from 1 to 12 + */ + int monthValue = monthDay.getMonthValue(); + System.out.println("monthValue = " + monthValue); + + /* + * Returns:the month-of-year, not null + */ + Month month = monthDay.getMonth(); + System.out.println("month = " + month); + System.out.println("month value = " + month.getValue()); + + } + +} diff --git a/BasicJava/MonthDayDemo_getmonth_day/Output.txt b/BasicJava/MonthDayDemo_getmonth_day/Output.txt new file mode 100644 index 000000000..08bf106ef --- /dev/null +++ b/BasicJava/MonthDayDemo_getmonth_day/Output.txt @@ -0,0 +1,5 @@ +monthDay = --01-18 +dayOfTheMonth = 18 +monthValue = 1 +month = JANUARY +month value = 1 diff --git a/BasicJava/MonthDayDemo_isAfter_before/MonthDayDemo/.classpath b/BasicJava/MonthDayDemo_isAfter_before/MonthDayDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/MonthDayDemo_isAfter_before/MonthDayDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/MonthDayDemo_isAfter_before/MonthDayDemo/.project b/BasicJava/MonthDayDemo_isAfter_before/MonthDayDemo/.project new file mode 100644 index 000000000..38ae1b32b --- /dev/null +++ b/BasicJava/MonthDayDemo_isAfter_before/MonthDayDemo/.project @@ -0,0 +1,17 @@ + + + MonthDayDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/MonthDayDemo_isAfter_before/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/MonthDayDemo_isAfter_before/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/MonthDayDemo_isAfter_before/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/MonthDayDemo_isAfter_before/MonthDayDemo/bin/MonthDayDemo.class b/BasicJava/MonthDayDemo_isAfter_before/MonthDayDemo/bin/MonthDayDemo.class new file mode 100644 index 000000000..3e41d8ae7 Binary files /dev/null and b/BasicJava/MonthDayDemo_isAfter_before/MonthDayDemo/bin/MonthDayDemo.class differ diff --git a/BasicJava/MonthDayDemo_isAfter_before/MonthDayDemo/src/MonthDayDemo.java b/BasicJava/MonthDayDemo_isAfter_before/MonthDayDemo/src/MonthDayDemo.java new file mode 100644 index 000000000..ece7f180f --- /dev/null +++ b/BasicJava/MonthDayDemo_isAfter_before/MonthDayDemo/src/MonthDayDemo.java @@ -0,0 +1,45 @@ +import java.time.MonthDay; + +public class MonthDayDemo +{ + + public static void main(String[] args) + { + MonthDay monthDay1 = MonthDay.parse("--12-30"); + MonthDay monthDay2 = MonthDay.parse("--02-20"); + + /* + * Parameters: + * + * other - the other month-day to compare to, not null + * + * Returns: + * + * true if this is after the specified month-day + */ + + System.out.println(monthDay1.isAfter(monthDay2)); + /* + * Parameters: + * + * other - the other month-day to compare to, not null + * + * Returns: + * + * true if this point is before the specified month-day + */ + System.out.println(monthDay1.isBefore(monthDay2)); + /* + * Parameters: + * + * obj - the object to check, null returns false + * + * Returns: + * + * true if this is equal to the other month-day + * + */ + System.out.println(monthDay1.equals(monthDay2)); + } + +} diff --git a/BasicJava/MonthDayDemo_isAfter_before/Output.txt b/BasicJava/MonthDayDemo_isAfter_before/Output.txt new file mode 100644 index 000000000..36bc6136b --- /dev/null +++ b/BasicJava/MonthDayDemo_isAfter_before/Output.txt @@ -0,0 +1,3 @@ +true +false +false diff --git a/BasicJava/MonthDayDemo_isValidYear/MonthDayDemo/.classpath b/BasicJava/MonthDayDemo_isValidYear/MonthDayDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/MonthDayDemo_isValidYear/MonthDayDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/MonthDayDemo_isValidYear/MonthDayDemo/.project b/BasicJava/MonthDayDemo_isValidYear/MonthDayDemo/.project new file mode 100644 index 000000000..38ae1b32b --- /dev/null +++ b/BasicJava/MonthDayDemo_isValidYear/MonthDayDemo/.project @@ -0,0 +1,17 @@ + + + MonthDayDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/MonthDayDemo_isValidYear/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/MonthDayDemo_isValidYear/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/MonthDayDemo_isValidYear/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/MonthDayDemo_isValidYear/MonthDayDemo/bin/MonthDayDemo.class b/BasicJava/MonthDayDemo_isValidYear/MonthDayDemo/bin/MonthDayDemo.class new file mode 100644 index 000000000..1425c0f8f Binary files /dev/null and b/BasicJava/MonthDayDemo_isValidYear/MonthDayDemo/bin/MonthDayDemo.class differ diff --git a/BasicJava/MonthDayDemo_isValidYear/MonthDayDemo/src/MonthDayDemo.java b/BasicJava/MonthDayDemo_isValidYear/MonthDayDemo/src/MonthDayDemo.java new file mode 100644 index 000000000..81dae5eee --- /dev/null +++ b/BasicJava/MonthDayDemo_isValidYear/MonthDayDemo/src/MonthDayDemo.java @@ -0,0 +1,30 @@ +import java.time.MonthDay; + +public class MonthDayDemo +{ + + public static void main(String[] args) + { + MonthDay monthDay = MonthDay.parse("--02-29"); + System.out.println(monthDay); + + /* + * Parameters: + * + * year - the year to validate + * + * Returns: + * + * true if the year is valid for this month-day + */ + boolean isYearValid = monthDay.isValidYear(2000); + System.out.println( + "is --02-29 valid for the year 2000 ? = " + isYearValid); + + isYearValid = monthDay.isValidYear(2017); + System.out.println( + "is --02-29 valid for the year 2017 ? = " + isYearValid); + + } + +} diff --git a/BasicJava/MonthDayDemo_isValidYear/Output.txt b/BasicJava/MonthDayDemo_isValidYear/Output.txt new file mode 100644 index 000000000..330d20965 --- /dev/null +++ b/BasicJava/MonthDayDemo_isValidYear/Output.txt @@ -0,0 +1,3 @@ +--02-29 +is --02-29 valid for the year 2000 ? = true +is --02-29 valid for the year 2017 ? = false diff --git a/BasicJava/MonthDayDemo_now_clock_zoneid/MonthDayDemo/.classpath b/BasicJava/MonthDayDemo_now_clock_zoneid/MonthDayDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/MonthDayDemo_now_clock_zoneid/MonthDayDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/MonthDayDemo_now_clock_zoneid/MonthDayDemo/.project b/BasicJava/MonthDayDemo_now_clock_zoneid/MonthDayDemo/.project new file mode 100644 index 000000000..38ae1b32b --- /dev/null +++ b/BasicJava/MonthDayDemo_now_clock_zoneid/MonthDayDemo/.project @@ -0,0 +1,17 @@ + + + MonthDayDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/MonthDayDemo_now_clock_zoneid/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/MonthDayDemo_now_clock_zoneid/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/MonthDayDemo_now_clock_zoneid/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/MonthDayDemo_now_clock_zoneid/MonthDayDemo/bin/MonthDayDemo1.class b/BasicJava/MonthDayDemo_now_clock_zoneid/MonthDayDemo/bin/MonthDayDemo1.class new file mode 100644 index 000000000..e0fb6deff Binary files /dev/null and b/BasicJava/MonthDayDemo_now_clock_zoneid/MonthDayDemo/bin/MonthDayDemo1.class differ diff --git a/BasicJava/MonthDayDemo_now_clock_zoneid/MonthDayDemo/bin/MonthDayDemo2.class b/BasicJava/MonthDayDemo_now_clock_zoneid/MonthDayDemo/bin/MonthDayDemo2.class new file mode 100644 index 000000000..e7ccfb03a Binary files /dev/null and b/BasicJava/MonthDayDemo_now_clock_zoneid/MonthDayDemo/bin/MonthDayDemo2.class differ diff --git a/BasicJava/MonthDayDemo_now_clock_zoneid/MonthDayDemo/src/MonthDayDemo1.java b/BasicJava/MonthDayDemo_now_clock_zoneid/MonthDayDemo/src/MonthDayDemo1.java new file mode 100644 index 000000000..29125563e --- /dev/null +++ b/BasicJava/MonthDayDemo_now_clock_zoneid/MonthDayDemo/src/MonthDayDemo1.java @@ -0,0 +1,24 @@ +import java.time.Clock; +import java.time.MonthDay; + +public class MonthDayDemo1 +{ + public static void main(String[] args) + { + Clock clock = Clock.systemUTC(); + System.out.println(clock); + /* + * Parameters: + * + * clock - the clock to use, not null + * + * Returns: + * + * the current month-day, not null + */ + MonthDay monthDay = MonthDay.now(clock); + System.out.println(monthDay); + + } + +} diff --git a/BasicJava/MonthDayDemo_now_clock_zoneid/MonthDayDemo/src/MonthDayDemo2.java b/BasicJava/MonthDayDemo_now_clock_zoneid/MonthDayDemo/src/MonthDayDemo2.java new file mode 100644 index 000000000..3acb1fad9 --- /dev/null +++ b/BasicJava/MonthDayDemo_now_clock_zoneid/MonthDayDemo/src/MonthDayDemo2.java @@ -0,0 +1,25 @@ +import java.time.MonthDay; +import java.time.ZoneId; + +public class MonthDayDemo2 +{ + public static void main(String[] args) + { + + ZoneId zoneId = ZoneId.systemDefault(); + System.out.println(zoneId); + /* + * Parameters: + * + * zone - the zone ID to use, not null + * + * Returns: + * + * the current month-day using the system clock, not + * null + */ + MonthDay monthDay = MonthDay.now(zoneId); + System.out.println(monthDay); + } + +} diff --git a/BasicJava/MonthDayDemo_now_clock_zoneid/MonthDayDemo1_Output.txt b/BasicJava/MonthDayDemo_now_clock_zoneid/MonthDayDemo1_Output.txt new file mode 100644 index 000000000..40061c3b5 --- /dev/null +++ b/BasicJava/MonthDayDemo_now_clock_zoneid/MonthDayDemo1_Output.txt @@ -0,0 +1,2 @@ +SystemClock[Z] +--01-23 diff --git a/BasicJava/MonthDayDemo_now_clock_zoneid/MonthDayDemo2_Output.txt b/BasicJava/MonthDayDemo_now_clock_zoneid/MonthDayDemo2_Output.txt new file mode 100644 index 000000000..5fc6eb5f9 --- /dev/null +++ b/BasicJava/MonthDayDemo_now_clock_zoneid/MonthDayDemo2_Output.txt @@ -0,0 +1,2 @@ +Asia/Calcutta +--01-23 diff --git a/BasicJava/MonthDayDemo_of/MonthDayDemo/.classpath b/BasicJava/MonthDayDemo_of/MonthDayDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/MonthDayDemo_of/MonthDayDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/MonthDayDemo_of/MonthDayDemo/.project b/BasicJava/MonthDayDemo_of/MonthDayDemo/.project new file mode 100644 index 000000000..38ae1b32b --- /dev/null +++ b/BasicJava/MonthDayDemo_of/MonthDayDemo/.project @@ -0,0 +1,17 @@ + + + MonthDayDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/MonthDayDemo_of/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/MonthDayDemo_of/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/MonthDayDemo_of/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/MonthDayDemo_of/MonthDayDemo/bin/MonthDayDemo.class b/BasicJava/MonthDayDemo_of/MonthDayDemo/bin/MonthDayDemo.class new file mode 100644 index 000000000..75d681864 Binary files /dev/null and b/BasicJava/MonthDayDemo_of/MonthDayDemo/bin/MonthDayDemo.class differ diff --git a/BasicJava/MonthDayDemo_of/MonthDayDemo/src/MonthDayDemo.java b/BasicJava/MonthDayDemo_of/MonthDayDemo/src/MonthDayDemo.java new file mode 100644 index 000000000..4942b7f64 --- /dev/null +++ b/BasicJava/MonthDayDemo_of/MonthDayDemo/src/MonthDayDemo.java @@ -0,0 +1,36 @@ +import java.time.Month; +import java.time.MonthDay; + +public class MonthDayDemo +{ + + public static void main(String[] args) + { + + /* + * Parameters: + * + * month - the month-of-year to represent, from 1 (January) to + * 12 (December) + * + * dayOfMonth - the day-of-month to represent, from 1 to + * 31Returns:the month-day, not null + */ + MonthDay monthDay1 = MonthDay.of(9, 30); + System.out.println(monthDay1); + + /* + * + * Parameters: + * + * month - the month-of-year to represent, not null + * + * dayOfMonth - the day-of-month to represent, from 1 to 31 + * + * Returns:the month-day, not null + */ + MonthDay monthDay2 = MonthDay.of(Month.JULY, 30); + System.out.println(monthDay2); + } + +} diff --git a/BasicJava/MonthDayDemo_of/Output.txt b/BasicJava/MonthDayDemo_of/Output.txt new file mode 100644 index 000000000..7e3e377f6 --- /dev/null +++ b/BasicJava/MonthDayDemo_of/Output.txt @@ -0,0 +1,2 @@ +--09-30 +--07-30 diff --git a/BasicJava/MonthDayDemo_parse/MonthDayDemo/.classpath b/BasicJava/MonthDayDemo_parse/MonthDayDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/MonthDayDemo_parse/MonthDayDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/MonthDayDemo_parse/MonthDayDemo/.project b/BasicJava/MonthDayDemo_parse/MonthDayDemo/.project new file mode 100644 index 000000000..38ae1b32b --- /dev/null +++ b/BasicJava/MonthDayDemo_parse/MonthDayDemo/.project @@ -0,0 +1,17 @@ + + + MonthDayDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/MonthDayDemo_parse/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/MonthDayDemo_parse/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/MonthDayDemo_parse/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/MonthDayDemo_parse/MonthDayDemo/bin/MonthDayDemo.class b/BasicJava/MonthDayDemo_parse/MonthDayDemo/bin/MonthDayDemo.class new file mode 100644 index 000000000..b4acd3e60 Binary files /dev/null and b/BasicJava/MonthDayDemo_parse/MonthDayDemo/bin/MonthDayDemo.class differ diff --git a/BasicJava/MonthDayDemo_parse/MonthDayDemo/src/MonthDayDemo.java b/BasicJava/MonthDayDemo_parse/MonthDayDemo/src/MonthDayDemo.java new file mode 100644 index 000000000..68e7e7f46 --- /dev/null +++ b/BasicJava/MonthDayDemo_parse/MonthDayDemo/src/MonthDayDemo.java @@ -0,0 +1,30 @@ +import java.time.MonthDay; +import java.time.format.DateTimeFormatter; + +public class MonthDayDemo +{ + + public static void main(String[] args) + { + DateTimeFormatter dateTimeFormatter = DateTimeFormatter + .ofPattern("--MM-dd"); + String strDate = "--11-15"; + + /* + * Parameters: + * + * text - the text to parse, not null + * + * formatter - the formatter to use, not nullReturns:the + * parsed month-day, not null + * + * Returns: + * + * the parsed month-day, not null + * + */ + MonthDay monthDay = MonthDay.parse(strDate, dateTimeFormatter); + System.out.println(monthDay); + } + +} diff --git a/BasicJava/MonthDayDemo_parse/Output.txt b/BasicJava/MonthDayDemo_parse/Output.txt new file mode 100644 index 000000000..d450027a3 --- /dev/null +++ b/BasicJava/MonthDayDemo_parse/Output.txt @@ -0,0 +1 @@ +--11-15 diff --git a/BasicJava/MonthDayDemo_with/MonthDayDemo/.classpath b/BasicJava/MonthDayDemo_with/MonthDayDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/MonthDayDemo_with/MonthDayDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/MonthDayDemo_with/MonthDayDemo/.project b/BasicJava/MonthDayDemo_with/MonthDayDemo/.project new file mode 100644 index 000000000..38ae1b32b --- /dev/null +++ b/BasicJava/MonthDayDemo_with/MonthDayDemo/.project @@ -0,0 +1,17 @@ + + + MonthDayDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/MonthDayDemo_with/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/MonthDayDemo_with/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/MonthDayDemo_with/MonthDayDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/MonthDayDemo_with/MonthDayDemo/bin/MonthDayDemo.class b/BasicJava/MonthDayDemo_with/MonthDayDemo/bin/MonthDayDemo.class new file mode 100644 index 000000000..0cf4c9eeb Binary files /dev/null and b/BasicJava/MonthDayDemo_with/MonthDayDemo/bin/MonthDayDemo.class differ diff --git a/BasicJava/MonthDayDemo_with/MonthDayDemo/src/MonthDayDemo.java b/BasicJava/MonthDayDemo_with/MonthDayDemo/src/MonthDayDemo.java new file mode 100644 index 000000000..f8ff21763 --- /dev/null +++ b/BasicJava/MonthDayDemo_with/MonthDayDemo/src/MonthDayDemo.java @@ -0,0 +1,55 @@ +import java.time.Month; +import java.time.MonthDay; + +public class MonthDayDemo +{ + + public static void main(String[] args) + { + MonthDay monthDay = MonthDay.parse("--12-15"); + + System.out.println("Before month Change = " + monthDay); + + /* + * Parameters: + * + * month - the month-of-year to set in the returned month-day, + * not null + * + * Returns:a MonthDay based on this month-day with the + * requested month, not null + */ + monthDay = monthDay.with(Month.APRIL); + + System.out.println("After month Change1 = " + monthDay); + + /* + * Parameters: + * + * month - the month-of-year to set in the returned month-day, + * from 1 (January) to 12 (December) + * + * Returns: a MonthDay based on this month-day with the + * requested month, not null + * + */ + monthDay = monthDay.withMonth(8); + + System.out.println("After month Change2 = " + monthDay); + + /* + * Parameters: + * + * dayOfMonth - the day-of-month to set in the return + * month-day, from 1 to 31 + * + * Returns:a MonthDay based on this month-day with the + * requested day, not null + */ + + monthDay = monthDay.withDayOfMonth(30); + + System.out.println("After day Change = " + monthDay); + } + +} diff --git a/BasicJava/MonthDayDemo_with/Output.txt b/BasicJava/MonthDayDemo_with/Output.txt new file mode 100644 index 000000000..01462c59b --- /dev/null +++ b/BasicJava/MonthDayDemo_with/Output.txt @@ -0,0 +1,4 @@ +Before month Change = --12-15 +After month Change1 = --04-15 +After month Change2 = --08-15 +After day Change = --08-30 diff --git a/BasicJava/OffsetDateTimeDemo_atZoneSameInstant/OffsetDateTimeDemo/.classpath b/BasicJava/OffsetDateTimeDemo_atZoneSameInstant/OffsetDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_atZoneSameInstant/OffsetDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetDateTimeDemo_atZoneSameInstant/OffsetDateTimeDemo/.project b/BasicJava/OffsetDateTimeDemo_atZoneSameInstant/OffsetDateTimeDemo/.project new file mode 100644 index 000000000..fc86e1541 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_atZoneSameInstant/OffsetDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetDateTimeDemo_atZoneSameInstant/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetDateTimeDemo_atZoneSameInstant/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_atZoneSameInstant/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetDateTimeDemo_atZoneSameInstant/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class b/BasicJava/OffsetDateTimeDemo_atZoneSameInstant/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class new file mode 100644 index 000000000..ee1ec5a9a Binary files /dev/null and b/BasicJava/OffsetDateTimeDemo_atZoneSameInstant/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class differ diff --git a/BasicJava/OffsetDateTimeDemo_atZoneSameInstant/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java b/BasicJava/OffsetDateTimeDemo_atZoneSameInstant/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java new file mode 100644 index 000000000..6f79991b9 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_atZoneSameInstant/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java @@ -0,0 +1,32 @@ +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; + +public class OffsetDateTimeDemo +{ + + public static void main(String[] args) + { + + OffsetDateTime offsetDateTime = OffsetDateTime + .parse("2017-02-03T12:30:30+01:00"); + System.out.println(offsetDateTime); + + ZoneId zoneId = ZoneId.systemDefault(); + System.out.println(zoneId); + + /* + * Parameters: + * + * zone - the time-zone to use, not null + * + * Returns: + * + * the zoned date-time formed from this date-time, not null + */ + ZonedDateTime zonedDateTime = offsetDateTime.atZoneSameInstant(zoneId); + System.out.println(zonedDateTime); + + } + +} diff --git a/BasicJava/OffsetDateTimeDemo_atZoneSameInstant/Output.txt b/BasicJava/OffsetDateTimeDemo_atZoneSameInstant/Output.txt new file mode 100644 index 000000000..5fa5dcaa9 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_atZoneSameInstant/Output.txt @@ -0,0 +1,3 @@ +2017-02-03T12:30:30+01:00 +Asia/Calcutta +2017-02-03T17:00:30+05:30[Asia/Calcutta] diff --git a/BasicJava/OffsetDateTimeDemo_atZoneSimilarLocal/OffsetDateTimeDemo/.classpath b/BasicJava/OffsetDateTimeDemo_atZoneSimilarLocal/OffsetDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_atZoneSimilarLocal/OffsetDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetDateTimeDemo_atZoneSimilarLocal/OffsetDateTimeDemo/.project b/BasicJava/OffsetDateTimeDemo_atZoneSimilarLocal/OffsetDateTimeDemo/.project new file mode 100644 index 000000000..fc86e1541 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_atZoneSimilarLocal/OffsetDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetDateTimeDemo_atZoneSimilarLocal/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetDateTimeDemo_atZoneSimilarLocal/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_atZoneSimilarLocal/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetDateTimeDemo_atZoneSimilarLocal/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class b/BasicJava/OffsetDateTimeDemo_atZoneSimilarLocal/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class new file mode 100644 index 000000000..c3a5ba780 Binary files /dev/null and b/BasicJava/OffsetDateTimeDemo_atZoneSimilarLocal/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class differ diff --git a/BasicJava/OffsetDateTimeDemo_atZoneSimilarLocal/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java b/BasicJava/OffsetDateTimeDemo_atZoneSimilarLocal/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java new file mode 100644 index 000000000..570a49d1d --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_atZoneSimilarLocal/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java @@ -0,0 +1,33 @@ +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; + +public class OffsetDateTimeDemo +{ + + public static void main(String[] args) + { + + OffsetDateTime offsetDateTime = OffsetDateTime + .parse("2017-02-03T12:30:30+01:00"); + System.out.println(offsetDateTime); + + ZoneId zoneId = ZoneId.systemDefault(); + System.out.println(zoneId); + + /* + * Parameters: + * + * zone - the time-zone to use, not null + * + * Returns: + * + * the zoned date-time formed from this date and the earliest + * valid time for the zone, not null + */ + ZonedDateTime zonedDateTime = offsetDateTime.atZoneSimilarLocal(zoneId); + System.out.println(zonedDateTime); + + } + +} diff --git a/BasicJava/OffsetDateTimeDemo_atZoneSimilarLocal/Output.txt b/BasicJava/OffsetDateTimeDemo_atZoneSimilarLocal/Output.txt new file mode 100644 index 000000000..e01d42e6c --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_atZoneSimilarLocal/Output.txt @@ -0,0 +1,3 @@ +2017-02-03T12:30:30+01:00 +Asia/Calcutta +2017-02-03T12:30:30+05:30[Asia/Calcutta] diff --git a/BasicJava/OffsetDateTimeDemo_format/OffsetDateTimeDemo/.classpath b/BasicJava/OffsetDateTimeDemo_format/OffsetDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_format/OffsetDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetDateTimeDemo_format/OffsetDateTimeDemo/.project b/BasicJava/OffsetDateTimeDemo_format/OffsetDateTimeDemo/.project new file mode 100644 index 000000000..fc86e1541 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_format/OffsetDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetDateTimeDemo_format/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetDateTimeDemo_format/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_format/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetDateTimeDemo_format/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class b/BasicJava/OffsetDateTimeDemo_format/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class new file mode 100644 index 000000000..8697dd373 Binary files /dev/null and b/BasicJava/OffsetDateTimeDemo_format/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class differ diff --git a/BasicJava/OffsetDateTimeDemo_format/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java b/BasicJava/OffsetDateTimeDemo_format/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java new file mode 100644 index 000000000..14d866bac --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_format/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java @@ -0,0 +1,32 @@ +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; + +public class OffsetDateTimeDemo +{ + + public static void main(String[] args) + { + + OffsetDateTime offsetDateTime = OffsetDateTime.now(); + System.out.println(offsetDateTime); + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ISO_DATE; + + /* + * Parameters: + * + * formatter - the formatter to use, not null + * + * Returns: + * + * the formatted date-time string, not null + */ + String formatedDate = offsetDateTime.format(dateTimeFormatter); + System.out.println("ISO_DATE = " + formatedDate); + + dateTimeFormatter = DateTimeFormatter.ISO_TIME; + formatedDate = offsetDateTime.format(dateTimeFormatter); + System.out.println("ISO_TIME = " + formatedDate); + + } + +} diff --git a/BasicJava/OffsetDateTimeDemo_format/Output.txt b/BasicJava/OffsetDateTimeDemo_format/Output.txt new file mode 100644 index 000000000..07f673b7f --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_format/Output.txt @@ -0,0 +1,3 @@ +2018-01-27T09:00:14.857+05:30 +ISO_DATE = 2018-01-27+05:30 +ISO_TIME = 09:00:14.857+05:30 diff --git a/BasicJava/OffsetDateTimeDemo_from/OffsetDateTimeDemo/.classpath b/BasicJava/OffsetDateTimeDemo_from/OffsetDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_from/OffsetDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetDateTimeDemo_from/OffsetDateTimeDemo/.project b/BasicJava/OffsetDateTimeDemo_from/OffsetDateTimeDemo/.project new file mode 100644 index 000000000..fc86e1541 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_from/OffsetDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetDateTimeDemo_from/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetDateTimeDemo_from/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_from/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetDateTimeDemo_from/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class b/BasicJava/OffsetDateTimeDemo_from/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class new file mode 100644 index 000000000..279d05f07 Binary files /dev/null and b/BasicJava/OffsetDateTimeDemo_from/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class differ diff --git a/BasicJava/OffsetDateTimeDemo_from/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java b/BasicJava/OffsetDateTimeDemo_from/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java new file mode 100644 index 000000000..1d88294b5 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_from/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java @@ -0,0 +1,28 @@ +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +public class OffsetDateTimeDemo +{ + + public static void main(String[] args) + { + + ZonedDateTime zonedDateTime = ZonedDateTime.now(); + System.out.println(zonedDateTime); + + + /* + * Parameters: + * + * temporal - the temporal object to convert, not null + * + * Returns: + * + * the offset date-time, not null + */ + OffsetDateTime offsetDateTime = OffsetDateTime.from(zonedDateTime); + System.out.println(offsetDateTime); + + } + +} diff --git a/BasicJava/OffsetDateTimeDemo_from/Output.txt b/BasicJava/OffsetDateTimeDemo_from/Output.txt new file mode 100644 index 000000000..81aa4baea --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_from/Output.txt @@ -0,0 +1,2 @@ +2018-01-28T08:24:05.350+05:30[Asia/Calcutta] +2018-01-28T08:24:05.350+05:30 diff --git a/BasicJava/OffsetDateTimeDemo_get_temporalfield/OffsetDateTimeDemo/.classpath b/BasicJava/OffsetDateTimeDemo_get_temporalfield/OffsetDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_get_temporalfield/OffsetDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetDateTimeDemo_get_temporalfield/OffsetDateTimeDemo/.project b/BasicJava/OffsetDateTimeDemo_get_temporalfield/OffsetDateTimeDemo/.project new file mode 100644 index 000000000..fc86e1541 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_get_temporalfield/OffsetDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetDateTimeDemo_get_temporalfield/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetDateTimeDemo_get_temporalfield/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_get_temporalfield/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetDateTimeDemo_get_temporalfield/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class b/BasicJava/OffsetDateTimeDemo_get_temporalfield/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class new file mode 100644 index 000000000..64bd5e597 Binary files /dev/null and b/BasicJava/OffsetDateTimeDemo_get_temporalfield/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class differ diff --git a/BasicJava/OffsetDateTimeDemo_get_temporalfield/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java b/BasicJava/OffsetDateTimeDemo_get_temporalfield/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java new file mode 100644 index 000000000..7f2078027 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_get_temporalfield/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java @@ -0,0 +1,30 @@ +import java.time.OffsetDateTime; +import java.time.temporal.ChronoField; + +public class OffsetDateTimeDemo +{ + + public static void main(String[] args) + { + + OffsetDateTime offsetDateTime = OffsetDateTime.now(); + System.out.println(offsetDateTime); + + /* + * Parameters: + * + * field - the field to get, not null + * + * Returns: + * + * the value for the field + */ + int dayOfMonth = offsetDateTime.get(ChronoField.DAY_OF_MONTH); + System.out.println("dayOfMonth = " + dayOfMonth); + + int monthOfYear = offsetDateTime.get(ChronoField.MONTH_OF_YEAR); + System.out.println("monthOfYear = " + monthOfYear); + + } + +} diff --git a/BasicJava/OffsetDateTimeDemo_get_temporalfield/Output.txt b/BasicJava/OffsetDateTimeDemo_get_temporalfield/Output.txt new file mode 100644 index 000000000..60f638e87 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_get_temporalfield/Output.txt @@ -0,0 +1,3 @@ +2018-01-28T08:35:20.954+05:30 +dayOfMonth = 28 +monthOfYear = 1 diff --git a/BasicJava/OffsetDateTimeDemo_intro/OffsetDateTimeDemo/.classpath b/BasicJava/OffsetDateTimeDemo_intro/OffsetDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_intro/OffsetDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetDateTimeDemo_intro/OffsetDateTimeDemo/.project b/BasicJava/OffsetDateTimeDemo_intro/OffsetDateTimeDemo/.project new file mode 100644 index 000000000..fc86e1541 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_intro/OffsetDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetDateTimeDemo_intro/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetDateTimeDemo_intro/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_intro/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetDateTimeDemo_intro/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class b/BasicJava/OffsetDateTimeDemo_intro/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class new file mode 100644 index 000000000..5761db2e2 Binary files /dev/null and b/BasicJava/OffsetDateTimeDemo_intro/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class differ diff --git a/BasicJava/OffsetDateTimeDemo_intro/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java b/BasicJava/OffsetDateTimeDemo_intro/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java new file mode 100644 index 000000000..06d5322f4 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_intro/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java @@ -0,0 +1,29 @@ +import java.time.OffsetDateTime; + +public class OffsetDateTimeDemo +{ + + public static void main(String[] args) + { + /* + * Returns:the current date-time using the system clock, not + * null. + */ + OffsetDateTime offsetDateTime = OffsetDateTime.now(); + System.out.println(offsetDateTime); + + System.out.println("Year = "+offsetDateTime.getYear()); + System.out.println("Month = "+offsetDateTime.getMonth()); + System.out.println("Month Value = "+offsetDateTime.getMonthValue()); + System.out.println("getDayOfMonth = "+offsetDateTime.getDayOfMonth()); + System.out.println("Hour = "+offsetDateTime.getHour()); + System.out.println("Min = "+offsetDateTime.getMinute()); + System.out.println("Second = "+offsetDateTime.getSecond()); + System.out.println("Nano Second = "+offsetDateTime.getNano()); + System.out.println("Offset = "+offsetDateTime.getOffset()); + System.out.println("DayOfYear = "+offsetDateTime.getDayOfYear()); + System.out.println("DayOfWeek = "+offsetDateTime.getDayOfWeek()); + + } + +} diff --git a/BasicJava/OffsetDateTimeDemo_intro/Output.txt b/BasicJava/OffsetDateTimeDemo_intro/Output.txt new file mode 100644 index 000000000..11b7cad44 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_intro/Output.txt @@ -0,0 +1,12 @@ +2018-01-25T10:04:20.738+05:30 +Year = 2018 +Month = JANUARY +Month Value = 1 +getDayOfMonth = 25 +Hour = 10 +Min = 4 +Second = 20 +Nano Second = 738000000 +Offset = +05:30 +DayOfYear = 25 +DayOfWeek = THURSDAY diff --git a/BasicJava/OffsetDateTimeDemo_isafter_before/OffsetDateTimeDemo/.classpath b/BasicJava/OffsetDateTimeDemo_isafter_before/OffsetDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_isafter_before/OffsetDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetDateTimeDemo_isafter_before/OffsetDateTimeDemo/.project b/BasicJava/OffsetDateTimeDemo_isafter_before/OffsetDateTimeDemo/.project new file mode 100644 index 000000000..fc86e1541 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_isafter_before/OffsetDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetDateTimeDemo_isafter_before/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetDateTimeDemo_isafter_before/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_isafter_before/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetDateTimeDemo_isafter_before/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class b/BasicJava/OffsetDateTimeDemo_isafter_before/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class new file mode 100644 index 000000000..cf4f3d921 Binary files /dev/null and b/BasicJava/OffsetDateTimeDemo_isafter_before/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class differ diff --git a/BasicJava/OffsetDateTimeDemo_isafter_before/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java b/BasicJava/OffsetDateTimeDemo_isafter_before/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java new file mode 100644 index 000000000..ff493496c --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_isafter_before/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java @@ -0,0 +1,36 @@ +import java.time.OffsetDateTime; + +public class OffsetDateTimeDemo +{ + + public static void main(String[] args) + { + + OffsetDateTime offsetDateTime1 = OffsetDateTime + .parse("2016-02-03T12:30:30+01:00"); + System.out.println(offsetDateTime1); + + OffsetDateTime offsetDateTime2 = OffsetDateTime + .parse("2017-02-03T12:30:30+01:00"); + System.out.println(offsetDateTime2); + /* + * Returns:true if this is equal to the other date-time + */ + System.out.println(offsetDateTime1.equals(offsetDateTime2)); + + /* + * Returns:true if this date-time is after the specified + * date-time + */ + System.out.println(offsetDateTime1.isAfter(offsetDateTime2)); + + /* + * Returns:true if this date-time is before the specified + * date-time + */ + + System.out.println(offsetDateTime1.isBefore(offsetDateTime2)); + + } + +} diff --git a/BasicJava/OffsetDateTimeDemo_isafter_before/Output.txt b/BasicJava/OffsetDateTimeDemo_isafter_before/Output.txt new file mode 100644 index 000000000..1f49b7aef --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_isafter_before/Output.txt @@ -0,0 +1,5 @@ +2016-02-03T12:30:30+01:00 +2017-02-03T12:30:30+01:00 +false +false +true diff --git a/BasicJava/OffsetDateTimeDemo_minus/OffsetDateTimeDemo/.classpath b/BasicJava/OffsetDateTimeDemo_minus/OffsetDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_minus/OffsetDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetDateTimeDemo_minus/OffsetDateTimeDemo/.project b/BasicJava/OffsetDateTimeDemo_minus/OffsetDateTimeDemo/.project new file mode 100644 index 000000000..fc86e1541 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_minus/OffsetDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetDateTimeDemo_minus/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetDateTimeDemo_minus/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_minus/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetDateTimeDemo_minus/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class b/BasicJava/OffsetDateTimeDemo_minus/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class new file mode 100644 index 000000000..0444c9bbe Binary files /dev/null and b/BasicJava/OffsetDateTimeDemo_minus/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class differ diff --git a/BasicJava/OffsetDateTimeDemo_minus/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java b/BasicJava/OffsetDateTimeDemo_minus/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java new file mode 100644 index 000000000..7c4433415 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_minus/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java @@ -0,0 +1,41 @@ +import java.time.OffsetDateTime; + +public class OffsetDateTimeDemo +{ + + public static void main(String[] args) + { + /* + * Returns:the current date-time using the system clock, not + * null. + */ + OffsetDateTime offsetDateTime1 = OffsetDateTime.now(); + System.out.println(offsetDateTime1); + + OffsetDateTime offsetDateTime2 = offsetDateTime1.minusYears(2); + System.out.println("\nYear changed = "+offsetDateTime2); + + OffsetDateTime offsetDateTime3 = offsetDateTime2.minusMonths(3); + System.out.println("Month changed = "+offsetDateTime3); + + OffsetDateTime offsetDateTime4 = offsetDateTime3.minusDays(5); + System.out.println("Day changed = "+offsetDateTime4); + + OffsetDateTime offsetDateTime5 = offsetDateTime4.minusHours(1); + System.out.println("Hour changed = "+offsetDateTime5); + + OffsetDateTime offsetDateTime6 = offsetDateTime5.minusMinutes(10); + System.out.println("Min changed = "+offsetDateTime6); + + OffsetDateTime offsetDateTime7 = offsetDateTime6.minusSeconds(20); + System.out.println("Sec changed = "+offsetDateTime7); + + OffsetDateTime offsetDateTime8 = offsetDateTime7.minusNanos(50); + System.out.println("NanoSec changed = "+offsetDateTime8); + + OffsetDateTime offsetDateTime9 = offsetDateTime8.minusWeeks(3); + System.out.println("Week changed = "+offsetDateTime9); + + } + +} diff --git a/BasicJava/OffsetDateTimeDemo_minus/Output.txt b/BasicJava/OffsetDateTimeDemo_minus/Output.txt new file mode 100644 index 000000000..85d9239ce --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_minus/Output.txt @@ -0,0 +1,10 @@ +2018-01-25T12:48:58.275+05:30 + +Year changed = 2016-01-25T12:48:58.275+05:30 +Month changed = 2015-10-25T12:48:58.275+05:30 +Day changed = 2015-10-20T12:48:58.275+05:30 +Hour changed = 2015-10-20T11:48:58.275+05:30 +Min changed = 2015-10-20T11:38:58.275+05:30 +Sec changed = 2015-10-20T11:38:38.275+05:30 +NanoSec changed = 2015-10-20T11:38:38.274999950+05:30 +Week changed = 2015-09-29T11:38:38.274999950+05:30 diff --git a/BasicJava/OffsetDateTimeDemo_now_methods/OffsetDateTimeDemo/.classpath b/BasicJava/OffsetDateTimeDemo_now_methods/OffsetDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_now_methods/OffsetDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetDateTimeDemo_now_methods/OffsetDateTimeDemo/.project b/BasicJava/OffsetDateTimeDemo_now_methods/OffsetDateTimeDemo/.project new file mode 100644 index 000000000..fc86e1541 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_now_methods/OffsetDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetDateTimeDemo_now_methods/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetDateTimeDemo_now_methods/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_now_methods/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetDateTimeDemo_now_methods/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class b/BasicJava/OffsetDateTimeDemo_now_methods/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class new file mode 100644 index 000000000..0f3b65c20 Binary files /dev/null and b/BasicJava/OffsetDateTimeDemo_now_methods/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class differ diff --git a/BasicJava/OffsetDateTimeDemo_now_methods/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java b/BasicJava/OffsetDateTimeDemo_now_methods/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java new file mode 100644 index 000000000..d60852a3e --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_now_methods/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java @@ -0,0 +1,40 @@ +import java.time.Clock; +import java.time.OffsetDateTime; +import java.time.ZoneId; + +public class OffsetDateTimeDemo +{ + + public static void main(String[] args) + { + + Clock clock = Clock.systemUTC(); + System.out.println(clock); + + /* + * Parameters: + * + * clock - the clock to use, not null + * + * Returns:the current date-time, not null + */ + OffsetDateTime offsetDateTime1 = OffsetDateTime.now(clock); + System.out.println(offsetDateTime1); + + ZoneId zoneId = ZoneId.systemDefault(); + System.out.println(zoneId); + + /* + * Parameters: + * + * zone - the zone ID to use, not null + * + * Returns:the current date-time using the system clock, not + * null + */ + OffsetDateTime offsetDateTime2 = OffsetDateTime.now(zoneId); + System.out.println(offsetDateTime2); + + } + +} diff --git a/BasicJava/OffsetDateTimeDemo_now_methods/Output.txt b/BasicJava/OffsetDateTimeDemo_now_methods/Output.txt new file mode 100644 index 000000000..548b821d5 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_now_methods/Output.txt @@ -0,0 +1,4 @@ +SystemClock[Z] +2018-01-29T03:53:50.554Z +Asia/Calcutta +2018-01-29T09:24:15.069+05:30 diff --git a/BasicJava/OffsetDateTimeDemo_ofInstant/OffsetDateTimeDemo/.classpath b/BasicJava/OffsetDateTimeDemo_ofInstant/OffsetDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_ofInstant/OffsetDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetDateTimeDemo_ofInstant/OffsetDateTimeDemo/.project b/BasicJava/OffsetDateTimeDemo_ofInstant/OffsetDateTimeDemo/.project new file mode 100644 index 000000000..fc86e1541 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_ofInstant/OffsetDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetDateTimeDemo_ofInstant/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetDateTimeDemo_ofInstant/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_ofInstant/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetDateTimeDemo_ofInstant/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class b/BasicJava/OffsetDateTimeDemo_ofInstant/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class new file mode 100644 index 000000000..2176c3f7a Binary files /dev/null and b/BasicJava/OffsetDateTimeDemo_ofInstant/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class differ diff --git a/BasicJava/OffsetDateTimeDemo_ofInstant/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java b/BasicJava/OffsetDateTimeDemo_ofInstant/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java new file mode 100644 index 000000000..eb8c5ecdd --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_ofInstant/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java @@ -0,0 +1,30 @@ +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; + +public class OffsetDateTimeDemo +{ + + public static void main(String[] args) + { + Instant instant = Instant.now(); + ZoneId zoneId = ZoneId.systemDefault(); + + /* + * Parameters: + * + * instant - the instant to create the date-time from, not + * null + * + * zone - the time-zone, which may be an offset, not null + * + * Returns: + * + * the offset date-time, not null + */ + OffsetDateTime offsetDateTime = OffsetDateTime.ofInstant(instant, + zoneId); + System.out.println(offsetDateTime); + } + +} diff --git a/BasicJava/OffsetDateTimeDemo_ofInstant/Output.txt b/BasicJava/OffsetDateTimeDemo_ofInstant/Output.txt new file mode 100644 index 000000000..6ea6ad352 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_ofInstant/Output.txt @@ -0,0 +1 @@ +2018-01-29T09:57:07.220+05:30 diff --git a/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo/.classpath b/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo/.project b/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo/.project new file mode 100644 index 000000000..fc86e1541 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo/bin/OffsetDateTimeDemo1.class b/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo/bin/OffsetDateTimeDemo1.class new file mode 100644 index 000000000..db6c80830 Binary files /dev/null and b/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo/bin/OffsetDateTimeDemo1.class differ diff --git a/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo/bin/OffsetDateTimeDemo2.class b/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo/bin/OffsetDateTimeDemo2.class new file mode 100644 index 000000000..52d7c872c Binary files /dev/null and b/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo/bin/OffsetDateTimeDemo2.class differ diff --git a/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo/bin/OffsetDateTimeDemo3.class b/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo/bin/OffsetDateTimeDemo3.class new file mode 100644 index 000000000..d4286d3f7 Binary files /dev/null and b/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo/bin/OffsetDateTimeDemo3.class differ diff --git a/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo/src/OffsetDateTimeDemo1.java b/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo/src/OffsetDateTimeDemo1.java new file mode 100644 index 000000000..3af84b192 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo/src/OffsetDateTimeDemo1.java @@ -0,0 +1,41 @@ +import java.time.OffsetDateTime; +import java.time.ZoneOffset; + +public class OffsetDateTimeDemo1 +{ + + public static void main(String[] args) + { + + /* + * Parameters: + * + * year - the year to represent, from MIN_YEAR to MAX_YEAR + * + * month - the month-of-year to represent, from 1 (January) to + * 12 (December) + * + * dayOfMonth - the day-of-month to represent, from 1 to 31 + * + * hour - the hour-of-day to represent, from 0 to 23 + * + * minute - the minute-of-hour to represent, from 0 to 59 + * + * second - the second-of-minute to represent, from 0 to 59 + * + * nanoOfSecond - the nano-of-second to represent, from 0 to + * 999,999,999 + * + * offset - the zone offset, not null + * + * Returns: + * + * the offset date-time, not null + */ + OffsetDateTime offsetDateTime1 = OffsetDateTime.of(2017, 2, 28, 6, 50, + 40, 50000, ZoneOffset.UTC); + System.out.println(offsetDateTime1); + + } + +} diff --git a/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo/src/OffsetDateTimeDemo2.java b/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo/src/OffsetDateTimeDemo2.java new file mode 100644 index 000000000..5d4a3b670 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo/src/OffsetDateTimeDemo2.java @@ -0,0 +1,36 @@ +import java.time.LocalDate; +import java.time.LocalTime; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; + +public class OffsetDateTimeDemo2 +{ + + public static void main(String[] args) + { + + LocalDate localDate = LocalDate.parse("2017-02-03"); + LocalTime localTime = LocalTime.parse("12:30:30"); + ZoneOffset zoneOffset = ZoneOffset.UTC; + + /* + * Parameters: + * + * date - the local date, not null. + * + * time - the local time, not null + * + * offset - the zone offset, not null. + * + * Returns: + * + * the offset date-time, not null + */ + + OffsetDateTime offsetDateTime = OffsetDateTime.of(localDate, localTime, + zoneOffset); + System.out.println(offsetDateTime); + + } + +} diff --git a/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo/src/OffsetDateTimeDemo3.java b/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo/src/OffsetDateTimeDemo3.java new file mode 100644 index 000000000..98697430a --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo/src/OffsetDateTimeDemo3.java @@ -0,0 +1,30 @@ +import java.time.LocalDateTime; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; + +public class OffsetDateTimeDemo3 +{ + + public static void main(String[] args) + { + LocalDateTime localDateTime = LocalDateTime + .parse("2017-02-03T12:20:30"); + ZoneOffset zoneOffset = ZoneOffset.UTC; + + /* + * Parameters: + * + * dateTime - the local date-time, not null. + * + * offset - the zone offset, not null + * + * Returns: + * + * the offset date-time, not null + */ + OffsetDateTime offsetDateTime = OffsetDateTime.of(localDateTime, + zoneOffset); + System.out.println(offsetDateTime); + } + +} diff --git a/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo1_Output.txt b/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo1_Output.txt new file mode 100644 index 000000000..3d2d5a1d9 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo1_Output.txt @@ -0,0 +1 @@ +2017-02-28T06:50:40.000050Z diff --git a/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo2_Output.txt b/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo2_Output.txt new file mode 100644 index 000000000..f5306c63c --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo2_Output.txt @@ -0,0 +1 @@ +2017-02-03T12:30:30Z diff --git a/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo3_Output.txt b/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo3_Output.txt new file mode 100644 index 000000000..e586df5a1 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_of_methods/OffsetDateTimeDemo3_Output.txt @@ -0,0 +1 @@ +2017-02-03T12:20:30Z diff --git a/BasicJava/OffsetDateTimeDemo_parse_formatter/OffsetDateTimeDemo/.classpath b/BasicJava/OffsetDateTimeDemo_parse_formatter/OffsetDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_parse_formatter/OffsetDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetDateTimeDemo_parse_formatter/OffsetDateTimeDemo/.project b/BasicJava/OffsetDateTimeDemo_parse_formatter/OffsetDateTimeDemo/.project new file mode 100644 index 000000000..fc86e1541 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_parse_formatter/OffsetDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetDateTimeDemo_parse_formatter/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetDateTimeDemo_parse_formatter/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_parse_formatter/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetDateTimeDemo_parse_formatter/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class b/BasicJava/OffsetDateTimeDemo_parse_formatter/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class new file mode 100644 index 000000000..b4843f13c Binary files /dev/null and b/BasicJava/OffsetDateTimeDemo_parse_formatter/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class differ diff --git a/BasicJava/OffsetDateTimeDemo_parse_formatter/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java b/BasicJava/OffsetDateTimeDemo_parse_formatter/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java new file mode 100644 index 000000000..d84905a7f --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_parse_formatter/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java @@ -0,0 +1,29 @@ +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; + +public class OffsetDateTimeDemo +{ + + public static void main(String[] args) + { + + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME; + String strDate = "2017-12-03T10:15:30+01:00"; + + /* + * Parameters: + * + * text - the text to parse, not null + * + * formatter - the formatter to use, not null + * + * Returns: + * + * the parsed offset date-time, not null + */ + OffsetDateTime offsetDateTime = OffsetDateTime.parse(strDate, + dateTimeFormatter); + System.out.println(offsetDateTime); + } + +} diff --git a/BasicJava/OffsetDateTimeDemo_parse_formatter/Output.txt b/BasicJava/OffsetDateTimeDemo_parse_formatter/Output.txt new file mode 100644 index 000000000..91be259f9 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_parse_formatter/Output.txt @@ -0,0 +1 @@ +2017-12-03T10:15:30+01:00 diff --git a/BasicJava/OffsetDateTimeDemo_plus/OffsetDateTimeDemo/.classpath b/BasicJava/OffsetDateTimeDemo_plus/OffsetDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_plus/OffsetDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetDateTimeDemo_plus/OffsetDateTimeDemo/.project b/BasicJava/OffsetDateTimeDemo_plus/OffsetDateTimeDemo/.project new file mode 100644 index 000000000..fc86e1541 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_plus/OffsetDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetDateTimeDemo_plus/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetDateTimeDemo_plus/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_plus/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetDateTimeDemo_plus/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class b/BasicJava/OffsetDateTimeDemo_plus/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class new file mode 100644 index 000000000..51507dd59 Binary files /dev/null and b/BasicJava/OffsetDateTimeDemo_plus/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class differ diff --git a/BasicJava/OffsetDateTimeDemo_plus/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java b/BasicJava/OffsetDateTimeDemo_plus/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java new file mode 100644 index 000000000..eb500bb34 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_plus/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java @@ -0,0 +1,41 @@ +import java.time.OffsetDateTime; + +public class OffsetDateTimeDemo +{ + + public static void main(String[] args) + { + /* + * Returns:the current date-time using the system clock, not + * null. + */ + OffsetDateTime offsetDateTime1 = OffsetDateTime.now(); + System.out.println(offsetDateTime1); + + OffsetDateTime offsetDateTime2 = offsetDateTime1.plusYears(2); + System.out.println("\nYear changed = "+offsetDateTime2); + + OffsetDateTime offsetDateTime3 = offsetDateTime2.plusMonths(3); + System.out.println("Month changed = "+offsetDateTime3); + + OffsetDateTime offsetDateTime4 = offsetDateTime3.plusDays(5); + System.out.println("Day changed = "+offsetDateTime4); + + OffsetDateTime offsetDateTime5 = offsetDateTime4.plusHours(1); + System.out.println("Hour changed = "+offsetDateTime5); + + OffsetDateTime offsetDateTime6 = offsetDateTime5.plusMinutes(10); + System.out.println("Min changed = "+offsetDateTime6); + + OffsetDateTime offsetDateTime7 = offsetDateTime6.plusSeconds(20); + System.out.println("Sec changed = "+offsetDateTime7); + + OffsetDateTime offsetDateTime8 = offsetDateTime7.plusNanos(50); + System.out.println("NanoSec changed = "+offsetDateTime8); + + OffsetDateTime offsetDateTime9 = offsetDateTime8.plusWeeks(3); + System.out.println("Week changed = "+offsetDateTime9); + + } + +} diff --git a/BasicJava/OffsetDateTimeDemo_plus/Output.txt b/BasicJava/OffsetDateTimeDemo_plus/Output.txt new file mode 100644 index 000000000..9839dc9b5 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_plus/Output.txt @@ -0,0 +1,10 @@ +2018-01-25T13:01:11.660+05:30 + +Year changed = 2020-01-25T13:01:11.660+05:30 +Month changed = 2020-04-25T13:01:11.660+05:30 +Day changed = 2020-04-30T13:01:11.660+05:30 +Hour changed = 2020-04-30T14:01:11.660+05:30 +Min changed = 2020-04-30T14:11:11.660+05:30 +Sec changed = 2020-04-30T14:11:31.660+05:30 +NanoSec changed = 2020-04-30T14:11:31.660000050+05:30 +Week changed = 2020-05-21T14:11:31.660000050+05:30 diff --git a/BasicJava/OffsetDateTimeDemo_to_methods/OffsetDateTimeDemo/.classpath b/BasicJava/OffsetDateTimeDemo_to_methods/OffsetDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_to_methods/OffsetDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetDateTimeDemo_to_methods/OffsetDateTimeDemo/.project b/BasicJava/OffsetDateTimeDemo_to_methods/OffsetDateTimeDemo/.project new file mode 100644 index 000000000..fc86e1541 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_to_methods/OffsetDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetDateTimeDemo_to_methods/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetDateTimeDemo_to_methods/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_to_methods/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetDateTimeDemo_to_methods/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class b/BasicJava/OffsetDateTimeDemo_to_methods/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class new file mode 100644 index 000000000..e651c2f04 Binary files /dev/null and b/BasicJava/OffsetDateTimeDemo_to_methods/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class differ diff --git a/BasicJava/OffsetDateTimeDemo_to_methods/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java b/BasicJava/OffsetDateTimeDemo_to_methods/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java new file mode 100644 index 000000000..93c79e479 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_to_methods/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java @@ -0,0 +1,37 @@ +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.OffsetDateTime; +import java.time.OffsetTime; +import java.time.ZonedDateTime; + +public class OffsetDateTimeDemo +{ + + public static void main(String[] args) + { + + OffsetDateTime offsetDateTime = OffsetDateTime.now(); + System.out.println("offsetDateTime = " + offsetDateTime); + + Instant instant = offsetDateTime.toInstant(); + System.out.println("instant = " + instant); + + LocalDate localDate = offsetDateTime.toLocalDate(); + System.out.println("localDate = " + localDate); + + LocalDateTime localDateTime = offsetDateTime.toLocalDateTime(); + System.out.println("localDateTime = " + localDateTime); + + LocalTime localTime = offsetDateTime.toLocalTime(); + System.out.println("localTime = " + localTime); + + OffsetTime offsetTime = offsetDateTime.toOffsetTime(); + System.out.println("offsetTime = " + offsetTime); + + ZonedDateTime zonedDateTime = offsetDateTime.toZonedDateTime(); + System.out.println("zonedDateTime = " + zonedDateTime); + } + +} diff --git a/BasicJava/OffsetDateTimeDemo_to_methods/Output.txt b/BasicJava/OffsetDateTimeDemo_to_methods/Output.txt new file mode 100644 index 000000000..41f6999fe --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_to_methods/Output.txt @@ -0,0 +1,7 @@ +offsetDateTime = 2018-01-30T09:24:53.355+05:30 +instant = 2018-01-30T03:54:53.355Z +localDate = 2018-01-30 +localDateTime = 2018-01-30T09:24:53.355 +localTime = 09:24:53.355 +offsetTime = 09:24:53.355+05:30 +zonedDateTime = 2018-01-30T09:24:53.355+05:30 diff --git a/BasicJava/OffsetDateTimeDemo_with/OffsetDateTimeDemo/.classpath b/BasicJava/OffsetDateTimeDemo_with/OffsetDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_with/OffsetDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetDateTimeDemo_with/OffsetDateTimeDemo/.project b/BasicJava/OffsetDateTimeDemo_with/OffsetDateTimeDemo/.project new file mode 100644 index 000000000..fc86e1541 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_with/OffsetDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetDateTimeDemo_with/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetDateTimeDemo_with/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_with/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetDateTimeDemo_with/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class b/BasicJava/OffsetDateTimeDemo_with/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class new file mode 100644 index 000000000..e70ccc2f0 Binary files /dev/null and b/BasicJava/OffsetDateTimeDemo_with/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class differ diff --git a/BasicJava/OffsetDateTimeDemo_with/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java b/BasicJava/OffsetDateTimeDemo_with/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java new file mode 100644 index 000000000..b3693b7bc --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_with/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java @@ -0,0 +1,34 @@ +import java.time.OffsetDateTime; + +public class OffsetDateTimeDemo +{ + + public static void main(String[] args) + { + OffsetDateTime offsetDateTime1 = OffsetDateTime.parse("2017-02-03T10:15:30+01:00"); + System.out.println("offsetDateTime1 = "+offsetDateTime1); + + OffsetDateTime offsetDateTime2 = offsetDateTime1.withYear(2018); + System.out.println("\nYear changed = "+offsetDateTime2); + + OffsetDateTime offsetDateTime3 = offsetDateTime2.withMonth(10); + System.out.println("Month changed = "+offsetDateTime3); + + OffsetDateTime offsetDateTime4 = offsetDateTime3.withDayOfMonth(25); + System.out.println("Day changed = "+offsetDateTime4); + + OffsetDateTime offsetDateTime5 = offsetDateTime4.withHour(1); + System.out.println("Hour changed = "+offsetDateTime5); + + OffsetDateTime offsetDateTime6 = offsetDateTime5.withMinute(10); + System.out.println("Min changed = "+offsetDateTime6); + + OffsetDateTime offsetDateTime7 = offsetDateTime6.withSecond(20); + System.out.println("Sec changed = "+offsetDateTime7); + + OffsetDateTime offsetDateTime8 = offsetDateTime7.withNano(50); + System.out.println("NanoSec changed = "+offsetDateTime8); + + } + +} diff --git a/BasicJava/OffsetDateTimeDemo_with/Output.txt b/BasicJava/OffsetDateTimeDemo_with/Output.txt new file mode 100644 index 000000000..4ea76d4f1 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_with/Output.txt @@ -0,0 +1,9 @@ +offsetDateTime1 = 2017-02-03T10:15:30+01:00 + +Year changed = 2018-02-03T10:15:30+01:00 +Month changed = 2018-10-03T10:15:30+01:00 +Day changed = 2018-10-25T10:15:30+01:00 +Hour changed = 2018-10-25T01:15:30+01:00 +Min changed = 2018-10-25T01:10:30+01:00 +Sec changed = 2018-10-25T01:10:20+01:00 +NanoSec changed = 2018-10-25T01:10:20.000000050+01:00 diff --git a/BasicJava/OffsetDateTimeDemo_withOffsetSameLocal/OffsetDateTimeDemo/.classpath b/BasicJava/OffsetDateTimeDemo_withOffsetSameLocal/OffsetDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_withOffsetSameLocal/OffsetDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetDateTimeDemo_withOffsetSameLocal/OffsetDateTimeDemo/.project b/BasicJava/OffsetDateTimeDemo_withOffsetSameLocal/OffsetDateTimeDemo/.project new file mode 100644 index 000000000..fc86e1541 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_withOffsetSameLocal/OffsetDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetDateTimeDemo_withOffsetSameLocal/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetDateTimeDemo_withOffsetSameLocal/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_withOffsetSameLocal/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetDateTimeDemo_withOffsetSameLocal/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class b/BasicJava/OffsetDateTimeDemo_withOffsetSameLocal/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class new file mode 100644 index 000000000..df88e0269 Binary files /dev/null and b/BasicJava/OffsetDateTimeDemo_withOffsetSameLocal/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class differ diff --git a/BasicJava/OffsetDateTimeDemo_withOffsetSameLocal/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java b/BasicJava/OffsetDateTimeDemo_withOffsetSameLocal/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java new file mode 100644 index 000000000..b93c69868 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_withOffsetSameLocal/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java @@ -0,0 +1,27 @@ +import java.time.OffsetDateTime; +import java.time.ZoneOffset; + +public class OffsetDateTimeDemo +{ + + public static void main(String[] args) + { + OffsetDateTime offsetDateTime1 = OffsetDateTime + .parse("2017-02-03T10:15:30+01:00"); + System.out.println("offsetDateTime1 = " + offsetDateTime1); + /* + * Parameters: + * + * offset - the zone offset to change to, not null + * + * Returns: + * + * an OffsetDateTime based on this date-time with the + * requested offset, not null + */ + OffsetDateTime offsetDateTime2 = offsetDateTime1 + .withOffsetSameLocal(ZoneOffset.UTC); + System.out.println("Offset changed = " + offsetDateTime2); + } + +} diff --git a/BasicJava/OffsetDateTimeDemo_withOffsetSameLocal/Output.txt b/BasicJava/OffsetDateTimeDemo_withOffsetSameLocal/Output.txt new file mode 100644 index 000000000..90a08819f --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_withOffsetSameLocal/Output.txt @@ -0,0 +1,2 @@ +offsetDateTime1 = 2017-02-03T10:15:30+01:00 +Offset changed = 2017-02-03T10:15:30Z diff --git a/BasicJava/OffsetDateTimeDemo_with_dayofyear/OffsetDateTimeDemo/.classpath b/BasicJava/OffsetDateTimeDemo_with_dayofyear/OffsetDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_with_dayofyear/OffsetDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetDateTimeDemo_with_dayofyear/OffsetDateTimeDemo/.project b/BasicJava/OffsetDateTimeDemo_with_dayofyear/OffsetDateTimeDemo/.project new file mode 100644 index 000000000..fc86e1541 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_with_dayofyear/OffsetDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetDateTimeDemo_with_dayofyear/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetDateTimeDemo_with_dayofyear/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_with_dayofyear/OffsetDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetDateTimeDemo_with_dayofyear/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class b/BasicJava/OffsetDateTimeDemo_with_dayofyear/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class new file mode 100644 index 000000000..5d9549505 Binary files /dev/null and b/BasicJava/OffsetDateTimeDemo_with_dayofyear/OffsetDateTimeDemo/bin/OffsetDateTimeDemo.class differ diff --git a/BasicJava/OffsetDateTimeDemo_with_dayofyear/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java b/BasicJava/OffsetDateTimeDemo_with_dayofyear/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java new file mode 100644 index 000000000..3210da786 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_with_dayofyear/OffsetDateTimeDemo/src/OffsetDateTimeDemo.java @@ -0,0 +1,37 @@ +import java.time.OffsetDateTime; +import java.time.ZoneOffset; + +public class OffsetDateTimeDemo +{ + + public static void main(String[] args) + { + OffsetDateTime offsetDateTime1 = OffsetDateTime + .parse("2017-02-03T10:15:30+01:00"); + System.out.println("offsetDateTime1 = " + offsetDateTime1); + /* + * Parameters: + * + * dayOfYear - the day-of-year to set in the result, from 1 to + * 365-366 + * + * Returns:an OffsetDateTime based on this date with the + * requested day, not null + */ + OffsetDateTime offsetDateTime2 = offsetDateTime1.withDayOfYear(150); + System.out.println("DayOfYear changed = " + offsetDateTime2); + + /* + * Parameters: + * + * offset - the zone offset to change to, not null + * + * Returns:an OffsetDateTime based on this date-time with the + * requested offset, not null + */ + OffsetDateTime offsetDateTime3 = offsetDateTime2 + .withOffsetSameInstant(ZoneOffset.UTC); + System.out.println("Offset changed = " + offsetDateTime3); + } + +} diff --git a/BasicJava/OffsetDateTimeDemo_with_dayofyear/Output.txt b/BasicJava/OffsetDateTimeDemo_with_dayofyear/Output.txt new file mode 100644 index 000000000..0a4226644 --- /dev/null +++ b/BasicJava/OffsetDateTimeDemo_with_dayofyear/Output.txt @@ -0,0 +1,3 @@ +offsetDateTime1 = 2017-02-03T10:15:30+01:00 +DayOfYear changed = 2017-05-30T10:15:30+01:00 +Offset changed = 2017-05-30T09:15:30Z diff --git a/BasicJava/OffsetTimeDemo-minus_temporalunit/OffsetTimeDemo/.classpath b/BasicJava/OffsetTimeDemo-minus_temporalunit/OffsetTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetTimeDemo-minus_temporalunit/OffsetTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetTimeDemo-minus_temporalunit/OffsetTimeDemo/.project b/BasicJava/OffsetTimeDemo-minus_temporalunit/OffsetTimeDemo/.project new file mode 100644 index 000000000..d1f0664d6 --- /dev/null +++ b/BasicJava/OffsetTimeDemo-minus_temporalunit/OffsetTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetTimeDemo-minus_temporalunit/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetTimeDemo-minus_temporalunit/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetTimeDemo-minus_temporalunit/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetTimeDemo-minus_temporalunit/OffsetTimeDemo/bin/OffsetTimeDemo.class b/BasicJava/OffsetTimeDemo-minus_temporalunit/OffsetTimeDemo/bin/OffsetTimeDemo.class new file mode 100644 index 000000000..0a152b400 Binary files /dev/null and b/BasicJava/OffsetTimeDemo-minus_temporalunit/OffsetTimeDemo/bin/OffsetTimeDemo.class differ diff --git a/BasicJava/OffsetTimeDemo-minus_temporalunit/OffsetTimeDemo/src/OffsetTimeDemo.java b/BasicJava/OffsetTimeDemo-minus_temporalunit/OffsetTimeDemo/src/OffsetTimeDemo.java new file mode 100644 index 000000000..f3ac9b602 --- /dev/null +++ b/BasicJava/OffsetTimeDemo-minus_temporalunit/OffsetTimeDemo/src/OffsetTimeDemo.java @@ -0,0 +1,33 @@ +import java.time.OffsetTime; +import java.time.temporal.ChronoUnit; + +public class OffsetTimeDemo +{ + + public static void main(String[] args) + { + OffsetTime offsetTime1 = OffsetTime.now(); + System.out.println("offsetTime1 = " + offsetTime1); + + /* + * Parameters: + * + * amountToSubtract - the amount of the unit to subtract from + * the result, may be negative + * + * unit - the unit of the amount to subtract, not null + * + * Returns: + * + * an OffsetTime based on this time with the specified amount + * subtracted, not null + */ + OffsetTime offsetTime2 = offsetTime1.minus(2, ChronoUnit.HOURS); + System.out.println("offsetTime2 = " + offsetTime2); + + + OffsetTime offsetTime3 = offsetTime2.minus(20, ChronoUnit.MINUTES); + System.out.println("offsetTime3 = " + offsetTime3); + } + +} diff --git a/BasicJava/OffsetTimeDemo-minus_temporalunit/Output.txt b/BasicJava/OffsetTimeDemo-minus_temporalunit/Output.txt new file mode 100644 index 000000000..ef0a0c53a --- /dev/null +++ b/BasicJava/OffsetTimeDemo-minus_temporalunit/Output.txt @@ -0,0 +1,3 @@ +offsetTime1 = 09:58:11.901+05:30 +offsetTime2 = 07:58:11.901+05:30 +offsetTime3 = 07:38:11.901+05:30 diff --git a/BasicJava/OffsetTimeDemo_atDate/OffsetTimeDemo/.classpath b/BasicJava/OffsetTimeDemo_atDate/OffsetTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetTimeDemo_atDate/OffsetTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetTimeDemo_atDate/OffsetTimeDemo/.project b/BasicJava/OffsetTimeDemo_atDate/OffsetTimeDemo/.project new file mode 100644 index 000000000..d1f0664d6 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_atDate/OffsetTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetTimeDemo_atDate/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetTimeDemo_atDate/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_atDate/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetTimeDemo_atDate/OffsetTimeDemo/bin/OffsetTimeDemo.class b/BasicJava/OffsetTimeDemo_atDate/OffsetTimeDemo/bin/OffsetTimeDemo.class new file mode 100644 index 000000000..6b3f2a256 Binary files /dev/null and b/BasicJava/OffsetTimeDemo_atDate/OffsetTimeDemo/bin/OffsetTimeDemo.class differ diff --git a/BasicJava/OffsetTimeDemo_atDate/OffsetTimeDemo/src/OffsetTimeDemo.java b/BasicJava/OffsetTimeDemo_atDate/OffsetTimeDemo/src/OffsetTimeDemo.java new file mode 100644 index 000000000..2f49f68bc --- /dev/null +++ b/BasicJava/OffsetTimeDemo_atDate/OffsetTimeDemo/src/OffsetTimeDemo.java @@ -0,0 +1,33 @@ +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.time.OffsetTime; + +public class OffsetTimeDemo +{ + + public static void main(String[] args) + { + + OffsetTime offsetTime = OffsetTime.parse("10:30:30+05:30"); + System.out.println("offsetTime = " + offsetTime); + + LocalDate localDate = LocalDate.now(); + System.out.println("localDate = " + localDate); + + /* + * Combines this time with a date to create an OffsetDateTime. + * + * Parameters: + * + * date - the date to combine with, not null + * + * Returns: + * + * the offset date-time formed from this time and the + * specified date, not null + */ + OffsetDateTime offsetDateTime = offsetTime.atDate(localDate); + System.out.println("offsetDateTime = " + offsetDateTime); + } + +} diff --git a/BasicJava/OffsetTimeDemo_atDate/Output.txt b/BasicJava/OffsetTimeDemo_atDate/Output.txt new file mode 100644 index 000000000..dc04b332c --- /dev/null +++ b/BasicJava/OffsetTimeDemo_atDate/Output.txt @@ -0,0 +1,3 @@ +offsetTime = 10:30:30+05:30 +localDate = 2018-01-31 +offsetDateTime = 2018-01-31T10:30:30+05:30 diff --git a/BasicJava/OffsetTimeDemo_from/OffsetTimeDemo/.classpath b/BasicJava/OffsetTimeDemo_from/OffsetTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetTimeDemo_from/OffsetTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetTimeDemo_from/OffsetTimeDemo/.project b/BasicJava/OffsetTimeDemo_from/OffsetTimeDemo/.project new file mode 100644 index 000000000..d1f0664d6 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_from/OffsetTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetTimeDemo_from/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetTimeDemo_from/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_from/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetTimeDemo_from/OffsetTimeDemo/bin/OffsetTimeDemo.class b/BasicJava/OffsetTimeDemo_from/OffsetTimeDemo/bin/OffsetTimeDemo.class new file mode 100644 index 000000000..3a524809c Binary files /dev/null and b/BasicJava/OffsetTimeDemo_from/OffsetTimeDemo/bin/OffsetTimeDemo.class differ diff --git a/BasicJava/OffsetTimeDemo_from/OffsetTimeDemo/src/OffsetTimeDemo.java b/BasicJava/OffsetTimeDemo_from/OffsetTimeDemo/src/OffsetTimeDemo.java new file mode 100644 index 000000000..c0cdf900f --- /dev/null +++ b/BasicJava/OffsetTimeDemo_from/OffsetTimeDemo/src/OffsetTimeDemo.java @@ -0,0 +1,26 @@ +import java.time.OffsetTime; +import java.time.ZonedDateTime; + +public class OffsetTimeDemo +{ + + public static void main(String[] args) + { + + ZonedDateTime zonedDateTime = ZonedDateTime.now(); + System.out.println("zonedDateTime = " + zonedDateTime); + + /* + * Parameters: + * + * temporal - the temporal object to convert, not null + * + * Returns: + * + * the offset time, not null + */ + OffsetTime offsetTime = OffsetTime.from(zonedDateTime); + System.out.println("offsetTime = " + offsetTime); + } + +} diff --git a/BasicJava/OffsetTimeDemo_from/Output.txt b/BasicJava/OffsetTimeDemo_from/Output.txt new file mode 100644 index 000000000..292c4a695 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_from/Output.txt @@ -0,0 +1,2 @@ +zonedDateTime = 2018-02-02T09:44:31.196+05:30[Asia/Calcutta] +offsetTime = 09:44:31.196+05:30 diff --git a/BasicJava/OffsetTimeDemo_get_field/OffsetTimeDemo/.classpath b/BasicJava/OffsetTimeDemo_get_field/OffsetTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetTimeDemo_get_field/OffsetTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetTimeDemo_get_field/OffsetTimeDemo/.project b/BasicJava/OffsetTimeDemo_get_field/OffsetTimeDemo/.project new file mode 100644 index 000000000..d1f0664d6 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_get_field/OffsetTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetTimeDemo_get_field/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetTimeDemo_get_field/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_get_field/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetTimeDemo_get_field/OffsetTimeDemo/bin/OffsetTimeDemo.class b/BasicJava/OffsetTimeDemo_get_field/OffsetTimeDemo/bin/OffsetTimeDemo.class new file mode 100644 index 000000000..0e7557c56 Binary files /dev/null and b/BasicJava/OffsetTimeDemo_get_field/OffsetTimeDemo/bin/OffsetTimeDemo.class differ diff --git a/BasicJava/OffsetTimeDemo_get_field/OffsetTimeDemo/src/OffsetTimeDemo.java b/BasicJava/OffsetTimeDemo_get_field/OffsetTimeDemo/src/OffsetTimeDemo.java new file mode 100644 index 000000000..28e7cfa39 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_get_field/OffsetTimeDemo/src/OffsetTimeDemo.java @@ -0,0 +1,32 @@ +import java.time.OffsetTime; +import java.time.temporal.ChronoField; + +public class OffsetTimeDemo +{ + + public static void main(String[] args) + { + OffsetTime offsetTime = OffsetTime.now(); + System.out.println("offsetTime = " + offsetTime); + + /* + * Parameters: + * + * field - the field to get, not null + * + * Returns: + * + * the value for the field + * + */ + int hour = offsetTime.get(ChronoField.HOUR_OF_DAY); + System.out.println("hour = " + hour); + + int minute = offsetTime.get(ChronoField.MINUTE_OF_HOUR); + System.out.println("minute = " + minute); + + int seconds = offsetTime.get(ChronoField.SECOND_OF_MINUTE); + System.out.println("seconds = " + seconds); + } + +} diff --git a/BasicJava/OffsetTimeDemo_get_field/Output.txt b/BasicJava/OffsetTimeDemo_get_field/Output.txt new file mode 100644 index 000000000..2e6e122a5 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_get_field/Output.txt @@ -0,0 +1,4 @@ +offsetTime = 09:58:56.596+05:30 +hour = 9 +minute = 58 +seconds = 56 diff --git a/BasicJava/OffsetTimeDemo_intro/OffsetTimeDemo/.classpath b/BasicJava/OffsetTimeDemo_intro/OffsetTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetTimeDemo_intro/OffsetTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetTimeDemo_intro/OffsetTimeDemo/.project b/BasicJava/OffsetTimeDemo_intro/OffsetTimeDemo/.project new file mode 100644 index 000000000..d1f0664d6 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_intro/OffsetTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetTimeDemo_intro/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetTimeDemo_intro/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_intro/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetTimeDemo_intro/OffsetTimeDemo/bin/OffsetTimeDemo.class b/BasicJava/OffsetTimeDemo_intro/OffsetTimeDemo/bin/OffsetTimeDemo.class new file mode 100644 index 000000000..fe584bd04 Binary files /dev/null and b/BasicJava/OffsetTimeDemo_intro/OffsetTimeDemo/bin/OffsetTimeDemo.class differ diff --git a/BasicJava/OffsetTimeDemo_intro/OffsetTimeDemo/src/OffsetTimeDemo.java b/BasicJava/OffsetTimeDemo_intro/OffsetTimeDemo/src/OffsetTimeDemo.java new file mode 100644 index 000000000..defbd2af0 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_intro/OffsetTimeDemo/src/OffsetTimeDemo.java @@ -0,0 +1,35 @@ +import java.time.OffsetTime; +import java.time.ZoneOffset; + +public class OffsetTimeDemo +{ + + public static void main(String[] args) + { + + /* + * Returns: + * + * the current time using the system clock and default + * time-zone, not null + */ + OffsetTime currentTime = OffsetTime.now(); + System.out.println("currentTime = " + currentTime); + + int hour = currentTime.getHour(); + System.out.println("hour = " + hour); + + int minute = currentTime.getMinute(); + System.out.println("minute = " + minute); + + int seconds = currentTime.getSecond(); + System.out.println("seconds = " + seconds); + + int nanoSeconds = currentTime.getNano(); + System.out.println("nanoSeconds = " + nanoSeconds); + + ZoneOffset zoneOffset = currentTime.getOffset(); + System.out.println("zoneOffset = " + zoneOffset.getId()); + } + +} diff --git a/BasicJava/OffsetTimeDemo_intro/Output.txt b/BasicJava/OffsetTimeDemo_intro/Output.txt new file mode 100644 index 000000000..47eada1d9 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_intro/Output.txt @@ -0,0 +1,6 @@ +currentTime = 09:55:12.169+05:30 +hour = 9 +minute = 55 +seconds = 12 +nanoSeconds = 169000000 +zoneOffset = +05:30 diff --git a/BasicJava/OffsetTimeDemo_isAfter_before/OffsetTimeDemo/.classpath b/BasicJava/OffsetTimeDemo_isAfter_before/OffsetTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetTimeDemo_isAfter_before/OffsetTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetTimeDemo_isAfter_before/OffsetTimeDemo/.project b/BasicJava/OffsetTimeDemo_isAfter_before/OffsetTimeDemo/.project new file mode 100644 index 000000000..d1f0664d6 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_isAfter_before/OffsetTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetTimeDemo_isAfter_before/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetTimeDemo_isAfter_before/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_isAfter_before/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetTimeDemo_isAfter_before/OffsetTimeDemo/bin/OffsetTimeDemo.class b/BasicJava/OffsetTimeDemo_isAfter_before/OffsetTimeDemo/bin/OffsetTimeDemo.class new file mode 100644 index 000000000..f3ab7c5df Binary files /dev/null and b/BasicJava/OffsetTimeDemo_isAfter_before/OffsetTimeDemo/bin/OffsetTimeDemo.class differ diff --git a/BasicJava/OffsetTimeDemo_isAfter_before/OffsetTimeDemo/src/OffsetTimeDemo.java b/BasicJava/OffsetTimeDemo_isAfter_before/OffsetTimeDemo/src/OffsetTimeDemo.java new file mode 100644 index 000000000..008e66206 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_isAfter_before/OffsetTimeDemo/src/OffsetTimeDemo.java @@ -0,0 +1,35 @@ +import java.time.OffsetTime; + +public class OffsetTimeDemo +{ + + public static void main(String[] args) + { + + OffsetTime offsetTime1 = OffsetTime.parse("10:30:30+05:30"); + System.out.println("offsetTime1 = " + offsetTime1); + + OffsetTime offsetTime2 = OffsetTime.parse("12:30:30+05:30"); + System.out.println("offsetTime2 = " + offsetTime2); + + /* + * Returns:true if this is equal to the other time + */ + System.out.println(offsetTime1.equals(offsetTime2)); + + /* + * Returns:true if this is after the instant of the specified + * time + */ + System.out.println(offsetTime1.isAfter(offsetTime2)); + + /* + * Returns:true if this is before the instant of the specified + * time + */ + + System.out.println(offsetTime1.isBefore(offsetTime2)); + + } + +} diff --git a/BasicJava/OffsetTimeDemo_isAfter_before/Output.txt b/BasicJava/OffsetTimeDemo_isAfter_before/Output.txt new file mode 100644 index 000000000..af3fd80e4 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_isAfter_before/Output.txt @@ -0,0 +1,5 @@ +offsetTime1 = 10:30:30+05:30 +offsetTime2 = 12:30:30+05:30 +false +false +true diff --git a/BasicJava/OffsetTimeDemo_minus/OffsetTimeDemo/.classpath b/BasicJava/OffsetTimeDemo_minus/OffsetTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetTimeDemo_minus/OffsetTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetTimeDemo_minus/OffsetTimeDemo/.project b/BasicJava/OffsetTimeDemo_minus/OffsetTimeDemo/.project new file mode 100644 index 000000000..d1f0664d6 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_minus/OffsetTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetTimeDemo_minus/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetTimeDemo_minus/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_minus/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetTimeDemo_minus/OffsetTimeDemo/bin/OffsetTimeDemo.class b/BasicJava/OffsetTimeDemo_minus/OffsetTimeDemo/bin/OffsetTimeDemo.class new file mode 100644 index 000000000..d07bfa4d5 Binary files /dev/null and b/BasicJava/OffsetTimeDemo_minus/OffsetTimeDemo/bin/OffsetTimeDemo.class differ diff --git a/BasicJava/OffsetTimeDemo_minus/OffsetTimeDemo/src/OffsetTimeDemo.java b/BasicJava/OffsetTimeDemo_minus/OffsetTimeDemo/src/OffsetTimeDemo.java new file mode 100644 index 000000000..db30cfdce --- /dev/null +++ b/BasicJava/OffsetTimeDemo_minus/OffsetTimeDemo/src/OffsetTimeDemo.java @@ -0,0 +1,26 @@ +import java.time.OffsetTime; + +public class OffsetTimeDemo +{ + + public static void main(String[] args) + { + + OffsetTime offsetTime1 = OffsetTime.now(); + System.out.println("offsetTime1 = " + offsetTime1); + + OffsetTime offsetTime2 = offsetTime1.minusHours(1); + System.out.println("Hour changed = " + offsetTime2); + + OffsetTime offsetTime3 = offsetTime2.minusMinutes(10); + System.out.println("Min changed = " + offsetTime3); + + OffsetTime offsetTime4 = offsetTime3.minusSeconds(20); + System.out.println("Sec changed = " + offsetTime4); + + OffsetTime offsetTime5 = offsetTime4.minusNanos(50); + System.out.println("NanoSec changed = " + offsetTime5); + + } + +} diff --git a/BasicJava/OffsetTimeDemo_minus/Output.txt b/BasicJava/OffsetTimeDemo_minus/Output.txt new file mode 100644 index 000000000..fea76ff4f --- /dev/null +++ b/BasicJava/OffsetTimeDemo_minus/Output.txt @@ -0,0 +1,5 @@ +offsetTime1 = 09:40:02.729+05:30 +Hour changed = 08:40:02.729+05:30 +Min changed = 08:30:02.729+05:30 +Sec changed = 08:29:42.729+05:30 +NanoSec changed = 08:29:42.728999950+05:30 diff --git a/BasicJava/OffsetTimeDemo_minus_temporalAmount/OffsetTimeDemo/.classpath b/BasicJava/OffsetTimeDemo_minus_temporalAmount/OffsetTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetTimeDemo_minus_temporalAmount/OffsetTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetTimeDemo_minus_temporalAmount/OffsetTimeDemo/.project b/BasicJava/OffsetTimeDemo_minus_temporalAmount/OffsetTimeDemo/.project new file mode 100644 index 000000000..d1f0664d6 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_minus_temporalAmount/OffsetTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetTimeDemo_minus_temporalAmount/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetTimeDemo_minus_temporalAmount/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_minus_temporalAmount/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetTimeDemo_minus_temporalAmount/OffsetTimeDemo/bin/OffsetTimeDemo.class b/BasicJava/OffsetTimeDemo_minus_temporalAmount/OffsetTimeDemo/bin/OffsetTimeDemo.class new file mode 100644 index 000000000..667c3332e Binary files /dev/null and b/BasicJava/OffsetTimeDemo_minus_temporalAmount/OffsetTimeDemo/bin/OffsetTimeDemo.class differ diff --git a/BasicJava/OffsetTimeDemo_minus_temporalAmount/OffsetTimeDemo/src/OffsetTimeDemo.java b/BasicJava/OffsetTimeDemo_minus_temporalAmount/OffsetTimeDemo/src/OffsetTimeDemo.java new file mode 100644 index 000000000..06526cdef --- /dev/null +++ b/BasicJava/OffsetTimeDemo_minus_temporalAmount/OffsetTimeDemo/src/OffsetTimeDemo.java @@ -0,0 +1,29 @@ +import java.time.Duration; +import java.time.OffsetTime; + +public class OffsetTimeDemo +{ + + public static void main(String[] args) + { + OffsetTime offsetTime1 = OffsetTime.now(); + System.out.println("offsetTime1 = " + offsetTime1); + + Duration duration = Duration.ofHours(2); + System.out.println("duration = "+duration); + + /* + * Parameters: + * + * amountToSubtract - the amount to subtract, not null + * + * Returns: + * + * an OffsetTime based on this time with the subtraction made, + * not null + */ + OffsetTime offsetTime2 = offsetTime1.minus(duration); + System.out.println("offsetTime2 = " + offsetTime2); + } + +} diff --git a/BasicJava/OffsetTimeDemo_minus_temporalAmount/Output.txt b/BasicJava/OffsetTimeDemo_minus_temporalAmount/Output.txt new file mode 100644 index 000000000..269176fba --- /dev/null +++ b/BasicJava/OffsetTimeDemo_minus_temporalAmount/Output.txt @@ -0,0 +1,3 @@ +offsetTime1 = 10:08:03.779+05:30 +duration = PT2H +offsetTime2 = 08:08:03.779+05:30 diff --git a/BasicJava/OffsetTimeDemo_now_clock_zone/OffsetTimeDemo/.classpath b/BasicJava/OffsetTimeDemo_now_clock_zone/OffsetTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetTimeDemo_now_clock_zone/OffsetTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetTimeDemo_now_clock_zone/OffsetTimeDemo/.project b/BasicJava/OffsetTimeDemo_now_clock_zone/OffsetTimeDemo/.project new file mode 100644 index 000000000..d1f0664d6 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_now_clock_zone/OffsetTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetTimeDemo_now_clock_zone/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetTimeDemo_now_clock_zone/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_now_clock_zone/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetTimeDemo_now_clock_zone/OffsetTimeDemo/bin/OffsetTimeDemo.class b/BasicJava/OffsetTimeDemo_now_clock_zone/OffsetTimeDemo/bin/OffsetTimeDemo.class new file mode 100644 index 000000000..2305be00f Binary files /dev/null and b/BasicJava/OffsetTimeDemo_now_clock_zone/OffsetTimeDemo/bin/OffsetTimeDemo.class differ diff --git a/BasicJava/OffsetTimeDemo_now_clock_zone/OffsetTimeDemo/src/OffsetTimeDemo.java b/BasicJava/OffsetTimeDemo_now_clock_zone/OffsetTimeDemo/src/OffsetTimeDemo.java new file mode 100644 index 000000000..777b3994a --- /dev/null +++ b/BasicJava/OffsetTimeDemo_now_clock_zone/OffsetTimeDemo/src/OffsetTimeDemo.java @@ -0,0 +1,43 @@ +import java.time.Clock; +import java.time.OffsetTime; +import java.time.ZoneId; + +public class OffsetTimeDemo +{ + + public static void main(String[] args) + { + + Clock clock = Clock.systemUTC(); + System.out.println(clock); + + /* + * Parameters: + * + * clock - the clock to use, not null + * + * Returns: + * + * the current time, not null + */ + + OffsetTime offsetTime1 = OffsetTime.now(clock); + System.out.println("offsetTime1 = " + offsetTime1); + + ZoneId zoneId = ZoneId.systemDefault(); + System.out.println(zoneId); + + /* + * Parameters: + * + * zone - the zone ID to use, not null + * + * Returns: + * + * the current time using the system clock, not null + */ + OffsetTime offsetTime2 = OffsetTime.now(zoneId); + System.out.println("offsetTime2 = " + offsetTime2); + } + +} diff --git a/BasicJava/OffsetTimeDemo_now_clock_zone/Output.txt b/BasicJava/OffsetTimeDemo_now_clock_zone/Output.txt new file mode 100644 index 000000000..34cf2285d --- /dev/null +++ b/BasicJava/OffsetTimeDemo_now_clock_zone/Output.txt @@ -0,0 +1,4 @@ +SystemClock[Z] +offsetTime1 = 02:57:23.033Z +Asia/Calcutta +offsetTime2 = 08:27:48.717+05:30 diff --git a/BasicJava/OffsetTimeDemo_ofInstant/OffsetTimeDemo/.classpath b/BasicJava/OffsetTimeDemo_ofInstant/OffsetTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetTimeDemo_ofInstant/OffsetTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetTimeDemo_ofInstant/OffsetTimeDemo/.project b/BasicJava/OffsetTimeDemo_ofInstant/OffsetTimeDemo/.project new file mode 100644 index 000000000..d1f0664d6 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_ofInstant/OffsetTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetTimeDemo_ofInstant/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetTimeDemo_ofInstant/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_ofInstant/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetTimeDemo_ofInstant/OffsetTimeDemo/bin/OffsetTimeDemo.class b/BasicJava/OffsetTimeDemo_ofInstant/OffsetTimeDemo/bin/OffsetTimeDemo.class new file mode 100644 index 000000000..057839993 Binary files /dev/null and b/BasicJava/OffsetTimeDemo_ofInstant/OffsetTimeDemo/bin/OffsetTimeDemo.class differ diff --git a/BasicJava/OffsetTimeDemo_ofInstant/OffsetTimeDemo/src/OffsetTimeDemo.java b/BasicJava/OffsetTimeDemo_ofInstant/OffsetTimeDemo/src/OffsetTimeDemo.java new file mode 100644 index 000000000..ddf6a7eb9 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_ofInstant/OffsetTimeDemo/src/OffsetTimeDemo.java @@ -0,0 +1,36 @@ +import java.time.Instant; +import java.time.OffsetTime; +import java.time.ZoneId; + +public class OffsetTimeDemo +{ + + public static void main(String[] args) + { + + Instant instant = Instant.now(); + System.out.println("instant = " + instant); + + ZoneId zoneId = ZoneId.systemDefault(); + System.out.println("zondId = "+zoneId); + + /* + * Obtains an instance of OffsetTime from an Instant and zone ID. + * + * Parameters: + * + * instant - the instant to create the time from, not null + * + * zone - the time-zone, which may be an offset, not null + * + * Returns: + * + * the offset time, not null + */ + + OffsetTime offsetTime = OffsetTime.ofInstant(instant, zoneId); + System.out.println("offsetTime = " + offsetTime); + + } + +} diff --git a/BasicJava/OffsetTimeDemo_ofInstant/Output.txt b/BasicJava/OffsetTimeDemo_ofInstant/Output.txt new file mode 100644 index 000000000..00ae41d53 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_ofInstant/Output.txt @@ -0,0 +1,3 @@ +instant = 2018-02-04T02:36:47.762Z +zondId = Asia/Calcutta +offsetTime = 08:06:47.762+05:30 diff --git a/BasicJava/OffsetTimeDemo_of_methods/OffsetTimeDemo/.classpath b/BasicJava/OffsetTimeDemo_of_methods/OffsetTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetTimeDemo_of_methods/OffsetTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetTimeDemo_of_methods/OffsetTimeDemo/.project b/BasicJava/OffsetTimeDemo_of_methods/OffsetTimeDemo/.project new file mode 100644 index 000000000..d1f0664d6 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_of_methods/OffsetTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetTimeDemo_of_methods/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetTimeDemo_of_methods/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_of_methods/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetTimeDemo_of_methods/OffsetTimeDemo/bin/OffsetTimeDemo.class b/BasicJava/OffsetTimeDemo_of_methods/OffsetTimeDemo/bin/OffsetTimeDemo.class new file mode 100644 index 000000000..c05263fc9 Binary files /dev/null and b/BasicJava/OffsetTimeDemo_of_methods/OffsetTimeDemo/bin/OffsetTimeDemo.class differ diff --git a/BasicJava/OffsetTimeDemo_of_methods/OffsetTimeDemo/src/OffsetTimeDemo.java b/BasicJava/OffsetTimeDemo_of_methods/OffsetTimeDemo/src/OffsetTimeDemo.java new file mode 100644 index 000000000..91b614a7a --- /dev/null +++ b/BasicJava/OffsetTimeDemo_of_methods/OffsetTimeDemo/src/OffsetTimeDemo.java @@ -0,0 +1,50 @@ +import java.time.LocalTime; +import java.time.OffsetTime; +import java.time.ZoneOffset; + +public class OffsetTimeDemo +{ + + public static void main(String[] args) + { + + /* + * Parameters: + * + * hour - the hour-of-day to represent, from 0 to 23 + * + * minute - the minute-of-hour to represent, from 0 to 59 + * + * second - the second-of-minute to represent, from 0 to 59 + * + * nanoOfSecond - the nano-of-second to represent, from 0 to + * 999,999,999 + * + * offset - the zone offset, not null + * + * Returns: + * + * the offset time, not null + */ + + OffsetTime offsetTime1 = OffsetTime.of(6, 30, 40, 50000, + ZoneOffset.UTC); + System.out.println("offsetTime1 = " + offsetTime1); + + LocalTime localTime = LocalTime.now(); + /* + * Parameters: + * + * time - the local time, not null + * + * offset - the zone offset, not null + * + * Returns: + * + * the offset time, not null + */ + OffsetTime offsetTime2 = OffsetTime.of(localTime, ZoneOffset.UTC); + System.out.println("offsetTime2 = " + offsetTime2); + } + +} diff --git a/BasicJava/OffsetTimeDemo_of_methods/Output.txt b/BasicJava/OffsetTimeDemo_of_methods/Output.txt new file mode 100644 index 000000000..4987782b7 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_of_methods/Output.txt @@ -0,0 +1,2 @@ +offsetTime1 = 06:30:40.000050Z +offsetTime2 = 07:51:57.581Z diff --git a/BasicJava/OffsetTimeDemo_plus/OffsetTimeDemo/.classpath b/BasicJava/OffsetTimeDemo_plus/OffsetTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetTimeDemo_plus/OffsetTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetTimeDemo_plus/OffsetTimeDemo/.project b/BasicJava/OffsetTimeDemo_plus/OffsetTimeDemo/.project new file mode 100644 index 000000000..d1f0664d6 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_plus/OffsetTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetTimeDemo_plus/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetTimeDemo_plus/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_plus/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetTimeDemo_plus/OffsetTimeDemo/bin/OffsetTimeDemo.class b/BasicJava/OffsetTimeDemo_plus/OffsetTimeDemo/bin/OffsetTimeDemo.class new file mode 100644 index 000000000..b1797afc7 Binary files /dev/null and b/BasicJava/OffsetTimeDemo_plus/OffsetTimeDemo/bin/OffsetTimeDemo.class differ diff --git a/BasicJava/OffsetTimeDemo_plus/OffsetTimeDemo/src/OffsetTimeDemo.java b/BasicJava/OffsetTimeDemo_plus/OffsetTimeDemo/src/OffsetTimeDemo.java new file mode 100644 index 000000000..b78bd07ba --- /dev/null +++ b/BasicJava/OffsetTimeDemo_plus/OffsetTimeDemo/src/OffsetTimeDemo.java @@ -0,0 +1,26 @@ +import java.time.OffsetTime; + +public class OffsetTimeDemo +{ + + public static void main(String[] args) + { + + OffsetTime offsetTime1 = OffsetTime.now(); + System.out.println("offsetTime1 = " + offsetTime1); + + OffsetTime offsetTime2 = offsetTime1.plusHours(1); + System.out.println("Hour changed = " + offsetTime2); + + OffsetTime offsetTime3 = offsetTime2.plusMinutes(10); + System.out.println("Min changed = " + offsetTime3); + + OffsetTime offsetTime4 = offsetTime3.plusSeconds(20); + System.out.println("Sec changed = " + offsetTime4); + + OffsetTime offsetTime5 = offsetTime4.plusNanos(50); + System.out.println("NanoSec changed = " + offsetTime5); + + } + +} diff --git a/BasicJava/OffsetTimeDemo_plus/Output.txt b/BasicJava/OffsetTimeDemo_plus/Output.txt new file mode 100644 index 000000000..a1366f41c --- /dev/null +++ b/BasicJava/OffsetTimeDemo_plus/Output.txt @@ -0,0 +1,5 @@ +offsetTime1 = 09:52:52.892+05:30 +Hour changed = 10:52:52.892+05:30 +Min changed = 11:02:52.892+05:30 +Sec changed = 11:03:12.892+05:30 +NanoSec changed = 11:03:12.892000050+05:30 diff --git a/BasicJava/OffsetTimeDemo_plus_long_unit/OffsetTimeDemo/.classpath b/BasicJava/OffsetTimeDemo_plus_long_unit/OffsetTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetTimeDemo_plus_long_unit/OffsetTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetTimeDemo_plus_long_unit/OffsetTimeDemo/.project b/BasicJava/OffsetTimeDemo_plus_long_unit/OffsetTimeDemo/.project new file mode 100644 index 000000000..d1f0664d6 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_plus_long_unit/OffsetTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetTimeDemo_plus_long_unit/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetTimeDemo_plus_long_unit/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_plus_long_unit/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetTimeDemo_plus_long_unit/OffsetTimeDemo/bin/OffsetTimeDemo.class b/BasicJava/OffsetTimeDemo_plus_long_unit/OffsetTimeDemo/bin/OffsetTimeDemo.class new file mode 100644 index 000000000..8121b0719 Binary files /dev/null and b/BasicJava/OffsetTimeDemo_plus_long_unit/OffsetTimeDemo/bin/OffsetTimeDemo.class differ diff --git a/BasicJava/OffsetTimeDemo_plus_long_unit/OffsetTimeDemo/src/OffsetTimeDemo.java b/BasicJava/OffsetTimeDemo_plus_long_unit/OffsetTimeDemo/src/OffsetTimeDemo.java new file mode 100644 index 000000000..7e57d86d5 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_plus_long_unit/OffsetTimeDemo/src/OffsetTimeDemo.java @@ -0,0 +1,33 @@ +import java.time.OffsetTime; +import java.time.temporal.ChronoUnit; + +public class OffsetTimeDemo +{ + + public static void main(String[] args) + { + OffsetTime offsetTime1 = OffsetTime.now(); + System.out.println("offsetTime1 = " + offsetTime1); + + /* + * Parameters: + * + * amountToAdd - the amount of the unit to add to the result, + * may be negative + * + * unit - the unit of the amount to add, not null + * + * Returns: + * + * an OffsetTime based on this time with the specified + * amount added, not null + */ + OffsetTime offsetTime2 = offsetTime1.plus(2, ChronoUnit.HOURS); + System.out.println("offsetTime2 = " + offsetTime2); + + + OffsetTime offsetTime3 = offsetTime2.plus(20, ChronoUnit.MINUTES); + System.out.println("offsetTime3 = " + offsetTime3); + } + +} diff --git a/BasicJava/OffsetTimeDemo_plus_long_unit/Output.txt b/BasicJava/OffsetTimeDemo_plus_long_unit/Output.txt new file mode 100644 index 000000000..54967cf21 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_plus_long_unit/Output.txt @@ -0,0 +1,3 @@ +offsetTime1 = 08:16:57.698+05:30 +offsetTime2 = 10:16:57.698+05:30 +offsetTime3 = 10:36:57.698+05:30 diff --git a/BasicJava/OffsetTimeDemo_plus_temporalAmount/OffsetTimeDemo/.classpath b/BasicJava/OffsetTimeDemo_plus_temporalAmount/OffsetTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetTimeDemo_plus_temporalAmount/OffsetTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetTimeDemo_plus_temporalAmount/OffsetTimeDemo/.project b/BasicJava/OffsetTimeDemo_plus_temporalAmount/OffsetTimeDemo/.project new file mode 100644 index 000000000..d1f0664d6 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_plus_temporalAmount/OffsetTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetTimeDemo_plus_temporalAmount/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetTimeDemo_plus_temporalAmount/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_plus_temporalAmount/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetTimeDemo_plus_temporalAmount/OffsetTimeDemo/bin/OffsetTimeDemo.class b/BasicJava/OffsetTimeDemo_plus_temporalAmount/OffsetTimeDemo/bin/OffsetTimeDemo.class new file mode 100644 index 000000000..5fac3cbe6 Binary files /dev/null and b/BasicJava/OffsetTimeDemo_plus_temporalAmount/OffsetTimeDemo/bin/OffsetTimeDemo.class differ diff --git a/BasicJava/OffsetTimeDemo_plus_temporalAmount/OffsetTimeDemo/src/OffsetTimeDemo.java b/BasicJava/OffsetTimeDemo_plus_temporalAmount/OffsetTimeDemo/src/OffsetTimeDemo.java new file mode 100644 index 000000000..775fadde6 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_plus_temporalAmount/OffsetTimeDemo/src/OffsetTimeDemo.java @@ -0,0 +1,29 @@ +import java.time.Duration; +import java.time.OffsetTime; + +public class OffsetTimeDemo +{ + + public static void main(String[] args) + { + OffsetTime offsetTime1 = OffsetTime.now(); + System.out.println("offsetTime1 = " + offsetTime1); + + Duration duration = Duration.ofHours(2); + System.out.println("duration = "+duration); + + /* + * Parameters: + * + * amountToAdd - the amount to add, not null + * + * Returns: + * + * an OffsetTime based on this time with the addition made, + * not null + */ + OffsetTime offsetTime2 = offsetTime1.plus(duration); + System.out.println("offsetTime2 = " + offsetTime2); + } + +} diff --git a/BasicJava/OffsetTimeDemo_plus_temporalAmount/Output.txt b/BasicJava/OffsetTimeDemo_plus_temporalAmount/Output.txt new file mode 100644 index 000000000..bfc32cf81 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_plus_temporalAmount/Output.txt @@ -0,0 +1,3 @@ +offsetTime1 = 07:58:35.706+05:30 +duration = PT2H +offsetTime2 = 09:58:35.706+05:30 diff --git a/BasicJava/OffsetTimeDemo_range/OffsetTimeDemo/.classpath b/BasicJava/OffsetTimeDemo_range/OffsetTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetTimeDemo_range/OffsetTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetTimeDemo_range/OffsetTimeDemo/.project b/BasicJava/OffsetTimeDemo_range/OffsetTimeDemo/.project new file mode 100644 index 000000000..d1f0664d6 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_range/OffsetTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetTimeDemo_range/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetTimeDemo_range/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_range/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetTimeDemo_range/OffsetTimeDemo/bin/OffsetTimeDemo.class b/BasicJava/OffsetTimeDemo_range/OffsetTimeDemo/bin/OffsetTimeDemo.class new file mode 100644 index 000000000..808fa0e99 Binary files /dev/null and b/BasicJava/OffsetTimeDemo_range/OffsetTimeDemo/bin/OffsetTimeDemo.class differ diff --git a/BasicJava/OffsetTimeDemo_range/OffsetTimeDemo/src/OffsetTimeDemo.java b/BasicJava/OffsetTimeDemo_range/OffsetTimeDemo/src/OffsetTimeDemo.java new file mode 100644 index 000000000..0b1030793 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_range/OffsetTimeDemo/src/OffsetTimeDemo.java @@ -0,0 +1,32 @@ +import java.time.OffsetTime; +import java.time.temporal.ChronoField; +import java.time.temporal.ValueRange; + +public class OffsetTimeDemo +{ + + public static void main(String[] args) + { + + OffsetTime offsetTime = OffsetTime.now(); + System.out.println("offsetTime = " + offsetTime); + + /* + * Gets the range of valid values for the specified field. + * + * Parameters: + * + * field - the field to query the range for, not null + * + * Returns: + * + * the range of valid values for the field, not null + */ + ValueRange valueRange = offsetTime.range(ChronoField.CLOCK_HOUR_OF_DAY); + + System.out.println("Range = " + valueRange); + System.out.println("Max = " + valueRange.getMaximum()); + System.out.println("min = " + valueRange.getMinimum()); + } + +} diff --git a/BasicJava/OffsetTimeDemo_range/Output.txt b/BasicJava/OffsetTimeDemo_range/Output.txt new file mode 100644 index 000000000..0cc4c2100 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_range/Output.txt @@ -0,0 +1,4 @@ +offsetTime = 08:19:20.784+05:30 +Range = 1 - 24 +Max = 24 +min = 1 diff --git a/BasicJava/OffsetTimeDemo_with/OffsetTimeDemo/.classpath b/BasicJava/OffsetTimeDemo_with/OffsetTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/OffsetTimeDemo_with/OffsetTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/OffsetTimeDemo_with/OffsetTimeDemo/.project b/BasicJava/OffsetTimeDemo_with/OffsetTimeDemo/.project new file mode 100644 index 000000000..d1f0664d6 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_with/OffsetTimeDemo/.project @@ -0,0 +1,17 @@ + + + OffsetTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/OffsetTimeDemo_with/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/OffsetTimeDemo_with/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_with/OffsetTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/OffsetTimeDemo_with/OffsetTimeDemo/bin/OffsetTimeDemo.class b/BasicJava/OffsetTimeDemo_with/OffsetTimeDemo/bin/OffsetTimeDemo.class new file mode 100644 index 000000000..4a97e951f Binary files /dev/null and b/BasicJava/OffsetTimeDemo_with/OffsetTimeDemo/bin/OffsetTimeDemo.class differ diff --git a/BasicJava/OffsetTimeDemo_with/OffsetTimeDemo/src/OffsetTimeDemo.java b/BasicJava/OffsetTimeDemo_with/OffsetTimeDemo/src/OffsetTimeDemo.java new file mode 100644 index 000000000..469513599 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_with/OffsetTimeDemo/src/OffsetTimeDemo.java @@ -0,0 +1,61 @@ +import java.time.OffsetTime; + +public class OffsetTimeDemo +{ + + public static void main(String[] args) + { + + OffsetTime offsetTime1 = OffsetTime.now(); + System.out.println("offsetTime1 = " + offsetTime1); + + /* + * Parameters: + * + * hour - the hour-of-day to set in the result, from 0 to 23 + * + * Returns:an OffsetTime based on this time with the requested + * hour, not null + */ + OffsetTime offsetTime2 = offsetTime1.withHour(1); + System.out.println("Hour changed = " + offsetTime2); + + /* + * Parameters: + * + * minute - the minute-of-hour to set in the result, from 0 to + * 59 + * + * Returns:an OffsetTime based on this time with the requested + * minute, not null + */ + OffsetTime offsetTime3 = offsetTime2.withMinute(10); + System.out.println("Min changed = " + offsetTime3); + + /* + * Parameters: + * + * second - the second-of-minute to set in the result, from 0 + * to 59 + * + * Returns:an OffsetTime based on this time with the requested + * second, not null + */ + OffsetTime offsetTime4 = offsetTime3.withSecond(20); + System.out.println("Sec changed = " + offsetTime4); + + /* + * Parameters: + * + * nanoOfSecond - the nano-of-second to set in the result, + * from 0 to 999,999,999 + * + * Returns:an OffsetTime based on this time with the requested + * nanosecond, not null + */ + OffsetTime offsetTime5 = offsetTime4.withNano(50); + System.out.println("NanoSec changed = " + offsetTime5); + + } + +} diff --git a/BasicJava/OffsetTimeDemo_with/Output.txt b/BasicJava/OffsetTimeDemo_with/Output.txt new file mode 100644 index 000000000..f480e3222 --- /dev/null +++ b/BasicJava/OffsetTimeDemo_with/Output.txt @@ -0,0 +1,5 @@ +offsetTime1 = 10:07:26.171+05:30 +Hour changed = 01:07:26.171+05:30 +Min changed = 01:10:26.171+05:30 +Sec changed = 01:10:20.171+05:30 +NanoSec changed = 01:10:20.000000050+05:30 diff --git a/BasicJava/PropertiesDemo_Intro_App/Output.txt b/BasicJava/PropertiesDemo_Intro_App/Output.txt new file mode 100644 index 000000000..11d0b5991 --- /dev/null +++ b/BasicJava/PropertiesDemo_Intro_App/Output.txt @@ -0,0 +1,2 @@ +user = root +password = oracle diff --git a/BasicJava/PropertiesDemo_Intro_App/PropertiesDemo/.classpath b/BasicJava/PropertiesDemo_Intro_App/PropertiesDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/PropertiesDemo_Intro_App/PropertiesDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/PropertiesDemo_Intro_App/PropertiesDemo/.project b/BasicJava/PropertiesDemo_Intro_App/PropertiesDemo/.project new file mode 100644 index 000000000..4a6f3ffb3 --- /dev/null +++ b/BasicJava/PropertiesDemo_Intro_App/PropertiesDemo/.project @@ -0,0 +1,17 @@ + + + PropertiesDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/PropertiesDemo_Intro_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/PropertiesDemo_Intro_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/PropertiesDemo_Intro_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/PropertiesDemo_Intro_App/PropertiesDemo/bin/PropertiesDemo.class b/BasicJava/PropertiesDemo_Intro_App/PropertiesDemo/bin/PropertiesDemo.class new file mode 100644 index 000000000..055830d50 Binary files /dev/null and b/BasicJava/PropertiesDemo_Intro_App/PropertiesDemo/bin/PropertiesDemo.class differ diff --git a/BasicJava/PropertiesDemo_Intro_App/PropertiesDemo/db.properties b/BasicJava/PropertiesDemo_Intro_App/PropertiesDemo/db.properties new file mode 100644 index 000000000..f3738306e --- /dev/null +++ b/BasicJava/PropertiesDemo_Intro_App/PropertiesDemo/db.properties @@ -0,0 +1,2 @@ +user=root +password=oracle \ No newline at end of file diff --git a/BasicJava/PropertiesDemo_Intro_App/PropertiesDemo/src/PropertiesDemo.java b/BasicJava/PropertiesDemo_Intro_App/PropertiesDemo/src/PropertiesDemo.java new file mode 100644 index 000000000..5c1078976 --- /dev/null +++ b/BasicJava/PropertiesDemo_Intro_App/PropertiesDemo/src/PropertiesDemo.java @@ -0,0 +1,55 @@ +import java.io.FileReader; +import java.io.IOException; +import java.util.Properties; + +/* + * public String getProperty(String key) + * + * Parameters: + * ---------- + * + * key - the property key. + * + * Returns: + * ------- + * + * the value in this property list with the specified + * key value. + */ +class PropertiesDemo +{ + + public static void main(String[] args) throws IOException + { + FileReader fileReader = null; + try + { + fileReader = new FileReader("db.properties"); + + Properties p = new Properties(); + /* + * Reads a property list (key and element pairs) + * from the input character stream in a simple + * line-oriented format. + */ + p.load(fileReader); + + /* + * Searches for the property with the specified + * key in this property list. + */ + String user = p.getProperty("user"); + String password = p.getProperty("password"); + + System.out.println("user = "+user); + System.out.println("password = "+password); + } + finally + { + if (fileReader != null) + { + fileReader.close(); + } + } + } +} \ No newline at end of file diff --git a/BasicJava/PropertiesDemo_System_App/Output.txt b/BasicJava/PropertiesDemo_System_App/Output.txt new file mode 100644 index 000000000..519cf64bd --- /dev/null +++ b/BasicJava/PropertiesDemo_System_App/Output.txt @@ -0,0 +1,55 @@ +java.runtime.name = Java(TM) SE Runtime Environment +sun.boot.library.path = C:\Java\jre1.8.0_111\bin +java.vm.version = 25.111-b14 +java.vm.vendor = Oracle Corporation +java.vendor.url = http://java.oracle.com/ +path.separator = ; +java.vm.name = Java HotSpot(TM) 64-Bit Server VM +file.encoding.pkg = sun.io +user.script = +user.country = US +sun.java.launcher = SUN_STANDARD +sun.os.patch.level = Service Pack 1 +java.vm.specification.name = Java Virtual Machine Specification +user.dir = D:\eclipse\workspace\PropertiesDemo +java.runtime.version = 1.8.0_111-b14 +java.awt.graphicsenv = sun.awt.Win32GraphicsEnvironment +java.endorsed.dirs = C:\Java\jre1.8.0_111\lib\endorsed +os.arch = amd64 +java.io.tmpdir = C:\Users\Ramesh\AppData\Local\Temp\ +line.separator = + +java.vm.specification.vendor = Oracle Corporation +user.variant = +os.name = Windows 7 +sun.jnu.encoding = Cp1252 +java.library.path = C:\Java\jre1.8.0_111\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Java/jre1.8.0_111/bin/server;C:/Java/jre1.8.0_111/bin;C:/Java/jre1.8.0_111/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\Lenovo\Bluetooth Software\;C:\Program Files\Lenovo\Bluetooth Software\syswow64;C:\Program Files\OpenVPN\bin;C:\Java\jdk1.8.0_111\bin;C:\Program Files\TortoiseGit\bin;C:\Program Files\Git\cmd;C:\Program Files\TortoiseHg\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;D:\eclipse;;. +java.specification.name = Java Platform API Specification +java.class.version = 52.0 +sun.management.compiler = HotSpot 64-Bit Tiered Compilers +os.version = 6.1 +user.home = C:\Users\Ramesh +user.timezone = +java.awt.printerjob = sun.awt.windows.WPrinterJob +file.encoding = Cp1252 +java.specification.version = 1.8 +user.name = Ramesh +java.class.path = D:\eclipse\workspace\PropertiesDemo\bin +java.vm.specification.version = 1.8 +sun.arch.data.model = 64 +java.home = C:\Java\jre1.8.0_111 +sun.java.command = PropertiesDemo +java.specification.vendor = Oracle Corporation +user.language = en +awt.toolkit = sun.awt.windows.WToolkit +java.vm.info = mixed mode +java.version = 1.8.0_111 +java.ext.dirs = C:\Java\jre1.8.0_111\lib\ext;C:\Windows\Sun\Java\lib\ext +sun.boot.class.path = C:\Java\jre1.8.0_111\lib\resources.jar;C:\Java\jre1.8.0_111\lib\rt.jar;C:\Java\jre1.8.0_111\lib\sunrsasign.jar;C:\Java\jre1.8.0_111\lib\jsse.jar;C:\Java\jre1.8.0_111\lib\jce.jar;C:\Java\jre1.8.0_111\lib\charsets.jar;C:\Java\jre1.8.0_111\lib\jfr.jar;C:\Java\jre1.8.0_111\classes +java.vendor = Oracle Corporation +file.separator = \ +java.vendor.url.bug = http://bugreport.sun.com/bugreport/ +sun.cpu.endian = little +sun.io.unicode.encoding = UnicodeLittle +sun.desktop = windows +sun.cpu.isalist = amd64 diff --git a/BasicJava/PropertiesDemo_System_App/PropertiesDemo/.classpath b/BasicJava/PropertiesDemo_System_App/PropertiesDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/PropertiesDemo_System_App/PropertiesDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/PropertiesDemo_System_App/PropertiesDemo/.project b/BasicJava/PropertiesDemo_System_App/PropertiesDemo/.project new file mode 100644 index 000000000..4a6f3ffb3 --- /dev/null +++ b/BasicJava/PropertiesDemo_System_App/PropertiesDemo/.project @@ -0,0 +1,17 @@ + + + PropertiesDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/PropertiesDemo_System_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/PropertiesDemo_System_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/PropertiesDemo_System_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/PropertiesDemo_System_App/PropertiesDemo/bin/PropertiesDemo.class b/BasicJava/PropertiesDemo_System_App/PropertiesDemo/bin/PropertiesDemo.class new file mode 100644 index 000000000..631059c23 Binary files /dev/null and b/BasicJava/PropertiesDemo_System_App/PropertiesDemo/bin/PropertiesDemo.class differ diff --git a/BasicJava/PropertiesDemo_System_App/PropertiesDemo/src/PropertiesDemo.java b/BasicJava/PropertiesDemo_System_App/PropertiesDemo/src/PropertiesDemo.java new file mode 100644 index 000000000..eca451b31 --- /dev/null +++ b/BasicJava/PropertiesDemo_System_App/PropertiesDemo/src/PropertiesDemo.java @@ -0,0 +1,40 @@ +import java.io.IOException; +import java.util.Iterator; +import java.util.Properties; +import java.util.Set; + +class PropertiesDemo +{ + + public static void main(String[] args) throws IOException + { + + /* + * Returns the system properties + */ + Properties p = System.getProperties(); + + /* + * Returns a set of keys in this property list where + * the key and its corresponding value are strings, + * including distinct keys in the default property + * list if a key of the same name has not already + * been found from the main properties list. + */ + Set set = p.stringPropertyNames(); + + Iterator itr = set.iterator(); + + while (itr.hasNext()) + { + String key = (String) itr.next(); + /* + * Gets the system property indicated by the + * specified key. + */ + String value = p.getProperty(key); + System.out.println(key + " = " + value); + } + + } +} \ No newline at end of file diff --git a/BasicJava/PropertiesDemo_default_Value_App/Output.txt b/BasicJava/PropertiesDemo_default_Value_App/Output.txt new file mode 100644 index 000000000..8dcebc193 --- /dev/null +++ b/BasicJava/PropertiesDemo_default_Value_App/Output.txt @@ -0,0 +1,2 @@ +user = root +password = Oracle diff --git a/BasicJava/PropertiesDemo_default_Value_App/PropertiesDemo/.classpath b/BasicJava/PropertiesDemo_default_Value_App/PropertiesDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/PropertiesDemo_default_Value_App/PropertiesDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/PropertiesDemo_default_Value_App/PropertiesDemo/.project b/BasicJava/PropertiesDemo_default_Value_App/PropertiesDemo/.project new file mode 100644 index 000000000..4a6f3ffb3 --- /dev/null +++ b/BasicJava/PropertiesDemo_default_Value_App/PropertiesDemo/.project @@ -0,0 +1,17 @@ + + + PropertiesDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/PropertiesDemo_default_Value_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/PropertiesDemo_default_Value_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/PropertiesDemo_default_Value_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/PropertiesDemo_default_Value_App/PropertiesDemo/bin/PropertiesDemo.class b/BasicJava/PropertiesDemo_default_Value_App/PropertiesDemo/bin/PropertiesDemo.class new file mode 100644 index 000000000..8cb71dac1 Binary files /dev/null and b/BasicJava/PropertiesDemo_default_Value_App/PropertiesDemo/bin/PropertiesDemo.class differ diff --git a/BasicJava/PropertiesDemo_default_Value_App/PropertiesDemo/db.properties b/BasicJava/PropertiesDemo_default_Value_App/PropertiesDemo/db.properties new file mode 100644 index 000000000..be780b562 --- /dev/null +++ b/BasicJava/PropertiesDemo_default_Value_App/PropertiesDemo/db.properties @@ -0,0 +1 @@ +user=root diff --git a/BasicJava/PropertiesDemo_default_Value_App/PropertiesDemo/src/PropertiesDemo.java b/BasicJava/PropertiesDemo_default_Value_App/PropertiesDemo/src/PropertiesDemo.java new file mode 100644 index 000000000..72393060d --- /dev/null +++ b/BasicJava/PropertiesDemo_default_Value_App/PropertiesDemo/src/PropertiesDemo.java @@ -0,0 +1,65 @@ +import java.io.FileReader; +import java.io.IOException; +import java.util.Properties; + +/* + * public String getProperty(String key, String + * defaultValue) + * + * Parameters: + * ---------- + * + * key - the hashtable key. + * + * defaultValue - a default value. + * + * Returns: + * ------- + * + * the value in this property list with the specified + * key value. + */ + +class PropertiesDemo +{ + + public static void main(String[] args) throws IOException + { + FileReader fileReader = null; + try + { + fileReader = new FileReader("db.properties"); + + Properties p = new Properties(); + /* + * Reads a property list (key and element pairs) + * from the input character stream in a simple + * line-oriented format. + */ + p.load(fileReader); + + /* + * Searches for the property with the specified + * key in this property list. If the key is not + * found in this property list, the default + * property list, and its defaults, recursively, + * are then checked. The method returns the + * default value argument if the property is not + * found. + */ + + String user = p.getProperty("user", "system"); + String password = p.getProperty("password", "Oracle"); + + System.out.println("user = "+user); + System.out.println("password = "+password); + } + finally + { + if (fileReader != null) + { + fileReader.close(); + } + } + } +} \ No newline at end of file diff --git a/BasicJava/PropertiesDemo_list_App/Output.txt b/BasicJava/PropertiesDemo_list_App/Output.txt new file mode 100644 index 000000000..3856c461d --- /dev/null +++ b/BasicJava/PropertiesDemo_list_App/Output.txt @@ -0,0 +1,3 @@ +-- listing properties -- +user=root +password=oracle diff --git a/BasicJava/PropertiesDemo_list_App/PropertiesDemo/.classpath b/BasicJava/PropertiesDemo_list_App/PropertiesDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/PropertiesDemo_list_App/PropertiesDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/PropertiesDemo_list_App/PropertiesDemo/.project b/BasicJava/PropertiesDemo_list_App/PropertiesDemo/.project new file mode 100644 index 000000000..4a6f3ffb3 --- /dev/null +++ b/BasicJava/PropertiesDemo_list_App/PropertiesDemo/.project @@ -0,0 +1,17 @@ + + + PropertiesDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/PropertiesDemo_list_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/PropertiesDemo_list_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/PropertiesDemo_list_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/PropertiesDemo_list_App/PropertiesDemo/bin/PropertiesDemo.class b/BasicJava/PropertiesDemo_list_App/PropertiesDemo/bin/PropertiesDemo.class new file mode 100644 index 000000000..2398f8ed8 Binary files /dev/null and b/BasicJava/PropertiesDemo_list_App/PropertiesDemo/bin/PropertiesDemo.class differ diff --git a/BasicJava/PropertiesDemo_list_App/PropertiesDemo/db.properties b/BasicJava/PropertiesDemo_list_App/PropertiesDemo/db.properties new file mode 100644 index 000000000..f3738306e --- /dev/null +++ b/BasicJava/PropertiesDemo_list_App/PropertiesDemo/db.properties @@ -0,0 +1,2 @@ +user=root +password=oracle \ No newline at end of file diff --git a/BasicJava/PropertiesDemo_list_App/PropertiesDemo/src/PropertiesDemo.java b/BasicJava/PropertiesDemo_list_App/PropertiesDemo/src/PropertiesDemo.java new file mode 100644 index 000000000..5542230cb --- /dev/null +++ b/BasicJava/PropertiesDemo_list_App/PropertiesDemo/src/PropertiesDemo.java @@ -0,0 +1,40 @@ +import java.io.FileReader; +import java.io.IOException; +import java.util.Properties; + +/* + * public void list(PrintStream out) + * + * Parameters: + * ---------- + * + * out - an output stream. + */ +class PropertiesDemo +{ + + public static void main(String[] args) throws IOException + { + + try (FileReader fileReader = new FileReader("db.properties");) + { + + Properties p = new Properties(); + /* + * Reads a property list (key and element pairs) + * from the input character stream in a simple + * line-oriented format. + */ + p.load(fileReader); + + /* + * Prints this property list out to the + * specified output stream.This method is useful + * for debugging. + */ + p.list(System.out); + + } + + } +} \ No newline at end of file diff --git a/BasicJava/PropertiesDemo_list_pw_App/Output.txt b/BasicJava/PropertiesDemo_list_pw_App/Output.txt new file mode 100644 index 000000000..3856c461d --- /dev/null +++ b/BasicJava/PropertiesDemo_list_pw_App/Output.txt @@ -0,0 +1,3 @@ +-- listing properties -- +user=root +password=oracle diff --git a/BasicJava/PropertiesDemo_list_pw_App/PropertiesDemo/.classpath b/BasicJava/PropertiesDemo_list_pw_App/PropertiesDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/PropertiesDemo_list_pw_App/PropertiesDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/PropertiesDemo_list_pw_App/PropertiesDemo/.project b/BasicJava/PropertiesDemo_list_pw_App/PropertiesDemo/.project new file mode 100644 index 000000000..4a6f3ffb3 --- /dev/null +++ b/BasicJava/PropertiesDemo_list_pw_App/PropertiesDemo/.project @@ -0,0 +1,17 @@ + + + PropertiesDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/PropertiesDemo_list_pw_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/PropertiesDemo_list_pw_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/PropertiesDemo_list_pw_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/PropertiesDemo_list_pw_App/PropertiesDemo/bin/PropertiesDemo.class b/BasicJava/PropertiesDemo_list_pw_App/PropertiesDemo/bin/PropertiesDemo.class new file mode 100644 index 000000000..df4d0e9c6 Binary files /dev/null and b/BasicJava/PropertiesDemo_list_pw_App/PropertiesDemo/bin/PropertiesDemo.class differ diff --git a/BasicJava/PropertiesDemo_list_pw_App/PropertiesDemo/db.properties b/BasicJava/PropertiesDemo_list_pw_App/PropertiesDemo/db.properties new file mode 100644 index 000000000..f3738306e --- /dev/null +++ b/BasicJava/PropertiesDemo_list_pw_App/PropertiesDemo/db.properties @@ -0,0 +1,2 @@ +user=root +password=oracle \ No newline at end of file diff --git a/BasicJava/PropertiesDemo_list_pw_App/PropertiesDemo/src/PropertiesDemo.java b/BasicJava/PropertiesDemo_list_pw_App/PropertiesDemo/src/PropertiesDemo.java new file mode 100644 index 000000000..95a1d462a --- /dev/null +++ b/BasicJava/PropertiesDemo_list_pw_App/PropertiesDemo/src/PropertiesDemo.java @@ -0,0 +1,45 @@ +import java.io.FileReader; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Properties; + +/* + * public void list(PrintWriter out) + * + * Parameters: + * ---------- + * + * out - an output stream. + */ +class PropertiesDemo +{ + + public static void main(String[] args) throws IOException + { + + try (FileReader fileReader = new FileReader("db.properties");) + { + + Properties p = new Properties(); + /* + * Reads a property list (key and element pairs) + * from the input character stream in a simple + * line-oriented format. + */ + p.load(fileReader); + + PrintWriter writer = new PrintWriter(System.out); + /* + * print the list with a PrintWriter object + */ + p.list(writer); + + /* + * flush the stream + */ + writer.flush(); + + } + + } +} \ No newline at end of file diff --git a/BasicJava/PropertiesDemo_loadFromXML_App/Output.txt b/BasicJava/PropertiesDemo_loadFromXML_App/Output.txt new file mode 100644 index 000000000..70921953a --- /dev/null +++ b/BasicJava/PropertiesDemo_loadFromXML_App/Output.txt @@ -0,0 +1,2 @@ +Width = 15 +Height = 200 diff --git a/BasicJava/PropertiesDemo_loadFromXML_App/PropertiesDemo/.classpath b/BasicJava/PropertiesDemo_loadFromXML_App/PropertiesDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/PropertiesDemo_loadFromXML_App/PropertiesDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/PropertiesDemo_loadFromXML_App/PropertiesDemo/.project b/BasicJava/PropertiesDemo_loadFromXML_App/PropertiesDemo/.project new file mode 100644 index 000000000..4a6f3ffb3 --- /dev/null +++ b/BasicJava/PropertiesDemo_loadFromXML_App/PropertiesDemo/.project @@ -0,0 +1,17 @@ + + + PropertiesDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/PropertiesDemo_loadFromXML_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/PropertiesDemo_loadFromXML_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/PropertiesDemo_loadFromXML_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/PropertiesDemo_loadFromXML_App/PropertiesDemo/bin/PropertiesDemo.class b/BasicJava/PropertiesDemo_loadFromXML_App/PropertiesDemo/bin/PropertiesDemo.class new file mode 100644 index 000000000..e909e976d Binary files /dev/null and b/BasicJava/PropertiesDemo_loadFromXML_App/PropertiesDemo/bin/PropertiesDemo.class differ diff --git a/BasicJava/PropertiesDemo_loadFromXML_App/PropertiesDemo/properties.xml b/BasicJava/PropertiesDemo_loadFromXML_App/PropertiesDemo/properties.xml new file mode 100644 index 000000000..a6849295a --- /dev/null +++ b/BasicJava/PropertiesDemo_loadFromXML_App/PropertiesDemo/properties.xml @@ -0,0 +1,6 @@ + + + +15 +200 + diff --git a/BasicJava/PropertiesDemo_loadFromXML_App/PropertiesDemo/src/PropertiesDemo.java b/BasicJava/PropertiesDemo_loadFromXML_App/PropertiesDemo/src/PropertiesDemo.java new file mode 100644 index 000000000..6d6137395 --- /dev/null +++ b/BasicJava/PropertiesDemo_loadFromXML_App/PropertiesDemo/src/PropertiesDemo.java @@ -0,0 +1,45 @@ +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Enumeration; +import java.util.Properties; + +/* + * public void loadFromXML(InputStream in) throws + * IOException, InvalidPropertiesFormatException + * + * Parameters: + * ----------- + * + * in - the input stream from which to read the XML + * document. + */ +class PropertiesDemo +{ + + public static void main(String[] args) throws IOException + { + Properties p = new Properties(); + + try (FileInputStream fis = new FileInputStream("properties.xml")) + { + /* + * Loads all of the properties represented by + * the XML document on the specified input + * stream into this properties table. + */ + p.loadFromXML(fis); + + Enumeration enumeration = p.propertyNames(); + + while (enumeration.hasMoreElements()) + { + String key = (String) enumeration.nextElement(); + String value = p.getProperty(key); + + System.out.println(key + " = " + value); + } + + } + + } +} \ No newline at end of file diff --git a/BasicJava/PropertiesDemo_propertyNames_App/Output.txt b/BasicJava/PropertiesDemo_propertyNames_App/Output.txt new file mode 100644 index 000000000..17991a6cf --- /dev/null +++ b/BasicJava/PropertiesDemo_propertyNames_App/Output.txt @@ -0,0 +1,2 @@ +Key = user , Value = root +Key = password , Value = oracle diff --git a/BasicJava/PropertiesDemo_propertyNames_App/PropertiesDemo/.classpath b/BasicJava/PropertiesDemo_propertyNames_App/PropertiesDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/PropertiesDemo_propertyNames_App/PropertiesDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/PropertiesDemo_propertyNames_App/PropertiesDemo/.project b/BasicJava/PropertiesDemo_propertyNames_App/PropertiesDemo/.project new file mode 100644 index 000000000..4a6f3ffb3 --- /dev/null +++ b/BasicJava/PropertiesDemo_propertyNames_App/PropertiesDemo/.project @@ -0,0 +1,17 @@ + + + PropertiesDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/PropertiesDemo_propertyNames_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/PropertiesDemo_propertyNames_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/PropertiesDemo_propertyNames_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/PropertiesDemo_propertyNames_App/PropertiesDemo/bin/PropertiesDemo.class b/BasicJava/PropertiesDemo_propertyNames_App/PropertiesDemo/bin/PropertiesDemo.class new file mode 100644 index 000000000..32bc0ece0 Binary files /dev/null and b/BasicJava/PropertiesDemo_propertyNames_App/PropertiesDemo/bin/PropertiesDemo.class differ diff --git a/BasicJava/PropertiesDemo_propertyNames_App/PropertiesDemo/db.properties b/BasicJava/PropertiesDemo_propertyNames_App/PropertiesDemo/db.properties new file mode 100644 index 000000000..f3738306e --- /dev/null +++ b/BasicJava/PropertiesDemo_propertyNames_App/PropertiesDemo/db.properties @@ -0,0 +1,2 @@ +user=root +password=oracle \ No newline at end of file diff --git a/BasicJava/PropertiesDemo_propertyNames_App/PropertiesDemo/src/PropertiesDemo.java b/BasicJava/PropertiesDemo_propertyNames_App/PropertiesDemo/src/PropertiesDemo.java new file mode 100644 index 000000000..a8b62b98f --- /dev/null +++ b/BasicJava/PropertiesDemo_propertyNames_App/PropertiesDemo/src/PropertiesDemo.java @@ -0,0 +1,60 @@ +import java.io.FileReader; +import java.io.IOException; +import java.util.Enumeration; +import java.util.Properties; + +/* + * public Enumeration propertyNames() + * + * Returns: + * -------- + * + * an enumeration of all the keys in this property list, + * including the keys in the default property list. + */ + +class PropertiesDemo +{ + + public static void main(String[] args) throws IOException + { + FileReader fileReader = null; + try + { + fileReader = new FileReader("db.properties"); + + Properties p = new Properties(); + /* + * Reads a property list (key and element pairs) + * from the input character stream in a simple + * line-oriented format. + */ + p.load(fileReader); + + /* + * Returns an enumeration of all the keys in + * this property list, including distinct keys + * in the default property list if a key of the + * same name has not already been found from the + * main properties list. + */ + Enumeration enumeration = p.propertyNames(); + + while (enumeration.hasMoreElements()) + { + String key = (String) enumeration.nextElement(); + String value = p.getProperty(key); + + System.out.println("Key = " + key + " , Value = " + value); + } + + } + finally + { + if (fileReader != null) + { + fileReader.close(); + } + } + } +} \ No newline at end of file diff --git a/BasicJava/PropertiesDemo_storeToXML_App/Output.txt b/BasicJava/PropertiesDemo_storeToXML_App/Output.txt new file mode 100644 index 000000000..e13fb5f83 --- /dev/null +++ b/BasicJava/PropertiesDemo_storeToXML_App/Output.txt @@ -0,0 +1 @@ +Xml file is created successfully.. diff --git a/BasicJava/PropertiesDemo_storeToXML_App/PropertiesDemo/.classpath b/BasicJava/PropertiesDemo_storeToXML_App/PropertiesDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/PropertiesDemo_storeToXML_App/PropertiesDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/PropertiesDemo_storeToXML_App/PropertiesDemo/.project b/BasicJava/PropertiesDemo_storeToXML_App/PropertiesDemo/.project new file mode 100644 index 000000000..4a6f3ffb3 --- /dev/null +++ b/BasicJava/PropertiesDemo_storeToXML_App/PropertiesDemo/.project @@ -0,0 +1,17 @@ + + + PropertiesDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/PropertiesDemo_storeToXML_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/PropertiesDemo_storeToXML_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/PropertiesDemo_storeToXML_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/PropertiesDemo_storeToXML_App/PropertiesDemo/bin/PropertiesDemo.class b/BasicJava/PropertiesDemo_storeToXML_App/PropertiesDemo/bin/PropertiesDemo.class new file mode 100644 index 000000000..f86558924 Binary files /dev/null and b/BasicJava/PropertiesDemo_storeToXML_App/PropertiesDemo/bin/PropertiesDemo.class differ diff --git a/BasicJava/PropertiesDemo_storeToXML_App/PropertiesDemo/properties.xml b/BasicJava/PropertiesDemo_storeToXML_App/PropertiesDemo/properties.xml new file mode 100644 index 000000000..74df15e05 --- /dev/null +++ b/BasicJava/PropertiesDemo_storeToXML_App/PropertiesDemo/properties.xml @@ -0,0 +1,7 @@ + + + +Animal properties +2 years +Dog + diff --git a/BasicJava/PropertiesDemo_storeToXML_App/PropertiesDemo/src/PropertiesDemo.java b/BasicJava/PropertiesDemo_storeToXML_App/PropertiesDemo/src/PropertiesDemo.java new file mode 100644 index 000000000..1c3442957 --- /dev/null +++ b/BasicJava/PropertiesDemo_storeToXML_App/PropertiesDemo/src/PropertiesDemo.java @@ -0,0 +1,41 @@ +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Properties; + +/* + * public void storeToXML(OutputStream os, String + * comment) throws IOException + * + * Parameters: + * ----------- + * + * os - the output stream on which to emit the XML + * document. + * + * comment - a description of the property list, + * or null if no comment is desired. + */ + +class PropertiesDemo +{ + + public static void main(String[] args) throws IOException + { + Properties p = new Properties(); + // add some properties + p.put("name", "Dog"); + p.put("age", "2 years"); + + try (FileOutputStream fos = new FileOutputStream("properties.xml")) + { + /* + * Emits an XML document representing all of the + * properties contained in this table. + */ + p.storeToXML(fos, "Animal properties"); + System.out.println("Xml file is created successfully.."); + + } + + } +} \ No newline at end of file diff --git a/BasicJava/PropertiesDemo_storeToXML_encoding_App/Output.txt b/BasicJava/PropertiesDemo_storeToXML_encoding_App/Output.txt new file mode 100644 index 000000000..e13fb5f83 --- /dev/null +++ b/BasicJava/PropertiesDemo_storeToXML_encoding_App/Output.txt @@ -0,0 +1 @@ +Xml file is created successfully.. diff --git a/BasicJava/PropertiesDemo_storeToXML_encoding_App/PropertiesDemo/.classpath b/BasicJava/PropertiesDemo_storeToXML_encoding_App/PropertiesDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/PropertiesDemo_storeToXML_encoding_App/PropertiesDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/PropertiesDemo_storeToXML_encoding_App/PropertiesDemo/.project b/BasicJava/PropertiesDemo_storeToXML_encoding_App/PropertiesDemo/.project new file mode 100644 index 000000000..4a6f3ffb3 --- /dev/null +++ b/BasicJava/PropertiesDemo_storeToXML_encoding_App/PropertiesDemo/.project @@ -0,0 +1,17 @@ + + + PropertiesDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/PropertiesDemo_storeToXML_encoding_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/PropertiesDemo_storeToXML_encoding_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/PropertiesDemo_storeToXML_encoding_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/PropertiesDemo_storeToXML_encoding_App/PropertiesDemo/bin/PropertiesDemo.class b/BasicJava/PropertiesDemo_storeToXML_encoding_App/PropertiesDemo/bin/PropertiesDemo.class new file mode 100644 index 000000000..60a39ce13 Binary files /dev/null and b/BasicJava/PropertiesDemo_storeToXML_encoding_App/PropertiesDemo/bin/PropertiesDemo.class differ diff --git a/BasicJava/PropertiesDemo_storeToXML_encoding_App/PropertiesDemo/properties.xml b/BasicJava/PropertiesDemo_storeToXML_encoding_App/PropertiesDemo/properties.xml new file mode 100644 index 000000000..74df15e05 --- /dev/null +++ b/BasicJava/PropertiesDemo_storeToXML_encoding_App/PropertiesDemo/properties.xml @@ -0,0 +1,7 @@ + + + +Animal properties +2 years +Dog + diff --git a/BasicJava/PropertiesDemo_storeToXML_encoding_App/PropertiesDemo/src/PropertiesDemo.java b/BasicJava/PropertiesDemo_storeToXML_encoding_App/PropertiesDemo/src/PropertiesDemo.java new file mode 100644 index 000000000..c489a3b66 --- /dev/null +++ b/BasicJava/PropertiesDemo_storeToXML_encoding_App/PropertiesDemo/src/PropertiesDemo.java @@ -0,0 +1,45 @@ +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Properties; + +/* + * public void storeToXML(OutputStream os, String + * comment, String encoding) + * throws IOException + * + * Parameters: + * ----------- + * + * os - the output stream on which to emit the XML + * document. + * + * comment - a description of the property list, or null + * if no comment is desired. + * + * encoding - the name of a supported character encoding + */ + +class PropertiesDemo +{ + + public static void main(String[] args) throws IOException + { + Properties p = new Properties(); + // add some properties + p.put("name", "Dog"); + p.put("age", "2 years"); + + try (FileOutputStream fos = new FileOutputStream("properties.xml")) + { + /* + * Emits an XML document representing all of the + * properties contained in this table, using the + * specified encoding. + */ + p.storeToXML(fos, "Animal properties", "UTF-8"); + System.out.println("Xml file is created successfully.."); + + } + + } +} \ No newline at end of file diff --git a/BasicJava/PropertiesDemo_store_App/Output.txt b/BasicJava/PropertiesDemo_store_App/Output.txt new file mode 100644 index 000000000..44adcd3a4 --- /dev/null +++ b/BasicJava/PropertiesDemo_store_App/Output.txt @@ -0,0 +1 @@ +Property file is created successfully.. diff --git a/BasicJava/PropertiesDemo_store_App/PropertiesDemo/.classpath b/BasicJava/PropertiesDemo_store_App/PropertiesDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/PropertiesDemo_store_App/PropertiesDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/PropertiesDemo_store_App/PropertiesDemo/.project b/BasicJava/PropertiesDemo_store_App/PropertiesDemo/.project new file mode 100644 index 000000000..4a6f3ffb3 --- /dev/null +++ b/BasicJava/PropertiesDemo_store_App/PropertiesDemo/.project @@ -0,0 +1,17 @@ + + + PropertiesDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/PropertiesDemo_store_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/PropertiesDemo_store_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/PropertiesDemo_store_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/PropertiesDemo_store_App/PropertiesDemo/bin/PropertiesDemo.class b/BasicJava/PropertiesDemo_store_App/PropertiesDemo/bin/PropertiesDemo.class new file mode 100644 index 000000000..74e5942ae Binary files /dev/null and b/BasicJava/PropertiesDemo_store_App/PropertiesDemo/bin/PropertiesDemo.class differ diff --git a/BasicJava/PropertiesDemo_store_App/PropertiesDemo/info.properties b/BasicJava/PropertiesDemo_store_App/PropertiesDemo/info.properties new file mode 100644 index 000000000..fdfd34259 --- /dev/null +++ b/BasicJava/PropertiesDemo_store_App/PropertiesDemo/info.properties @@ -0,0 +1,4 @@ +#User Info +#Wed Mar 01 09:25:09 IST 2017 +email=ram@yahoo.com +name=Ram diff --git a/BasicJava/PropertiesDemo_store_App/PropertiesDemo/src/PropertiesDemo.java b/BasicJava/PropertiesDemo_store_App/PropertiesDemo/src/PropertiesDemo.java new file mode 100644 index 000000000..f7d018660 --- /dev/null +++ b/BasicJava/PropertiesDemo_store_App/PropertiesDemo/src/PropertiesDemo.java @@ -0,0 +1,39 @@ +import java.io.FileWriter; +import java.io.IOException; +import java.util.Properties; + +/* + * public void store(Writer writer, String comments) + * throws IOException + * + * Parameters: + * ---------- + * + * writer - an output character stream writer. + * comments - a description of the property list. + */ +class PropertiesDemo +{ + public static void main(String[] args) throws IOException + { + + try (FileWriter fileWriter = new FileWriter("info.properties")) + { + + Properties p = new Properties(); + p.setProperty("name", "Ram"); + p.setProperty("email", "ram@yahoo.com"); + + /* + * Writes this property list (key and element + * pairs) in this Properties table to the output + * character stream in a format suitable for + * using the load(Reader) method. + */ + p.store(fileWriter, "User Info"); + + System.out.println("Property file is created successfully.."); + } + + } +} \ No newline at end of file diff --git a/BasicJava/PropertiesDemo_stringPropertyNames_App/Output.txt b/BasicJava/PropertiesDemo_stringPropertyNames_App/Output.txt new file mode 100644 index 000000000..17991a6cf --- /dev/null +++ b/BasicJava/PropertiesDemo_stringPropertyNames_App/Output.txt @@ -0,0 +1,2 @@ +Key = user , Value = root +Key = password , Value = oracle diff --git a/BasicJava/PropertiesDemo_stringPropertyNames_App/PropertiesDemo/.classpath b/BasicJava/PropertiesDemo_stringPropertyNames_App/PropertiesDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/PropertiesDemo_stringPropertyNames_App/PropertiesDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/PropertiesDemo_stringPropertyNames_App/PropertiesDemo/.project b/BasicJava/PropertiesDemo_stringPropertyNames_App/PropertiesDemo/.project new file mode 100644 index 000000000..4a6f3ffb3 --- /dev/null +++ b/BasicJava/PropertiesDemo_stringPropertyNames_App/PropertiesDemo/.project @@ -0,0 +1,17 @@ + + + PropertiesDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/PropertiesDemo_stringPropertyNames_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/PropertiesDemo_stringPropertyNames_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/PropertiesDemo_stringPropertyNames_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/PropertiesDemo_stringPropertyNames_App/PropertiesDemo/bin/PropertiesDemo.class b/BasicJava/PropertiesDemo_stringPropertyNames_App/PropertiesDemo/bin/PropertiesDemo.class new file mode 100644 index 000000000..ab1d7b5aa Binary files /dev/null and b/BasicJava/PropertiesDemo_stringPropertyNames_App/PropertiesDemo/bin/PropertiesDemo.class differ diff --git a/BasicJava/PropertiesDemo_stringPropertyNames_App/PropertiesDemo/db.properties b/BasicJava/PropertiesDemo_stringPropertyNames_App/PropertiesDemo/db.properties new file mode 100644 index 000000000..f3738306e --- /dev/null +++ b/BasicJava/PropertiesDemo_stringPropertyNames_App/PropertiesDemo/db.properties @@ -0,0 +1,2 @@ +user=root +password=oracle \ No newline at end of file diff --git a/BasicJava/PropertiesDemo_stringPropertyNames_App/PropertiesDemo/src/PropertiesDemo.java b/BasicJava/PropertiesDemo_stringPropertyNames_App/PropertiesDemo/src/PropertiesDemo.java new file mode 100644 index 000000000..1ba59b6c0 --- /dev/null +++ b/BasicJava/PropertiesDemo_stringPropertyNames_App/PropertiesDemo/src/PropertiesDemo.java @@ -0,0 +1,64 @@ +import java.io.FileReader; +import java.io.IOException; +import java.util.Iterator; +import java.util.Properties; +import java.util.Set; + +/* + * public Set stringPropertyNames() + * + * Returns: + * -------- + * + * a set of keys in this property list where the key and + * its corresponding value are strings, including the + * keys in the default property list. + */ + +class PropertiesDemo +{ + + public static void main(String[] args) throws IOException + { + FileReader fileReader = null; + try + { + fileReader = new FileReader("db.properties"); + + Properties p = new Properties(); + /* + * Reads a property list (key and element pairs) + * from the input character stream in a simple + * line-oriented format. + */ + p.load(fileReader); + + /* + * Returns a set of keys in this property list + * where the key and its corresponding value are + * strings, including distinct keys in the + * default property list if a key of the same + * name has not already been found from the main + * properties list. + */ + Set set = p.stringPropertyNames(); + + Iterator itr = set.iterator(); + + while (itr.hasNext()) + { + String key = (String) itr.next(); + String value = p.getProperty(key); + System.out.println("Key = " + key + " , Value = " + value); + } + + } + finally + { + if (fileReader != null) + { + fileReader.close(); + } + } + } +} \ No newline at end of file diff --git a/BasicJava/PropertiesDemo_system_modify_App/Output.txt b/BasicJava/PropertiesDemo_system_modify_App/Output.txt new file mode 100644 index 000000000..0bdb3d483 --- /dev/null +++ b/BasicJava/PropertiesDemo_system_modify_App/Output.txt @@ -0,0 +1,58 @@ +-- listing properties -- +java.runtime.name=Java(TM) SE Runtime Environment +sun.boot.library.path=C:\Java\jre1.8.0_111\bin +java.vm.version=25.111-b14 +java.vm.vendor=Oracle Corporation +java.vendor.url=http://java.oracle.com/ +path.separator=; +java.vm.name=Java HotSpot(TM) 64-Bit Server VM +file.encoding.pkg=sun.io +user.script= +user.country=US +sun.java.launcher=SUN_STANDARD +sun.os.patch.level=Service Pack 1 +java.vm.specification.name=Java Virtual Machine Specification +user.dir=D:\eclipse\workspace\PropertiesDemo +java.runtime.version=1.8.0_111-b14 +java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment +java.endorsed.dirs=C:\Java\jre1.8.0_111\lib\endorsed +os.arch=amd64 +name=Peter +java.io.tmpdir=C:\Users\Ramesh\AppData\Local\Temp\ +line.separator= + +java.vm.specification.vendor=Oracle Corporation +user.variant= +os.name=Windows 7 +sun.jnu.encoding=Cp1252 +java.library.path=C:\Java\jre1.8.0_111\bin;C:\Windows\S... +email=peter@yahoo.com +java.specification.name=Java Platform API Specification +java.class.version=52.0 +sun.management.compiler=HotSpot 64-Bit Tiered Compilers +os.version=6.1 +user.home=C:\Users\Ramesh +user.timezone= +java.awt.printerjob=sun.awt.windows.WPrinterJob +file.encoding=Cp1252 +java.specification.version=1.8 +user.name=Ramesh +java.class.path=D:\eclipse\workspace\PropertiesDemo\bin +java.vm.specification.version=1.8 +sun.arch.data.model=64 +java.home=C:\Java\jre1.8.0_111 +sun.java.command=PropertiesDemo +java.specification.vendor=Oracle Corporation +user.language=en +awt.toolkit=sun.awt.windows.WToolkit +java.vm.info=mixed mode +java.version=1.8.0_111 +java.ext.dirs=C:\Java\jre1.8.0_111\lib\ext;C:\Windo... +sun.boot.class.path=C:\Java\jre1.8.0_111\lib\resources.ja... +java.vendor=Oracle Corporation +file.separator=\ +java.vendor.url.bug=http://bugreport.sun.com/bugreport/ +sun.cpu.endian=little +sun.io.unicode.encoding=UnicodeLittle +sun.desktop=windows +sun.cpu.isalist=amd64 diff --git a/BasicJava/PropertiesDemo_system_modify_App/PropertiesDemo/.classpath b/BasicJava/PropertiesDemo_system_modify_App/PropertiesDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/PropertiesDemo_system_modify_App/PropertiesDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/PropertiesDemo_system_modify_App/PropertiesDemo/.project b/BasicJava/PropertiesDemo_system_modify_App/PropertiesDemo/.project new file mode 100644 index 000000000..4a6f3ffb3 --- /dev/null +++ b/BasicJava/PropertiesDemo_system_modify_App/PropertiesDemo/.project @@ -0,0 +1,17 @@ + + + PropertiesDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/PropertiesDemo_system_modify_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/PropertiesDemo_system_modify_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/PropertiesDemo_system_modify_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/PropertiesDemo_system_modify_App/PropertiesDemo/bin/PropertiesDemo.class b/BasicJava/PropertiesDemo_system_modify_App/PropertiesDemo/bin/PropertiesDemo.class new file mode 100644 index 000000000..307cacce7 Binary files /dev/null and b/BasicJava/PropertiesDemo_system_modify_App/PropertiesDemo/bin/PropertiesDemo.class differ diff --git a/BasicJava/PropertiesDemo_system_modify_App/PropertiesDemo/myProperties.txt b/BasicJava/PropertiesDemo_system_modify_App/PropertiesDemo/myProperties.txt new file mode 100644 index 000000000..bfb553904 --- /dev/null +++ b/BasicJava/PropertiesDemo_system_modify_App/PropertiesDemo/myProperties.txt @@ -0,0 +1,2 @@ +name=Peter +email=peter@yahoo.com \ No newline at end of file diff --git a/BasicJava/PropertiesDemo_system_modify_App/PropertiesDemo/src/PropertiesDemo.java b/BasicJava/PropertiesDemo_system_modify_App/PropertiesDemo/src/PropertiesDemo.java new file mode 100644 index 000000000..19d884c02 --- /dev/null +++ b/BasicJava/PropertiesDemo_system_modify_App/PropertiesDemo/src/PropertiesDemo.java @@ -0,0 +1,36 @@ +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Properties; + +public class PropertiesDemo +{ + + public static void main(String[] args) throws IOException + { + /* + * Set up new properties object from file + * "myProperties.txt" + */ + FileInputStream fis = new FileInputStream("myProperties.txt"); + /* + * This statement initializes the new properties + * object, p, with the current set of system + * properties + */ + Properties p = new Properties(System.getProperties()); + p.load(fis); + + /* + * To modify the existing set of system properties, + * use System.setProperties. This method takes a + * Properties object that has been initialized to + * contain the properties to be set. This method + * replaces the entire set of system properties with + * the new set represented by the Properties object. * + */ + System.setProperties(p); + // display new properties + System.getProperties().list(System.out); + + } +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo-invoke_method/Output.txt b/BasicJava/ReflectionDemo-invoke_method/Output.txt new file mode 100644 index 000000000..45b983be3 --- /dev/null +++ b/BasicJava/ReflectionDemo-invoke_method/Output.txt @@ -0,0 +1 @@ +hi diff --git a/BasicJava/ReflectionDemo-invoke_method/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo-invoke_method/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo-invoke_method/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo-invoke_method/ReflectionDemo/.project b/BasicJava/ReflectionDemo-invoke_method/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo-invoke_method/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo-invoke_method/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo-invoke_method/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo-invoke_method/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo-invoke_method/ReflectionDemo/bin/DisplayMessage.class b/BasicJava/ReflectionDemo-invoke_method/ReflectionDemo/bin/DisplayMessage.class new file mode 100644 index 000000000..fd6152fcc Binary files /dev/null and b/BasicJava/ReflectionDemo-invoke_method/ReflectionDemo/bin/DisplayMessage.class differ diff --git a/BasicJava/ReflectionDemo-invoke_method/ReflectionDemo/bin/ReflectionDemo.class b/BasicJava/ReflectionDemo-invoke_method/ReflectionDemo/bin/ReflectionDemo.class new file mode 100644 index 000000000..4e5860ad5 Binary files /dev/null and b/BasicJava/ReflectionDemo-invoke_method/ReflectionDemo/bin/ReflectionDemo.class differ diff --git a/BasicJava/ReflectionDemo-invoke_method/ReflectionDemo/src/DisplayMessage.java b/BasicJava/ReflectionDemo-invoke_method/ReflectionDemo/src/DisplayMessage.java new file mode 100644 index 000000000..ed54ca308 --- /dev/null +++ b/BasicJava/ReflectionDemo-invoke_method/ReflectionDemo/src/DisplayMessage.java @@ -0,0 +1,8 @@ +class DisplayMessage +{ + public void displayMessage(String message) + { + System.out.println(message); + } +} + diff --git a/BasicJava/ReflectionDemo-invoke_method/ReflectionDemo/src/ReflectionDemo.java b/BasicJava/ReflectionDemo-invoke_method/ReflectionDemo/src/ReflectionDemo.java new file mode 100644 index 000000000..4aa563c5f --- /dev/null +++ b/BasicJava/ReflectionDemo-invoke_method/ReflectionDemo/src/ReflectionDemo.java @@ -0,0 +1,35 @@ +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +/** + * + * Invoking Methods using Method Object. + * + */ +public class ReflectionDemo +{ + public static void main(String[] args) + { + try + { + Class classObj = DisplayMessage.class; + Method method = classObj.getMethod("displayMessage", + new Class[] { String.class }); + + DisplayMessage displayMessageObj= classObj.newInstance(); + /* + * Invokes the underlying method represented by this Method object, + * on the specified object with the specified parameters. + */ + method.invoke(displayMessageObj, "hi"); + + } + catch (SecurityException | IllegalArgumentException + | NoSuchMethodException | IllegalAccessException + | InvocationTargetException | InstantiationException e) + { + e.printStackTrace(); + } + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo-invoke_staticmethod/Output.txt b/BasicJava/ReflectionDemo-invoke_staticmethod/Output.txt new file mode 100644 index 000000000..45b983be3 --- /dev/null +++ b/BasicJava/ReflectionDemo-invoke_staticmethod/Output.txt @@ -0,0 +1 @@ +hi diff --git a/BasicJava/ReflectionDemo-invoke_staticmethod/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo-invoke_staticmethod/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo-invoke_staticmethod/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo-invoke_staticmethod/ReflectionDemo/.project b/BasicJava/ReflectionDemo-invoke_staticmethod/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo-invoke_staticmethod/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo-invoke_staticmethod/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo-invoke_staticmethod/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo-invoke_staticmethod/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo-invoke_staticmethod/ReflectionDemo/bin/DisplayMessage.class b/BasicJava/ReflectionDemo-invoke_staticmethod/ReflectionDemo/bin/DisplayMessage.class new file mode 100644 index 000000000..e84d9398e Binary files /dev/null and b/BasicJava/ReflectionDemo-invoke_staticmethod/ReflectionDemo/bin/DisplayMessage.class differ diff --git a/BasicJava/ReflectionDemo-invoke_staticmethod/ReflectionDemo/bin/ReflectionDemo.class b/BasicJava/ReflectionDemo-invoke_staticmethod/ReflectionDemo/bin/ReflectionDemo.class new file mode 100644 index 000000000..1935d9ee0 Binary files /dev/null and b/BasicJava/ReflectionDemo-invoke_staticmethod/ReflectionDemo/bin/ReflectionDemo.class differ diff --git a/BasicJava/ReflectionDemo-invoke_staticmethod/ReflectionDemo/src/DisplayMessage.java b/BasicJava/ReflectionDemo-invoke_staticmethod/ReflectionDemo/src/DisplayMessage.java new file mode 100644 index 000000000..e6587f9e5 --- /dev/null +++ b/BasicJava/ReflectionDemo-invoke_staticmethod/ReflectionDemo/src/DisplayMessage.java @@ -0,0 +1,8 @@ +class DisplayMessage +{ + public static void displayMessage(String message) + { + System.out.println(message); + } +} + diff --git a/BasicJava/ReflectionDemo-invoke_staticmethod/ReflectionDemo/src/ReflectionDemo.java b/BasicJava/ReflectionDemo-invoke_staticmethod/ReflectionDemo/src/ReflectionDemo.java new file mode 100644 index 000000000..23881284a --- /dev/null +++ b/BasicJava/ReflectionDemo-invoke_staticmethod/ReflectionDemo/src/ReflectionDemo.java @@ -0,0 +1,35 @@ +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +/** + * + * Invoking Static Method using Method Object. + * + */ +public class ReflectionDemo +{ + public static void main(String[] args) + { + try + { + Class classObj = DisplayMessage.class; + + Method method = classObj.getMethod("displayMessage", + new Class[] { String.class }); + + /* + * Invokes the underlying method represented by this Method object, + * on the specified object with the specified parameters. + */ + method.invoke(null, "hi"); + + } + catch (SecurityException | IllegalArgumentException + | NoSuchMethodException | IllegalAccessException + | InvocationTargetException e) + { + e.printStackTrace(); + } + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_Call_Private_method/Output.txt b/BasicJava/ReflectionDemo_Call_Private_method/Output.txt new file mode 100644 index 000000000..865228379 --- /dev/null +++ b/BasicJava/ReflectionDemo_Call_Private_method/Output.txt @@ -0,0 +1 @@ +Peter J diff --git a/BasicJava/ReflectionDemo_Call_Private_method/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo_Call_Private_method/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo_Call_Private_method/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo_Call_Private_method/ReflectionDemo/.project b/BasicJava/ReflectionDemo_Call_Private_method/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo_Call_Private_method/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo_Call_Private_method/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo_Call_Private_method/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo_Call_Private_method/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo_Call_Private_method/ReflectionDemo/bin/ReflectionDemo.class b/BasicJava/ReflectionDemo_Call_Private_method/ReflectionDemo/bin/ReflectionDemo.class new file mode 100644 index 000000000..a2293cda2 Binary files /dev/null and b/BasicJava/ReflectionDemo_Call_Private_method/ReflectionDemo/bin/ReflectionDemo.class differ diff --git a/BasicJava/ReflectionDemo_Call_Private_method/ReflectionDemo/bin/Student.class b/BasicJava/ReflectionDemo_Call_Private_method/ReflectionDemo/bin/Student.class new file mode 100644 index 000000000..e62bd73cd Binary files /dev/null and b/BasicJava/ReflectionDemo_Call_Private_method/ReflectionDemo/bin/Student.class differ diff --git a/BasicJava/ReflectionDemo_Call_Private_method/ReflectionDemo/src/ReflectionDemo.java b/BasicJava/ReflectionDemo_Call_Private_method/ReflectionDemo/src/ReflectionDemo.java new file mode 100644 index 000000000..c3eb26cfb --- /dev/null +++ b/BasicJava/ReflectionDemo_Call_Private_method/ReflectionDemo/src/ReflectionDemo.java @@ -0,0 +1,45 @@ +import java.lang.reflect.Method; + +/** + * How to call private method from another class in java? + * + * We can call the private method from outside the class by changing + * the runtime behaviour of the class. + * + * By the help of "java.lang.Class" class and + * "java.lang.reflect.Method" class, we can call private method from + * any other class. + * + */ +public class ReflectionDemo +{ + public static void main(String[] args) + { + try + { + Class classObj = Class.forName("Student"); + Student studentObj = (Student) classObj.newInstance(); + Method method = classObj.getDeclaredMethod("showStudentFullName", null); + method.setAccessible(true); + /* + * Parameters: + * + * obj - the object the underlying method is invoked from + * + * args - the arguments used for the method call + * + * Returns: the result of dispatching the method + * represented by this object on obj with parameters args + * + */ + + method.invoke(studentObj, null); + } + catch (Exception e) + { + e.printStackTrace(); + } + + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_Call_Private_method/ReflectionDemo/src/Student.java b/BasicJava/ReflectionDemo_Call_Private_method/ReflectionDemo/src/Student.java new file mode 100644 index 000000000..5147e1f68 --- /dev/null +++ b/BasicJava/ReflectionDemo_Call_Private_method/ReflectionDemo/src/Student.java @@ -0,0 +1,13 @@ + +public class Student +{ + private String firstName = "Peter"; + private String lastName = "J"; + + + private void showStudentFullName() + { + System.out.println(firstName + " " + lastName); + } + +} diff --git a/BasicJava/ReflectionDemo_Intro/Output.txt b/BasicJava/ReflectionDemo_Intro/Output.txt new file mode 100644 index 000000000..e89b6462b --- /dev/null +++ b/BasicJava/ReflectionDemo_Intro/Output.txt @@ -0,0 +1,16 @@ +getName +setName +getAge +setAge +wait +wait +wait +equals +toString +hashCode +getClass +notify +notifyAll +---------------------------------- +name +age diff --git a/BasicJava/ReflectionDemo_Intro/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo_Intro/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo_Intro/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo_Intro/ReflectionDemo/.project b/BasicJava/ReflectionDemo_Intro/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo_Intro/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo_Intro/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo_Intro/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo_Intro/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo_Intro/ReflectionDemo/bin/ReflectionDemo.class b/BasicJava/ReflectionDemo_Intro/ReflectionDemo/bin/ReflectionDemo.class new file mode 100644 index 000000000..5e1112229 Binary files /dev/null and b/BasicJava/ReflectionDemo_Intro/ReflectionDemo/bin/ReflectionDemo.class differ diff --git a/BasicJava/ReflectionDemo_Intro/ReflectionDemo/bin/Student.class b/BasicJava/ReflectionDemo_Intro/ReflectionDemo/bin/Student.class new file mode 100644 index 000000000..d92290344 Binary files /dev/null and b/BasicJava/ReflectionDemo_Intro/ReflectionDemo/bin/Student.class differ diff --git a/BasicJava/ReflectionDemo_Intro/ReflectionDemo/src/ReflectionDemo.java b/BasicJava/ReflectionDemo_Intro/ReflectionDemo/src/ReflectionDemo.java new file mode 100644 index 000000000..2e910bcc8 --- /dev/null +++ b/BasicJava/ReflectionDemo_Intro/ReflectionDemo/src/ReflectionDemo.java @@ -0,0 +1,43 @@ +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +public class ReflectionDemo +{ + public static void main(String[] args) + { + Student student = new Student("Peter", 25); + + /* + * Returns: The Class object that represents the runtime class + * of this object. + * + */ + Class studentClass = student.getClass(); + + /* + * Returns: the array of Method objects representing the + * public methods of this class + */ + Method[] methodArray = studentClass.getMethods(); + + for (Method method : methodArray) + { + System.out.println(method.getName()); + } + + System.out.println("----------------------------------"); + + /* + * Returns:the array of Field objects representing all the + * declared fields of this class + */ + Field[] fieldArray = studentClass.getDeclaredFields(); + + for (Field field : fieldArray) + { + System.out.println(field.getName()); + } + + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_Intro/ReflectionDemo/src/Student.java b/BasicJava/ReflectionDemo_Intro/ReflectionDemo/src/Student.java new file mode 100644 index 000000000..1f18bee50 --- /dev/null +++ b/BasicJava/ReflectionDemo_Intro/ReflectionDemo/src/Student.java @@ -0,0 +1,33 @@ +public class Student +{ + private String name; + private int age; + + public Student(String name, int age) + { + super(); + this.name = name; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + +} diff --git a/BasicJava/ReflectionDemo_Intro_2_details/Output.txt b/BasicJava/ReflectionDemo_Intro_2_details/Output.txt new file mode 100644 index 000000000..ef5f01cc5 --- /dev/null +++ b/BasicJava/ReflectionDemo_Intro_2_details/Output.txt @@ -0,0 +1,19 @@ +The name of class is Display +The name of constructor is Display + +The public methods of class are : +method2 +method1 +wait +wait +wait +equals +toString +hashCode +getClass +notify +notifyAll + +Inside method2,The number is 19 +Inside method1,The string is JAVA +Private method invoked diff --git a/BasicJava/ReflectionDemo_Intro_2_details/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo_Intro_2_details/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo_Intro_2_details/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo_Intro_2_details/ReflectionDemo/.project b/BasicJava/ReflectionDemo_Intro_2_details/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo_Intro_2_details/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo_Intro_2_details/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo_Intro_2_details/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo_Intro_2_details/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo_Intro_2_details/ReflectionDemo/bin/Display.class b/BasicJava/ReflectionDemo_Intro_2_details/ReflectionDemo/bin/Display.class new file mode 100644 index 000000000..38fcd811a Binary files /dev/null and b/BasicJava/ReflectionDemo_Intro_2_details/ReflectionDemo/bin/Display.class differ diff --git a/BasicJava/ReflectionDemo_Intro_2_details/ReflectionDemo/bin/ReflectionDemo.class b/BasicJava/ReflectionDemo_Intro_2_details/ReflectionDemo/bin/ReflectionDemo.class new file mode 100644 index 000000000..a729c5079 Binary files /dev/null and b/BasicJava/ReflectionDemo_Intro_2_details/ReflectionDemo/bin/ReflectionDemo.class differ diff --git a/BasicJava/ReflectionDemo_Intro_2_details/ReflectionDemo/src/Display.java b/BasicJava/ReflectionDemo_Intro_2_details/ReflectionDemo/src/Display.java new file mode 100644 index 000000000..23dc10353 --- /dev/null +++ b/BasicJava/ReflectionDemo_Intro_2_details/ReflectionDemo/src/Display.java @@ -0,0 +1,24 @@ +class Display +{ + private String str; + + public Display() + { + str = "Welcome"; + } + + public void method1() + { + System.out.println("Inside method1,The string is " + str); + } + + public void method2(int n) + { + System.out.println("\nInside method2,The number is " + n); + } + + private void method3() + { + System.out.println("Private method invoked"); + } +} diff --git a/BasicJava/ReflectionDemo_Intro_2_details/ReflectionDemo/src/ReflectionDemo.java b/BasicJava/ReflectionDemo_Intro_2_details/ReflectionDemo/src/ReflectionDemo.java new file mode 100644 index 000000000..7033fde40 --- /dev/null +++ b/BasicJava/ReflectionDemo_Intro_2_details/ReflectionDemo/src/ReflectionDemo.java @@ -0,0 +1,103 @@ +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +/* + * A simple Java program to demonstrate the use of reflection. + */ +public class ReflectionDemo +{ + public static void main(String[] args) throws Exception + { + /* + * Creating object whose property is to be checked + */ + Display displayObj = new Display(); + + /* + * Creating class object from the object using getclass method + */ + Class classObj = displayObj.getClass(); + System.out.println("The name of class is " + classObj.getName()); + + /* + * Getting the constructor of the class through the object of the class + */ + Constructor constructor = classObj.getConstructor(); + System.out.println("The name of constructor is " + constructor.getName()); + + System.out.println("\nThe public methods of class are : "); + + /* + * Getting methods of the class through the object of the class by using + * getMethods + */ + Method[] methodArray = classObj.getMethods(); + + /* + * Printing method names + */ + for (Method method : methodArray) + { + System.out.println(method.getName()); + } + + /* + * Creates object of desired method by providing the method name and + * parameter class as arguments to the getDeclaredMethod + */ + Method method2Obj = classObj.getDeclaredMethod("method2", int.class); + + /* + * invokes the method at runtime + */ + method2Obj.invoke(displayObj, 19); + + /* + * Creates object of the desired field by providing the name of field as + * argument to the getDeclaredField method + */ + Field field = classObj.getDeclaredField("str"); + + /* + * Allows the object to access the field irrespective of the access + * specifier used with the field + */ + field.setAccessible(true); + + /* + * Takes object and the new value to be assigned to the field as + * arguments + */ + field.set(displayObj, "JAVA"); + + /* + * Creates object of desired method by providing the method name as + * argument to the getDeclaredMethod + */ + Method method1Obj = classObj.getDeclaredMethod("method1"); + + /* + * invokes the method at runtime + */ + method1Obj.invoke(displayObj); + + /* + * Creates object of the desired method by providing the name of method + * as argument to the getDeclaredMethod method + */ + Method method3Obj = classObj.getDeclaredMethod("method3"); + + /* + * Allows the object to access the method irrespective + * of the access specifier used with the method + */ + method3Obj.setAccessible(true); + + /* + * invokes the method at runtime + */ + method3Obj.invoke(displayObj); + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/.project b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/bin/ReflectionDemo1.class b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/bin/ReflectionDemo1.class new file mode 100644 index 000000000..143a5fe12 Binary files /dev/null and b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/bin/ReflectionDemo1.class differ diff --git a/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/bin/ReflectionDemo2.class b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/bin/ReflectionDemo2.class new file mode 100644 index 000000000..87310c8d6 Binary files /dev/null and b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/bin/ReflectionDemo2.class differ diff --git a/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/bin/ReflectionDemo3.class b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/bin/ReflectionDemo3.class new file mode 100644 index 000000000..f8c8e8247 Binary files /dev/null and b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/bin/ReflectionDemo3.class differ diff --git a/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/bin/ReflectionDemo4.class b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/bin/ReflectionDemo4.class new file mode 100644 index 000000000..57f3a9309 Binary files /dev/null and b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/bin/ReflectionDemo4.class differ diff --git a/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/bin/Student.class b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/bin/Student.class new file mode 100644 index 000000000..9c2c91c82 Binary files /dev/null and b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/bin/Student.class differ diff --git a/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/src/ReflectionDemo1.java b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/src/ReflectionDemo1.java new file mode 100644 index 000000000..e7c02d903 --- /dev/null +++ b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/src/ReflectionDemo1.java @@ -0,0 +1,22 @@ +public class ReflectionDemo1 +{ + public static void main(String[] args) + { + try + { + /* + * forName method takes fully qualified name of classes or interface + * as its argument and returns instance of the class assocaited with + * it. + */ + Class classObj = Class.forName("Student"); + System.out.println(classObj.getName()); + } + catch (ClassNotFoundException e) + { + e.printStackTrace(); + } + + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/src/ReflectionDemo2.java b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/src/ReflectionDemo2.java new file mode 100644 index 000000000..b59654e2f --- /dev/null +++ b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/src/ReflectionDemo2.java @@ -0,0 +1,40 @@ +import java.lang.reflect.Constructor; + +public class ReflectionDemo2 +{ + public static void main(String[] args) + { + + try + { + Class classObj = Class.forName("Student"); + + /* + * getConstructors() method returns array of Constructors object + * that represent all the public constructors of the invoking + * object. Remember, this method only returns public constructors. + */ + Constructor[] ct = classObj.getConstructors(); + for (int i = 0; i < ct.length; i++) + { + System.out.println(ct[i]); + } + + System.out.println("--------------------------------------"); + + /* + * If you want to see all the declared constructors of a class then + * use getDeclaredConstructors() + */ + Constructor[] cdt = classObj.getDeclaredConstructors(); + for (int i = 0; i < cdt.length; i++) + { + System.out.println(cdt[i]); + } + } + catch (ClassNotFoundException e) + { + e.printStackTrace(); + } + } +} diff --git a/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/src/ReflectionDemo3.java b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/src/ReflectionDemo3.java new file mode 100644 index 000000000..b652a213f --- /dev/null +++ b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/src/ReflectionDemo3.java @@ -0,0 +1,38 @@ +import java.lang.reflect.Method; + +public class ReflectionDemo3 +{ + public static void main(String[] args) + { + try + { + Class classObj = Class.forName("Student"); + + /* + * getMethods() method returns array of Method object that reflect + * all the public method of invoking object. + */ + Method[] methodArray = classObj.getMethods(); + for (int i = 0; i < methodArray.length; i++) + { + System.out.println(methodArray[i]); + } + + System.out.println("---------------------------------"); + + /* + * getDeclaredMethods() returns only the declared methods of the + * invoking class object. + */ + Method[] declaredMethodArray = classObj.getDeclaredMethods(); + for (Method method : declaredMethodArray) + { + System.out.println(method); + } + } + catch (ClassNotFoundException e) + { + e.printStackTrace(); + } + } +} diff --git a/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/src/ReflectionDemo4.java b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/src/ReflectionDemo4.java new file mode 100644 index 000000000..99cf0068c --- /dev/null +++ b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/src/ReflectionDemo4.java @@ -0,0 +1,41 @@ +import java.lang.reflect.Field; + +public class ReflectionDemo4 +{ + public static void main(String[] args) + { + try + { + Class classObj = Class.forName("Student"); + + /* + * getFields() returns an array containing Field objects reflecting + * all the accessible public members of the class or interface + * represented by this Class object. + */ + Field[] fieldArray = classObj.getFields(); + for (Field field : fieldArray) + { + System.out.println(field); + } + + System.out.println("-------------------------------"); + + /* + * getDeclaredFields() returns array of Field objects reflecting all + * the fields declared by the class or interface represented by this + * Class object. + */ + Field[] declaredFieldArray = classObj.getDeclaredFields(); + for (Field field : declaredFieldArray) + { + System.out.println(field); + } + + } + catch (ClassNotFoundException e) + { + e.printStackTrace(); + } + } +} diff --git a/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/src/Student.java b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/src/Student.java new file mode 100644 index 000000000..90971483c --- /dev/null +++ b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo/src/Student.java @@ -0,0 +1,30 @@ +class Student +{ + public String name; + public int age; + private String gender; + + public Student() + { + + } + + private Student(String name, int age) + { + super(); + this.name = name; + this.age = age; + } + + public void displayHello() + { + System.out.println("Hello"); + } + + + private void displayWelcome() + { + System.out.println("Welcome"); + } + +} diff --git a/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo1_Output.txt b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo1_Output.txt new file mode 100644 index 000000000..ee5ad868c --- /dev/null +++ b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo1_Output.txt @@ -0,0 +1 @@ +Student diff --git a/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo2_Output.txt b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo2_Output.txt new file mode 100644 index 000000000..55c94eece --- /dev/null +++ b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo2_Output.txt @@ -0,0 +1,4 @@ +public Student() +-------------------------------------- +public Student() +private Student(java.lang.String,int) diff --git a/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo3_Output.txt b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo3_Output.txt new file mode 100644 index 000000000..39083a6a4 --- /dev/null +++ b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo3_Output.txt @@ -0,0 +1,13 @@ +public void Student.displayHello() +public final void java.lang.Object.wait() throws java.lang.InterruptedException +public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException +public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException +public boolean java.lang.Object.equals(java.lang.Object) +public java.lang.String java.lang.Object.toString() +public native int java.lang.Object.hashCode() +public final native java.lang.Class java.lang.Object.getClass() +public final native void java.lang.Object.notify() +public final native void java.lang.Object.notifyAll() +--------------------------------- +public void Student.displayHello() +private void Student.displayWelcome() diff --git a/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo4_Output.txt b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo4_Output.txt new file mode 100644 index 000000000..3cbf53555 --- /dev/null +++ b/BasicJava/ReflectionDemo_Intro_3_details/ReflectionDemo4_Output.txt @@ -0,0 +1,6 @@ +public java.lang.String Student.name +public int Student.age +------------------------------- +public java.lang.String Student.name +public int Student.age +private java.lang.String Student.gender diff --git a/BasicJava/ReflectionDemo_access_annotation/Output.txt b/BasicJava/ReflectionDemo_access_annotation/Output.txt new file mode 100644 index 000000000..7f9393a2e --- /dev/null +++ b/BasicJava/ReflectionDemo_access_annotation/Output.txt @@ -0,0 +1 @@ +@MyAnnotation() diff --git a/BasicJava/ReflectionDemo_access_annotation/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo_access_annotation/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo_access_annotation/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo_access_annotation/ReflectionDemo/.project b/BasicJava/ReflectionDemo_access_annotation/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo_access_annotation/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo_access_annotation/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo_access_annotation/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo_access_annotation/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo_access_annotation/ReflectionDemo/bin/Display.class b/BasicJava/ReflectionDemo_access_annotation/ReflectionDemo/bin/Display.class new file mode 100644 index 000000000..8a96796fe Binary files /dev/null and b/BasicJava/ReflectionDemo_access_annotation/ReflectionDemo/bin/Display.class differ diff --git a/BasicJava/ReflectionDemo_access_annotation/ReflectionDemo/bin/MyAnnotation.class b/BasicJava/ReflectionDemo_access_annotation/ReflectionDemo/bin/MyAnnotation.class new file mode 100644 index 000000000..ae262baaf Binary files /dev/null and b/BasicJava/ReflectionDemo_access_annotation/ReflectionDemo/bin/MyAnnotation.class differ diff --git a/BasicJava/ReflectionDemo_access_annotation/ReflectionDemo/bin/ReflectionDemo.class b/BasicJava/ReflectionDemo_access_annotation/ReflectionDemo/bin/ReflectionDemo.class new file mode 100644 index 000000000..0d7ad0f47 Binary files /dev/null and b/BasicJava/ReflectionDemo_access_annotation/ReflectionDemo/bin/ReflectionDemo.class differ diff --git a/BasicJava/ReflectionDemo_access_annotation/ReflectionDemo/src/Display.java b/BasicJava/ReflectionDemo_access_annotation/ReflectionDemo/src/Display.java new file mode 100644 index 000000000..014a12ec5 --- /dev/null +++ b/BasicJava/ReflectionDemo_access_annotation/ReflectionDemo/src/Display.java @@ -0,0 +1,23 @@ +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Inherited +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface MyAnnotation + { + + } + +@MyAnnotation +class Display +{ + public void showMessage() + { + System.out.println("Hi"); + } +} + diff --git a/BasicJava/ReflectionDemo_access_annotation/ReflectionDemo/src/ReflectionDemo.java b/BasicJava/ReflectionDemo_access_annotation/ReflectionDemo/src/ReflectionDemo.java new file mode 100644 index 000000000..cb39fac41 --- /dev/null +++ b/BasicJava/ReflectionDemo_access_annotation/ReflectionDemo/src/ReflectionDemo.java @@ -0,0 +1,28 @@ +import java.lang.annotation.Annotation; + +/** + * + * We can access the class annotations of a class. + * + */ +public class ReflectionDemo +{ + public static void main(String[] args) + { + + Class classObj = Display.class; + + /* + * Returns:annotations present on this element. + */ + + Annotation[] annotationArray = classObj.getAnnotations(); + + for (Annotation annotation : annotationArray) + { + System.out.println(annotation); + } + + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo/.project b/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo/bin/Display.class b/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo/bin/Display.class new file mode 100644 index 000000000..da558183d Binary files /dev/null and b/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo/bin/Display.class differ diff --git a/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo/bin/MyAnnotation.class b/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo/bin/MyAnnotation.class new file mode 100644 index 000000000..3591c657a Binary files /dev/null and b/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo/bin/MyAnnotation.class differ diff --git a/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo/bin/ReflectionDemo1.class b/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo/bin/ReflectionDemo1.class new file mode 100644 index 000000000..1b091078d Binary files /dev/null and b/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo/bin/ReflectionDemo1.class differ diff --git a/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo/bin/ReflectionDemo2.class b/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo/bin/ReflectionDemo2.class new file mode 100644 index 000000000..005e3d296 Binary files /dev/null and b/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo/bin/ReflectionDemo2.class differ diff --git a/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo/src/Display.java b/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo/src/Display.java new file mode 100644 index 000000000..77c699d77 --- /dev/null +++ b/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo/src/Display.java @@ -0,0 +1,20 @@ +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) + +@interface MyAnnotation +{ + public String name(); + + public String value(); +} + +@MyAnnotation(name = "age", value = "23") +public class Display +{ + +} diff --git a/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo/src/ReflectionDemo1.java b/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo/src/ReflectionDemo1.java new file mode 100644 index 000000000..b004c57de --- /dev/null +++ b/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo/src/ReflectionDemo1.java @@ -0,0 +1,30 @@ +import java.lang.annotation.Annotation; + +/** + * We can access the annotations of a class, method or field at + * runtime. + * + * Class Annotations Example: + */ +public class ReflectionDemo1 +{ + public static void main(String[] args) + { + Class classObj = Display.class; + /* + * Returns:annotations present on this element + */ + Annotation[] annotationArray = classObj.getAnnotations(); + + for (Annotation annotation : annotationArray) + { + if (annotation instanceof MyAnnotation) + { + MyAnnotation myAnnotation = (MyAnnotation) annotation; + System.out.println("name: " + myAnnotation.name()); + System.out.println("value: " + myAnnotation.value()); + } + } + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo/src/ReflectionDemo2.java b/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo/src/ReflectionDemo2.java new file mode 100644 index 000000000..8a303cbbd --- /dev/null +++ b/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo/src/ReflectionDemo2.java @@ -0,0 +1,22 @@ +/** + * We can access the annotations of a class, method or field at + * runtime. + * + * Class Annotations Example: + */ +public class ReflectionDemo2 +{ + public static void main(String[] args) + { + Class classObj = Display.class; + /* + * Returns:this element's annotation for the specified + * annotation type if present on this element, else null + */ + MyAnnotation myAnnotation = classObj.getAnnotation(MyAnnotation.class); + + System.out.println("name: " + myAnnotation.name()); + System.out.println("value: " + myAnnotation.value()); + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo1_Output.txt b/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo1_Output.txt new file mode 100644 index 000000000..4a4fd0d0c --- /dev/null +++ b/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo1_Output.txt @@ -0,0 +1,2 @@ +name: age +value: 23 diff --git a/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo2_Output.txt b/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo2_Output.txt new file mode 100644 index 000000000..4a4fd0d0c --- /dev/null +++ b/BasicJava/ReflectionDemo_access_class_annotation/ReflectionDemo2_Output.txt @@ -0,0 +1,2 @@ +name: age +value: 23 diff --git a/BasicJava/ReflectionDemo_access_constructors/Output.txt b/BasicJava/ReflectionDemo_access_constructors/Output.txt new file mode 100644 index 000000000..7484011b2 --- /dev/null +++ b/BasicJava/ReflectionDemo_access_constructors/Output.txt @@ -0,0 +1,12 @@ +public java.util.ArrayList(java.util.Collection) +Name = java.util.ArrayList +ParameterCount = 1 +----------------------------- +public java.util.ArrayList() +Name = java.util.ArrayList +ParameterCount = 0 +----------------------------- +public java.util.ArrayList(int) +Name = java.util.ArrayList +ParameterCount = 1 +----------------------------- diff --git a/BasicJava/ReflectionDemo_access_constructors/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo_access_constructors/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo_access_constructors/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo_access_constructors/ReflectionDemo/.project b/BasicJava/ReflectionDemo_access_constructors/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo_access_constructors/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo_access_constructors/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo_access_constructors/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo_access_constructors/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo_access_constructors/ReflectionDemo/bin/ReflectionDemo.class b/BasicJava/ReflectionDemo_access_constructors/ReflectionDemo/bin/ReflectionDemo.class new file mode 100644 index 000000000..e3b192b1c Binary files /dev/null and b/BasicJava/ReflectionDemo_access_constructors/ReflectionDemo/bin/ReflectionDemo.class differ diff --git a/BasicJava/ReflectionDemo_access_constructors/ReflectionDemo/src/ReflectionDemo.java b/BasicJava/ReflectionDemo_access_constructors/ReflectionDemo/src/ReflectionDemo.java new file mode 100644 index 000000000..a5b71728e --- /dev/null +++ b/BasicJava/ReflectionDemo_access_constructors/ReflectionDemo/src/ReflectionDemo.java @@ -0,0 +1,33 @@ +import java.lang.reflect.Constructor; +import java.util.ArrayList; + +/** + * + * We can access the constructors of a class. + * + */ +public class ReflectionDemo +{ + public static void main(String[] args) + { + + Class classObj = ArrayList.class; + + /* + * Returns:the array of Constructor objects representing the public + * constructors of this class + */ + + Constructor[] constructorArray = classObj.getConstructors(); + + for (Constructor constructor : constructorArray) + { + System.out.println(constructor); + System.out.println("Name = "+constructor.getName()); + System.out.println("ParameterCount = "+constructor.getParameterCount()); + System.out.println("-----------------------------"); + } + + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_access_field_annotation/Output.txt b/BasicJava/ReflectionDemo_access_field_annotation/Output.txt new file mode 100644 index 000000000..348c20542 --- /dev/null +++ b/BasicJava/ReflectionDemo_access_field_annotation/Output.txt @@ -0,0 +1,2 @@ +name: age +value: 25 diff --git a/BasicJava/ReflectionDemo_access_field_annotation/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo_access_field_annotation/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo_access_field_annotation/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo_access_field_annotation/ReflectionDemo/.project b/BasicJava/ReflectionDemo_access_field_annotation/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo_access_field_annotation/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo_access_field_annotation/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo_access_field_annotation/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo_access_field_annotation/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo_access_field_annotation/ReflectionDemo/bin/Display.class b/BasicJava/ReflectionDemo_access_field_annotation/ReflectionDemo/bin/Display.class new file mode 100644 index 000000000..5039c416a Binary files /dev/null and b/BasicJava/ReflectionDemo_access_field_annotation/ReflectionDemo/bin/Display.class differ diff --git a/BasicJava/ReflectionDemo_access_field_annotation/ReflectionDemo/bin/MyAnnotation.class b/BasicJava/ReflectionDemo_access_field_annotation/ReflectionDemo/bin/MyAnnotation.class new file mode 100644 index 000000000..b6a0f64b7 Binary files /dev/null and b/BasicJava/ReflectionDemo_access_field_annotation/ReflectionDemo/bin/MyAnnotation.class differ diff --git a/BasicJava/ReflectionDemo_access_field_annotation/ReflectionDemo/bin/ReflectionDemo1.class b/BasicJava/ReflectionDemo_access_field_annotation/ReflectionDemo/bin/ReflectionDemo1.class new file mode 100644 index 000000000..336ef015e Binary files /dev/null and b/BasicJava/ReflectionDemo_access_field_annotation/ReflectionDemo/bin/ReflectionDemo1.class differ diff --git a/BasicJava/ReflectionDemo_access_field_annotation/ReflectionDemo/bin/ReflectionDemo2.class b/BasicJava/ReflectionDemo_access_field_annotation/ReflectionDemo/bin/ReflectionDemo2.class new file mode 100644 index 000000000..68e1dbda5 Binary files /dev/null and b/BasicJava/ReflectionDemo_access_field_annotation/ReflectionDemo/bin/ReflectionDemo2.class differ diff --git a/BasicJava/ReflectionDemo_access_field_annotation/ReflectionDemo/src/Display.java b/BasicJava/ReflectionDemo_access_field_annotation/ReflectionDemo/src/Display.java new file mode 100644 index 000000000..c2a656561 --- /dev/null +++ b/BasicJava/ReflectionDemo_access_field_annotation/ReflectionDemo/src/Display.java @@ -0,0 +1,21 @@ +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) + +@interface MyAnnotation +{ + public String name(); + + public String value(); +} + +public class Display +{ + + @MyAnnotation(name = "age", value = "25") + public String myField = null; +} diff --git a/BasicJava/ReflectionDemo_access_field_annotation/ReflectionDemo/src/ReflectionDemo1.java b/BasicJava/ReflectionDemo_access_field_annotation/ReflectionDemo/src/ReflectionDemo1.java new file mode 100644 index 000000000..3e7389b66 --- /dev/null +++ b/BasicJava/ReflectionDemo_access_field_annotation/ReflectionDemo/src/ReflectionDemo1.java @@ -0,0 +1,34 @@ +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; + +/** + * Example of a field with annotations + */ +public class ReflectionDemo1 +{ + public static void main(String[] args) + { + try + { + Class classObj = Display.class; + Field field = classObj.getField("myField"); + Annotation[] annotations = field.getDeclaredAnnotations(); + + for (Annotation annotation : annotations) + { + if (annotation instanceof MyAnnotation) + { + MyAnnotation myAnnotation = (MyAnnotation) annotation; + System.out.println("name: " + myAnnotation.name()); + System.out.println("value: " + myAnnotation.value()); + } + } + } + catch (NoSuchFieldException | SecurityException e) + { + e.printStackTrace(); + } + + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_access_field_annotation/ReflectionDemo/src/ReflectionDemo2.java b/BasicJava/ReflectionDemo_access_field_annotation/ReflectionDemo/src/ReflectionDemo2.java new file mode 100644 index 000000000..5ecb25eca --- /dev/null +++ b/BasicJava/ReflectionDemo_access_field_annotation/ReflectionDemo/src/ReflectionDemo2.java @@ -0,0 +1,26 @@ +import java.lang.reflect.Field; + +/** + * Example of a field with annotations + */ +public class ReflectionDemo2 +{ + public static void main(String[] args) + { + try + { + Class classObj = Display.class; + Field field = classObj.getField("myField"); + MyAnnotation myAnnotation = field.getAnnotation(MyAnnotation.class); + + System.out.println("name: " + myAnnotation.name()); + System.out.println("value: " + myAnnotation.value()); + } + catch (NoSuchFieldException | SecurityException e) + { + e.printStackTrace(); + } + + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_access_fields/Output.txt b/BasicJava/ReflectionDemo_access_fields/Output.txt new file mode 100644 index 000000000..730ed3d91 --- /dev/null +++ b/BasicJava/ReflectionDemo_access_fields/Output.txt @@ -0,0 +1,6 @@ +public java.lang.String Student.name +name +--------------------------------- +public java.lang.String Student.age +age +--------------------------------- diff --git a/BasicJava/ReflectionDemo_access_fields/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo_access_fields/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo_access_fields/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo_access_fields/ReflectionDemo/.project b/BasicJava/ReflectionDemo_access_fields/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo_access_fields/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo_access_fields/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo_access_fields/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo_access_fields/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo_access_fields/ReflectionDemo/bin/ReflectionDemo.class b/BasicJava/ReflectionDemo_access_fields/ReflectionDemo/bin/ReflectionDemo.class new file mode 100644 index 000000000..f05d10bc4 Binary files /dev/null and b/BasicJava/ReflectionDemo_access_fields/ReflectionDemo/bin/ReflectionDemo.class differ diff --git a/BasicJava/ReflectionDemo_access_fields/ReflectionDemo/bin/Student.class b/BasicJava/ReflectionDemo_access_fields/ReflectionDemo/bin/Student.class new file mode 100644 index 000000000..02ee8a2e1 Binary files /dev/null and b/BasicJava/ReflectionDemo_access_fields/ReflectionDemo/bin/Student.class differ diff --git a/BasicJava/ReflectionDemo_access_fields/ReflectionDemo/src/ReflectionDemo.java b/BasicJava/ReflectionDemo_access_fields/ReflectionDemo/src/ReflectionDemo.java new file mode 100644 index 000000000..9464a9c2a --- /dev/null +++ b/BasicJava/ReflectionDemo_access_fields/ReflectionDemo/src/ReflectionDemo.java @@ -0,0 +1,30 @@ +import java.lang.reflect.Field; + +/** + * + * We can access the fields (member variables) of a class. + * + */ +public class ReflectionDemo +{ + public static void main(String[] args) + { + + Class classObj = Student.class; + + /* + * Returns:the array of Field objects representing the public fields. + */ + + Field[] fieldArray = classObj.getFields(); + + for (Field field : fieldArray) + { + System.out.println(field); + System.out.println(field.getName()); + System.out.println("---------------------------------"); + } + + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_access_fields/ReflectionDemo/src/Student.java b/BasicJava/ReflectionDemo_access_fields/ReflectionDemo/src/Student.java new file mode 100644 index 000000000..a8805d630 --- /dev/null +++ b/BasicJava/ReflectionDemo_access_fields/ReflectionDemo/src/Student.java @@ -0,0 +1,11 @@ +class Student +{ + public String name; + public String age; + + public void showMessage() + { + System.out.println("Hi"); + } +} + diff --git a/BasicJava/ReflectionDemo_access_interfaces/Output.txt b/BasicJava/ReflectionDemo_access_interfaces/Output.txt new file mode 100644 index 000000000..66ab41d6a --- /dev/null +++ b/BasicJava/ReflectionDemo_access_interfaces/Output.txt @@ -0,0 +1,4 @@ +java.util.List +java.util.RandomAccess +java.lang.Cloneable +java.io.Serializable diff --git a/BasicJava/ReflectionDemo_access_interfaces/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo_access_interfaces/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo_access_interfaces/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo_access_interfaces/ReflectionDemo/.project b/BasicJava/ReflectionDemo_access_interfaces/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo_access_interfaces/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo_access_interfaces/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo_access_interfaces/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo_access_interfaces/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo_access_interfaces/ReflectionDemo/bin/ReflectionDemo.class b/BasicJava/ReflectionDemo_access_interfaces/ReflectionDemo/bin/ReflectionDemo.class new file mode 100644 index 000000000..95235a75b Binary files /dev/null and b/BasicJava/ReflectionDemo_access_interfaces/ReflectionDemo/bin/ReflectionDemo.class differ diff --git a/BasicJava/ReflectionDemo_access_interfaces/ReflectionDemo/src/ReflectionDemo.java b/BasicJava/ReflectionDemo_access_interfaces/ReflectionDemo/src/ReflectionDemo.java new file mode 100644 index 000000000..a4f288b2a --- /dev/null +++ b/BasicJava/ReflectionDemo_access_interfaces/ReflectionDemo/src/ReflectionDemo.java @@ -0,0 +1,32 @@ +import java.util.ArrayList; + +/** + * + * It is possible to get a list of the interfaces implemented by a given class + * + */ +public class ReflectionDemo +{ + public static void main(String[] args) + { + + Class classObj = ArrayList.class; + + /* + * Returns:an array of interfaces implemented by this class. + * + * A class can implement many interfaces. Therefore an array of Class is + * returned. Interfaces are also represented by Class objects in Java + * Reflection. + */ + + Class[] classArray = classObj.getInterfaces(); + + for (Class class1 : classArray) + { + System.out.println(class1.getName()); + } + + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo/.project b/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo/bin/Display.class b/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo/bin/Display.class new file mode 100644 index 000000000..022a2ed9e Binary files /dev/null and b/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo/bin/Display.class differ diff --git a/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo/bin/MyAnnotation.class b/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo/bin/MyAnnotation.class new file mode 100644 index 000000000..8be981f2f Binary files /dev/null and b/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo/bin/MyAnnotation.class differ diff --git a/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo/bin/ReflectionDemo1.class b/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo/bin/ReflectionDemo1.class new file mode 100644 index 000000000..7c3986b52 Binary files /dev/null and b/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo/bin/ReflectionDemo1.class differ diff --git a/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo/bin/ReflectionDemo2.class b/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo/bin/ReflectionDemo2.class new file mode 100644 index 000000000..5639afe6e Binary files /dev/null and b/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo/bin/ReflectionDemo2.class differ diff --git a/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo/src/Display.java b/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo/src/Display.java new file mode 100644 index 000000000..51ce3d10b --- /dev/null +++ b/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo/src/Display.java @@ -0,0 +1,22 @@ +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) + +@interface MyAnnotation +{ + public String name(); + + public String value(); +} + +public class Display +{ + @MyAnnotation(name = "Country", value = "India") + public void doSomething() + { + } +} diff --git a/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo/src/ReflectionDemo1.java b/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo/src/ReflectionDemo1.java new file mode 100644 index 000000000..fb080b386 --- /dev/null +++ b/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo/src/ReflectionDemo1.java @@ -0,0 +1,38 @@ +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; + +/** + * We can access the annotations of a class,method or field at runtime. + * + * Method Annotations Example: + */ +public class ReflectionDemo1 +{ + public static void main(String[] args) + { + try + { + Class classObj = Display.class; + Method method = classObj.getMethod("doSomething", null); + /* + * Returns:annotations present on this element * + */ + Annotation[] annotationArray = method.getAnnotations(); + + for (Annotation annotation : annotationArray) + { + if(annotation instanceof MyAnnotation) + { + MyAnnotation myAnnotation = (MyAnnotation)annotation; + System.out.println("name: "+myAnnotation.name()); + System.out.println("value: "+myAnnotation.value()); + } + } + } + catch (NoSuchMethodException | SecurityException e) + { + e.printStackTrace(); + } + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo/src/ReflectionDemo2.java b/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo/src/ReflectionDemo2.java new file mode 100644 index 000000000..f9ad0f674 --- /dev/null +++ b/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo/src/ReflectionDemo2.java @@ -0,0 +1,33 @@ +import java.lang.reflect.Method; + +/** + * We can access the annotations of a class,method or field at + * runtime. + * + * Method Annotations Example: + */ +public class ReflectionDemo2 +{ + public static void main(String[] args) + { + try + { + Class classObj = Display.class; + Method method = classObj.getMethod("doSomething", null); + /* + * Returns: this element's annotation for the specified + * annotation type if present on this element, else null + * + */ + MyAnnotation myAnnotation = method.getAnnotation(MyAnnotation.class); + System.out.println("name: " + myAnnotation.name()); + System.out.println("value: " + myAnnotation.value()); + + } + catch (NoSuchMethodException | SecurityException e) + { + e.printStackTrace(); + } + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo1_Output.txt b/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo1_Output.txt new file mode 100644 index 000000000..ebfbbe14c --- /dev/null +++ b/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo1_Output.txt @@ -0,0 +1,2 @@ +name: Country +value: India diff --git a/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo2_Output.txt b/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo2_Output.txt new file mode 100644 index 000000000..ebfbbe14c --- /dev/null +++ b/BasicJava/ReflectionDemo_access_method_annotation/ReflectionDemo2_Output.txt @@ -0,0 +1,2 @@ +name: Country +value: India diff --git a/BasicJava/ReflectionDemo_access_methods/Output.txt b/BasicJava/ReflectionDemo_access_methods/Output.txt new file mode 100644 index 000000000..e5a7cb556 --- /dev/null +++ b/BasicJava/ReflectionDemo_access_methods/Output.txt @@ -0,0 +1,42 @@ +public boolean java.util.ArrayList.add(java.lang.Object) +public void java.util.ArrayList.add(int,java.lang.Object) +public boolean java.util.ArrayList.remove(java.lang.Object) +public java.lang.Object java.util.ArrayList.remove(int) +public java.lang.Object java.util.ArrayList.get(int) +public java.lang.Object java.util.ArrayList.clone() +public int java.util.ArrayList.indexOf(java.lang.Object) +public void java.util.ArrayList.clear() +public boolean java.util.ArrayList.contains(java.lang.Object) +public boolean java.util.ArrayList.isEmpty() +public java.util.Iterator java.util.ArrayList.iterator() +public int java.util.ArrayList.lastIndexOf(java.lang.Object) +public void java.util.ArrayList.replaceAll(java.util.function.UnaryOperator) +public int java.util.ArrayList.size() +public java.util.List java.util.ArrayList.subList(int,int) +public java.lang.Object[] java.util.ArrayList.toArray(java.lang.Object[]) +public java.lang.Object[] java.util.ArrayList.toArray() +public java.util.Spliterator java.util.ArrayList.spliterator() +public boolean java.util.ArrayList.addAll(int,java.util.Collection) +public boolean java.util.ArrayList.addAll(java.util.Collection) +public void java.util.ArrayList.forEach(java.util.function.Consumer) +public java.lang.Object java.util.ArrayList.set(int,java.lang.Object) +public void java.util.ArrayList.ensureCapacity(int) +public void java.util.ArrayList.trimToSize() +public java.util.ListIterator java.util.ArrayList.listIterator() +public java.util.ListIterator java.util.ArrayList.listIterator(int) +public boolean java.util.ArrayList.removeAll(java.util.Collection) +public boolean java.util.ArrayList.removeIf(java.util.function.Predicate) +public boolean java.util.ArrayList.retainAll(java.util.Collection) +public void java.util.ArrayList.sort(java.util.Comparator) +public boolean java.util.AbstractList.equals(java.lang.Object) +public int java.util.AbstractList.hashCode() +public java.lang.String java.util.AbstractCollection.toString() +public boolean java.util.AbstractCollection.containsAll(java.util.Collection) +public final void java.lang.Object.wait() throws java.lang.InterruptedException +public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException +public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException +public final native java.lang.Class java.lang.Object.getClass() +public final native void java.lang.Object.notify() +public final native void java.lang.Object.notifyAll() +public default java.util.stream.Stream java.util.Collection.stream() +public default java.util.stream.Stream java.util.Collection.parallelStream() diff --git a/BasicJava/ReflectionDemo_access_methods/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo_access_methods/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo_access_methods/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo_access_methods/ReflectionDemo/.project b/BasicJava/ReflectionDemo_access_methods/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo_access_methods/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo_access_methods/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo_access_methods/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo_access_methods/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo_access_methods/ReflectionDemo/bin/ReflectionDemo.class b/BasicJava/ReflectionDemo_access_methods/ReflectionDemo/bin/ReflectionDemo.class new file mode 100644 index 000000000..0399957a2 Binary files /dev/null and b/BasicJava/ReflectionDemo_access_methods/ReflectionDemo/bin/ReflectionDemo.class differ diff --git a/BasicJava/ReflectionDemo_access_methods/ReflectionDemo/src/ReflectionDemo.java b/BasicJava/ReflectionDemo_access_methods/ReflectionDemo/src/ReflectionDemo.java new file mode 100644 index 000000000..1992bdd58 --- /dev/null +++ b/BasicJava/ReflectionDemo_access_methods/ReflectionDemo/src/ReflectionDemo.java @@ -0,0 +1,30 @@ +import java.lang.reflect.Method; +import java.util.ArrayList; + +/** + * + * We can access the methods of a class. + * + */ +public class ReflectionDemo +{ + public static void main(String[] args) + { + + Class classObj = ArrayList.class; + + /* + * Returns:the array of Method objects representing the public methods + * of this class. + */ + + Method[] methodArray = classObj.getMethods(); + + for (Method method : methodArray) + { + System.out.println(method); + } + + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_access_param_annotation/Output.txt b/BasicJava/ReflectionDemo_access_param_annotation/Output.txt new file mode 100644 index 000000000..5ad0afa81 --- /dev/null +++ b/BasicJava/ReflectionDemo_access_param_annotation/Output.txt @@ -0,0 +1,3 @@ +param: java.lang.String +name : age +value: 23 diff --git a/BasicJava/ReflectionDemo_access_param_annotation/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo_access_param_annotation/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo_access_param_annotation/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo_access_param_annotation/ReflectionDemo/.project b/BasicJava/ReflectionDemo_access_param_annotation/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo_access_param_annotation/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo_access_param_annotation/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo_access_param_annotation/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo_access_param_annotation/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo_access_param_annotation/ReflectionDemo/bin/Display.class b/BasicJava/ReflectionDemo_access_param_annotation/ReflectionDemo/bin/Display.class new file mode 100644 index 000000000..8458b16c4 Binary files /dev/null and b/BasicJava/ReflectionDemo_access_param_annotation/ReflectionDemo/bin/Display.class differ diff --git a/BasicJava/ReflectionDemo_access_param_annotation/ReflectionDemo/bin/MyAnnotation.class b/BasicJava/ReflectionDemo_access_param_annotation/ReflectionDemo/bin/MyAnnotation.class new file mode 100644 index 000000000..d4481872d Binary files /dev/null and b/BasicJava/ReflectionDemo_access_param_annotation/ReflectionDemo/bin/MyAnnotation.class differ diff --git a/BasicJava/ReflectionDemo_access_param_annotation/ReflectionDemo/bin/ReflectionDemo.class b/BasicJava/ReflectionDemo_access_param_annotation/ReflectionDemo/bin/ReflectionDemo.class new file mode 100644 index 000000000..9d13cfe70 Binary files /dev/null and b/BasicJava/ReflectionDemo_access_param_annotation/ReflectionDemo/bin/ReflectionDemo.class differ diff --git a/BasicJava/ReflectionDemo_access_param_annotation/ReflectionDemo/src/Display.java b/BasicJava/ReflectionDemo_access_param_annotation/ReflectionDemo/src/Display.java new file mode 100644 index 000000000..6deca0903 --- /dev/null +++ b/BasicJava/ReflectionDemo_access_param_annotation/ReflectionDemo/src/Display.java @@ -0,0 +1,22 @@ +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.PARAMETER) + +@interface MyAnnotation +{ + public String name(); + + public String value(); +} + +public class Display +{ + + public void doSomething(@MyAnnotation(name = "age", value = "23") String value) + { + } +} diff --git a/BasicJava/ReflectionDemo_access_param_annotation/ReflectionDemo/src/ReflectionDemo.java b/BasicJava/ReflectionDemo_access_param_annotation/ReflectionDemo/src/ReflectionDemo.java new file mode 100644 index 000000000..cb9a0522f --- /dev/null +++ b/BasicJava/ReflectionDemo_access_param_annotation/ReflectionDemo/src/ReflectionDemo.java @@ -0,0 +1,47 @@ +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; + +/** + * Parameter Annotations: + * + * We can access parameter annotations from the Method object like below. + */ +public class ReflectionDemo +{ + public static void main(String[] args) + { + try + { + Class classObj = Display.class; + Method method = classObj.getMethod("doSomething", String.class); + /* + * Returns:a two-dimensional Annotation array, containing an + * array of annotations for each method parameter. + */ + Annotation[][] parameterAnnotations = method.getParameterAnnotations(); + Class[] parameterTypes = method.getParameterTypes(); + + int i = 0; + for (Annotation[] annotations : parameterAnnotations) + { + Class parameterType = parameterTypes[i++]; + + for (Annotation annotation : annotations) + { + if (annotation instanceof MyAnnotation) + { + MyAnnotation myAnnotation = (MyAnnotation) annotation; + System.out.println("param: " + parameterType.getName()); + System.out.println("name : " + myAnnotation.name()); + System.out.println("value: " + myAnnotation.value()); + } + } + } + } + catch (NoSuchMethodException e) + { + e.printStackTrace(); + } + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_access_private_field/Output.txt b/BasicJava/ReflectionDemo_access_private_field/Output.txt new file mode 100644 index 000000000..57e528a09 --- /dev/null +++ b/BasicJava/ReflectionDemo_access_private_field/Output.txt @@ -0,0 +1 @@ +privateNameField value = Peter diff --git a/BasicJava/ReflectionDemo_access_private_field/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo_access_private_field/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo_access_private_field/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo_access_private_field/ReflectionDemo/.project b/BasicJava/ReflectionDemo_access_private_field/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo_access_private_field/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo_access_private_field/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo_access_private_field/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo_access_private_field/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo_access_private_field/ReflectionDemo/bin/ReflectionDemo.class b/BasicJava/ReflectionDemo_access_private_field/ReflectionDemo/bin/ReflectionDemo.class new file mode 100644 index 000000000..c8a094f97 Binary files /dev/null and b/BasicJava/ReflectionDemo_access_private_field/ReflectionDemo/bin/ReflectionDemo.class differ diff --git a/BasicJava/ReflectionDemo_access_private_field/ReflectionDemo/bin/Student.class b/BasicJava/ReflectionDemo_access_private_field/ReflectionDemo/bin/Student.class new file mode 100644 index 000000000..8bcbd7c68 Binary files /dev/null and b/BasicJava/ReflectionDemo_access_private_field/ReflectionDemo/bin/Student.class differ diff --git a/BasicJava/ReflectionDemo_access_private_field/ReflectionDemo/src/ReflectionDemo.java b/BasicJava/ReflectionDemo_access_private_field/ReflectionDemo/src/ReflectionDemo.java new file mode 100644 index 000000000..317f7a83a --- /dev/null +++ b/BasicJava/ReflectionDemo_access_private_field/ReflectionDemo/src/ReflectionDemo.java @@ -0,0 +1,47 @@ +import java.lang.reflect.Field; + +/** + * + * Despite the common belief it is actually possible to access private fields + * and methods of other classes via Java Reflection. It is not even that + * difficult. This can be very handy during unit testing. + * + */ +public class ReflectionDemo +{ + public static void main(String[] args) + { + try + { + Class classObj = Student.class; + Field privateFieldObj = classObj.getDeclaredField("name"); + /* + * Set the accessible flag for this object to the indicated boolean + * value. A value of true indicates that the reflected object should + * suppress Java language access checking when it is used. A value + * of false indicates that the reflected object should enforce Java + * language access checks. + * + * First, if there is a security manager, its checkPermission method + * is called with a ReflectPermission("suppressAccessChecks") + * permission. + * + * By calling Field.setAcessible(true) you turn off the access + * checks for this particular Field instance, for reflection only. + * Now you can access it even if it is private, protected or package + * scope, even if the caller is not part of those scopes. + */ + privateFieldObj.setAccessible(true); + Student student = new Student("Peter"); + String fieldValue = (String) privateFieldObj.get(student); + System.out.println("privateNameField value = " + fieldValue); + } + catch (NoSuchFieldException | SecurityException + | IllegalArgumentException | IllegalAccessException e) + { + e.printStackTrace(); + } + + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_access_private_field/ReflectionDemo/src/Student.java b/BasicJava/ReflectionDemo_access_private_field/ReflectionDemo/src/Student.java new file mode 100644 index 000000000..d9eddc810 --- /dev/null +++ b/BasicJava/ReflectionDemo_access_private_field/ReflectionDemo/src/Student.java @@ -0,0 +1,10 @@ +class Student +{ + private String name; + + public Student(String name) + { + this.name = name; + } + +} diff --git a/BasicJava/ReflectionDemo_access_superclass/Output.txt b/BasicJava/ReflectionDemo_access_superclass/Output.txt new file mode 100644 index 000000000..38fc6c540 --- /dev/null +++ b/BasicJava/ReflectionDemo_access_superclass/Output.txt @@ -0,0 +1,3 @@ +class java.util.AbstractList +Name = java.util.AbstractList +Simple Name = AbstractList diff --git a/BasicJava/ReflectionDemo_access_superclass/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo_access_superclass/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo_access_superclass/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo_access_superclass/ReflectionDemo/.project b/BasicJava/ReflectionDemo_access_superclass/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo_access_superclass/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo_access_superclass/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo_access_superclass/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo_access_superclass/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo_access_superclass/ReflectionDemo/bin/ReflectionDemo.class b/BasicJava/ReflectionDemo_access_superclass/ReflectionDemo/bin/ReflectionDemo.class new file mode 100644 index 000000000..509579d99 Binary files /dev/null and b/BasicJava/ReflectionDemo_access_superclass/ReflectionDemo/bin/ReflectionDemo.class differ diff --git a/BasicJava/ReflectionDemo_access_superclass/ReflectionDemo/src/ReflectionDemo.java b/BasicJava/ReflectionDemo_access_superclass/ReflectionDemo/src/ReflectionDemo.java new file mode 100644 index 000000000..478f13b2c --- /dev/null +++ b/BasicJava/ReflectionDemo_access_superclass/ReflectionDemo/src/ReflectionDemo.java @@ -0,0 +1,27 @@ +import java.util.ArrayList; + +/** + * + * From the Class object we can access the superclass of the class. + * + */ +public class ReflectionDemo +{ + public static void main(String[] args) + { + + Class classObj = ArrayList.class; + + /* + * Returns:the superclass of the class represented by this object. + */ + + Class superClass = classObj.getSuperclass(); + + System.out.println(superClass); + System.out.println("Name = "+superClass.getName()); + System.out.println("Simple Name = "+superClass.getSimpleName()); + + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_call_private_getmethod/Output.txt b/BasicJava/ReflectionDemo_call_private_getmethod/Output.txt new file mode 100644 index 000000000..7e3fe5df7 --- /dev/null +++ b/BasicJava/ReflectionDemo_call_private_getmethod/Output.txt @@ -0,0 +1 @@ +returnValue = Peter diff --git a/BasicJava/ReflectionDemo_call_private_getmethod/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo_call_private_getmethod/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo_call_private_getmethod/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo_call_private_getmethod/ReflectionDemo/.project b/BasicJava/ReflectionDemo_call_private_getmethod/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo_call_private_getmethod/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo_call_private_getmethod/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo_call_private_getmethod/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo_call_private_getmethod/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo_call_private_getmethod/ReflectionDemo/bin/ReflectionDemo.class b/BasicJava/ReflectionDemo_call_private_getmethod/ReflectionDemo/bin/ReflectionDemo.class new file mode 100644 index 000000000..6fa1533ed Binary files /dev/null and b/BasicJava/ReflectionDemo_call_private_getmethod/ReflectionDemo/bin/ReflectionDemo.class differ diff --git a/BasicJava/ReflectionDemo_call_private_getmethod/ReflectionDemo/bin/Student.class b/BasicJava/ReflectionDemo_call_private_getmethod/ReflectionDemo/bin/Student.class new file mode 100644 index 000000000..bae9e6a9d Binary files /dev/null and b/BasicJava/ReflectionDemo_call_private_getmethod/ReflectionDemo/bin/Student.class differ diff --git a/BasicJava/ReflectionDemo_call_private_getmethod/ReflectionDemo/src/ReflectionDemo.java b/BasicJava/ReflectionDemo_call_private_getmethod/ReflectionDemo/src/ReflectionDemo.java new file mode 100644 index 000000000..eccd2f96f --- /dev/null +++ b/BasicJava/ReflectionDemo_call_private_getmethod/ReflectionDemo/src/ReflectionDemo.java @@ -0,0 +1,52 @@ +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +/** + * + * Despite the common belief it is actually possible to access private fields + * and methods of other classes via Java Reflection. It is not even that + * difficult. This can be very handy during unit testing. + * + */ +public class ReflectionDemo +{ + public static void main(String[] args) + { + try + { + Class classObj = Student.class; + Method privateGetNameMethod = classObj.getDeclaredMethod("getName", null); + + /* + * Set the accessible flag for this object to the indicated boolean + * value. A value of true indicates that the reflected object should + * suppress Java language access checking when it is used. A value + * of false indicates that the reflected object should enforce Java + * language access checks. + * + * First, if there is a security manager, its checkPermission method + * is called with a ReflectPermission("suppressAccessChecks") + * permission. + * + * By calling Method.setAcessible(true) you turn off the access + * checks for this particular Method instance, for reflection only. + * Now you can access it even if it is private, protected or package + * scope, even if the caller is not part of those scopes. + * + */ + privateGetNameMethod.setAccessible(true); + + Student student = new Student("Peter"); + String returnValue = (String) privateGetNameMethod.invoke(student,null); + + System.out.println("returnValue = " + returnValue); + } + catch (NoSuchMethodException | InvocationTargetException + | IllegalAccessException | IllegalArgumentException e) + { + e.printStackTrace(); + } + + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_call_private_getmethod/ReflectionDemo/src/Student.java b/BasicJava/ReflectionDemo_call_private_getmethod/ReflectionDemo/src/Student.java new file mode 100644 index 000000000..a1ba2b7ac --- /dev/null +++ b/BasicJava/ReflectionDemo_call_private_getmethod/ReflectionDemo/src/Student.java @@ -0,0 +1,15 @@ +class Student +{ + private String name; + + public Student(String name) + { + this.name = name; + } + + private String getName() + { + return name; + } + +} diff --git a/BasicJava/ReflectionDemo_classObj_int_str_array/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo_classObj_int_str_array/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo_classObj_int_str_array/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo_classObj_int_str_array/ReflectionDemo/.project b/BasicJava/ReflectionDemo_classObj_int_str_array/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo_classObj_int_str_array/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo_classObj_int_str_array/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo_classObj_int_str_array/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo_classObj_int_str_array/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo_classObj_int_str_array/ReflectionDemo/bin/ReflectionDemo1.class b/BasicJava/ReflectionDemo_classObj_int_str_array/ReflectionDemo/bin/ReflectionDemo1.class new file mode 100644 index 000000000..2cbf822ac Binary files /dev/null and b/BasicJava/ReflectionDemo_classObj_int_str_array/ReflectionDemo/bin/ReflectionDemo1.class differ diff --git a/BasicJava/ReflectionDemo_classObj_int_str_array/ReflectionDemo/bin/ReflectionDemo2.class b/BasicJava/ReflectionDemo_classObj_int_str_array/ReflectionDemo/bin/ReflectionDemo2.class new file mode 100644 index 000000000..902c7c6e2 Binary files /dev/null and b/BasicJava/ReflectionDemo_classObj_int_str_array/ReflectionDemo/bin/ReflectionDemo2.class differ diff --git a/BasicJava/ReflectionDemo_classObj_int_str_array/ReflectionDemo/src/ReflectionDemo1.java b/BasicJava/ReflectionDemo_classObj_int_str_array/ReflectionDemo/src/ReflectionDemo1.java new file mode 100644 index 000000000..dc0c61fce --- /dev/null +++ b/BasicJava/ReflectionDemo_classObj_int_str_array/ReflectionDemo/src/ReflectionDemo1.java @@ -0,0 +1,14 @@ +/** + * Obtaining the Class Object of an Array + * + */ +public class ReflectionDemo1 +{ + public static void main(String[] args) + { + Class stringArrayClassObj = String[].class; + System.out.println(stringArrayClassObj); + System.out.println(stringArrayClassObj.getName()); + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_classObj_int_str_array/ReflectionDemo/src/ReflectionDemo2.java b/BasicJava/ReflectionDemo_classObj_int_str_array/ReflectionDemo/src/ReflectionDemo2.java new file mode 100644 index 000000000..2361cab55 --- /dev/null +++ b/BasicJava/ReflectionDemo_classObj_int_str_array/ReflectionDemo/src/ReflectionDemo2.java @@ -0,0 +1,37 @@ +/** + * Obtaining the Class Object of an Array + * + */ +public class ReflectionDemo2 +{ + public static void main(String[] args) + { + try + { + /* + * The JVM represents an int via the letter I. The [ on the left + * means it is the class of an int array I am interested in. This + * works for all other primitives too + */ + Class intArrayClassObj = Class.forName("[I"); + System.out.println(intArrayClassObj); + System.out.println(intArrayClassObj.getName()); + + System.out.println("------------------------------"); + + /* + * Notice the [L to the left of the class name, and the ; to the + * right. This means an array of objects with the given type. + */ + Class stringArrayClassObj = Class.forName("[Ljava.lang.String;"); + System.out.println(stringArrayClassObj); + System.out.println(stringArrayClassObj.getName()); + } + catch (ClassNotFoundException e) + { + e.printStackTrace(); + } + + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_classObj_int_str_array/ReflectionDemo1_Output.txt b/BasicJava/ReflectionDemo_classObj_int_str_array/ReflectionDemo1_Output.txt new file mode 100644 index 000000000..37c46b424 --- /dev/null +++ b/BasicJava/ReflectionDemo_classObj_int_str_array/ReflectionDemo1_Output.txt @@ -0,0 +1,2 @@ +class [Ljava.lang.String; +[Ljava.lang.String; diff --git a/BasicJava/ReflectionDemo_classObj_int_str_array/ReflectionDemo2_Output.txt b/BasicJava/ReflectionDemo_classObj_int_str_array/ReflectionDemo2_Output.txt new file mode 100644 index 000000000..80f03749a --- /dev/null +++ b/BasicJava/ReflectionDemo_classObj_int_str_array/ReflectionDemo2_Output.txt @@ -0,0 +1,5 @@ +class [I +[I +------------------------------ +class [Ljava.lang.String; +[Ljava.lang.String; diff --git a/BasicJava/ReflectionDemo_cons_instantiate/Output.txt b/BasicJava/ReflectionDemo_cons_instantiate/Output.txt new file mode 100644 index 000000000..5089231f7 --- /dev/null +++ b/BasicJava/ReflectionDemo_cons_instantiate/Output.txt @@ -0,0 +1 @@ +Peter diff --git a/BasicJava/ReflectionDemo_cons_instantiate/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo_cons_instantiate/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo_cons_instantiate/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo_cons_instantiate/ReflectionDemo/.project b/BasicJava/ReflectionDemo_cons_instantiate/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo_cons_instantiate/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo_cons_instantiate/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo_cons_instantiate/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo_cons_instantiate/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo_cons_instantiate/ReflectionDemo/bin/ReflectionDemo.class b/BasicJava/ReflectionDemo_cons_instantiate/ReflectionDemo/bin/ReflectionDemo.class new file mode 100644 index 000000000..9a1e37e26 Binary files /dev/null and b/BasicJava/ReflectionDemo_cons_instantiate/ReflectionDemo/bin/ReflectionDemo.class differ diff --git a/BasicJava/ReflectionDemo_cons_instantiate/ReflectionDemo/src/ReflectionDemo.java b/BasicJava/ReflectionDemo_cons_instantiate/ReflectionDemo/src/ReflectionDemo.java new file mode 100644 index 000000000..100a958bd --- /dev/null +++ b/BasicJava/ReflectionDemo_cons_instantiate/ReflectionDemo/src/ReflectionDemo.java @@ -0,0 +1,46 @@ +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; + +/** + * + * Instantiating Objects using Constructor Object. + * + */ +public class ReflectionDemo +{ + public static void main(String[] args) + { + try + { + + Class classObj = String.class; + /* + * Parameters: + * + * parameterTypes - the parameter array + * + * Returns: the Constructor object of the public + * constructor that matches the specified parameterTypes + * + */ + + Constructor constructor = classObj.getConstructor(StringBuffer.class); + StringBuffer sb = new StringBuffer("Peter"); + /* + * Returns:a new object created by calling the constructor + * this object represents + */ + String str = (String) constructor.newInstance(sb); + System.out.println(str); + } + catch (NoSuchMethodException | SecurityException + | InstantiationException | IllegalAccessException + | IllegalArgumentException + | InvocationTargetException e) + { + e.printStackTrace(); + } + + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_cons_param/Output.txt b/BasicJava/ReflectionDemo_cons_param/Output.txt new file mode 100644 index 000000000..407276fd8 --- /dev/null +++ b/BasicJava/ReflectionDemo_cons_param/Output.txt @@ -0,0 +1,20 @@ +constructor = public java.util.HashSet(int) +Parameter Count = 1 +Parameter Type = int +Parameter Name = arg0 +-------------------------------- +constructor = public java.util.HashSet(int,float) +Parameter Count = 2 +Parameter Type = int +Parameter Name = arg0 +Parameter Type = float +Parameter Name = arg1 +-------------------------------- +constructor = public java.util.HashSet(java.util.Collection) +Parameter Count = 1 +Parameter Type = java.util.Collection +Parameter Name = arg0 +-------------------------------- +constructor = public java.util.HashSet() +Parameter Count = 0 +-------------------------------- diff --git a/BasicJava/ReflectionDemo_cons_param/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo_cons_param/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo_cons_param/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo_cons_param/ReflectionDemo/.project b/BasicJava/ReflectionDemo_cons_param/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo_cons_param/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo_cons_param/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo_cons_param/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo_cons_param/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo_cons_param/ReflectionDemo/bin/ReflectionDemo.class b/BasicJava/ReflectionDemo_cons_param/ReflectionDemo/bin/ReflectionDemo.class new file mode 100644 index 000000000..9a9531b3f Binary files /dev/null and b/BasicJava/ReflectionDemo_cons_param/ReflectionDemo/bin/ReflectionDemo.class differ diff --git a/BasicJava/ReflectionDemo_cons_param/ReflectionDemo/bin/Student.class b/BasicJava/ReflectionDemo_cons_param/ReflectionDemo/bin/Student.class new file mode 100644 index 000000000..02ee8a2e1 Binary files /dev/null and b/BasicJava/ReflectionDemo_cons_param/ReflectionDemo/bin/Student.class differ diff --git a/BasicJava/ReflectionDemo_cons_param/ReflectionDemo/src/ReflectionDemo.java b/BasicJava/ReflectionDemo_cons_param/ReflectionDemo/src/ReflectionDemo.java new file mode 100644 index 000000000..77644606f --- /dev/null +++ b/BasicJava/ReflectionDemo_cons_param/ReflectionDemo/src/ReflectionDemo.java @@ -0,0 +1,43 @@ +import java.lang.reflect.Constructor; +import java.lang.reflect.Parameter; +import java.util.HashSet; + +/** + * + * We can read what parameters a given constructor can takes. + * + */ +public class ReflectionDemo +{ + public static void main(String[] args) + { + + Class classObj = HashSet.class; + + /* + * Returns:the array of Constructor objects representing the public + * constructors of this class + */ + + Constructor[] constructorArray= classObj.getConstructors(); + + for (Constructor constructor : constructorArray) + { + System.out.println("constructor = "+constructor); + System.out.println("Parameter Count = "+constructor.getParameterCount()); + /* + * Returns:an array of Parameter objects representing all the + * parameters to the executable this object represents. + */ + Parameter[] parameterArray = constructor.getParameters(); + for (Parameter parameter : parameterArray) + { + System.out.println("Parameter Type = "+parameter.getParameterizedType()); + System.out.println("Parameter Name = "+parameter.getName()); + } + System.out.println("--------------------------------"); + } + + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_create_access_array/Output.txt b/BasicJava/ReflectionDemo_create_access_array/Output.txt new file mode 100644 index 000000000..1acbf915c --- /dev/null +++ b/BasicJava/ReflectionDemo_create_access_array/Output.txt @@ -0,0 +1,3 @@ +intArray[0] = 10 +intArray[1] = 20 +intArray[2] = 30 diff --git a/BasicJava/ReflectionDemo_create_access_array/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo_create_access_array/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo_create_access_array/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo_create_access_array/ReflectionDemo/.project b/BasicJava/ReflectionDemo_create_access_array/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo_create_access_array/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo_create_access_array/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo_create_access_array/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo_create_access_array/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo_create_access_array/ReflectionDemo/bin/ReflectionDemo.class b/BasicJava/ReflectionDemo_create_access_array/ReflectionDemo/bin/ReflectionDemo.class new file mode 100644 index 000000000..7264f0705 Binary files /dev/null and b/BasicJava/ReflectionDemo_create_access_array/ReflectionDemo/bin/ReflectionDemo.class differ diff --git a/BasicJava/ReflectionDemo_create_access_array/ReflectionDemo/src/ReflectionDemo.java b/BasicJava/ReflectionDemo_create_access_array/ReflectionDemo/src/ReflectionDemo.java new file mode 100644 index 000000000..f8852b588 --- /dev/null +++ b/BasicJava/ReflectionDemo_create_access_array/ReflectionDemo/src/ReflectionDemo.java @@ -0,0 +1,37 @@ +import java.lang.reflect.Array; + +/** + * Creating Array and Accessing Array. + * + */ +public class ReflectionDemo +{ + public static void main(String[] args) + { + /* + * Creating arrays via Java Reflection is done using the + * java.lang.reflect.Array class + * + * This code sample creates an array of int. The first parameter + * int.class given to the Array.newInstance() method tells what type + * each element in the array should be of. The second parameter states + * how many elements the array should have space for. + */ + int[] intArray = (int[]) Array.newInstance(int.class, 3); + + /* + * It is possible to access the elements of an array using Java + * Reflection. This is done via the Array.get(...) and Array.set(...) + * methods. + */ + Array.set(intArray, 0, 10); + Array.set(intArray, 1, 20); + Array.set(intArray, 2, 30); + + System.out.println("intArray[0] = " + Array.get(intArray, 0)); + System.out.println("intArray[1] = " + Array.get(intArray, 1)); + System.out.println("intArray[2] = " + Array.get(intArray, 2)); + + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_determine_classObj/Output.txt b/BasicJava/ReflectionDemo_determine_classObj/Output.txt new file mode 100644 index 000000000..f79f690ce --- /dev/null +++ b/BasicJava/ReflectionDemo_determine_classObj/Output.txt @@ -0,0 +1,3 @@ +Is a Interface = true +Is a MemberClass = false +Is a Primitive = false diff --git a/BasicJava/ReflectionDemo_determine_classObj/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo_determine_classObj/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo_determine_classObj/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo_determine_classObj/ReflectionDemo/.project b/BasicJava/ReflectionDemo_determine_classObj/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo_determine_classObj/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo_determine_classObj/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo_determine_classObj/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo_determine_classObj/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo_determine_classObj/ReflectionDemo/bin/ReflectionDemo.class b/BasicJava/ReflectionDemo_determine_classObj/ReflectionDemo/bin/ReflectionDemo.class new file mode 100644 index 000000000..5564bc7f7 Binary files /dev/null and b/BasicJava/ReflectionDemo_determine_classObj/ReflectionDemo/bin/ReflectionDemo.class differ diff --git a/BasicJava/ReflectionDemo_determine_classObj/ReflectionDemo/src/ReflectionDemo.java b/BasicJava/ReflectionDemo_determine_classObj/ReflectionDemo/src/ReflectionDemo.java new file mode 100644 index 000000000..cd72db85c --- /dev/null +++ b/BasicJava/ReflectionDemo_determine_classObj/ReflectionDemo/src/ReflectionDemo.java @@ -0,0 +1,33 @@ +/** + * How to determine the class object. + * + */ +public class ReflectionDemo +{ + public static void main(String[] args) + { + try + { + Class classObj = Class.forName("java.util.List"); + + /* + * Returns:true if this object represents an interface; false otherwise. + */ + System.out.println("Is a Interface = " + classObj.isInterface()); + /* + * Returns:true if and only if this class is a member class. + */ + System.out.println("Is a MemberClass = " + classObj.isMemberClass()); + /* + * Returns:true if and only if this class represents a primitive type + */ + System.out.println("Is a Primitive = " + classObj.isPrimitive()); + } + catch (ClassNotFoundException e) + { + e.printStackTrace(); + } + + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_display_metadata/Output.txt b/BasicJava/ReflectionDemo_display_metadata/Output.txt new file mode 100644 index 000000000..371c364fe --- /dev/null +++ b/BasicJava/ReflectionDemo_display_metadata/Output.txt @@ -0,0 +1,65 @@ +Enter the ClassName: java.util.ArrayList +Fields: +private static final long java.util.ArrayList.serialVersionUID +private static final int java.util.ArrayList.DEFAULT_CAPACITY +private static final java.lang.Object[] java.util.ArrayList.EMPTY_ELEMENTDATA +private static final java.lang.Object[] java.util.ArrayList.DEFAULTCAPACITY_EMPTY_ELEMENTDATA +transient java.lang.Object[] java.util.ArrayList.elementData +private int java.util.ArrayList.size +private static final int java.util.ArrayList.MAX_ARRAY_SIZE +--------------------------------------- + +Constructors: +public java.util.ArrayList(java.util.Collection) +public java.util.ArrayList() +public java.util.ArrayList(int) +--------------------------------------- + +Methods: +public boolean java.util.ArrayList.add(java.lang.Object) +public void java.util.ArrayList.add(int,java.lang.Object) +public boolean java.util.ArrayList.remove(java.lang.Object) +public java.lang.Object java.util.ArrayList.remove(int) +public java.lang.Object java.util.ArrayList.get(int) +public java.lang.Object java.util.ArrayList.clone() +public int java.util.ArrayList.indexOf(java.lang.Object) +public void java.util.ArrayList.clear() +public boolean java.util.ArrayList.contains(java.lang.Object) +public boolean java.util.ArrayList.isEmpty() +public java.util.Iterator java.util.ArrayList.iterator() +public int java.util.ArrayList.lastIndexOf(java.lang.Object) +public void java.util.ArrayList.replaceAll(java.util.function.UnaryOperator) +public int java.util.ArrayList.size() +public java.util.List java.util.ArrayList.subList(int,int) +public java.lang.Object[] java.util.ArrayList.toArray(java.lang.Object[]) +public java.lang.Object[] java.util.ArrayList.toArray() +public java.util.Spliterator java.util.ArrayList.spliterator() +static int java.util.ArrayList.access$100(java.util.ArrayList) +public boolean java.util.ArrayList.addAll(int,java.util.Collection) +public boolean java.util.ArrayList.addAll(java.util.Collection) +private void java.util.ArrayList.readObject(java.io.ObjectInputStream) + throws java.io.IOException,java.lang.ClassNotFoundException +private void java.util.ArrayList.writeObject(java.io.ObjectOutputStream) + throws java.io.IOException +public void java.util.ArrayList.forEach(java.util.function.Consumer) +public java.lang.Object java.util.ArrayList.set(int,java.lang.Object) +public void java.util.ArrayList.ensureCapacity(int) +public void java.util.ArrayList.trimToSize() +private void java.util.ArrayList.ensureCapacityInternal(int) +private static int java.util.ArrayList.hugeCapacity(int) +java.lang.Object java.util.ArrayList.elementData(int) +private void java.util.ArrayList.grow(int) +public java.util.ListIterator java.util.ArrayList.listIterator() +public java.util.ListIterator java.util.ArrayList.listIterator(int) +public boolean java.util.ArrayList.removeAll(java.util.Collection) +public boolean java.util.ArrayList.removeIf(java.util.function.Predicate) +protected void java.util.ArrayList.removeRange(int,int) +public boolean java.util.ArrayList.retainAll(java.util.Collection) +public void java.util.ArrayList.sort(java.util.Comparator) +private java.lang.String java.util.ArrayList.outOfBoundsMsg(int) +private void java.util.ArrayList.rangeCheckForAdd(int) +private boolean java.util.ArrayList.batchRemove(java.util.Collection,boolean) +private void java.util.ArrayList.ensureExplicitCapacity(int) +private void java.util.ArrayList.fastRemove(int) +private void java.util.ArrayList.rangeCheck(int) +static void java.util.ArrayList.subListRangeCheck(int,int,int) diff --git a/BasicJava/ReflectionDemo_display_metadata/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo_display_metadata/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo_display_metadata/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo_display_metadata/ReflectionDemo/.project b/BasicJava/ReflectionDemo_display_metadata/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo_display_metadata/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo_display_metadata/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo_display_metadata/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo_display_metadata/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo_display_metadata/ReflectionDemo/bin/ReflectionDemo.class b/BasicJava/ReflectionDemo_display_metadata/ReflectionDemo/bin/ReflectionDemo.class new file mode 100644 index 000000000..a4e2df9a0 Binary files /dev/null and b/BasicJava/ReflectionDemo_display_metadata/ReflectionDemo/bin/ReflectionDemo.class differ diff --git a/BasicJava/ReflectionDemo_display_metadata/ReflectionDemo/bin/Student.class b/BasicJava/ReflectionDemo_display_metadata/ReflectionDemo/bin/Student.class new file mode 100644 index 000000000..a69f0f358 Binary files /dev/null and b/BasicJava/ReflectionDemo_display_metadata/ReflectionDemo/bin/Student.class differ diff --git a/BasicJava/ReflectionDemo_display_metadata/ReflectionDemo/src/ReflectionDemo.java b/BasicJava/ReflectionDemo_display_metadata/ReflectionDemo/src/ReflectionDemo.java new file mode 100644 index 000000000..894761535 --- /dev/null +++ b/BasicJava/ReflectionDemo_display_metadata/ReflectionDemo/src/ReflectionDemo.java @@ -0,0 +1,70 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +/** + * How to display the metadata of a class. + * + */ +public class ReflectionDemo +{ + public static void main(String[] args) + { + + try + { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + System.out.print("Enter the ClassName: "); + String className= br.readLine(); + br.close(); + + Class classObj = Class.forName(className); + System.out.println("Fields: "); + + /* + * Returns:the array of Field objects representing all the declared + * fields of this class + */ + Field[] fieldArray = classObj.getDeclaredFields(); + for (Field field : fieldArray) + { + System.out.println(field); + } + + System.out.println("---------------------------------------"); + + System.out.println("\nConstructors:"); + /* + * Returns:the array of Constructor objects representing all the + * declared constructors of this class + */ + Constructor[] constructorArray = classObj.getDeclaredConstructors(); + for (Constructor constructor : constructorArray) + { + System.out.println(constructor); + } + System.out.println("---------------------------------------"); + + System.out.println("\nMethods:"); + /* + * Returns:the array of Method objects representing all the declared + * methods of this class + */ + Method[] methodArray = classObj.getDeclaredMethods(); + + for (Method method : methodArray) + { + System.out.println(method); + } + } + catch (ClassNotFoundException | IOException e) + { + e.printStackTrace(); + } + + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_display_metadata/ReflectionDemo/src/Student.java b/BasicJava/ReflectionDemo_display_metadata/ReflectionDemo/src/Student.java new file mode 100644 index 000000000..855e7f3ac --- /dev/null +++ b/BasicJava/ReflectionDemo_display_metadata/ReflectionDemo/src/Student.java @@ -0,0 +1,28 @@ + +public class Student +{ + private String first; // first name + private String last; // last name + private String email; // email address + private int section; // section number + + // construct a new student with given fields + public Student(String first, String last, String email, int section) + { + this.first = first; + this.last = last; + this.email = email; + this.section = section; + } + + public void showStudentFullName() + { + System.out.println(first+last); + } + + // return a string representation of the invoking object + public String toString() + { + return section + " " + first + " " + last + " " + email; + } +} diff --git a/BasicJava/ReflectionDemo_genericfieldType/Output.txt b/BasicJava/ReflectionDemo_genericfieldType/Output.txt new file mode 100644 index 000000000..1286bb73a --- /dev/null +++ b/BasicJava/ReflectionDemo_genericfieldType/Output.txt @@ -0,0 +1,3 @@ +genericFieldType = java.util.List +fieldArgClass = class java.lang.String +fieldArgClass Name = java.lang.String diff --git a/BasicJava/ReflectionDemo_genericfieldType/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo_genericfieldType/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo_genericfieldType/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo_genericfieldType/ReflectionDemo/.project b/BasicJava/ReflectionDemo_genericfieldType/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo_genericfieldType/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo_genericfieldType/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo_genericfieldType/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo_genericfieldType/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo_genericfieldType/ReflectionDemo/bin/Display.class b/BasicJava/ReflectionDemo_genericfieldType/ReflectionDemo/bin/Display.class new file mode 100644 index 000000000..8edca5d28 Binary files /dev/null and b/BasicJava/ReflectionDemo_genericfieldType/ReflectionDemo/bin/Display.class differ diff --git a/BasicJava/ReflectionDemo_genericfieldType/ReflectionDemo/bin/ReflectionDemo.class b/BasicJava/ReflectionDemo_genericfieldType/ReflectionDemo/bin/ReflectionDemo.class new file mode 100644 index 000000000..73f976c12 Binary files /dev/null and b/BasicJava/ReflectionDemo_genericfieldType/ReflectionDemo/bin/ReflectionDemo.class differ diff --git a/BasicJava/ReflectionDemo_genericfieldType/ReflectionDemo/src/Display.java b/BasicJava/ReflectionDemo_genericfieldType/ReflectionDemo/src/Display.java new file mode 100644 index 000000000..0a3933b84 --- /dev/null +++ b/BasicJava/ReflectionDemo_genericfieldType/ReflectionDemo/src/Display.java @@ -0,0 +1,7 @@ +import java.util.Arrays; +import java.util.List; + +public class Display +{ + public List nameList = Arrays.asList("Peter", "Juli", "Dave"); +} diff --git a/BasicJava/ReflectionDemo_genericfieldType/ReflectionDemo/src/ReflectionDemo.java b/BasicJava/ReflectionDemo_genericfieldType/ReflectionDemo/src/ReflectionDemo.java new file mode 100644 index 000000000..f09ad6125 --- /dev/null +++ b/BasicJava/ReflectionDemo_genericfieldType/ReflectionDemo/src/ReflectionDemo.java @@ -0,0 +1,41 @@ +import java.lang.reflect.Field; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; + +/** + * Generic Field Types:It is possible to access the generic types of public + * fields. + * + */ +public class ReflectionDemo +{ + public static void main(String[] args) + { + try + { + Class classObj = Display.class; + Field field = classObj.getField("nameList"); + Type genericFieldType = field.getGenericType(); + System.out.println("genericFieldType = " + genericFieldType); + + if (genericFieldType instanceof ParameterizedType) + { + ParameterizedType aType = (ParameterizedType) genericFieldType; + Type[] fieldArgTypes = aType.getActualTypeArguments(); + for (Type fieldArgType : fieldArgTypes) + { + Class fieldArgClass = (Class) fieldArgType; + System.out.println("fieldArgClass = " + fieldArgClass); + System.out.println( "fieldArgClass Name = " + fieldArgClass.getName()); + } + } + + } + catch (NoSuchFieldException | SecurityException e) + { + e.printStackTrace(); + } + + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_genericreturntype_method/Output.txt b/BasicJava/ReflectionDemo_genericreturntype_method/Output.txt new file mode 100644 index 000000000..37338b6c5 --- /dev/null +++ b/BasicJava/ReflectionDemo_genericreturntype_method/Output.txt @@ -0,0 +1,3 @@ +type = java.util.List +typeArgClass = class java.lang.String +typeArgClass Name = java.lang.String diff --git a/BasicJava/ReflectionDemo_genericreturntype_method/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo_genericreturntype_method/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo_genericreturntype_method/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo_genericreturntype_method/ReflectionDemo/.project b/BasicJava/ReflectionDemo_genericreturntype_method/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo_genericreturntype_method/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo_genericreturntype_method/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo_genericreturntype_method/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo_genericreturntype_method/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo_genericreturntype_method/ReflectionDemo/bin/Display.class b/BasicJava/ReflectionDemo_genericreturntype_method/ReflectionDemo/bin/Display.class new file mode 100644 index 000000000..fb6c712e9 Binary files /dev/null and b/BasicJava/ReflectionDemo_genericreturntype_method/ReflectionDemo/bin/Display.class differ diff --git a/BasicJava/ReflectionDemo_genericreturntype_method/ReflectionDemo/bin/ReflectionDemo.class b/BasicJava/ReflectionDemo_genericreturntype_method/ReflectionDemo/bin/ReflectionDemo.class new file mode 100644 index 000000000..955ae1009 Binary files /dev/null and b/BasicJava/ReflectionDemo_genericreturntype_method/ReflectionDemo/bin/ReflectionDemo.class differ diff --git a/BasicJava/ReflectionDemo_genericreturntype_method/ReflectionDemo/src/Display.java b/BasicJava/ReflectionDemo_genericreturntype_method/ReflectionDemo/src/Display.java new file mode 100644 index 000000000..24fc7723d --- /dev/null +++ b/BasicJava/ReflectionDemo_genericreturntype_method/ReflectionDemo/src/Display.java @@ -0,0 +1,13 @@ +import java.util.Arrays; +import java.util.List; + +public class Display +{ + + protected List nameList = Arrays.asList("Peter","Juli","Dave"); + + public List getNameList() + { + return this.nameList; + } +} diff --git a/BasicJava/ReflectionDemo_genericreturntype_method/ReflectionDemo/src/ReflectionDemo.java b/BasicJava/ReflectionDemo_genericreturntype_method/ReflectionDemo/src/ReflectionDemo.java new file mode 100644 index 000000000..8e163e298 --- /dev/null +++ b/BasicJava/ReflectionDemo_genericreturntype_method/ReflectionDemo/src/ReflectionDemo.java @@ -0,0 +1,38 @@ +import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; + +/** + * How to get Generic return Type of the method + */ +public class ReflectionDemo +{ + public static void main(String[] args) + { + try + { + Class classObj = Display.class; + Method method = classObj.getMethod("getNameList", null); + Type type = method.getGenericReturnType(); + System.out.println("type = "+type); + + if (type instanceof ParameterizedType) + { + ParameterizedType parameterizedType = (ParameterizedType) type; + Type[] typeArguments = parameterizedType.getActualTypeArguments(); + for (Type typeArgument : typeArguments) + { + Class typeArgClass = (Class) typeArgument; + System.out.println("typeArgClass = " + typeArgClass); + System.out.println("typeArgClass Name = " + typeArgClass.getName()); + } + } + } + catch (NoSuchMethodException | SecurityException e) + { + e.printStackTrace(); + } + + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_genericreturntype_param/Output.txt b/BasicJava/ReflectionDemo_genericreturntype_param/Output.txt new file mode 100644 index 000000000..05cf7d8da --- /dev/null +++ b/BasicJava/ReflectionDemo_genericreturntype_param/Output.txt @@ -0,0 +1,3 @@ +genericParameterType = java.util.List +parameterArgClass = class java.lang.String +parameterArgClass Name = java.lang.String diff --git a/BasicJava/ReflectionDemo_genericreturntype_param/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo_genericreturntype_param/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo_genericreturntype_param/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo_genericreturntype_param/ReflectionDemo/.project b/BasicJava/ReflectionDemo_genericreturntype_param/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo_genericreturntype_param/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo_genericreturntype_param/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo_genericreturntype_param/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo_genericreturntype_param/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo_genericreturntype_param/ReflectionDemo/bin/Display.class b/BasicJava/ReflectionDemo_genericreturntype_param/ReflectionDemo/bin/Display.class new file mode 100644 index 000000000..6312946e1 Binary files /dev/null and b/BasicJava/ReflectionDemo_genericreturntype_param/ReflectionDemo/bin/Display.class differ diff --git a/BasicJava/ReflectionDemo_genericreturntype_param/ReflectionDemo/bin/ReflectionDemo.class b/BasicJava/ReflectionDemo_genericreturntype_param/ReflectionDemo/bin/ReflectionDemo.class new file mode 100644 index 000000000..6a854d82e Binary files /dev/null and b/BasicJava/ReflectionDemo_genericreturntype_param/ReflectionDemo/bin/ReflectionDemo.class differ diff --git a/BasicJava/ReflectionDemo_genericreturntype_param/ReflectionDemo/src/Display.java b/BasicJava/ReflectionDemo_genericreturntype_param/ReflectionDemo/src/Display.java new file mode 100644 index 000000000..038f23c14 --- /dev/null +++ b/BasicJava/ReflectionDemo_genericreturntype_param/ReflectionDemo/src/Display.java @@ -0,0 +1,13 @@ +import java.util.List; + +public class Display +{ + + protected List nameList; + + public void setNameList(List nameList) + { + this.nameList = nameList; + } + +} diff --git a/BasicJava/ReflectionDemo_genericreturntype_param/ReflectionDemo/src/ReflectionDemo.java b/BasicJava/ReflectionDemo_genericreturntype_param/ReflectionDemo/src/ReflectionDemo.java new file mode 100644 index 000000000..4ae06499a --- /dev/null +++ b/BasicJava/ReflectionDemo_genericreturntype_param/ReflectionDemo/src/ReflectionDemo.java @@ -0,0 +1,42 @@ +import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.List; + +/** + * We can access the generic parameter types of the method parameters + */ +public class ReflectionDemo +{ + public static void main(String[] args) + { + try + { + Class classObj = Display.class; + Method method = classObj.getMethod("setNameList", List.class); + Type[] genericParameterTypes = method.getGenericParameterTypes(); + + for (Type genericParameterType : genericParameterTypes) + { + System.out.println("genericParameterType = "+genericParameterType); + if (genericParameterType instanceof ParameterizedType) + { + ParameterizedType aType = (ParameterizedType) genericParameterType; + Type[] parameterArgTypes = aType.getActualTypeArguments(); + for (Type parameterArgType : parameterArgTypes) + { + Class parameterArgClass = (Class) parameterArgType; + System.out.println("parameterArgClass = " + parameterArgClass); + System.out.println("parameterArgClass Name = " + parameterArgClass.getName()); + } + } + } + } + catch (NoSuchMethodException | SecurityException e) + { + e.printStackTrace(); + } + + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/.project b/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/bin/ReflectionDemo1.class b/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/bin/ReflectionDemo1.class new file mode 100644 index 000000000..b0e36faea Binary files /dev/null and b/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/bin/ReflectionDemo1.class differ diff --git a/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/bin/ReflectionDemo2.class b/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/bin/ReflectionDemo2.class new file mode 100644 index 000000000..f05c63a87 Binary files /dev/null and b/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/bin/ReflectionDemo2.class differ diff --git a/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/bin/ReflectionDemo3.class b/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/bin/ReflectionDemo3.class new file mode 100644 index 000000000..c2c73b880 Binary files /dev/null and b/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/bin/ReflectionDemo3.class differ diff --git a/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/bin/com/Student.class b/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/bin/com/Student.class new file mode 100644 index 000000000..a95672064 Binary files /dev/null and b/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/bin/com/Student.class differ diff --git a/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/src/ReflectionDemo1.java b/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/src/ReflectionDemo1.java new file mode 100644 index 000000000..0b9993c98 --- /dev/null +++ b/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/src/ReflectionDemo1.java @@ -0,0 +1,26 @@ +public class ReflectionDemo1 +{ + public static void main(String[] args) + { + try + { + /* + * forName() method is used to load the class dynamically + * + * Returns:the Class object for the class with the + * specified name. + * + * forName() method should be used if you know the fully + * qualified name of class.This cannot be used for + * primitive types. r + */ + Class classObj = Class.forName("com.Student"); + System.out.println(classObj.getName()); + System.out.println(classObj.getSimpleName()); + } + catch (ClassNotFoundException e) + { + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/src/ReflectionDemo2.java b/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/src/ReflectionDemo2.java new file mode 100644 index 000000000..6885e8fe8 --- /dev/null +++ b/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/src/ReflectionDemo2.java @@ -0,0 +1,18 @@ +import com.Student; + +public class ReflectionDemo2 +{ + public static void main(String[] args) + { + Student student = new Student("Peter", 25); + + /* + * Returns:The Class object that represents the runtime class of this + * object. + */ + Class classObj = student.getClass(); + System.out.println(classObj.getName()); + + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/src/ReflectionDemo3.java b/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/src/ReflectionDemo3.java new file mode 100644 index 000000000..a918778fb --- /dev/null +++ b/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/src/ReflectionDemo3.java @@ -0,0 +1,19 @@ +import com.Student; + +public class ReflectionDemo3 +{ + public static void main(String[] args) + { + /* + * If a type is available but there is no instance then it is possible + * to obtain a Class by appending ".class" to the name of the type.It + * can be used for primitive data type also. + */ + Class studentClassObj = Student.class; + System.out.println(studentClassObj.getName()); + + Class intClassObj = int.class; + System.out.println(intClassObj.getName()); + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/src/com/Student.java b/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/src/com/Student.java new file mode 100644 index 000000000..d3dbf439b --- /dev/null +++ b/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo/src/com/Student.java @@ -0,0 +1,35 @@ +package com; + +public class Student +{ + private String name; + private int age; + + public Student(String name, int age) + { + super(); + this.name = name; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + +} diff --git a/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo1_Output.txt b/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo1_Output.txt new file mode 100644 index 000000000..f37264377 --- /dev/null +++ b/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo1_Output.txt @@ -0,0 +1,2 @@ +com.Student +Student diff --git a/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo2_Output.txt b/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo2_Output.txt new file mode 100644 index 000000000..6723d4420 --- /dev/null +++ b/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo2_Output.txt @@ -0,0 +1 @@ +com.Student diff --git a/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo3_Output.txt b/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo3_Output.txt new file mode 100644 index 000000000..464e31a12 --- /dev/null +++ b/BasicJava/ReflectionDemo_get_objectOfClass/ReflectionDemo3_Output.txt @@ -0,0 +1,2 @@ +com.Student +int diff --git a/BasicJava/ReflectionDemo_get_set_field/Output.txt b/BasicJava/ReflectionDemo_get_set_field/Output.txt new file mode 100644 index 000000000..55c52941d --- /dev/null +++ b/BasicJava/ReflectionDemo_get_set_field/Output.txt @@ -0,0 +1,3 @@ +Field Name = age +Field Type = int +age = 23 diff --git a/BasicJava/ReflectionDemo_get_set_field/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo_get_set_field/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo_get_set_field/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo_get_set_field/ReflectionDemo/.project b/BasicJava/ReflectionDemo_get_set_field/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo_get_set_field/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo_get_set_field/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo_get_set_field/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo_get_set_field/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo_get_set_field/ReflectionDemo/bin/ReflectionDemo.class b/BasicJava/ReflectionDemo_get_set_field/ReflectionDemo/bin/ReflectionDemo.class new file mode 100644 index 000000000..65bcd2370 Binary files /dev/null and b/BasicJava/ReflectionDemo_get_set_field/ReflectionDemo/bin/ReflectionDemo.class differ diff --git a/BasicJava/ReflectionDemo_get_set_field/ReflectionDemo/bin/Student.class b/BasicJava/ReflectionDemo_get_set_field/ReflectionDemo/bin/Student.class new file mode 100644 index 000000000..5e8dfb1a5 Binary files /dev/null and b/BasicJava/ReflectionDemo_get_set_field/ReflectionDemo/bin/Student.class differ diff --git a/BasicJava/ReflectionDemo_get_set_field/ReflectionDemo/src/ReflectionDemo.java b/BasicJava/ReflectionDemo_get_set_field/ReflectionDemo/src/ReflectionDemo.java new file mode 100644 index 000000000..42b020f80 --- /dev/null +++ b/BasicJava/ReflectionDemo_get_set_field/ReflectionDemo/src/ReflectionDemo.java @@ -0,0 +1,39 @@ +import java.lang.reflect.Field; + +/** + * + * Getting and Setting Field Values. + * + */ +public class ReflectionDemo +{ + public static void main(String[] args) + { + try + { + Class classObj = Student.class; + /* + * Returns:the Field object of this class specified by name + */ + Field ageField = classObj.getField("age"); + System.out.println("Field Name = " + ageField.getName()); + System.out.println("Field Type = " + ageField.getType()); + + Student student = classObj.newInstance(); + /* + * Sets the field represented by this Field object on the specified + * object argument to the specified new value. + */ + ageField.set(student, 23); + Object ageValue = ageField.get(student); + System.out.println("age = "+ageValue); + } + catch (NoSuchFieldException | SecurityException + | IllegalArgumentException | IllegalAccessException + | InstantiationException e) + { + e.printStackTrace(); + } + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_get_set_field/ReflectionDemo/src/Student.java b/BasicJava/ReflectionDemo_get_set_field/ReflectionDemo/src/Student.java new file mode 100644 index 000000000..f404ac264 --- /dev/null +++ b/BasicJava/ReflectionDemo_get_set_field/ReflectionDemo/src/Student.java @@ -0,0 +1,6 @@ +class Student +{ + public String name; + public int age; +} + diff --git a/BasicJava/ReflectionDemo_getter_setter_find/Output.txt b/BasicJava/ReflectionDemo_getter_setter_find/Output.txt new file mode 100644 index 000000000..f409355cd --- /dev/null +++ b/BasicJava/ReflectionDemo_getter_setter_find/Output.txt @@ -0,0 +1,5 @@ +getter: public java.lang.String Student.getName() +setter: public void Student.setName(java.lang.String) +getter: public int Student.getAge() +setter: public void Student.setAge(int) +getter: public final native java.lang.Class java.lang.Object.getClass() diff --git a/BasicJava/ReflectionDemo_getter_setter_find/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo_getter_setter_find/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo_getter_setter_find/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo_getter_setter_find/ReflectionDemo/.project b/BasicJava/ReflectionDemo_getter_setter_find/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo_getter_setter_find/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo_getter_setter_find/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo_getter_setter_find/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo_getter_setter_find/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo_getter_setter_find/ReflectionDemo/bin/ReflectionDemo.class b/BasicJava/ReflectionDemo_getter_setter_find/ReflectionDemo/bin/ReflectionDemo.class new file mode 100644 index 000000000..3f408f7bd Binary files /dev/null and b/BasicJava/ReflectionDemo_getter_setter_find/ReflectionDemo/bin/ReflectionDemo.class differ diff --git a/BasicJava/ReflectionDemo_getter_setter_find/ReflectionDemo/bin/Student.class b/BasicJava/ReflectionDemo_getter_setter_find/ReflectionDemo/bin/Student.class new file mode 100644 index 000000000..f7581b8c2 Binary files /dev/null and b/BasicJava/ReflectionDemo_getter_setter_find/ReflectionDemo/bin/Student.class differ diff --git a/BasicJava/ReflectionDemo_getter_setter_find/ReflectionDemo/src/ReflectionDemo.java b/BasicJava/ReflectionDemo_getter_setter_find/ReflectionDemo/src/ReflectionDemo.java new file mode 100644 index 000000000..66711b441 --- /dev/null +++ b/BasicJava/ReflectionDemo_getter_setter_find/ReflectionDemo/src/ReflectionDemo.java @@ -0,0 +1,61 @@ +import java.lang.reflect.Method; + +/** + * + * Java Reflection - Getters and Setters. + * + */ +public class ReflectionDemo +{ + public static void main(String[] args) + { + Class classObj = Student.class; + Method[] methodArray = classObj.getMethods(); + for (Method method : methodArray) + { + if (isGetter(method)) + System.out.println("getter: " + method); + if (isSetter(method)) + System.out.println("setter: " + method); + } + } + + /** + * Getter: A getter method have its name start with "get", take 0 + * parameters, and returns a value. + */ + public static boolean isGetter(Method method) + { + if (!method.getName().startsWith("get")) + { + return false; + } + if (method.getParameterTypes().length != 0) + { + return false; + } + if (void.class.equals(method.getReturnType())) + { + return false; + } + return true; + } + + /** + * Setter: A setter method have its name start with "set", and + * takes 1 parameter. + */ + public static boolean isSetter(Method method) + { + if (!method.getName().startsWith("set")) + { + return false; + } + if (method.getParameterTypes().length != 1) + { + return false; + } + return true; + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_getter_setter_find/ReflectionDemo/src/Student.java b/BasicJava/ReflectionDemo_getter_setter_find/ReflectionDemo/src/Student.java new file mode 100644 index 000000000..fc7f76271 --- /dev/null +++ b/BasicJava/ReflectionDemo_getter_setter_find/ReflectionDemo/src/Student.java @@ -0,0 +1,30 @@ +class Student +{ + private String name; + private int age; + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + public void displayMessage(String message) + { + System.out.println(message); + } +} diff --git a/BasicJava/ReflectionDemo_method_paramcount/Output.txt b/BasicJava/ReflectionDemo_method_paramcount/Output.txt new file mode 100644 index 000000000..66aeac409 --- /dev/null +++ b/BasicJava/ReflectionDemo_method_paramcount/Output.txt @@ -0,0 +1,30 @@ +public void DisplayMessage.displayMessage(java.lang.String) +Parameter Count = 1 +--------------------------- +public final void java.lang.Object.wait() throws java.lang.InterruptedException +Parameter Count = 0 +--------------------------- +public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException +Parameter Count = 2 +--------------------------- +public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException +Parameter Count = 1 +--------------------------- +public boolean java.lang.Object.equals(java.lang.Object) +Parameter Count = 1 +--------------------------- +public java.lang.String java.lang.Object.toString() +Parameter Count = 0 +--------------------------- +public native int java.lang.Object.hashCode() +Parameter Count = 0 +--------------------------- +public final native java.lang.Class java.lang.Object.getClass() +Parameter Count = 0 +--------------------------- +public final native void java.lang.Object.notify() +Parameter Count = 0 +--------------------------- +public final native void java.lang.Object.notifyAll() +Parameter Count = 0 +--------------------------- diff --git a/BasicJava/ReflectionDemo_method_paramcount/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo_method_paramcount/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo_method_paramcount/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo_method_paramcount/ReflectionDemo/.project b/BasicJava/ReflectionDemo_method_paramcount/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo_method_paramcount/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo_method_paramcount/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo_method_paramcount/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo_method_paramcount/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo_method_paramcount/ReflectionDemo/bin/DisplayMessage.class b/BasicJava/ReflectionDemo_method_paramcount/ReflectionDemo/bin/DisplayMessage.class new file mode 100644 index 000000000..085495cee Binary files /dev/null and b/BasicJava/ReflectionDemo_method_paramcount/ReflectionDemo/bin/DisplayMessage.class differ diff --git a/BasicJava/ReflectionDemo_method_paramcount/ReflectionDemo/bin/ReflectionDemo.class b/BasicJava/ReflectionDemo_method_paramcount/ReflectionDemo/bin/ReflectionDemo.class new file mode 100644 index 000000000..5c10fcbb3 Binary files /dev/null and b/BasicJava/ReflectionDemo_method_paramcount/ReflectionDemo/bin/ReflectionDemo.class differ diff --git a/BasicJava/ReflectionDemo_method_paramcount/ReflectionDemo/src/DisplayMessage.java b/BasicJava/ReflectionDemo_method_paramcount/ReflectionDemo/src/DisplayMessage.java new file mode 100644 index 000000000..c90a4a2e3 --- /dev/null +++ b/BasicJava/ReflectionDemo_method_paramcount/ReflectionDemo/src/DisplayMessage.java @@ -0,0 +1,9 @@ +class DisplayMessage +{ + + public void displayMessage(String message) + { + System.out.println(message); + } +} + diff --git a/BasicJava/ReflectionDemo_method_paramcount/ReflectionDemo/src/ReflectionDemo.java b/BasicJava/ReflectionDemo_method_paramcount/ReflectionDemo/src/ReflectionDemo.java new file mode 100644 index 000000000..15e7f6098 --- /dev/null +++ b/BasicJava/ReflectionDemo_method_paramcount/ReflectionDemo/src/ReflectionDemo.java @@ -0,0 +1,22 @@ +import java.lang.reflect.Method; + +/** + * + * How to get method parameter count. + * + */ +public class ReflectionDemo +{ + public static void main(String[] args) + { + Class classObj = DisplayMessage.class; + Method[] methodArray = classObj.getMethods(); + for (Method method : methodArray) + { + System.out.println(method); + System.out.println("Parameter Count = "+method.getParameterCount()); + System.out.println("---------------------------"); + } + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_newInstance/Output.txt b/BasicJava/ReflectionDemo_newInstance/Output.txt new file mode 100644 index 000000000..4216f14b6 --- /dev/null +++ b/BasicJava/ReflectionDemo_newInstance/Output.txt @@ -0,0 +1 @@ +Hello....... diff --git a/BasicJava/ReflectionDemo_newInstance/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo_newInstance/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo_newInstance/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo_newInstance/ReflectionDemo/.project b/BasicJava/ReflectionDemo_newInstance/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo_newInstance/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo_newInstance/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo_newInstance/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo_newInstance/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo_newInstance/ReflectionDemo/bin/DisplayMessage.class b/BasicJava/ReflectionDemo_newInstance/ReflectionDemo/bin/DisplayMessage.class new file mode 100644 index 000000000..e4a48c4da Binary files /dev/null and b/BasicJava/ReflectionDemo_newInstance/ReflectionDemo/bin/DisplayMessage.class differ diff --git a/BasicJava/ReflectionDemo_newInstance/ReflectionDemo/bin/ReflectionDemo.class b/BasicJava/ReflectionDemo_newInstance/ReflectionDemo/bin/ReflectionDemo.class new file mode 100644 index 000000000..4286f3406 Binary files /dev/null and b/BasicJava/ReflectionDemo_newInstance/ReflectionDemo/bin/ReflectionDemo.class differ diff --git a/BasicJava/ReflectionDemo_newInstance/ReflectionDemo/src/DisplayMessage.java b/BasicJava/ReflectionDemo_newInstance/ReflectionDemo/src/DisplayMessage.java new file mode 100644 index 000000000..8c1ad9e09 --- /dev/null +++ b/BasicJava/ReflectionDemo_newInstance/ReflectionDemo/src/DisplayMessage.java @@ -0,0 +1,8 @@ + +public class DisplayMessage +{ + public void sayHello() + { + System.out.println("Hello......."); + } +} diff --git a/BasicJava/ReflectionDemo_newInstance/ReflectionDemo/src/ReflectionDemo.java b/BasicJava/ReflectionDemo_newInstance/ReflectionDemo/src/ReflectionDemo.java new file mode 100644 index 000000000..6d89ddaca --- /dev/null +++ b/BasicJava/ReflectionDemo_newInstance/ReflectionDemo/src/ReflectionDemo.java @@ -0,0 +1,24 @@ +public class ReflectionDemo +{ + public static void main(String[] args) + { + + try + { + Class classObj = Class.forName("DisplayMessage"); + /* + * Returns:a newly allocated instance of the class represented by + * this object. + */ + DisplayMessage displayMessage = (DisplayMessage) classObj.newInstance(); + displayMessage.sayHello(); + } + catch (InstantiationException | IllegalAccessException + | ClassNotFoundException e) + { + e.printStackTrace(); + } + + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_package_info/Output.txt b/BasicJava/ReflectionDemo_package_info/Output.txt new file mode 100644 index 000000000..bd83d5178 --- /dev/null +++ b/BasicJava/ReflectionDemo_package_info/Output.txt @@ -0,0 +1,5 @@ +Package Name = java.util +ImplementationTitle = Java Runtime Environment +ImplementationVersion = 1.8.0_144 +SpecificationVendor = Oracle Corporation +SpecificationTitle = Java Platform API Specification diff --git a/BasicJava/ReflectionDemo_package_info/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo_package_info/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo_package_info/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo_package_info/ReflectionDemo/.project b/BasicJava/ReflectionDemo_package_info/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo_package_info/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo_package_info/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo_package_info/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo_package_info/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo_package_info/ReflectionDemo/bin/ReflectionDemo.class b/BasicJava/ReflectionDemo_package_info/ReflectionDemo/bin/ReflectionDemo.class new file mode 100644 index 000000000..1ff6913b5 Binary files /dev/null and b/BasicJava/ReflectionDemo_package_info/ReflectionDemo/bin/ReflectionDemo.class differ diff --git a/BasicJava/ReflectionDemo_package_info/ReflectionDemo/src/ReflectionDemo.java b/BasicJava/ReflectionDemo_package_info/ReflectionDemo/src/ReflectionDemo.java new file mode 100644 index 000000000..7ca9c2770 --- /dev/null +++ b/BasicJava/ReflectionDemo_package_info/ReflectionDemo/src/ReflectionDemo.java @@ -0,0 +1,37 @@ +import java.util.ArrayList; + +public class ReflectionDemo +{ + public static void main(String[] args) + { + + Class classObj = ArrayList.class; + /* + * Gets the package for this class. The class loader of this class is + * used to find the package. + */ + Package packageObj = classObj.getPackage(); + /* + * Returns:The fully-qualified name of this package + */ + System.out.println("Package Name = " + packageObj.getName()); + /* + * Returns:the title of the implementation, null is returned if it is not known. + */ + System.out.println("ImplementationTitle = "+packageObj.getImplementationTitle()); + /* + * Returns:the version of the implementation, null is returned if it is not known. + */ + System.out.println("ImplementationVersion = "+packageObj.getImplementationVersion()); + /* + * Returns:the specification vendor, null is returned if it is not known. + */ + System.out.println("SpecificationVendor = "+packageObj.getSpecificationVendor()); + + /* + * Returns:the specification title, null is returned if it is not known. + */ + System.out.println("SpecificationTitle = "+packageObj.getSpecificationTitle()); + } + +} \ No newline at end of file diff --git a/BasicJava/ReflectionDemo_param_private_method/Output.txt b/BasicJava/ReflectionDemo_param_private_method/Output.txt new file mode 100644 index 000000000..83b33d238 --- /dev/null +++ b/BasicJava/ReflectionDemo_param_private_method/Output.txt @@ -0,0 +1 @@ +1000 diff --git a/BasicJava/ReflectionDemo_param_private_method/ReflectionDemo/.classpath b/BasicJava/ReflectionDemo_param_private_method/ReflectionDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ReflectionDemo_param_private_method/ReflectionDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ReflectionDemo_param_private_method/ReflectionDemo/.project b/BasicJava/ReflectionDemo_param_private_method/ReflectionDemo/.project new file mode 100644 index 000000000..7e4540c4f --- /dev/null +++ b/BasicJava/ReflectionDemo_param_private_method/ReflectionDemo/.project @@ -0,0 +1,17 @@ + + + ReflectionDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ReflectionDemo_param_private_method/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ReflectionDemo_param_private_method/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ReflectionDemo_param_private_method/ReflectionDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ReflectionDemo_param_private_method/ReflectionDemo/bin/Display.class b/BasicJava/ReflectionDemo_param_private_method/ReflectionDemo/bin/Display.class new file mode 100644 index 000000000..a78ed16cc Binary files /dev/null and b/BasicJava/ReflectionDemo_param_private_method/ReflectionDemo/bin/Display.class differ diff --git a/BasicJava/ReflectionDemo_param_private_method/ReflectionDemo/bin/ReflectionDemo.class b/BasicJava/ReflectionDemo_param_private_method/ReflectionDemo/bin/ReflectionDemo.class new file mode 100644 index 000000000..e52f7bc60 Binary files /dev/null and b/BasicJava/ReflectionDemo_param_private_method/ReflectionDemo/bin/ReflectionDemo.class differ diff --git a/BasicJava/ReflectionDemo_param_private_method/ReflectionDemo/src/Display.java b/BasicJava/ReflectionDemo_param_private_method/ReflectionDemo/src/Display.java new file mode 100644 index 000000000..ce3ff5f9d --- /dev/null +++ b/BasicJava/ReflectionDemo_param_private_method/ReflectionDemo/src/Display.java @@ -0,0 +1,8 @@ + +public class Display +{ + private void DisplayNumber(int i) + { + System.out.println(i); + } +} diff --git a/BasicJava/ReflectionDemo_param_private_method/ReflectionDemo/src/ReflectionDemo.java b/BasicJava/ReflectionDemo_param_private_method/ReflectionDemo/src/ReflectionDemo.java new file mode 100644 index 000000000..98fd9feee --- /dev/null +++ b/BasicJava/ReflectionDemo_param_private_method/ReflectionDemo/src/ReflectionDemo.java @@ -0,0 +1,33 @@ +import java.lang.reflect.Method; + +/** + * How to call parameterized private method from another class? + * + * We can call the private method from outside the class by changing the runtime + * behaviour of the class. + * + * By the help of "java.lang.Class" class and "java.lang.reflect.Method" class, + * we can call private method from any other class. + * + */ +public class ReflectionDemo +{ + public static void main(String[] args) + { + try + { + Class classObj = Display.class; + Object displayObject = classObj.newInstance(); + + Method method = classObj.getDeclaredMethod("DisplayNumber", new Class[] { int.class }); + method.setAccessible(true); + method.invoke(displayObject, 1000); + } + catch (Exception e) + { + e.printStackTrace(); + } + + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo-multiple_group_john/Output.txt b/BasicJava/RegexDemo-multiple_group_john/Output.txt new file mode 100644 index 000000000..54e402501 --- /dev/null +++ b/BasicJava/RegexDemo-multiple_group_john/Output.txt @@ -0,0 +1,3 @@ +found: John writes +found: John Doe +found: John Wayne diff --git a/BasicJava/RegexDemo-multiple_group_john/RegexDemo/.classpath b/BasicJava/RegexDemo-multiple_group_john/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo-multiple_group_john/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo-multiple_group_john/RegexDemo/.project b/BasicJava/RegexDemo-multiple_group_john/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo-multiple_group_john/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo-multiple_group_john/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo-multiple_group_john/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo-multiple_group_john/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo-multiple_group_john/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo-multiple_group_john/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..5ff98c5dd Binary files /dev/null and b/BasicJava/RegexDemo-multiple_group_john/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo-multiple_group_john/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo-multiple_group_john/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..a61d239fc --- /dev/null +++ b/BasicJava/RegexDemo-multiple_group_john/RegexDemo/src/RegexDemo.java @@ -0,0 +1,40 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Multiple Groups: + * A regular expression can have multiple groups. + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + String text = "John writes about this, and John Doe writes about that," + + " and John Wayne writes about everything."; + + /* + * This expression matches the text "John" followed by a + * space, and then one or more characters. + * + * This expression contains a few characters with special + * meanings in a regular expression. The . means + * "any character". The + means "one or more times", and + * relates to the . (any character, one or more times). The ? + * means "match as small a number of characters as possible". + */ + String regex = "(John) (.+?) "; + + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(text); + + while (matcher.find()) + { + System.out.println("found: " + matcher.group(1) + " " + + matcher.group(2)); + } + + } + +} diff --git a/BasicJava/RegexDemo_24hrs/Output.txt b/BasicJava/RegexDemo_24hrs/Output.txt new file mode 100644 index 000000000..e9f4ad31c --- /dev/null +++ b/BasicJava/RegexDemo_24hrs/Output.txt @@ -0,0 +1,8 @@ +2:00 is Valid? = true +23:00 is Valid? = true +14:50 is Valid? = true +-------------------------------------- +24:00 is Valid? = false +13:1 is Valid? = false +1:9 is Valid? = false +110:20 is Valid? = false diff --git a/BasicJava/RegexDemo_24hrs/RegexDemo/.classpath b/BasicJava/RegexDemo_24hrs/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_24hrs/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_24hrs/RegexDemo/.project b/BasicJava/RegexDemo_24hrs/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_24hrs/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_24hrs/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_24hrs/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_24hrs/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_24hrs/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_24hrs/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..ca964d514 Binary files /dev/null and b/BasicJava/RegexDemo_24hrs/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_24hrs/RegexDemo/bin/Time24HoursValidator.class b/BasicJava/RegexDemo_24hrs/RegexDemo/bin/Time24HoursValidator.class new file mode 100644 index 000000000..40924e048 Binary files /dev/null and b/BasicJava/RegexDemo_24hrs/RegexDemo/bin/Time24HoursValidator.class differ diff --git a/BasicJava/RegexDemo_24hrs/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_24hrs/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..92656927c --- /dev/null +++ b/BasicJava/RegexDemo_24hrs/RegexDemo/src/RegexDemo.java @@ -0,0 +1,37 @@ +import java.util.Arrays; +import java.util.List; + +/** + * + * How to validate Time in 24 Hours format with regular expression + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + List validTimeList = Arrays.asList("2:00", "23:00", "14:50"); + + Time24HoursValidator time24HoursValidator = new Time24HoursValidator(); + + for (String time : validTimeList) + { + System.out.println(time + " is Valid? = " + + time24HoursValidator.validate(time)); + } + + System.out.println("--------------------------------------"); + + List inValidTimeList = Arrays.asList("24:00", "13:1", "1:9", "110:20"); + + for (String time : inValidTimeList) + { + System.out.println(time + " is Valid? = " + + time24HoursValidator.validate(time)); + } + + + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_24hrs/RegexDemo/src/Time24HoursValidator.java b/BasicJava/RegexDemo_24hrs/RegexDemo/src/Time24HoursValidator.java new file mode 100644 index 000000000..5083a65ca --- /dev/null +++ b/BasicJava/RegexDemo_24hrs/RegexDemo/src/Time24HoursValidator.java @@ -0,0 +1,27 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * How to validate Time in 24 Hours format with regular expression + * + */ +public class Time24HoursValidator +{ + + private Pattern pattern; + private Matcher matcher; + + private static final String TIME24HOURS_REGEX = "([01]?[0-9]|2[0-3]):[0-5][0-9]"; + + public Time24HoursValidator() + { + pattern = Pattern.compile(TIME24HOURS_REGEX); + } + + public boolean validate(final String time) + { + matcher = pattern.matcher(time); + return matcher.matches(); + } +} diff --git a/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo/.classpath b/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo/.project b/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo/bin/RegexDemo1.class b/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo/bin/RegexDemo1.class new file mode 100644 index 000000000..05baafcea Binary files /dev/null and b/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo/bin/RegexDemo1.class differ diff --git a/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo/bin/RegexDemo2.class b/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo/bin/RegexDemo2.class new file mode 100644 index 000000000..69c3a35f2 Binary files /dev/null and b/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo/bin/RegexDemo2.class differ diff --git a/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo/bin/RegexDemo3.class b/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo/bin/RegexDemo3.class new file mode 100644 index 000000000..d7ed503f0 Binary files /dev/null and b/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo/bin/RegexDemo3.class differ diff --git a/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo/src/RegexDemo1.java b/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo/src/RegexDemo1.java new file mode 100644 index 000000000..7bee5104d --- /dev/null +++ b/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo/src/RegexDemo1.java @@ -0,0 +1,28 @@ +import java.util.regex.Pattern; + + +public class RegexDemo1 +{ + public static void main(String[] args) + { + System.out.println("X{n} = X occurs n times only"); + /* + * Parameters: + * + * regex - The expression to be compiled + * + * input - The character sequence to be matched + * + * Returns: + * + * whether or not the regular expression matches on the input + * + */ + System.out.println(Pattern.matches("a{3}", "aaa"));//true (a should come 3 times) + System.out.println(Pattern.matches("a{3}", "aaaaaa"));//false (a should come 3 times) + System.out.println(Pattern.matches("a{3}", "aa"));//false (a should come 3 times) + System.out.println(Pattern.matches("a{3}", "a"));//false (a should come 3 times) + System.out.println(Pattern.matches("a{3}", "bbb"));//false (a should come 3 times) + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo/src/RegexDemo2.java b/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo/src/RegexDemo2.java new file mode 100644 index 000000000..f997b33ab --- /dev/null +++ b/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo/src/RegexDemo2.java @@ -0,0 +1,27 @@ +import java.util.regex.Pattern; + +public class RegexDemo2 +{ + public static void main(String[] args) + { + System.out.println("X{n,} = X occurs n or more times"); + /* + * Parameters: + * + * regex - The expression to be compiled + * + * input - The character sequence to be matched + * + * Returns: + * + * whether or not the regular expression matches on the input + * + */ + System.out.println(Pattern.matches("a{3,}", "aaa"));//true (a can come 3 times or more) + System.out.println(Pattern.matches("a{3,}", "aaaaaa"));//true (a can come 3 times or more) + System.out.println(Pattern.matches("a{3,}", "aa"));//false (a can come 3 times or more) + System.out.println(Pattern.matches("a{3,}", "a"));//false (a can come 3 times or more) + System.out.println(Pattern.matches("a{3,}", "bbb"));//false (a can come 3 times or more) + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo/src/RegexDemo3.java b/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo/src/RegexDemo3.java new file mode 100644 index 000000000..96760d1bf --- /dev/null +++ b/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo/src/RegexDemo3.java @@ -0,0 +1,28 @@ +import java.util.regex.Pattern; + +public class RegexDemo3 +{ + public static void main(String[] args) + { + System.out.println("X{y,z} = X occurs at least y times but less than or equal to z times"); + /* + * Parameters: + * + * regex - The expression to be compiled + * + * input - The character sequence to be matched + * + * Returns: + * + * whether or not the regular expression matches on the input + * + */ + System.out.println(Pattern.matches("a{3,6}", "aaa"));//true (a can come 3 times or <= 6 times) + System.out.println(Pattern.matches("a{3,6}", "aaaaaa"));//true (a can come 3 times or <= 6 times) + System.out.println(Pattern.matches("a{3,6}", "aaaaaaaaaaa"));//false (a can come 3 times or <= 6 times) + System.out.println(Pattern.matches("a{3,6}", "aa"));//false (a can come 3 times or <= 6 times) + System.out.println(Pattern.matches("a{3,6}", "a"));//false (a can come 3 times or <= 6 times) + System.out.println(Pattern.matches("a{3,6}", "bbb"));//false (a can come 3 times or <= 6 times) + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo1_Output.txt b/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo1_Output.txt new file mode 100644 index 000000000..50ec45429 --- /dev/null +++ b/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo1_Output.txt @@ -0,0 +1,6 @@ +X{n} = X occurs n times only +true +false +false +false +false diff --git a/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo2_Output.txt b/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo2_Output.txt new file mode 100644 index 000000000..c08137e8b --- /dev/null +++ b/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo2_Output.txt @@ -0,0 +1,6 @@ +X{n,} = X occurs n or more times +true +true +false +false +false diff --git a/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo3_Output.txt b/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo3_Output.txt new file mode 100644 index 000000000..b9daa2e5f --- /dev/null +++ b/BasicJava/RegexDemo_Quantifier_number_of_times/RegexDemo3_Output.txt @@ -0,0 +1,7 @@ +X{y,z} = X occurs at least y times but less than or equal to z times +true +true +false +false +false +false diff --git a/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo/.classpath b/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo/.project b/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo/bin/RegexDemo1.class b/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo/bin/RegexDemo1.class new file mode 100644 index 000000000..a9525ea3a Binary files /dev/null and b/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo/bin/RegexDemo1.class differ diff --git a/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo/bin/RegexDemo2.class b/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo/bin/RegexDemo2.class new file mode 100644 index 000000000..fb45ffdad Binary files /dev/null and b/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo/bin/RegexDemo2.class differ diff --git a/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo/bin/RegexDemo3.class b/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo/bin/RegexDemo3.class new file mode 100644 index 000000000..f4ed30290 Binary files /dev/null and b/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo/bin/RegexDemo3.class differ diff --git a/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo/src/RegexDemo1.java b/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo/src/RegexDemo1.java new file mode 100644 index 000000000..0683a302a --- /dev/null +++ b/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo/src/RegexDemo1.java @@ -0,0 +1,29 @@ +import java.util.regex.Pattern; + + +public class RegexDemo1 +{ + public static void main(String[] args) + { + System.out.println("? quantifier = occurs once or not at all"); + /* + * Parameters: + * + * regex - The expression to be compiled + * + * input - The character sequence to be matched + * + * Returns: + * + * whether or not the regular expression matches on the input + * + */ + System.out.println(Pattern.matches("[ab]?", "a"));//true (a or b comes one time) + System.out.println(Pattern.matches("[ab]?", "b"));//true (a or b comes one time) + System.out.println(Pattern.matches("[ab]?", ""));//true (occurs once or not at all) + System.out.println(Pattern.matches("[ab]?", "ab"));//false (a and b comes one time) + System.out.println(Pattern.matches("[ab]?", "aaa"));//false (a comes more than one time) + System.out.println(Pattern.matches("[ab]?", "aabbb"));//false (a and b comes more than one time) + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo/src/RegexDemo2.java b/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo/src/RegexDemo2.java new file mode 100644 index 000000000..5ac6a9736 --- /dev/null +++ b/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo/src/RegexDemo2.java @@ -0,0 +1,27 @@ +import java.util.regex.Pattern; + +public class RegexDemo2 +{ + public static void main(String[] args) + { + System.out.println("+ quantifier = occurs once or more times"); + + /* + * Parameters: + * + * regex - The expression to be compiled + * + * input - The character sequence to be matched + * + * Returns: + * + * whether or not the regular expression matches on the input + * + */ + System.out.println(Pattern.matches("[ab]+", "a"));//true (a or b once or more times) + System.out.println(Pattern.matches("[ab]+", "aaa"));//true (a comes more than one time) + System.out.println(Pattern.matches("[ab]+", "aabb"));//true (a and b comes more than once) + System.out.println(Pattern.matches("[ab]+", "aazzb"));//false (z is not matching pattern) + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo/src/RegexDemo3.java b/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo/src/RegexDemo3.java new file mode 100644 index 000000000..ac8dec6c4 --- /dev/null +++ b/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo/src/RegexDemo3.java @@ -0,0 +1,27 @@ +import java.util.regex.Pattern; + +public class RegexDemo3 +{ + public static void main(String[] args) + { + System.out.println("* quantifier = occurs zero or more times"); + /* + * Parameters: + * + * regex - The expression to be compiled + * + * input - The character sequence to be matched + * + * Returns: + * + * whether or not the regular expression matches on the input + * + */ + System.out.println(Pattern.matches("[ab]*", ""));//true (a or b may come zero or more times) + System.out.println(Pattern.matches("[ab]*", "a"));//true (a or b may come zero or more times) + System.out.println(Pattern.matches("[ab]*", "aaa"));//true (a or b may come zero or more times) + System.out.println(Pattern.matches("[ab]*", "aaabbb"));//true (a or b may come zero or more times) + System.out.println(Pattern.matches("[ab]*", "aaabbbx"));//true (x is not matching pattern) + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo1_Output.txt b/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo1_Output.txt new file mode 100644 index 000000000..fdfb1ee8f --- /dev/null +++ b/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo1_Output.txt @@ -0,0 +1,7 @@ +? quantifier = occurs once or not at all +true +true +true +false +false +false diff --git a/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo2_Output.txt b/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo2_Output.txt new file mode 100644 index 000000000..d90935827 --- /dev/null +++ b/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo2_Output.txt @@ -0,0 +1,5 @@ ++ quantifier = occurs once or more times +true +true +true +false diff --git a/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo3_Output.txt b/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo3_Output.txt new file mode 100644 index 000000000..4e3a17647 --- /dev/null +++ b/BasicJava/RegexDemo_Quantifier_x_question/RegexDemo3_Output.txt @@ -0,0 +1,6 @@ +* quantifier = occurs zero or more times +true +true +true +true +false diff --git a/BasicJava/RegexDemo_SSN/Output.txt b/BasicJava/RegexDemo_SSN/Output.txt new file mode 100644 index 000000000..7ee5a4b42 --- /dev/null +++ b/BasicJava/RegexDemo_SSN/Output.txt @@ -0,0 +1,3 @@ +Found good SSN: 123-45-6789 +Found good SSN: 987-65-4321 +Found good SSN: 192-83-7465 diff --git a/BasicJava/RegexDemo_SSN/RegexDemo/.classpath b/BasicJava/RegexDemo_SSN/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_SSN/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_SSN/RegexDemo/.project b/BasicJava/RegexDemo_SSN/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_SSN/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_SSN/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_SSN/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_SSN/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_SSN/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_SSN/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..9ed1d53fd Binary files /dev/null and b/BasicJava/RegexDemo_SSN/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_SSN/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_SSN/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..3283953cc --- /dev/null +++ b/BasicJava/RegexDemo_SSN/RegexDemo/src/RegexDemo.java @@ -0,0 +1,37 @@ +import java.util.ArrayList; +import java.util.List; + +/** + * + * A Social Security Number (SSN) consists of nine digits, commonly written as + * three fields separated by hyphens: AAA-GG-SSSS. + * + * The first three-digit field is called the "area number". + * The central, two-digit field is called the group number". + * The final, four-digit field is called the "serial number" + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + List ssnList = new ArrayList(); + ssnList.add("123-45-6789"); + ssnList.add("9876-5-4321"); + ssnList.add("987-65-4321 (G)"); + ssnList.add("987-65-4321"); + ssnList.add("192-83-7465"); + + String ssnRegex = "^(\\d{3}-\\d{2}-\\d{4})"; + + for (String ssn : ssnList) + { + if (ssn.matches(ssnRegex)) + { + System.out.println("Found good SSN: " + ssn); + } + } + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_StringMatcher_threeLetters/Output.txt b/BasicJava/RegexDemo_StringMatcher_threeLetters/Output.txt new file mode 100644 index 000000000..327f46e5c --- /dev/null +++ b/BasicJava/RegexDemo_StringMatcher_threeLetters/Output.txt @@ -0,0 +1,5 @@ +true +false +----------------------------- +true +false diff --git a/BasicJava/RegexDemo_StringMatcher_threeLetters/RegexDemo/.classpath b/BasicJava/RegexDemo_StringMatcher_threeLetters/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_StringMatcher_threeLetters/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_StringMatcher_threeLetters/RegexDemo/.project b/BasicJava/RegexDemo_StringMatcher_threeLetters/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_StringMatcher_threeLetters/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_StringMatcher_threeLetters/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_StringMatcher_threeLetters/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_StringMatcher_threeLetters/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_StringMatcher_threeLetters/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_StringMatcher_threeLetters/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..a8c65b7fb Binary files /dev/null and b/BasicJava/RegexDemo_StringMatcher_threeLetters/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_StringMatcher_threeLetters/RegexDemo/bin/StringMatcher.class b/BasicJava/RegexDemo_StringMatcher_threeLetters/RegexDemo/bin/StringMatcher.class new file mode 100644 index 000000000..8adc2ae6e Binary files /dev/null and b/BasicJava/RegexDemo_StringMatcher_threeLetters/RegexDemo/bin/StringMatcher.class differ diff --git a/BasicJava/RegexDemo_StringMatcher_threeLetters/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_StringMatcher_threeLetters/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..7e52a29c9 --- /dev/null +++ b/BasicJava/RegexDemo_StringMatcher_threeLetters/RegexDemo/src/RegexDemo.java @@ -0,0 +1,17 @@ +public class RegexDemo +{ + public static void main(String[] args) + { + StringMatcher stringMatcher = new StringMatcher(); + + System.out.println(stringMatcher.isThreeLetters("cat")); // true + System.out.println(stringMatcher.isThreeLetters("tiger")); // false + + System.out.println("-----------------------------"); + + System.out.println(stringMatcher.isNoNumberAtBeginning("Hello")); // true + System.out.println(stringMatcher.isNoNumberAtBeginning("9Hello")); // false + + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_StringMatcher_threeLetters/RegexDemo/src/StringMatcher.java b/BasicJava/RegexDemo_StringMatcher_threeLetters/RegexDemo/src/StringMatcher.java new file mode 100644 index 000000000..a41d836d0 --- /dev/null +++ b/BasicJava/RegexDemo_StringMatcher_threeLetters/RegexDemo/src/StringMatcher.java @@ -0,0 +1,20 @@ + +public class StringMatcher +{ + /* + * returns true if the string contains of three letters + */ + public boolean isThreeLetters(String s) + { + return s.matches("[a-zA-Z]{3}"); + } + + /* + * returns true if the string does not have a number at the beginning + */ + public boolean isNoNumberAtBeginning(String s) + { + return s.matches("^[^\\d].*"); + } + +} diff --git a/BasicJava/RegexDemo_alphanumeric_length_4/Output.txt b/BasicJava/RegexDemo_alphanumeric_length_4/Output.txt new file mode 100644 index 000000000..5f8cc1d19 --- /dev/null +++ b/BasicJava/RegexDemo_alphanumeric_length_4/Output.txt @@ -0,0 +1,4 @@ +true +true +false +false diff --git a/BasicJava/RegexDemo_alphanumeric_length_4/RegexDemo/.classpath b/BasicJava/RegexDemo_alphanumeric_length_4/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_alphanumeric_length_4/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_alphanumeric_length_4/RegexDemo/.project b/BasicJava/RegexDemo_alphanumeric_length_4/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_alphanumeric_length_4/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_alphanumeric_length_4/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_alphanumeric_length_4/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_alphanumeric_length_4/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_alphanumeric_length_4/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_alphanumeric_length_4/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..52474e17b Binary files /dev/null and b/BasicJava/RegexDemo_alphanumeric_length_4/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_alphanumeric_length_4/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_alphanumeric_length_4/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..ece734083 --- /dev/null +++ b/BasicJava/RegexDemo_alphanumeric_length_4/RegexDemo/src/RegexDemo.java @@ -0,0 +1,32 @@ +import java.util.regex.Pattern; + +/** + * + * Create a regular expression that accepts alpha numeric characters only. Its + * length must be 4 characters long only. + * + */ + +public class RegexDemo +{ + public static void main(String[] args) + { + /* + * Parameters: + * + * regex - The expression to be compiled + * + * input - The character sequence to be matched + * + * Returns: + * + * whether or not the regular expression matches on the input + * + */ + System.out.println(Pattern.matches("[a-zA-Z0-9]{4}", "Juli"));//true + System.out.println(Pattern.matches("[a-zA-Z0-9]{4}", "Ju22"));//true + System.out.println(Pattern.matches("[a-zA-Z0-9]{4}", "Peter"));//false (more than 4 char) + System.out.println(Pattern.matches("[a-zA-Z0-9]{4}", "J$22"));//false ($ is not matched) + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_append/Output.txt b/BasicJava/RegexDemo_append/Output.txt new file mode 100644 index 000000000..ab4f2e134 --- /dev/null +++ b/BasicJava/RegexDemo_append/Output.txt @@ -0,0 +1 @@ +-foo-foo-foo- diff --git a/BasicJava/RegexDemo_append/RegexDemo/.classpath b/BasicJava/RegexDemo_append/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_append/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_append/RegexDemo/.project b/BasicJava/RegexDemo_append/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_append/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_append/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_append/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_append/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_append/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_append/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..9708df931 Binary files /dev/null and b/BasicJava/RegexDemo_append/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_append/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_append/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..f7e71b096 --- /dev/null +++ b/BasicJava/RegexDemo_append/RegexDemo/src/RegexDemo.java @@ -0,0 +1,39 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * The Matcher class provides appendReplacement and appendTail methods for text + * replacement. + * + */ +public class RegexDemo +{ + private static String REGEX = "aa"; + private static String INPUT = "aafooaafooaafooaa"; + private static String REPLACE = "-"; + + public static void main(String[] args) + { + Pattern pattern = Pattern.compile(REGEX); + Matcher matcher = pattern.matcher(INPUT); + + StringBuffer sb = new StringBuffer(); + while (matcher.find()) + { + /* + * Parameters: + * + * sb - The target string buffer + * replacement - The replacement string + * + * Returns: This matcher + * + */ + matcher.appendReplacement(sb, REPLACE); + } + matcher.appendTail(sb); + System.out.println(sb.toString()); + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_asPredicate/RegexDemo/.classpath b/BasicJava/RegexDemo_asPredicate/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_asPredicate/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_asPredicate/RegexDemo/.project b/BasicJava/RegexDemo_asPredicate/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_asPredicate/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_asPredicate/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_asPredicate/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_asPredicate/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_asPredicate/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_asPredicate/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..51f9d9fa1 Binary files /dev/null and b/BasicJava/RegexDemo_asPredicate/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_asPredicate/RegexDemo/bin/RegexPredicateDemo.class b/BasicJava/RegexDemo_asPredicate/RegexDemo/bin/RegexPredicateDemo.class new file mode 100644 index 000000000..2781f8787 Binary files /dev/null and b/BasicJava/RegexDemo_asPredicate/RegexDemo/bin/RegexPredicateDemo.class differ diff --git a/BasicJava/RegexDemo_asPredicate/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_asPredicate/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..469f64f62 --- /dev/null +++ b/BasicJava/RegexDemo_asPredicate/RegexDemo/src/RegexDemo.java @@ -0,0 +1,30 @@ +import java.util.Arrays; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class RegexDemo +{ + + public static void main(String[] args) + { + + String regex = "^(.+)@gmail.com$"; + Pattern pattern = Pattern.compile(regex); + + List emailList = Arrays.asList("peter@yahoo.com", + "bob@gmail.com", "juli@gmail.com", + "david@rediff.com"); + + for (String email : emailList) + { + Matcher matcher = pattern.matcher(email); + + if (matcher.matches()) + { + System.out.println(email); + } + } + } + +} diff --git a/BasicJava/RegexDemo_asPredicate/RegexDemo/src/RegexPredicateDemo.java b/BasicJava/RegexDemo_asPredicate/RegexDemo/src/RegexPredicateDemo.java new file mode 100644 index 000000000..c6e3f30fe --- /dev/null +++ b/BasicJava/RegexDemo_asPredicate/RegexDemo/src/RegexPredicateDemo.java @@ -0,0 +1,35 @@ +import java.util.Arrays; +import java.util.List; +import java.util.function.Predicate; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +public class RegexPredicateDemo +{ + + public static void main(String[] args) + { + String regex = "^(.+)@gmail.com$"; + Pattern pattern = Pattern.compile(regex); + + /* + * Returns:The predicate which can be used for matching on a + * string + */ + Predicate emailFilterPredicate = pattern.asPredicate(); + + List emailList = Arrays.asList("peter@yahoo.com", + "bob@gmail.com", "juli@gmail.com", + "david@rediff.com"); + + /* + * Apply predicate filter + */ + List desiredEmailList = emailList.stream() + .filter(emailFilterPredicate) + .collect(Collectors.toList()); + + desiredEmailList.forEach(System.out::println); + } + +} diff --git a/BasicJava/RegexDemo_asPredicate/RegexDemo_Output.txt b/BasicJava/RegexDemo_asPredicate/RegexDemo_Output.txt new file mode 100644 index 000000000..b137a2680 --- /dev/null +++ b/BasicJava/RegexDemo_asPredicate/RegexDemo_Output.txt @@ -0,0 +1,2 @@ +bob@gmail.com +juli@gmail.com diff --git a/BasicJava/RegexDemo_asPredicate/RegexPredicateDemo_Output.txt b/BasicJava/RegexDemo_asPredicate/RegexPredicateDemo_Output.txt new file mode 100644 index 000000000..b137a2680 --- /dev/null +++ b/BasicJava/RegexDemo_asPredicate/RegexPredicateDemo_Output.txt @@ -0,0 +1,2 @@ +bob@gmail.com +juli@gmail.com diff --git a/BasicJava/RegexDemo_backslash/Output.txt b/BasicJava/RegexDemo_backslash/Output.txt new file mode 100644 index 000000000..27ba77dda --- /dev/null +++ b/BasicJava/RegexDemo_backslash/Output.txt @@ -0,0 +1 @@ +true diff --git a/BasicJava/RegexDemo_backslash/RegexDemo/.classpath b/BasicJava/RegexDemo_backslash/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_backslash/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_backslash/RegexDemo/.project b/BasicJava/RegexDemo_backslash/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_backslash/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_backslash/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_backslash/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_backslash/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_backslash/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_backslash/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..275d8705b Binary files /dev/null and b/BasicJava/RegexDemo_backslash/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_backslash/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_backslash/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..d0715eec9 --- /dev/null +++ b/BasicJava/RegexDemo_backslash/RegexDemo/src/RegexDemo.java @@ -0,0 +1,14 @@ +import java.util.regex.Pattern; + +public class RegexDemo +{ + public static void main(String[] args) + { + /* + * If you want to define \d, then you must be using \\d in + * your regex. + */ + System.out.println(Pattern.matches("\\d*", "245")); // true + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_boundary_dog/Output.txt b/BasicJava/RegexDemo_boundary_dog/Output.txt new file mode 100644 index 000000000..4d8169ab3 --- /dev/null +++ b/BasicJava/RegexDemo_boundary_dog/Output.txt @@ -0,0 +1,2 @@ +Number of Matches = 1 +Number of Matches = 0 diff --git a/BasicJava/RegexDemo_boundary_dog/RegexDemo/.classpath b/BasicJava/RegexDemo_boundary_dog/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_boundary_dog/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_boundary_dog/RegexDemo/.project b/BasicJava/RegexDemo_boundary_dog/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_boundary_dog/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_boundary_dog/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_boundary_dog/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_boundary_dog/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_boundary_dog/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_boundary_dog/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..7714b8c77 Binary files /dev/null and b/BasicJava/RegexDemo_boundary_dog/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_boundary_dog/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_boundary_dog/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..87d7bf444 --- /dev/null +++ b/BasicJava/RegexDemo_boundary_dog/RegexDemo/src/RegexDemo.java @@ -0,0 +1,41 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * Boundary Matchers + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + + /* + * To match only when the required regex is true at the + * beginning of the text, we use the caret ^. + */ + calculateMatches("^dog", "dogs are friendly"); + calculateMatches("^dog", "are dogs are friendly?"); + } + + private static void calculateMatches(String regex, String inputText) + { + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(inputText); + int matches = 0; + + /* + * The find method keeps advancing through the input text and + * returns true for every match, so we can use it to find the + * match count as well: + */ + while (matcher.find()) + { + ++matches; + } + System.out.println("Number of Matches = " + matches); + } + +} diff --git a/BasicJava/RegexDemo_boundary_dog_end/Output.txt b/BasicJava/RegexDemo_boundary_dog_end/Output.txt new file mode 100644 index 000000000..4d8169ab3 --- /dev/null +++ b/BasicJava/RegexDemo_boundary_dog_end/Output.txt @@ -0,0 +1,2 @@ +Number of Matches = 1 +Number of Matches = 0 diff --git a/BasicJava/RegexDemo_boundary_dog_end/RegexDemo/.classpath b/BasicJava/RegexDemo_boundary_dog_end/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_boundary_dog_end/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_boundary_dog_end/RegexDemo/.project b/BasicJava/RegexDemo_boundary_dog_end/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_boundary_dog_end/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_boundary_dog_end/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_boundary_dog_end/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_boundary_dog_end/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_boundary_dog_end/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_boundary_dog_end/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..e86cb654d Binary files /dev/null and b/BasicJava/RegexDemo_boundary_dog_end/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_boundary_dog_end/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_boundary_dog_end/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..f02569bb4 --- /dev/null +++ b/BasicJava/RegexDemo_boundary_dog_end/RegexDemo/src/RegexDemo.java @@ -0,0 +1,41 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * Boundary Matchers + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + + /* + * To match only when the required regex is true at the end of + * the text, we use the dollar character $. + */ + calculateMatches("dog$", "Man's best friend is a dog"); + calculateMatches("dog$", "is a dog man's best friend?"); + } + + private static void calculateMatches(String regex, String inputText) + { + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(inputText); + int matches = 0; + + /* + * The find method keeps advancing through the input text and + * returns true for every match, so we can use it to find the + * match count as well: + */ + while (matcher.find()) + { + ++matches; + } + System.out.println("Number of Matches = " + matches); + } + +} diff --git a/BasicJava/RegexDemo_boundary_middle/Output.txt b/BasicJava/RegexDemo_boundary_middle/Output.txt new file mode 100644 index 000000000..b18cc5e44 --- /dev/null +++ b/BasicJava/RegexDemo_boundary_middle/Output.txt @@ -0,0 +1,4 @@ +Number of Matches = 1 +Number of Matches = 2 +Number of Matches = 0 +Number of Matches = 1 diff --git a/BasicJava/RegexDemo_boundary_middle/RegexDemo/.classpath b/BasicJava/RegexDemo_boundary_middle/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_boundary_middle/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_boundary_middle/RegexDemo/.project b/BasicJava/RegexDemo_boundary_middle/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_boundary_middle/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_boundary_middle/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_boundary_middle/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_boundary_middle/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_boundary_middle/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_boundary_middle/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..e7a8178a5 Binary files /dev/null and b/BasicJava/RegexDemo_boundary_middle/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_boundary_middle/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_boundary_middle/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..790ac51a2 --- /dev/null +++ b/BasicJava/RegexDemo_boundary_middle/RegexDemo/src/RegexDemo.java @@ -0,0 +1,50 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * Boundary Matchers + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + + /* + * If we want a match only when the required text is found at + * a word boundary, we use \\b regex at the beginning and end + * of the regex: + */ + calculateMatches("\\bdog\\b", "a dog is friendly"); + calculateMatches("\\bdog\\b", "dog is man's best friend,dog is good"); + calculateMatches("\\bdog\\b", "snoop dogg is a rapper"); + + /* + * Two-word characters appearing in a row does not mark a word + * boundary, but we can make it pass by changing the end of + * the regex to look for a non-word boundary: + */ + calculateMatches("\\bdog\\B", "snoop dogg is a rapper"); + } + + private static void calculateMatches(String regex, String inputText) + { + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(inputText); + int matches = 0; + + /* + * The find method keeps advancing through the input text and + * returns true for every match, so we can use it to find the + * match count as well: + */ + while (matcher.find()) + { + ++matches; + } + System.out.println("Number of Matches = " + matches); + } + +} diff --git a/BasicJava/RegexDemo_boundary_nondigit/Output.txt b/BasicJava/RegexDemo_boundary_nondigit/Output.txt new file mode 100644 index 000000000..7fd883523 --- /dev/null +++ b/BasicJava/RegexDemo_boundary_nondigit/Output.txt @@ -0,0 +1,6 @@ +true +false +---------------------------------- +false +true +false diff --git a/BasicJava/RegexDemo_boundary_nondigit/RegexDemo/.classpath b/BasicJava/RegexDemo_boundary_nondigit/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_boundary_nondigit/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_boundary_nondigit/RegexDemo/.project b/BasicJava/RegexDemo_boundary_nondigit/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_boundary_nondigit/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_boundary_nondigit/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_boundary_nondigit/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_boundary_nondigit/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_boundary_nondigit/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_boundary_nondigit/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..28e02d585 Binary files /dev/null and b/BasicJava/RegexDemo_boundary_nondigit/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_boundary_nondigit/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_boundary_nondigit/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..ff6d194a7 --- /dev/null +++ b/BasicJava/RegexDemo_boundary_nondigit/RegexDemo/src/RegexDemo.java @@ -0,0 +1,26 @@ +import java.util.regex.Pattern; + +public class RegexDemo +{ + + public static void main(String[] args) + { + /* + * returns true if the string contains 0 or more non-digits + */ + System.out.println(Pattern.matches("\\D*", "abcde")); // True + System.out.println(Pattern.matches("\\D*", "abcde123")); // False + + System.out.println("----------------------------------"); + + /* + * Boundary Matchers example ^ denotes start of the line $ denotes end + * of the line + */ + System.out.println(Pattern.matches("^This$", "This is Chaitanya")); // False + System.out.println(Pattern.matches("^This$", "This")); // True + System.out.println(Pattern.matches("^This$", "Is This Chaitanya")); // False + + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_calculate_matches/Output.txt b/BasicJava/RegexDemo_calculate_matches/Output.txt new file mode 100644 index 000000000..1ed6fc900 --- /dev/null +++ b/BasicJava/RegexDemo_calculate_matches/Output.txt @@ -0,0 +1 @@ +Number of Matches = 2 diff --git a/BasicJava/RegexDemo_calculate_matches/RegexDemo/.classpath b/BasicJava/RegexDemo_calculate_matches/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_calculate_matches/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_calculate_matches/RegexDemo/.project b/BasicJava/RegexDemo_calculate_matches/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_calculate_matches/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_calculate_matches/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_calculate_matches/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_calculate_matches/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_calculate_matches/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_calculate_matches/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..6eda914ad Binary files /dev/null and b/BasicJava/RegexDemo_calculate_matches/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_calculate_matches/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_calculate_matches/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..7e83307cd --- /dev/null +++ b/BasicJava/RegexDemo_calculate_matches/RegexDemo/src/RegexDemo.java @@ -0,0 +1,30 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class RegexDemo +{ + + public static void main(String[] args) + { + calculateMatches("foo", "foo come foo"); + } + + private static void calculateMatches(String regex, String inputText) + { + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(inputText); + int matches = 0; + + /* + * The find method keeps advancing through the input text and + * returns true for every match, so we can use it to find the + * match count as well: + */ + while (matcher.find()) + { + ++matches; + } + System.out.println("Number of Matches = "+matches); + } + +} diff --git a/BasicJava/RegexDemo_capture_group/Output.txt b/BasicJava/RegexDemo_capture_group/Output.txt new file mode 100644 index 000000000..44736a2e2 --- /dev/null +++ b/BasicJava/RegexDemo_capture_group/Output.txt @@ -0,0 +1,3 @@ +Regex = (\d\d) , InputText = 12 is matching? = true +Regex = (\d\d) , InputText = 123 is matching? = false +Regex = (\d\d) , InputText = a2 is matching? = false diff --git a/BasicJava/RegexDemo_capture_group/RegexDemo/.classpath b/BasicJava/RegexDemo_capture_group/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_capture_group/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_capture_group/RegexDemo/.project b/BasicJava/RegexDemo_capture_group/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_capture_group/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_capture_group/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_capture_group/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_capture_group/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_capture_group/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_capture_group/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..f9df64f6f Binary files /dev/null and b/BasicJava/RegexDemo_capture_group/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_capture_group/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_capture_group/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..ed9b98cf0 --- /dev/null +++ b/BasicJava/RegexDemo_capture_group/RegexDemo/src/RegexDemo.java @@ -0,0 +1,34 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * Capturing Groups + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + + /* + * The API also allows us to treat multiple digits as a + * single unit through capturing groups. + */ + isMatch("(\\d\\d)", "12"); + isMatch("(\\d\\d)", "123"); + isMatch("(\\d\\d)", "a2"); + + } + + private static void isMatch(String regex, String inputText) + { + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(inputText); + + System.out.println("Regex = " + regex + " , " + "InputText = " + + inputText + " is matching? = " + matcher.matches()); + } + +} diff --git a/BasicJava/RegexDemo_capture_group_backref/Output.txt b/BasicJava/RegexDemo_capture_group_backref/Output.txt new file mode 100644 index 000000000..c7bdddff6 --- /dev/null +++ b/BasicJava/RegexDemo_capture_group_backref/Output.txt @@ -0,0 +1,4 @@ +Regex = (\d\d)\1 , InputText = 3434 is matching? = true +Regex = (\d\d)\1 , InputText = 3499 is matching? = false +Regex = (\d\d)\1\1 , InputText = 343434 is matching? = true +Regex = (\d\d)\1\1 , InputText = 343439 is matching? = false diff --git a/BasicJava/RegexDemo_capture_group_backref/RegexDemo/.classpath b/BasicJava/RegexDemo_capture_group_backref/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_capture_group_backref/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_capture_group_backref/RegexDemo/.project b/BasicJava/RegexDemo_capture_group_backref/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_capture_group_backref/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_capture_group_backref/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_capture_group_backref/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_capture_group_backref/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_capture_group_backref/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_capture_group_backref/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..7e105bbf2 Binary files /dev/null and b/BasicJava/RegexDemo_capture_group_backref/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_capture_group_backref/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_capture_group_backref/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..80c304233 --- /dev/null +++ b/BasicJava/RegexDemo_capture_group_backref/RegexDemo/src/RegexDemo.java @@ -0,0 +1,37 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * Capturing Groups + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + + /* + * Where there are two separate matches for the input, we can + * have one match but propagating the same regex match to span + * the entire length of the input using back referencing: + */ + isMatch("(\\d\\d)\\1", "3434"); + isMatch("(\\d\\d)\\1", "3499"); + + isMatch("(\\d\\d)\\1\\1", "343434"); + isMatch("(\\d\\d)\\1\\1", "343439"); + + } + + private static void isMatch(String regex, String inputText) + { + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(inputText); + + System.out.println("Regex = " + regex + " , " + "InputText = " + + inputText + " is matching? = " + matcher.matches()); + } + +} diff --git a/BasicJava/RegexDemo_case_insensitive/Output.txt b/BasicJava/RegexDemo_case_insensitive/Output.txt new file mode 100644 index 000000000..c1280a216 --- /dev/null +++ b/BasicJava/RegexDemo_case_insensitive/Output.txt @@ -0,0 +1,2 @@ +CASE_INSENSITIVE matches = true +CASE_SENSITIVE matches = false diff --git a/BasicJava/RegexDemo_case_insensitive/RegexDemo/.classpath b/BasicJava/RegexDemo_case_insensitive/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_case_insensitive/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_case_insensitive/RegexDemo/.project b/BasicJava/RegexDemo_case_insensitive/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_case_insensitive/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_case_insensitive/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_case_insensitive/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_case_insensitive/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_case_insensitive/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_case_insensitive/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..4c8562082 Binary files /dev/null and b/BasicJava/RegexDemo_case_insensitive/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_case_insensitive/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_case_insensitive/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..87375c6fe --- /dev/null +++ b/BasicJava/RegexDemo_case_insensitive/RegexDemo/src/RegexDemo.java @@ -0,0 +1,39 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class RegexDemo +{ + + public static void main(String[] args) + { + String inputCharSeq = "Hello peter"; + String regex = "HELLO PETER"; + + /* + * Parameters: + * + * regex - The expression to be compiled + * + * flags - Match flags, a bit mask that may include + * CASE_INSENSITIVE, MULTILINE, DOTALL, UNICODE_CASE, + * CANON_EQ, UNIX_LINES, LITERAL, UNICODE_CHARACTER_CLASS and + * COMMENTS + * + * Returns: + * + * the given regular expression compiled into a pattern with + * the given flags + * + */ + Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE); + Matcher matcher = pattern.matcher(inputCharSeq); + + System.out.println("CASE_INSENSITIVE matches = " + matcher.matches()); + + pattern = Pattern.compile(regex); + matcher = pattern.matcher(inputCharSeq); + + System.out.println("CASE_SENSITIVE matches = " + matcher.matches()); + } + +} diff --git a/BasicJava/RegexDemo_caseinsensitive_dog/Output.txt b/BasicJava/RegexDemo_caseinsensitive_dog/Output.txt new file mode 100644 index 000000000..5a892ca6f --- /dev/null +++ b/BasicJava/RegexDemo_caseinsensitive_dog/Output.txt @@ -0,0 +1 @@ +Number of Matches = 1 diff --git a/BasicJava/RegexDemo_caseinsensitive_dog/RegexDemo/.classpath b/BasicJava/RegexDemo_caseinsensitive_dog/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_caseinsensitive_dog/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_caseinsensitive_dog/RegexDemo/.project b/BasicJava/RegexDemo_caseinsensitive_dog/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_caseinsensitive_dog/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_caseinsensitive_dog/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_caseinsensitive_dog/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_caseinsensitive_dog/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_caseinsensitive_dog/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_caseinsensitive_dog/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..c9bf9ed79 Binary files /dev/null and b/BasicJava/RegexDemo_caseinsensitive_dog/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_caseinsensitive_dog/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_caseinsensitive_dog/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..bb1f27d22 --- /dev/null +++ b/BasicJava/RegexDemo_caseinsensitive_dog/RegexDemo/src/RegexDemo.java @@ -0,0 +1,44 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * Flags + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + /* + * Pattern.CASE_INSENSITIVE + * + * This flag enables matching regardless of case. By default + * matching takes case into account + * + * So using this flag, we can change the default behavior: + */ + calculateMatches("dog", "This is a DOG", Pattern.CASE_INSENSITIVE); + } + + private static void calculateMatches(String regex, String inputText, + int flag) + { + Pattern pattern = Pattern.compile(regex, flag); + Matcher matcher = pattern.matcher(inputText); + int matches = 0; + + /* + * The find method keeps advancing through the input text and + * returns true for every match, so we can use it to find the + * match count as well: + */ + while (matcher.find()) + { + ++matches; + } + System.out.println("Number of Matches = " + matches); + } + +} diff --git a/BasicJava/RegexDemo_char_class_abc/RegexDemo/.classpath b/BasicJava/RegexDemo_char_class_abc/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_char_class_abc/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_char_class_abc/RegexDemo/.project b/BasicJava/RegexDemo_char_class_abc/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_char_class_abc/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_char_class_abc/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_char_class_abc/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_char_class_abc/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_char_class_abc/RegexDemo/bin/RegexDemo1.class b/BasicJava/RegexDemo_char_class_abc/RegexDemo/bin/RegexDemo1.class new file mode 100644 index 000000000..d2360c0cd Binary files /dev/null and b/BasicJava/RegexDemo_char_class_abc/RegexDemo/bin/RegexDemo1.class differ diff --git a/BasicJava/RegexDemo_char_class_abc/RegexDemo/bin/RegexDemo2.class b/BasicJava/RegexDemo_char_class_abc/RegexDemo/bin/RegexDemo2.class new file mode 100644 index 000000000..aad2ee4df Binary files /dev/null and b/BasicJava/RegexDemo_char_class_abc/RegexDemo/bin/RegexDemo2.class differ diff --git a/BasicJava/RegexDemo_char_class_abc/RegexDemo/src/RegexDemo1.java b/BasicJava/RegexDemo_char_class_abc/RegexDemo/src/RegexDemo1.java new file mode 100644 index 000000000..b653e2045 --- /dev/null +++ b/BasicJava/RegexDemo_char_class_abc/RegexDemo/src/RegexDemo1.java @@ -0,0 +1,33 @@ +import java.util.regex.Pattern; + +/** + * + * [abc] = if a or b or c returns true else false. + * + */ +public class RegexDemo1 +{ + public static void main(String[] args) + { + /* + * Parameters: + * + * regex - The expression to be compiled + * + * input - The character sequence to be matched + * + * Returns: + * + * whether or not the regular expression matches on the input + * + */ + + System.out.println("[abc] matches a = " + Pattern.matches("[abc]", "a")); + System.out.println("[abc] matches b = " + Pattern.matches("[abc]", "b")); + System.out.println("[abc] matches c = " + Pattern.matches("[abc]", "c")); + System.out.println("[abc] matches z = " + Pattern.matches("[abc]", "z")); + System.out.println("[abc] matches aa = " + Pattern.matches("[abc]", "aa")); + System.out.println("[abc] matches abc = " + Pattern.matches("[abc]", "abc")); + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_char_class_abc/RegexDemo/src/RegexDemo2.java b/BasicJava/RegexDemo_char_class_abc/RegexDemo/src/RegexDemo2.java new file mode 100644 index 000000000..9238cc4af --- /dev/null +++ b/BasicJava/RegexDemo_char_class_abc/RegexDemo/src/RegexDemo2.java @@ -0,0 +1,33 @@ +import java.util.regex.Pattern; + +/** + * + * [^abc] = if any character except a or b or c returns true else false. + * + */ +public class RegexDemo2 +{ + public static void main(String[] args) + { + /* + * Parameters: + * + * regex - The expression to be compiled + * + * input - The character sequence to be matched + * + * Returns: + * + * whether or not the regular expression matches on the input + * + */ + + System.out.println("[^abc] matches a = " + Pattern.matches("[^abc]", "a")); + System.out.println("[^abc] matches b = " + Pattern.matches("[^abc]", "b")); + System.out.println("[^abc] matches c = " + Pattern.matches("[^abc]", "c")); + System.out.println("[^abc] matches z = " + Pattern.matches("[^abc]", "z")); + System.out.println("[^abc] matches zz = " + Pattern.matches("[^abc]", "zz")); + System.out.println("[^abc] matches zzz = " + Pattern.matches("[^abc]", "zzz")); + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_char_class_abc/RegexDemo1_Output.txt b/BasicJava/RegexDemo_char_class_abc/RegexDemo1_Output.txt new file mode 100644 index 000000000..8d3651682 --- /dev/null +++ b/BasicJava/RegexDemo_char_class_abc/RegexDemo1_Output.txt @@ -0,0 +1,6 @@ +[abc] matches a = true +[abc] matches b = true +[abc] matches c = true +[abc] matches z = false +[abc] matches aa = false +[abc] matches abc = false diff --git a/BasicJava/RegexDemo_char_class_abc/RegexDemo2_Output.txt b/BasicJava/RegexDemo_char_class_abc/RegexDemo2_Output.txt new file mode 100644 index 000000000..27f36d77b --- /dev/null +++ b/BasicJava/RegexDemo_char_class_abc/RegexDemo2_Output.txt @@ -0,0 +1,6 @@ +[^abc] matches a = false +[^abc] matches b = false +[^abc] matches c = false +[^abc] matches z = true +[^abc] matches zz = false +[^abc] matches zzz = false diff --git a/BasicJava/RegexDemo_char_class_azAZ/RegexDemo/.classpath b/BasicJava/RegexDemo_char_class_azAZ/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_char_class_azAZ/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_char_class_azAZ/RegexDemo/.project b/BasicJava/RegexDemo_char_class_azAZ/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_char_class_azAZ/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_char_class_azAZ/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_char_class_azAZ/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_char_class_azAZ/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_char_class_azAZ/RegexDemo/bin/RegexDemo1.class b/BasicJava/RegexDemo_char_class_azAZ/RegexDemo/bin/RegexDemo1.class new file mode 100644 index 000000000..b22207b5e Binary files /dev/null and b/BasicJava/RegexDemo_char_class_azAZ/RegexDemo/bin/RegexDemo1.class differ diff --git a/BasicJava/RegexDemo_char_class_azAZ/RegexDemo/bin/RegexDemo2.class b/BasicJava/RegexDemo_char_class_azAZ/RegexDemo/bin/RegexDemo2.class new file mode 100644 index 000000000..39acc648c Binary files /dev/null and b/BasicJava/RegexDemo_char_class_azAZ/RegexDemo/bin/RegexDemo2.class differ diff --git a/BasicJava/RegexDemo_char_class_azAZ/RegexDemo/src/RegexDemo1.java b/BasicJava/RegexDemo_char_class_azAZ/RegexDemo/src/RegexDemo1.java new file mode 100644 index 000000000..737e23315 --- /dev/null +++ b/BasicJava/RegexDemo_char_class_azAZ/RegexDemo/src/RegexDemo1.java @@ -0,0 +1,30 @@ +import java.util.regex.Pattern; + +/** + * + * [a-zA-Z] : Means any character that IS a-z OR A-Z + * + */ +public class RegexDemo1 +{ + public static void main(String[] args) + { + /* + * Parameters: + * + * regex - The expression to be compiled + * + * input - The character sequence to be matched + * + * Returns: + * + * whether or not the regular expression matches on the input + * + */ + System.out.println("[a-zA-Z] matches A = " + Pattern.matches("[a-zA-Z]", "A")); + System.out.println("[a-zA-Z] matches d = " + Pattern.matches("[a-zA-Z]", "d")); + System.out.println("[a-zA-Z] matches ddZY = " + Pattern.matches("[a-zA-Z]", "ddZY")); + System.out.println("[a-zA-Z] matches 1 = " + Pattern.matches("[a-zA-Z]", "1")); + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_char_class_azAZ/RegexDemo/src/RegexDemo2.java b/BasicJava/RegexDemo_char_class_azAZ/RegexDemo/src/RegexDemo2.java new file mode 100644 index 000000000..4a58e5117 --- /dev/null +++ b/BasicJava/RegexDemo_char_class_azAZ/RegexDemo/src/RegexDemo2.java @@ -0,0 +1,31 @@ +import java.util.regex.Pattern; + +/** + * + * [a-zA-Z] = Means any character that IS a-d OR m-p. + * + */ +public class RegexDemo2 +{ + public static void main(String[] args) + { + /* + * Parameters: + * + * regex - The expression to be compiled + * + * input - The character sequence to be matched + * + * Returns: + * + * whether or not the regular expression matches on the input + * + */ + System.out.println("[a-d[m-p]] matches a = " + Pattern.matches("[a-d[m-p]]", "a")); + System.out.println("[a-d[m-p]] matches n = " + Pattern.matches("[a-d[m-p]]", "n")); + System.out.println("[a-d[m-p]] matches e = " + Pattern.matches("[a-d[m-p]]", "e")); + System.out.println("[a-d[m-p]] matches A = " + Pattern.matches("[a-d[m-p]]", "A")); + System.out.println("[a-d[m-p]] matches am = " + Pattern.matches("[a-d[m-p]]", "am")); + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_char_class_azAZ/RegexDemo1_Output.txt b/BasicJava/RegexDemo_char_class_azAZ/RegexDemo1_Output.txt new file mode 100644 index 000000000..5ee924c12 --- /dev/null +++ b/BasicJava/RegexDemo_char_class_azAZ/RegexDemo1_Output.txt @@ -0,0 +1,4 @@ +[a-zA-Z] matches A = true +[a-zA-Z] matches d = true +[a-zA-Z] matches ddZY = false +[a-zA-Z] matches 1 = false diff --git a/BasicJava/RegexDemo_char_class_azAZ/RegexDemo2_Output.txt b/BasicJava/RegexDemo_char_class_azAZ/RegexDemo2_Output.txt new file mode 100644 index 000000000..924fbef2c --- /dev/null +++ b/BasicJava/RegexDemo_char_class_azAZ/RegexDemo2_Output.txt @@ -0,0 +1,5 @@ +[a-d[m-p]] matches a = true +[a-d[m-p]] matches n = true +[a-d[m-p]] matches e = false +[a-d[m-p]] matches A = false +[a-d[m-p]] matches am = false diff --git a/BasicJava/RegexDemo_char_class_intersection/RegexDemo/.classpath b/BasicJava/RegexDemo_char_class_intersection/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_char_class_intersection/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_char_class_intersection/RegexDemo/.project b/BasicJava/RegexDemo_char_class_intersection/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_char_class_intersection/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_char_class_intersection/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_char_class_intersection/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_char_class_intersection/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_char_class_intersection/RegexDemo/bin/RegexDemo1.class b/BasicJava/RegexDemo_char_class_intersection/RegexDemo/bin/RegexDemo1.class new file mode 100644 index 000000000..c5f216796 Binary files /dev/null and b/BasicJava/RegexDemo_char_class_intersection/RegexDemo/bin/RegexDemo1.class differ diff --git a/BasicJava/RegexDemo_char_class_intersection/RegexDemo/bin/RegexDemo2.class b/BasicJava/RegexDemo_char_class_intersection/RegexDemo/bin/RegexDemo2.class new file mode 100644 index 000000000..04547444d Binary files /dev/null and b/BasicJava/RegexDemo_char_class_intersection/RegexDemo/bin/RegexDemo2.class differ diff --git a/BasicJava/RegexDemo_char_class_intersection/RegexDemo/bin/RegexDemo3.class b/BasicJava/RegexDemo_char_class_intersection/RegexDemo/bin/RegexDemo3.class new file mode 100644 index 000000000..5615a6c0b Binary files /dev/null and b/BasicJava/RegexDemo_char_class_intersection/RegexDemo/bin/RegexDemo3.class differ diff --git a/BasicJava/RegexDemo_char_class_intersection/RegexDemo/src/RegexDemo1.java b/BasicJava/RegexDemo_char_class_intersection/RegexDemo/src/RegexDemo1.java new file mode 100644 index 000000000..14aded0cc --- /dev/null +++ b/BasicJava/RegexDemo_char_class_intersection/RegexDemo/src/RegexDemo1.java @@ -0,0 +1,31 @@ +import java.util.regex.Pattern; + +/** + * + * [a-z&&[def]] = d, e, or f (intersection) + * + */ +public class RegexDemo1 +{ + public static void main(String[] args) + { + /* + * Parameters: + * + * regex - The expression to be compiled + * + * input - The character sequence to be matched + * + * Returns: + * + * whether or not the regular expression matches on the input + * + */ + System.out.println("[a-z&&[def]] matches d = " + Pattern.matches("[a-z&&[def]]", "d")); + System.out.println("[a-z&&[def]] matches e = " + Pattern.matches("[a-z&&[def]]", "e")); + System.out.println("[a-z&&[def]] matches f = " + Pattern.matches("[a-z&&[def]]", "f")); + System.out.println("[a-z&&[def]] matches z = " + Pattern.matches("[a-z&&[def]]", "z")); + System.out.println("[a-z&&[def]] matches def = " + Pattern.matches("[a-z&&[def]]", "def")); + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_char_class_intersection/RegexDemo/src/RegexDemo2.java b/BasicJava/RegexDemo_char_class_intersection/RegexDemo/src/RegexDemo2.java new file mode 100644 index 000000000..f89bceb2b --- /dev/null +++ b/BasicJava/RegexDemo_char_class_intersection/RegexDemo/src/RegexDemo2.java @@ -0,0 +1,29 @@ +import java.util.regex.Pattern; + +/** + * + * [a-z&&[^bc]] = a through z, except for b and c + * + */ +public class RegexDemo2 +{ + public static void main(String[] args) + { + /* + * Parameters: + * + * regex - The expression to be compiled + * + * input - The character sequence to be matched + * + * Returns: + * + * whether or not the regular expression matches on the input + * + */ + System.out.println("[a-z&&[^bc]] matches h = " + Pattern.matches("[a-z&&[^bc]]", "h")); + System.out.println("[a-z&&[^bc]] matches c = " + Pattern.matches("[a-z&&[^bc]]", "c")); + System.out.println("[a-z&&[^bc]] matches hh = " + Pattern.matches("[a-z&&[^bc]]", "hh")); + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_char_class_intersection/RegexDemo/src/RegexDemo3.java b/BasicJava/RegexDemo_char_class_intersection/RegexDemo/src/RegexDemo3.java new file mode 100644 index 000000000..df3dbb8a7 --- /dev/null +++ b/BasicJava/RegexDemo_char_class_intersection/RegexDemo/src/RegexDemo3.java @@ -0,0 +1,29 @@ +import java.util.regex.Pattern; + +/** + * + * [a-z&&[^m-p]] = a through z, and not m through p + * + */ +public class RegexDemo3 +{ + public static void main(String[] args) + { + /* + * Parameters: + * + * regex - The expression to be compiled + * + * input - The character sequence to be matched + * + * Returns: + * + * whether or not the regular expression matches on the input + * + */ + System.out.println("[a-z&&[^m-p]] matches b = " + Pattern.matches("[a-z&&[^m-p]]", "b")); + System.out.println("[a-z&&[^m-p]] matches o = " + Pattern.matches("[a-z&&[^m-p]]", "o")); + System.out.println("[a-z&&[^m-p]] matches bb = " + Pattern.matches("[a-z&&[^m-p]]", "bb")); + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_char_class_intersection/RegexDemo1_Output.txt b/BasicJava/RegexDemo_char_class_intersection/RegexDemo1_Output.txt new file mode 100644 index 000000000..62bc0aca5 --- /dev/null +++ b/BasicJava/RegexDemo_char_class_intersection/RegexDemo1_Output.txt @@ -0,0 +1,5 @@ +[a-z&&[def]] matches d = true +[a-z&&[def]] matches e = true +[a-z&&[def]] matches f = true +[a-z&&[def]] matches z = false +[a-z&&[def]] matches def = false diff --git a/BasicJava/RegexDemo_char_class_intersection/RegexDemo2_Output.txt b/BasicJava/RegexDemo_char_class_intersection/RegexDemo2_Output.txt new file mode 100644 index 000000000..f7816068f --- /dev/null +++ b/BasicJava/RegexDemo_char_class_intersection/RegexDemo2_Output.txt @@ -0,0 +1,3 @@ +[a-z&&[^bc]] matches h = true +[a-z&&[^bc]] matches c = false +[a-z&&[^bc]] matches hh = false diff --git a/BasicJava/RegexDemo_char_class_intersection/RegexDemo3_Output.txt b/BasicJava/RegexDemo_char_class_intersection/RegexDemo3_Output.txt new file mode 100644 index 000000000..16889ce80 --- /dev/null +++ b/BasicJava/RegexDemo_char_class_intersection/RegexDemo3_Output.txt @@ -0,0 +1,3 @@ +[a-z&&[^m-p]] matches b = true +[a-z&&[^m-p]] matches o = false +[a-z&&[^m-p]] matches bb = false diff --git a/BasicJava/RegexDemo_comments_flag/Output.txt b/BasicJava/RegexDemo_comments_flag/Output.txt new file mode 100644 index 000000000..5a892ca6f --- /dev/null +++ b/BasicJava/RegexDemo_comments_flag/Output.txt @@ -0,0 +1 @@ +Number of Matches = 1 diff --git a/BasicJava/RegexDemo_comments_flag/RegexDemo/.classpath b/BasicJava/RegexDemo_comments_flag/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_comments_flag/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_comments_flag/RegexDemo/.project b/BasicJava/RegexDemo_comments_flag/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_comments_flag/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_comments_flag/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_comments_flag/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_comments_flag/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_comments_flag/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_comments_flag/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..4e77a9141 Binary files /dev/null and b/BasicJava/RegexDemo_comments_flag/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_comments_flag/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_comments_flag/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..69a021113 --- /dev/null +++ b/BasicJava/RegexDemo_comments_flag/RegexDemo/src/RegexDemo.java @@ -0,0 +1,44 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * Flags + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + /* + * Pattern.COMMENTS + * + * when we use the flag, it will ignore the extra spaces and + * the every text starting with # will be seen as a comment to + * be ignored for each line: + */ + calculateMatches("dog$ #check end of text", "This is a dog", + Pattern.COMMENTS); + } + + private static void calculateMatches(String regex, String inputText, + int flag) + { + Pattern pattern = Pattern.compile(regex, flag); + Matcher matcher = pattern.matcher(inputText); + int matches = 0; + + /* + * The find method keeps advancing through the input text and + * returns true for every match, so we can use it to find the + * match count as well: + */ + while (matcher.find()) + { + ++matches; + } + System.out.println("Number of Matches = " + matches); + } + +} diff --git a/BasicJava/RegexDemo_contains_http/Output.txt b/BasicJava/RegexDemo_contains_http/Output.txt new file mode 100644 index 000000000..74c06beb7 --- /dev/null +++ b/BasicJava/RegexDemo_contains_http/Output.txt @@ -0,0 +1 @@ +matches = true diff --git a/BasicJava/RegexDemo_contains_http/RegexDemo/.classpath b/BasicJava/RegexDemo_contains_http/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_contains_http/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_contains_http/RegexDemo/.project b/BasicJava/RegexDemo_contains_http/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_contains_http/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_contains_http/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_contains_http/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_contains_http/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_contains_http/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_contains_http/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..1a108d69b Binary files /dev/null and b/BasicJava/RegexDemo_contains_http/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_contains_http/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_contains_http/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..b5d426561 --- /dev/null +++ b/BasicJava/RegexDemo_contains_http/RegexDemo/src/RegexDemo.java @@ -0,0 +1,35 @@ +import java.util.regex.Pattern; + +public class RegexDemo +{ + + public static void main(String[] args) + { + /* + * The inputText variable contains the text to be checked with + * the regular expression. + */ + String inputText = "This is the text to be searched " + + "for occurrences of the http:// pattern."; + + /* + * The regular expression matches all texts which contains one + * or more characters (.*) followed by the text http:// + * followed by one or more characters (.*). + */ + String regex = ".*http://.*"; + + /* + * the Pattern.matches() static method to check if the regular + * expression (pattern) matches the text. If the regular + * expression matches the text, then Pattern.matches() returns + * true. If the regular expression does not match the text + * Pattern.matches() returns false. + */ + boolean matches = Pattern.matches(regex, inputText); + + System.out.println("matches = " + matches); + + } + +} diff --git a/BasicJava/RegexDemo_count_word_dog/Output.txt b/BasicJava/RegexDemo_count_word_dog/Output.txt new file mode 100644 index 000000000..c92e85ce2 --- /dev/null +++ b/BasicJava/RegexDemo_count_word_dog/Output.txt @@ -0,0 +1,16 @@ +Match number 1 +start(): 0 +end(): 3 +--------------------- +Match number 2 +start(): 4 +end(): 7 +--------------------- +Match number 3 +start(): 8 +end(): 11 +--------------------- +Match number 4 +start(): 19 +end(): 22 +--------------------- diff --git a/BasicJava/RegexDemo_count_word_dog/RegexDemo/.classpath b/BasicJava/RegexDemo_count_word_dog/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_count_word_dog/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_count_word_dog/RegexDemo/.project b/BasicJava/RegexDemo_count_word_dog/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_count_word_dog/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_count_word_dog/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_count_word_dog/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_count_word_dog/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_count_word_dog/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_count_word_dog/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..afee03556 Binary files /dev/null and b/BasicJava/RegexDemo_count_word_dog/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_count_word_dog/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_count_word_dog/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..4aff17548 --- /dev/null +++ b/BasicJava/RegexDemo_count_word_dog/RegexDemo/src/RegexDemo.java @@ -0,0 +1,41 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * This example that counts the number of times the word "dog" appears in the + * input string + * + */ +public class RegexDemo +{ + private static final String REGEX = "\\bdog\\b"; + private static final String INPUT = "dog dog dog dogiee dog"; + + public static void main(String[] args) + { + Pattern p = Pattern.compile(REGEX); + Matcher m = p.matcher(INPUT); // get a matcher object + int count = 0; + + /* + * Returns:true if, and only if, a subsequence of the input sequence + * matches this matcher's pattern + */ + while (m.find()) + { + count++; + System.out.println("Match number " + count); + /* + * Returns the start index of the previous match. + */ + System.out.println("start(): " + m.start()); + /* + * Returns the offset after the last character matched. + */ + System.out.println("end(): " + m.end()); + System.out.println("---------------------"); + } + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_date_format/Output.txt b/BasicJava/RegexDemo_date_format/Output.txt new file mode 100644 index 000000000..efbd451ee --- /dev/null +++ b/BasicJava/RegexDemo_date_format/Output.txt @@ -0,0 +1,9 @@ +01/01/2020 is Valid? = true +31/01/2020 is Valid? = true +31/8/2010 is Valid? = true +1/1/2010 is Valid? = true +-------------------------------------- +32/1/2010 is Valid? = false +31/9/2010 is Valid? = false +333/2/200f is Valid? = false +110:20 is Valid? = false diff --git a/BasicJava/RegexDemo_date_format/RegexDemo/.classpath b/BasicJava/RegexDemo_date_format/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_date_format/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_date_format/RegexDemo/.project b/BasicJava/RegexDemo_date_format/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_date_format/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_date_format/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_date_format/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_date_format/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_date_format/RegexDemo/bin/DateValidator.class b/BasicJava/RegexDemo_date_format/RegexDemo/bin/DateValidator.class new file mode 100644 index 000000000..0aabc29c4 Binary files /dev/null and b/BasicJava/RegexDemo_date_format/RegexDemo/bin/DateValidator.class differ diff --git a/BasicJava/RegexDemo_date_format/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_date_format/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..7c337dd93 Binary files /dev/null and b/BasicJava/RegexDemo_date_format/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_date_format/RegexDemo/src/DateValidator.java b/BasicJava/RegexDemo_date_format/RegexDemo/src/DateValidator.java new file mode 100644 index 000000000..eb261b4f1 --- /dev/null +++ b/BasicJava/RegexDemo_date_format/RegexDemo/src/DateValidator.java @@ -0,0 +1,90 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * How to validate date with regular expression + */ +public class DateValidator +{ + + private Pattern pattern; + private Matcher matcher; + + private static final String DATE_REGEX = "(0?[1-9]|[12][0-9]|3[01])/(0?[1-9]|1[012])/((19|20)\\d\\d)"; + + public DateValidator() + { + pattern = Pattern.compile(DATE_REGEX); + } + + /* + * 1.Date is valid against Regex. + * 2.Days of the month is valid. + */ + public boolean validate(final String date) + { + + matcher = pattern.matcher(date); + + if (matcher.matches()) + { + + matcher.reset(); + + if (matcher.find()) + { + + String day = matcher.group(1); + String month = matcher.group(2); + int year = Integer.parseInt(matcher.group(3)); + + if (day.equals("31") && (month.equals("4") || month.equals("6") + || month.equals("9") || month.equals("11") + || month.equals("04") || month.equals("06") + || month.equals("09"))) + { + return false; // only 1,3,5,7,8,10,12 has 31 days + } + else if (month.equals("2") || month.equals("02")) + { + // leap year + if (year % 4 == 0) + { + if (day.equals("30") || day.equals("31")) + { + return false; + } + else + { + return true; + } + } + else + { + if (day.equals("29") || day.equals("30") + || day.equals("31")) + { + return false; + } + else + { + return true; + } + } + } + else + { + return true; + } + } + else + { + return false; + } + } + else + { + return false; + } + } +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_date_format/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_date_format/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..657f7422f --- /dev/null +++ b/BasicJava/RegexDemo_date_format/RegexDemo/src/RegexDemo.java @@ -0,0 +1,39 @@ +import java.util.Arrays; +import java.util.List; + +/** + * + * How to validate date with regular expression + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + List validDateList = Arrays.asList("01/01/2020", "31/01/2020", + "31/8/2010", "1/1/2010"); + + DateValidator dateValidator = new DateValidator(); + + for (String date : validDateList) + { + System.out.println( + date + " is Valid? = " + dateValidator.validate(date)); + } + + System.out.println("--------------------------------------"); + + List inValidDateList = Arrays.asList("32/1/2010", "31/9/2010", + "333/2/200f", "110:20"); + + for (String date : inValidDateList) + { + System.out.println( + date + " is Valid? = " + dateValidator.validate(date)); + } + + + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_diff_lookingAt_matches/Output.txt b/BasicJava/RegexDemo_diff_lookingAt_matches/Output.txt new file mode 100644 index 000000000..cab461279 --- /dev/null +++ b/BasicJava/RegexDemo_diff_lookingAt_matches/Output.txt @@ -0,0 +1,2 @@ +lookingAt = true +matches = false diff --git a/BasicJava/RegexDemo_diff_lookingAt_matches/RegexDemo/.classpath b/BasicJava/RegexDemo_diff_lookingAt_matches/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_diff_lookingAt_matches/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_diff_lookingAt_matches/RegexDemo/.project b/BasicJava/RegexDemo_diff_lookingAt_matches/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_diff_lookingAt_matches/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_diff_lookingAt_matches/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_diff_lookingAt_matches/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_diff_lookingAt_matches/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_diff_lookingAt_matches/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_diff_lookingAt_matches/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..07562abc2 Binary files /dev/null and b/BasicJava/RegexDemo_diff_lookingAt_matches/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_diff_lookingAt_matches/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_diff_lookingAt_matches/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..2d156a3c4 --- /dev/null +++ b/BasicJava/RegexDemo_diff_lookingAt_matches/RegexDemo/src/RegexDemo.java @@ -0,0 +1,32 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class RegexDemo +{ + + public static void main(String[] args) + { + String inputCharSeq = "Hello peter how are you?"; + + String regex = "Hello peter"; + + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(inputCharSeq); + + /* + * The Matcher lookingAt() method works like the matches() + * method with one major difference. + * + * The lookingAt() method only matches the regular expression + * against the beginning of the text, whereas matches() + * matches the regular expression against the whole text. + * + * In other words, if the regular expression matches the + * beginning of a text but not the whole text, lookingAt() + * will return true, whereas matches() will return false. + */ + System.out.println("lookingAt = " + matcher.lookingAt()); + System.out.println("matches = " + matcher.matches()); + } + +} diff --git a/BasicJava/RegexDemo_dot_r/Output.txt b/BasicJava/RegexDemo_dot_r/Output.txt new file mode 100644 index 000000000..21b8aebfe --- /dev/null +++ b/BasicJava/RegexDemo_dot_r/Output.txt @@ -0,0 +1,5 @@ +true +false +false +false +true diff --git a/BasicJava/RegexDemo_dot_r/RegexDemo/.classpath b/BasicJava/RegexDemo_dot_r/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_dot_r/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_dot_r/RegexDemo/.project b/BasicJava/RegexDemo_dot_r/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_dot_r/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_dot_r/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_dot_r/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_dot_r/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_dot_r/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_dot_r/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..c180d672e Binary files /dev/null and b/BasicJava/RegexDemo_dot_r/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_dot_r/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_dot_r/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..572af6fdc --- /dev/null +++ b/BasicJava/RegexDemo_dot_r/RegexDemo/src/RegexDemo.java @@ -0,0 +1,27 @@ +import java.util.regex.Pattern; + +public class RegexDemo +{ + public static void main(String[] args) + { + /* + * Parameters: + * + * regex - The expression to be compiled + * + * input - The character sequence to be matched + * + * Returns: + * + * whether or not the regular expression matches on the input + * + */ + + System.out.println(Pattern.matches(".r", "ar"));//true (2nd char is r) + System.out.println(Pattern.matches(".r", "ak"));//false (2nd char is not r) + System.out.println(Pattern.matches(".r", "arr"));//false (has more than 2 char) + System.out.println(Pattern.matches(".r", "arrr"));//false (has more than 2 char) + System.out.println(Pattern.matches("..r", "par"));//true (3rd char is r) + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_email/Output.txt b/BasicJava/RegexDemo_email/Output.txt new file mode 100644 index 000000000..ee9bd6e70 --- /dev/null +++ b/BasicJava/RegexDemo_email/Output.txt @@ -0,0 +1,12 @@ +peter@yahoo.com is Valid = true +peter@yahoo.net is Valid = true +peter.50@yahoo.com is Valid = true +peter-100@yahoo.com is Valid = true +peter@gmail.com is Valid = true +peter+900@oracle.com is Valid = true +-------------------------------------- +peteryahoo.com is Valid = false +peter.50@.yahoo.com is Valid = false +peter.@yahoo.com is Valid = false +peter@gmail@com is Valid = false +peter..900@oracle.com is Valid = false diff --git a/BasicJava/RegexDemo_email/RegexDemo/.classpath b/BasicJava/RegexDemo_email/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_email/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_email/RegexDemo/.project b/BasicJava/RegexDemo_email/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_email/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_email/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_email/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_email/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_email/RegexDemo/bin/EmailValidator.class b/BasicJava/RegexDemo_email/RegexDemo/bin/EmailValidator.class new file mode 100644 index 000000000..ac7a284f0 Binary files /dev/null and b/BasicJava/RegexDemo_email/RegexDemo/bin/EmailValidator.class differ diff --git a/BasicJava/RegexDemo_email/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_email/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..39aba8536 Binary files /dev/null and b/BasicJava/RegexDemo_email/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_email/RegexDemo/src/EmailValidator.java b/BasicJava/RegexDemo_email/RegexDemo/src/EmailValidator.java new file mode 100644 index 000000000..0ae4adc8a --- /dev/null +++ b/BasicJava/RegexDemo_email/RegexDemo/src/EmailValidator.java @@ -0,0 +1,34 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * How to validate email address with regular expression + * + */ +public class EmailValidator +{ + + private Pattern pattern; + private Matcher matcher; + + private static final String EMAIL_REGEX = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@" + + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"; + + public EmailValidator() + { + pattern = Pattern.compile(EMAIL_REGEX); + } + + /** + * Validate hex with regular expression + * + * @param email email for validation + * @return true valid email, false invalid email + */ + public boolean validate(final String email) + { + matcher = pattern.matcher(email); + return matcher.matches(); + } +} diff --git a/BasicJava/RegexDemo_email/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_email/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..f55db6b5a --- /dev/null +++ b/BasicJava/RegexDemo_email/RegexDemo/src/RegexDemo.java @@ -0,0 +1,45 @@ +import java.util.ArrayList; + +/** + * + * How to validate email address with regular expression + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + ArrayList validEmailList = new ArrayList<>(); + validEmailList.add("peter@yahoo.com"); + validEmailList.add("peter@yahoo.net"); + validEmailList.add("peter.50@yahoo.com"); + validEmailList.add("peter-100@yahoo.com"); + validEmailList.add("peter@gmail.com"); + validEmailList.add("peter+900@oracle.com"); + + EmailValidator emailValidator = new EmailValidator(); + + for (String email : validEmailList) + { + System.out.println(email + " is Valid = " + emailValidator.validate(email)); + } + + + System.out.println("--------------------------------------"); + + ArrayList inValidEmailList = new ArrayList<>(); + inValidEmailList.add("peteryahoo.com"); // @ Symbol missing + inValidEmailList.add("peter.50@.yahoo.com"); //. after @ symbol is not allowed + inValidEmailList.add("peter.@yahoo.com");//. before @ symbol is not allowed + inValidEmailList.add("peter@gmail@com");// two @ symbols are not allowed + inValidEmailList.add("peter..900@oracle.com");// two dots are not allowed + + for (String email : inValidEmailList) + { + System.out.println(email + " is Valid = " + emailValidator.validate(email)); + } + + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_extract_animal/Output.txt b/BasicJava/RegexDemo_extract_animal/Output.txt new file mode 100644 index 000000000..29ef190ab --- /dev/null +++ b/BasicJava/RegexDemo_extract_animal/Output.txt @@ -0,0 +1,3 @@ +Found a cat. +Found a dog. +animalList = [cat, dog] diff --git a/BasicJava/RegexDemo_extract_animal/RegexDemo/.classpath b/BasicJava/RegexDemo_extract_animal/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_extract_animal/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_extract_animal/RegexDemo/.project b/BasicJava/RegexDemo_extract_animal/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_extract_animal/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_extract_animal/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_extract_animal/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_extract_animal/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_extract_animal/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_extract_animal/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..89a9628a3 Binary files /dev/null and b/BasicJava/RegexDemo_extract_animal/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_extract_animal/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_extract_animal/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..4f0ea42c6 --- /dev/null +++ b/BasicJava/RegexDemo_extract_animal/RegexDemo/src/RegexDemo.java @@ -0,0 +1,44 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * Extracting/Capturing: + * + * Specific values can be selected out of a large complex body of text. These + * values can be used in the application. + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + String inputCharSeq = "I have a cat, but I like my dog better."; + + /* + * () - group everything within the parenthesis as group 1 + * + * mouse - match the text ‘mouse’ + * + * | - alternation: match any one of the sections of this group + * + * cat - match the text ‘cat’ + */ + + Pattern pattern = Pattern.compile("(mouse|cat|dog|wolf)"); + Matcher matcher = pattern.matcher(inputCharSeq); + + List animalList = new ArrayList(); + while (matcher.find()) + { + System.out.println("Found a " + matcher.group() + "."); + animalList.add(matcher.group()); + } + + System.out.println("animalList = " + animalList); + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_find_multiocc/Output.txt b/BasicJava/RegexDemo_find_multiocc/Output.txt new file mode 100644 index 000000000..6ee152cf4 --- /dev/null +++ b/BasicJava/RegexDemo_find_multiocc/Output.txt @@ -0,0 +1,4 @@ +Found at: 0 - 3 +Found at: 7 - 10 +Found at: 14 - 17 +Found at: 22 - 25 diff --git a/BasicJava/RegexDemo_find_multiocc/RegexDemo/.classpath b/BasicJava/RegexDemo_find_multiocc/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_find_multiocc/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_find_multiocc/RegexDemo/.project b/BasicJava/RegexDemo_find_multiocc/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_find_multiocc/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_find_multiocc/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_find_multiocc/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_find_multiocc/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_find_multiocc/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_find_multiocc/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..2fcde14ce Binary files /dev/null and b/BasicJava/RegexDemo_find_multiocc/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_find_multiocc/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_find_multiocc/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..f5ab6a663 --- /dev/null +++ b/BasicJava/RegexDemo_find_multiocc/RegexDemo/src/RegexDemo.java @@ -0,0 +1,30 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * Example to find out the multiple occurrences using Matcher methods. + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + String inputCharSeq = "Cat AA Cat AA Cat AAA Cat"; + String regex = "Cat"; + + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(inputCharSeq); + + /* + * Returns: true if, and only if, a subsequence of the input sequence + * matches this matcher's pattern + */ + while (matcher.find()) + { + System.out.println("Found at: " + matcher.start() + " - " + matcher.end()); + } + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_finder/Output.txt b/BasicJava/RegexDemo_finder/Output.txt new file mode 100644 index 000000000..e2ea04e92 --- /dev/null +++ b/BasicJava/RegexDemo_finder/Output.txt @@ -0,0 +1,6 @@ +Enter regex pattern: +india +I found the text india starting at index 11 and ending at index 16 +Enter regex pattern: +peter +I found the text peter starting at index 17 and ending at index 22 diff --git a/BasicJava/RegexDemo_finder/RegexDemo/.classpath b/BasicJava/RegexDemo_finder/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_finder/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_finder/RegexDemo/.project b/BasicJava/RegexDemo_finder/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_finder/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_finder/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_finder/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_finder/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_finder/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_finder/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..07e90a016 Binary files /dev/null and b/BasicJava/RegexDemo_finder/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_finder/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_finder/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..1f74a15f5 --- /dev/null +++ b/BasicJava/RegexDemo_finder/RegexDemo/src/RegexDemo.java @@ -0,0 +1,42 @@ +import java.util.Scanner; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * Java Regex Finder Example + * + */ + +public class RegexDemo +{ + public static void main(String[] args) + { + try (Scanner sc = new Scanner(System.in)) + { + while (true) + { + System.out.println("Enter regex pattern:"); + String regexPattern = sc.nextLine(); + Pattern pattern = Pattern.compile(regexPattern); + Matcher matcher = pattern.matcher("Welcome to india peter"); + boolean found = false; + while (matcher.find()) + { + System.out.println("I found the text " + + matcher.group() + " starting at index " + + matcher.start() + + " and ending at index " + + matcher.end()); + found = true; + } + if (!found) + { + System.out.println("No match found."); + } + } + } + + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_group_append/Output.txt b/BasicJava/RegexDemo_group_append/Output.txt new file mode 100644 index 000000000..d9a516aad --- /dev/null +++ b/BasicJava/RegexDemo_group_append/Output.txt @@ -0,0 +1,4 @@ +Peter +Peter writes about this, and Peter +Peter writes about this, and Peter Doe writes about that, and Peter +Peter writes about this, and Peter Doe writes about that, and Peter Wayne writes about everything. diff --git a/BasicJava/RegexDemo_group_append/RegexDemo/.classpath b/BasicJava/RegexDemo_group_append/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_group_append/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_group_append/RegexDemo/.project b/BasicJava/RegexDemo_group_append/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_group_append/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_group_append/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_group_append/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_group_append/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_group_append/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_group_append/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..bb035bc93 Binary files /dev/null and b/BasicJava/RegexDemo_group_append/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_group_append/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_group_append/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..36a7b237e --- /dev/null +++ b/BasicJava/RegexDemo_group_append/RegexDemo/src/RegexDemo.java @@ -0,0 +1,55 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * appendReplacement() and appendTail(): + * + * The Matcher appendReplacement() and appendTail() methods are used + * to replace string tokens in an input text, and append the resulting + * string to a StringBuffer. + * + * When you have found a match using the find() method, you can call + * the appendReplacement(). Doing so results in the characters from + * the input text being appended to the StringBuffer, and the matched + * text being replaced. Only the characters starting from then end of + * the last match, and until just before the matched characters are + * copied. + * + * The appendReplacement() method keeps track of what has been copied + * into the StringBuffer, so you can continue searching for matches + * using find() until no more matches are found in the input text. + * + * Once the last match has been found, a part of the input text will + * still not have been copied into the StringBuffer. This is the + * characters from the end of the last match and until the end of the + * input text. By calling appendTail() you can append these last + * characters to the StringBuffer too. + * + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + String text = "John writes about this, and John Doe writes about that," + + " and John Wayne writes about everything."; + + String regex = "(John) "; + + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(text); + StringBuffer stringBuffer = new StringBuffer(); + + while (matcher.find()) + { + matcher.appendReplacement(stringBuffer, "Peter "); + System.out.println(stringBuffer.toString()); + } + matcher.appendTail(stringBuffer); + + System.out.println(stringBuffer.toString()); + } + +} diff --git a/BasicJava/RegexDemo_group_john/Output.txt b/BasicJava/RegexDemo_group_john/Output.txt new file mode 100644 index 000000000..840f399d3 --- /dev/null +++ b/BasicJava/RegexDemo_group_john/Output.txt @@ -0,0 +1,3 @@ +found: John , start: 0, end: 4 +found: John , start: 28, end: 32 +found: John , start: 56, end: 60 diff --git a/BasicJava/RegexDemo_group_john/RegexDemo/.classpath b/BasicJava/RegexDemo_group_john/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_group_john/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_group_john/RegexDemo/.project b/BasicJava/RegexDemo_group_john/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_group_john/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_group_john/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_group_john/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_group_john/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_group_john/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_group_john/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..90be00c52 Binary files /dev/null and b/BasicJava/RegexDemo_group_john/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_group_john/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_group_john/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..8795de712 --- /dev/null +++ b/BasicJava/RegexDemo_group_john/RegexDemo/src/RegexDemo.java @@ -0,0 +1,53 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * This example searches the text for occurrences of the word John. + * For each match found, group number 1 is extracted, which is what + * matched the group marked with parentheses. + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + String text = "John writes about this, and John writes about that," + + " and John writes about everything. "; + + /* + * Groups are marked with parentheses in the regular + * expression. + * + * This regular expression matches the text John. The + * parentheses are not part of the text that is matched. The + * parentheses mark a group. When a match is found in a text, + * you can get access to the part of the regular expression + * inside the group. + */ + String regex = "(John)"; + + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(text); + + while (matcher.find()) + { + /* + * We access a group using the group(int groupNo) method. + * A regular expression can have more than one group. Each + * group is thus marked with a separate set of + * parentheses. To get access to the text that matched the + * subpart of the expression in a specific group, pass the + * number of the group to the group(int groupNo) method. + * + * The group with number 0 is always the whole regular + * expression. To get access to a group marked by + * parentheses you should start with group numbers 1. + */ + System.out.println("found: " + matcher.group(1) + " , start: " + + matcher.start() + ", end: " + matcher.end()); + } + } + +} diff --git a/BasicJava/RegexDemo_image_name/Output.txt b/BasicJava/RegexDemo_image_name/Output.txt new file mode 100644 index 000000000..8b5aed540 --- /dev/null +++ b/BasicJava/RegexDemo_image_name/Output.txt @@ -0,0 +1,17 @@ +cat.jpg is Valid? = true +cat.gif is Valid? = true +cat.png is Valid? = true +cat.bmp is Valid? = true +dog.JPG is Valid? = true +dog.GIF is Valid? = true +dog.PNG is Valid? = true +dog.BMP is Valid? = true +rose.JpG is Valid? = true +rose.gIF is Valid? = true +rose.PNg is Valid? = true +rose.BMp is Valid? = true +-------------------------------------- +.jpg is Valid? = false + .gif is Valid? = false +dog.txt is Valid? = false +jpg is Valid? = false diff --git a/BasicJava/RegexDemo_image_name/RegexDemo/.classpath b/BasicJava/RegexDemo_image_name/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_image_name/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_image_name/RegexDemo/.project b/BasicJava/RegexDemo_image_name/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_image_name/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_image_name/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_image_name/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_image_name/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_image_name/RegexDemo/bin/ImageValidator.class b/BasicJava/RegexDemo_image_name/RegexDemo/bin/ImageValidator.class new file mode 100644 index 000000000..c96e700cb Binary files /dev/null and b/BasicJava/RegexDemo_image_name/RegexDemo/bin/ImageValidator.class differ diff --git a/BasicJava/RegexDemo_image_name/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_image_name/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..62acc0dbc Binary files /dev/null and b/BasicJava/RegexDemo_image_name/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_image_name/RegexDemo/src/ImageValidator.java b/BasicJava/RegexDemo_image_name/RegexDemo/src/ImageValidator.java new file mode 100644 index 000000000..1d622bda1 --- /dev/null +++ b/BasicJava/RegexDemo_image_name/RegexDemo/src/ImageValidator.java @@ -0,0 +1,33 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * How to validate image file extension with regular expression + * + */ +public class ImageValidator +{ + + private Pattern pattern; + private Matcher matcher; + + private static final String IMAGE_NAME_REGEX = "([^\\s]+(\\.(?i)(jpg|png|gif|bmp))$)"; + + public ImageValidator() + { + pattern = Pattern.compile(IMAGE_NAME_REGEX); + } + + /** + * Validate image with regular expression + * + * @param imageName imageName for validation + * @return true valid imageName, false invalid imageName + */ + public boolean validate(final String imageName) + { + matcher = pattern.matcher(imageName); + return matcher.matches(); + } +} diff --git a/BasicJava/RegexDemo_image_name/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_image_name/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..55f7d8e91 --- /dev/null +++ b/BasicJava/RegexDemo_image_name/RegexDemo/src/RegexDemo.java @@ -0,0 +1,37 @@ +import java.util.Arrays; +import java.util.List; + +/** + * + * How to validate image file extension with regular expression + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + List validImageNameList = Arrays.asList("cat.jpg", "cat.gif", + "cat.png", "cat.bmp", "dog.JPG", "dog.GIF", "dog.PNG", + "dog.BMP","rose.JpG", "rose.gIF", "rose.PNg", + "rose.BMp"); + + ImageValidator imageValidator = new ImageValidator(); + + for (String imageName : validImageNameList) + { + System.out.println(imageName + " is Valid? = " + imageValidator.validate(imageName)); + } + + System.out.println("--------------------------------------"); + + List inValidImageNameList = Arrays.asList(".jpg", " .gif","dog.txt","jpg"); + + for (String imageName : inValidImageNameList) + { + System.out.println(imageName + " is Valid? = " + imageValidator.validate(imageName)); + } + + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_index_methods/Output.txt b/BasicJava/RegexDemo_index_methods/Output.txt new file mode 100644 index 000000000..4a809467a --- /dev/null +++ b/BasicJava/RegexDemo_index_methods/Output.txt @@ -0,0 +1,2 @@ +Starting position = 5 +Ending position = 8 diff --git a/BasicJava/RegexDemo_index_methods/RegexDemo/.classpath b/BasicJava/RegexDemo_index_methods/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_index_methods/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_index_methods/RegexDemo/.project b/BasicJava/RegexDemo_index_methods/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_index_methods/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_index_methods/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_index_methods/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_index_methods/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_index_methods/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_index_methods/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..608b57c20 Binary files /dev/null and b/BasicJava/RegexDemo_index_methods/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_index_methods/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_index_methods/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..12473e204 --- /dev/null +++ b/BasicJava/RegexDemo_index_methods/RegexDemo/src/RegexDemo.java @@ -0,0 +1,31 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * Index Methods + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + Pattern pattern = Pattern.compile("dog"); + Matcher matcher = pattern.matcher("This dog is mine"); + + while (matcher.find()) + { + + /* + * Index methods provide useful index values that show + * precisely where the match was found in the input String + * . In the following test, we will confirm the start and + * end indices of the match for dog in the input String. + */ + System.out.println("Starting position = " + matcher.start()); + System.out.println("Ending position = " + matcher.end()); + } + } + +} diff --git a/BasicJava/RegexDemo_intersection_class/Output.txt b/BasicJava/RegexDemo_intersection_class/Output.txt new file mode 100644 index 000000000..29a7a1fc9 --- /dev/null +++ b/BasicJava/RegexDemo_intersection_class/Output.txt @@ -0,0 +1,2 @@ +Number of Matches = 4 +Number of Matches = 4 diff --git a/BasicJava/RegexDemo_intersection_class/RegexDemo/.classpath b/BasicJava/RegexDemo_intersection_class/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_intersection_class/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_intersection_class/RegexDemo/.project b/BasicJava/RegexDemo_intersection_class/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_intersection_class/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_intersection_class/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_intersection_class/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_intersection_class/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_intersection_class/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_intersection_class/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..6cd0881a0 Binary files /dev/null and b/BasicJava/RegexDemo_intersection_class/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_intersection_class/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_intersection_class/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..0c6623e82 --- /dev/null +++ b/BasicJava/RegexDemo_intersection_class/RegexDemo/src/RegexDemo.java @@ -0,0 +1,40 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * Intersection Class + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + /* + * We will get 4 matches because the intersection of the two + * sets has only 4 elements[3456]. + */ + calculateMatches("[1-6&&[3-9]]", "3456"); + calculateMatches("[1-6&&[3-9]]", "123456789"); + } + + private static void calculateMatches(String regex, String inputText) + { + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(inputText); + int matches = 0; + + /* + * The find method keeps advancing through the input text and + * returns true for every match, so we can use it to find the + * match count as well: + */ + while (matcher.find()) + { + ++matches; + } + System.out.println("Number of Matches = " + matches); + } + +} diff --git a/BasicJava/RegexDemo_ipaddress/Output.txt b/BasicJava/RegexDemo_ipaddress/Output.txt new file mode 100644 index 000000000..f883f426c --- /dev/null +++ b/BasicJava/RegexDemo_ipaddress/Output.txt @@ -0,0 +1,11 @@ +1.1.1.1 is Valid? = true +255.255.255.255 is Valid? = true +192.168.1.2 is Valid? = true +10.10.1.1 is Valid? = true +132.253.111.10 is Valid? = true +26.10.2.10 is Valid? = true +127.0.0.1 is Valid? = true +-------------------------------------- +10.10.10 is Valid? = false +222.222.2.999 is Valid? = false +10.0.0.a is Valid? = false diff --git a/BasicJava/RegexDemo_ipaddress/RegexDemo/.classpath b/BasicJava/RegexDemo_ipaddress/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_ipaddress/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_ipaddress/RegexDemo/.project b/BasicJava/RegexDemo_ipaddress/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_ipaddress/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_ipaddress/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_ipaddress/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_ipaddress/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_ipaddress/RegexDemo/bin/IPAddressValidator.class b/BasicJava/RegexDemo_ipaddress/RegexDemo/bin/IPAddressValidator.class new file mode 100644 index 000000000..85a963ae8 Binary files /dev/null and b/BasicJava/RegexDemo_ipaddress/RegexDemo/bin/IPAddressValidator.class differ diff --git a/BasicJava/RegexDemo_ipaddress/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_ipaddress/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..9a6094656 Binary files /dev/null and b/BasicJava/RegexDemo_ipaddress/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_ipaddress/RegexDemo/src/IPAddressValidator.java b/BasicJava/RegexDemo_ipaddress/RegexDemo/src/IPAddressValidator.java new file mode 100644 index 000000000..f47872c1d --- /dev/null +++ b/BasicJava/RegexDemo_ipaddress/RegexDemo/src/IPAddressValidator.java @@ -0,0 +1,36 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * How to validate IP address with regular expression + * + */ +public class IPAddressValidator +{ + + private Pattern pattern; + private Matcher matcher; + + private static final String IP_ADDRESS_REGEX = "^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." + + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." + + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." + + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])$"; + + public IPAddressValidator() + { + pattern = Pattern.compile(IP_ADDRESS_REGEX); + } + + /** + * Validate ipAddress with regular expression + * + * @param ipAddress ip address for validation + * @return true valid ip address, false invalid ip address + */ + public boolean validate(final String ipAddress) + { + matcher = pattern.matcher(ipAddress); + return matcher.matches(); + } +} diff --git a/BasicJava/RegexDemo_ipaddress/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_ipaddress/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..9ec16e197 --- /dev/null +++ b/BasicJava/RegexDemo_ipaddress/RegexDemo/src/RegexDemo.java @@ -0,0 +1,39 @@ +import java.util.Arrays; +import java.util.List; + +/** + * + * How to validate IP address with regular expression + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + List validIPList = Arrays.asList("1.1.1.1", "255.255.255.255", + "192.168.1.2", "10.10.1.1", "132.253.111.10", "26.10.2.10", + "127.0.0.1"); + + IPAddressValidator ipAddressValidator = new IPAddressValidator(); + + + for (String ipAddress : validIPList) + { + System.out.println(ipAddress + " is Valid? = " + + ipAddressValidator.validate(ipAddress)); + } + + System.out.println("--------------------------------------"); + + List inValidIPList = Arrays.asList("10.10.10", "222.222.2.999", + "10.0.0.a"); + + for (String ipAddress : inValidIPList) + { + System.out.println(ipAddress + " is Valid? = " + + ipAddressValidator.validate(ipAddress)); + } + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_logical_operatior_to/RegexDemo/.classpath b/BasicJava/RegexDemo_logical_operatior_to/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_logical_operatior_to/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_logical_operatior_to/RegexDemo/.project b/BasicJava/RegexDemo_logical_operatior_to/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_logical_operatior_to/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_logical_operatior_to/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_logical_operatior_to/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_logical_operatior_to/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_logical_operatior_to/RegexDemo/bin/RegexDemo1.class b/BasicJava/RegexDemo_logical_operatior_to/RegexDemo/bin/RegexDemo1.class new file mode 100644 index 000000000..7b6d873f4 Binary files /dev/null and b/BasicJava/RegexDemo_logical_operatior_to/RegexDemo/bin/RegexDemo1.class differ diff --git a/BasicJava/RegexDemo_logical_operatior_to/RegexDemo/bin/RegexDemo2.class b/BasicJava/RegexDemo_logical_operatior_to/RegexDemo/bin/RegexDemo2.class new file mode 100644 index 000000000..91d4a6eb0 Binary files /dev/null and b/BasicJava/RegexDemo_logical_operatior_to/RegexDemo/bin/RegexDemo2.class differ diff --git a/BasicJava/RegexDemo_logical_operatior_to/RegexDemo/src/RegexDemo1.java b/BasicJava/RegexDemo_logical_operatior_to/RegexDemo/src/RegexDemo1.java new file mode 100644 index 000000000..33bbe8659 --- /dev/null +++ b/BasicJava/RegexDemo_logical_operatior_to/RegexDemo/src/RegexDemo1.java @@ -0,0 +1,27 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * Logical Operators + * + */ +public class RegexDemo1 +{ + + public static void main(String[] args) + { + /* + * The Logical Operator XY matches the X followed by Y. + */ + Pattern pattern = Pattern.compile("to"); + Matcher matcher = pattern.matcher("Welcome to India"); + + while (matcher.find()) + { + System.out.println(matcher.group() + ", Match String start(): " + + matcher.start()); + } + } + +} diff --git a/BasicJava/RegexDemo_logical_operatior_to/RegexDemo/src/RegexDemo2.java b/BasicJava/RegexDemo_logical_operatior_to/RegexDemo/src/RegexDemo2.java new file mode 100644 index 000000000..37897ca0f --- /dev/null +++ b/BasicJava/RegexDemo_logical_operatior_to/RegexDemo/src/RegexDemo2.java @@ -0,0 +1,27 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * Logical Operators + * + */ +public class RegexDemo2 +{ + + public static void main(String[] args) + { + /* + * The Logical Operator X|Y matches the X or Y. + */ + Pattern pattern = Pattern.compile("t|o"); + Matcher matcher = pattern.matcher("Welcome to India"); + + while (matcher.find()) + { + System.out.println(matcher.group() + ", Match String start(): " + + matcher.start()); + } + } + +} diff --git a/BasicJava/RegexDemo_logical_operatior_to/RegexDemo1_Output.txt b/BasicJava/RegexDemo_logical_operatior_to/RegexDemo1_Output.txt new file mode 100644 index 000000000..0c4d36275 --- /dev/null +++ b/BasicJava/RegexDemo_logical_operatior_to/RegexDemo1_Output.txt @@ -0,0 +1 @@ +to, Match String start(): 8 diff --git a/BasicJava/RegexDemo_logical_operatior_to/RegexDemo2_Output.txt b/BasicJava/RegexDemo_logical_operatior_to/RegexDemo2_Output.txt new file mode 100644 index 000000000..6b46e1105 --- /dev/null +++ b/BasicJava/RegexDemo_logical_operatior_to/RegexDemo2_Output.txt @@ -0,0 +1,3 @@ +o, Match String start(): 4 +t, Match String start(): 8 +o, Match String start(): 9 diff --git a/BasicJava/RegexDemo_lookingAt/Output.txt b/BasicJava/RegexDemo_lookingAt/Output.txt new file mode 100644 index 000000000..3545dade7 --- /dev/null +++ b/BasicJava/RegexDemo_lookingAt/Output.txt @@ -0,0 +1,4 @@ +REGEX is: bar +INPUT is: barooooooooooooooo +lookingAt(): true +matches(): false diff --git a/BasicJava/RegexDemo_lookingAt/RegexDemo/.classpath b/BasicJava/RegexDemo_lookingAt/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_lookingAt/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_lookingAt/RegexDemo/.project b/BasicJava/RegexDemo_lookingAt/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_lookingAt/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_lookingAt/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_lookingAt/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_lookingAt/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_lookingAt/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_lookingAt/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..4f120c567 Binary files /dev/null and b/BasicJava/RegexDemo_lookingAt/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_lookingAt/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_lookingAt/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..b85d0a6ce --- /dev/null +++ b/BasicJava/RegexDemo_lookingAt/RegexDemo/src/RegexDemo.java @@ -0,0 +1,30 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class RegexDemo +{ + private static final String REGEX = "bar"; + private static final String INPUT = "barooooooooooooooo"; + + public static void main(String[] args) + { + Pattern pattern = Pattern.compile(REGEX); + Matcher matcher = pattern.matcher(INPUT); + + System.out.println("REGEX is: " + REGEX); + System.out.println("INPUT is: " + INPUT); + + /* + * Returns:true if, and only if, a prefix of the input sequence matches + * this matcher's pattern. + */ + System.out.println("lookingAt(): " + matcher.lookingAt()); + + /* + * Returns:true if, and only if, the entire region sequence matches this + * matcher's pattern + */ + System.out.println("matches(): " + matcher.matches()); + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_matcher_find/Output.txt b/BasicJava/RegexDemo_matcher_find/Output.txt new file mode 100644 index 000000000..27ba77dda --- /dev/null +++ b/BasicJava/RegexDemo_matcher_find/Output.txt @@ -0,0 +1 @@ +true diff --git a/BasicJava/RegexDemo_matcher_find/RegexDemo/.classpath b/BasicJava/RegexDemo_matcher_find/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_matcher_find/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_matcher_find/RegexDemo/.project b/BasicJava/RegexDemo_matcher_find/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_matcher_find/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_matcher_find/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_matcher_find/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_matcher_find/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_matcher_find/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_matcher_find/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..c27103380 Binary files /dev/null and b/BasicJava/RegexDemo_matcher_find/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_matcher_find/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_matcher_find/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..300ca1e5b --- /dev/null +++ b/BasicJava/RegexDemo_matcher_find/RegexDemo/src/RegexDemo.java @@ -0,0 +1,42 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class RegexDemo +{ + public static void main(String[] args) + { + String input = "TV Price is 500 Rs"; + String regex = "(.*)(\\d+)(.*)"; + + /* + * Parameters: + * + * regex - The expression to be compiled + * + * Returns: + * + * the given regular expression compiled into a pattern + * + */ + Pattern patternObj = Pattern.compile(regex); + + /* + * Parameters: + * + * input - The character sequence to be matched + * + * Returns: + * + * A new matcher for this pattern + */ + Matcher matcher = patternObj.matcher(input); + /* + * Returns: + * + * true if, and only if, a subsequence of the input sequence + * matches this matcher's pattern + */ + System.out.println(matcher.find()); + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_matches_contains_notstart/Output.txt b/BasicJava/RegexDemo_matches_contains_notstart/Output.txt new file mode 100644 index 000000000..b893e13da --- /dev/null +++ b/BasicJava/RegexDemo_matches_contains_notstart/Output.txt @@ -0,0 +1,8 @@ +true +------------------------------------ +false +true +------------------------------------ +true +true +false diff --git a/BasicJava/RegexDemo_matches_contains_notstart/RegexDemo/.classpath b/BasicJava/RegexDemo_matches_contains_notstart/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_matches_contains_notstart/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_matches_contains_notstart/RegexDemo/.project b/BasicJava/RegexDemo_matches_contains_notstart/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_matches_contains_notstart/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_matches_contains_notstart/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_matches_contains_notstart/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_matches_contains_notstart/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_matches_contains_notstart/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_matches_contains_notstart/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..556355a63 Binary files /dev/null and b/BasicJava/RegexDemo_matches_contains_notstart/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_matches_contains_notstart/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_matches_contains_notstart/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..e108c4bdd --- /dev/null +++ b/BasicJava/RegexDemo_matches_contains_notstart/RegexDemo/src/RegexDemo.java @@ -0,0 +1,30 @@ +import java.util.regex.Pattern; + +public class RegexDemo +{ + + public static void main(String[] args) + { + /* + * returns true if the string contains "abc" at any place + */ + System.out.println(Pattern.matches(".*abc.*", "deabcpq"));// True + + System.out.println("------------------------------------"); + + /* + * returns true if the string does not have a number at the beginning + */ + System.out.println(Pattern.matches("^[^\\d].*", "123abc")); // False + System.out.println(Pattern.matches("^[^\\d].*", "abc123")); // True + + System.out.println("------------------------------------"); + + // returns true if the string contains of three letters + System.out.println(Pattern.matches("[a-zA-Z][a-zA-Z][a-zA-Z]", "aPz"));// True + System.out.println(Pattern.matches("[a-zA-Z][a-zA-Z][a-zA-Z]", "aAA"));// True + System.out.println(Pattern.matches("[a-zA-Z][a-zA-Z][a-zA-Z]", "apZx"));// False + + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_metachar_d/RegexDemo/.classpath b/BasicJava/RegexDemo_metachar_d/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_metachar_d/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_metachar_d/RegexDemo/.project b/BasicJava/RegexDemo_metachar_d/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_metachar_d/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_metachar_d/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_metachar_d/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_metachar_d/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_metachar_d/RegexDemo/bin/RegexDemo1.class b/BasicJava/RegexDemo_metachar_d/RegexDemo/bin/RegexDemo1.class new file mode 100644 index 000000000..70af276ef Binary files /dev/null and b/BasicJava/RegexDemo_metachar_d/RegexDemo/bin/RegexDemo1.class differ diff --git a/BasicJava/RegexDemo_metachar_d/RegexDemo/bin/RegexDemo2.class b/BasicJava/RegexDemo_metachar_d/RegexDemo/bin/RegexDemo2.class new file mode 100644 index 000000000..498f87251 Binary files /dev/null and b/BasicJava/RegexDemo_metachar_d/RegexDemo/bin/RegexDemo2.class differ diff --git a/BasicJava/RegexDemo_metachar_d/RegexDemo/bin/RegexDemo3.class b/BasicJava/RegexDemo_metachar_d/RegexDemo/bin/RegexDemo3.class new file mode 100644 index 000000000..9842a3392 Binary files /dev/null and b/BasicJava/RegexDemo_metachar_d/RegexDemo/bin/RegexDemo3.class differ diff --git a/BasicJava/RegexDemo_metachar_d/RegexDemo/src/RegexDemo1.java b/BasicJava/RegexDemo_metachar_d/RegexDemo/src/RegexDemo1.java new file mode 100644 index 000000000..27f6d2fe8 --- /dev/null +++ b/BasicJava/RegexDemo_metachar_d/RegexDemo/src/RegexDemo1.java @@ -0,0 +1,39 @@ +import java.util.regex.Pattern; + +/** + * + * \d = Any digits, short of [0-9] + * + */ + +public class RegexDemo1 +{ + public static void main(String[] args) + { + System.out.println("metacharacters d"); + + /* + * Parameters: + * + * regex - The expression to be compiled + * + * input - The character sequence to be matched + * + * Returns: + * + * whether or not the regular expression matches on the input + * + */ + + System.out.println(Pattern.matches("\\d", "9"));//true (digit and comes once) + System.out.println(Pattern.matches("\\d", "dfg"));//false (non-digit) + System.out.println(Pattern.matches("\\d", "8888"));//false (digit but comes more than once) + System.out.println(Pattern.matches("\\d", "555abc"));//false (digit and char) + + System.out.println("----------------------------------"); + + System.out.println("metacharacters d with quantifier...."); + System.out.println(Pattern.matches("\\d*", "56565"));//true (digit may come 0 or more times) + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_metachar_d/RegexDemo/src/RegexDemo2.java b/BasicJava/RegexDemo_metachar_d/RegexDemo/src/RegexDemo2.java new file mode 100644 index 000000000..707b5ddfe --- /dev/null +++ b/BasicJava/RegexDemo_metachar_d/RegexDemo/src/RegexDemo2.java @@ -0,0 +1,38 @@ +import java.util.regex.Pattern; + +/** + * + * \D = Any non-digit, short for [^0-9] + * + */ +public class RegexDemo2 +{ + public static void main(String[] args) + { + System.out.println("metacharacters D.."); + /* + * Parameters: + * + * regex - The expression to be compiled + * + * input - The character sequence to be matched + * + * Returns: + * + * whether or not the regular expression matches on the input + * + */ + System.out.println(Pattern.matches("\\D", "m"));//true (non-digit and comes once) + System.out.println(Pattern.matches("\\D", "xds"));//false (non-digit but comes more than once) + System.out.println(Pattern.matches("\\D", "1"));//false (digit) + System.out.println(Pattern.matches("\\D", "8989"));//false (digit) + System.out.println(Pattern.matches("\\D", "121abc"));//false (digit and char) + + System.out.println("----------------------------------"); + + System.out.println("metacharacters D with quantifier...."); + System.out.println(Pattern.matches("\\D*", "peter"));//true (non-digit and may come 0 or more times) + + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_metachar_d/RegexDemo/src/RegexDemo3.java b/BasicJava/RegexDemo_metachar_d/RegexDemo/src/RegexDemo3.java new file mode 100644 index 000000000..f703fccf9 --- /dev/null +++ b/BasicJava/RegexDemo_metachar_d/RegexDemo/src/RegexDemo3.java @@ -0,0 +1,31 @@ +import java.util.regex.Pattern; + +/** + * + * . = Any character (may or may not match terminator) + * + */ +public class RegexDemo3 +{ + public static void main(String[] args) + { + /* + * Parameters: + * + * regex - The expression to be compiled + * + * input - The character sequence to be matched + * + * Returns: + * + * whether or not the regular expression matches on the input + * + */ + System.out.println(Pattern.matches(".", "m"));//true [char and comes once] + System.out.println(Pattern.matches(".", "8"));//true [char and comes once] + System.out.println(Pattern.matches(".", "99"));//false [char but comes more than once] + System.out.println(Pattern.matches(".", "uiui"));//false [char but comes more than once] + + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_metachar_d/RegexDemo1_Output.txt b/BasicJava/RegexDemo_metachar_d/RegexDemo1_Output.txt new file mode 100644 index 000000000..7a988deee --- /dev/null +++ b/BasicJava/RegexDemo_metachar_d/RegexDemo1_Output.txt @@ -0,0 +1,8 @@ +metacharacters d +true +false +false +false +---------------------------------- +metacharacters d with quantifier.... +true diff --git a/BasicJava/RegexDemo_metachar_d/RegexDemo2_Output.txt b/BasicJava/RegexDemo_metachar_d/RegexDemo2_Output.txt new file mode 100644 index 000000000..e239b2b12 --- /dev/null +++ b/BasicJava/RegexDemo_metachar_d/RegexDemo2_Output.txt @@ -0,0 +1,9 @@ +metacharacters D.. +true +false +false +false +false +---------------------------------- +metacharacters D with quantifier.... +true diff --git a/BasicJava/RegexDemo_metachar_d/RegexDemo3_Output.txt b/BasicJava/RegexDemo_metachar_d/RegexDemo3_Output.txt new file mode 100644 index 000000000..5f8cc1d19 --- /dev/null +++ b/BasicJava/RegexDemo_metachar_d/RegexDemo3_Output.txt @@ -0,0 +1,4 @@ +true +true +false +false diff --git a/BasicJava/RegexDemo_metachar_dot_cal/Output.txt b/BasicJava/RegexDemo_metachar_dot_cal/Output.txt new file mode 100644 index 000000000..b3aa690e6 --- /dev/null +++ b/BasicJava/RegexDemo_metachar_dot_cal/Output.txt @@ -0,0 +1,2 @@ +Number of Matches = 6 +Number of Matches = 1 diff --git a/BasicJava/RegexDemo_metachar_dot_cal/RegexDemo/.classpath b/BasicJava/RegexDemo_metachar_dot_cal/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_metachar_dot_cal/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_metachar_dot_cal/RegexDemo/.project b/BasicJava/RegexDemo_metachar_dot_cal/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_metachar_dot_cal/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_metachar_dot_cal/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_metachar_dot_cal/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_metachar_dot_cal/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_metachar_dot_cal/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_metachar_dot_cal/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..616192332 Binary files /dev/null and b/BasicJava/RegexDemo_metachar_dot_cal/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_metachar_dot_cal/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_metachar_dot_cal/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..3b46165dd --- /dev/null +++ b/BasicJava/RegexDemo_metachar_dot_cal/RegexDemo/src/RegexDemo.java @@ -0,0 +1,47 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Meta Characters example + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + /* + * Meta characters affect the way a pattern is matched, in a + * way adding logic to the search pattern. The Java API + * supports several metacharacters, the most straightforward + * being the dot “.” which matches any character: + */ + calculateMatches(".", "foofoo"); + /* + * Notice the dot after the foo in the regex. The matcher + * matches every text that is preceded by foo since the last + * dot part means any character after. So after finding the + * first foo, the rest is seen as any character. That is why + * there is only a single match. + */ + calculateMatches("foo.", "foofoo"); + } + + private static void calculateMatches(String regex, String inputText) + { + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(inputText); + int matches = 0; + + /* + * The find method keeps advancing through the input text and + * returns true for every match, so we can use it to find the + * match count as well: + */ + while (matcher.find()) + { + ++matches; + } + System.out.println("Number of Matches = " + matches); + } + +} diff --git a/BasicJava/RegexDemo_metachar_nor_class/Output.txt b/BasicJava/RegexDemo_metachar_nor_class/Output.txt new file mode 100644 index 000000000..5652e460e --- /dev/null +++ b/BasicJava/RegexDemo_metachar_nor_class/Output.txt @@ -0,0 +1,3 @@ +Number of Matches = 1 +Number of Matches = 2 +Number of Matches = 3 diff --git a/BasicJava/RegexDemo_metachar_nor_class/RegexDemo/.classpath b/BasicJava/RegexDemo_metachar_nor_class/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_metachar_nor_class/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_metachar_nor_class/RegexDemo/.project b/BasicJava/RegexDemo_metachar_nor_class/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_metachar_nor_class/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_metachar_nor_class/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_metachar_nor_class/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_metachar_nor_class/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_metachar_nor_class/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_metachar_nor_class/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..7424e2ab5 Binary files /dev/null and b/BasicJava/RegexDemo_metachar_nor_class/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_metachar_nor_class/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_metachar_nor_class/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..c9841d247 --- /dev/null +++ b/BasicJava/RegexDemo_metachar_nor_class/RegexDemo/src/RegexDemo.java @@ -0,0 +1,36 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; +/** + * + * NOR Class Example + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + calculateMatches("[^abc]", "z"); + calculateMatches("[^bcr]at", "sat mat"); + calculateMatches("[^bcr]at", "sat mat eat bat cat"); + } + + private static void calculateMatches(String regex, String inputText) + { + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(inputText); + int matches = 0; + + /* + * The find method keeps advancing through the input text and + * returns true for every match, so we can use it to find the + * match count as well: + */ + while (matcher.find()) + { + ++matches; + } + System.out.println("Number of Matches = " + matches); + } + +} diff --git a/BasicJava/RegexDemo_metachar_or_class/Output.txt b/BasicJava/RegexDemo_metachar_or_class/Output.txt new file mode 100644 index 000000000..9e940a47f --- /dev/null +++ b/BasicJava/RegexDemo_metachar_or_class/Output.txt @@ -0,0 +1,4 @@ +Number of Matches = 1 +Number of Matches = 3 +Number of Matches = 2 +Number of Matches = 3 diff --git a/BasicJava/RegexDemo_metachar_or_class/RegexDemo/.classpath b/BasicJava/RegexDemo_metachar_or_class/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_metachar_or_class/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_metachar_or_class/RegexDemo/.project b/BasicJava/RegexDemo_metachar_or_class/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_metachar_or_class/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_metachar_or_class/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_metachar_or_class/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_metachar_or_class/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_metachar_or_class/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_metachar_or_class/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..31c561689 Binary files /dev/null and b/BasicJava/RegexDemo_metachar_or_class/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_metachar_or_class/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_metachar_or_class/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..f6392b8f1 --- /dev/null +++ b/BasicJava/RegexDemo_metachar_or_class/RegexDemo/src/RegexDemo.java @@ -0,0 +1,47 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * OR Class Example + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + /* + * [abc] - Any of the elements in the set is matched + */ + calculateMatches("[abc]", "b"); + calculateMatches("[abc]", "cab"); + calculateMatches("[abc]", "caABZ9"); + + /* + * They can also be alternated as part of a String. In the + * following example, when we create different words by + * alternating the first letter with each element of the set, + * they are all matched: + */ + calculateMatches("[bcr]at", "bat cat rat zat"); + + } + + private static void calculateMatches(String regex, String inputText) + { + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(inputText); + int matches = 0; + + /* + * The find method keeps advancing through the input text and + * returns true for every match, so we can use it to find the + * match count as well: + */ + while (matcher.find()) + { + ++matches; + } + System.out.println("Number of Matches = " + matches); + } + +} diff --git a/BasicJava/RegexDemo_metachar_range_class/Output.txt b/BasicJava/RegexDemo_metachar_range_class/Output.txt new file mode 100644 index 000000000..8a0b3fd2a --- /dev/null +++ b/BasicJava/RegexDemo_metachar_range_class/Output.txt @@ -0,0 +1,4 @@ +Number of Matches = 3 +Number of Matches = 2 +Number of Matches = 3 +Number of Matches = 1 diff --git a/BasicJava/RegexDemo_metachar_range_class/RegexDemo/.classpath b/BasicJava/RegexDemo_metachar_range_class/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_metachar_range_class/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_metachar_range_class/RegexDemo/.project b/BasicJava/RegexDemo_metachar_range_class/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_metachar_range_class/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_metachar_range_class/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_metachar_range_class/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_metachar_range_class/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_metachar_range_class/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_metachar_range_class/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..17503f6ca Binary files /dev/null and b/BasicJava/RegexDemo_metachar_range_class/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_metachar_range_class/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_metachar_range_class/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..8ea8699e6 --- /dev/null +++ b/BasicJava/RegexDemo_metachar_range_class/RegexDemo/src/RegexDemo.java @@ -0,0 +1,50 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; +/** + * + * Range Class Example + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + /* + * Matching uppercase letters: + */ + calculateMatches( "[A-Z]", "Welcome To India"); + /* + * Matching lowercase letters: + */ + calculateMatches( "[a-z]", "Two"); + /* + * Matching both upper case and lower case letters: + */ + calculateMatches("[a-zA-Z]", "Two"); + /* + * Matching a given range of numbers: + */ + calculateMatches( "[1-5]", "hi 65"); + + } + + private static void calculateMatches(String regex, String inputText) + { + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(inputText); + int matches = 0; + + /* + * The find method keeps advancing through the input text and + * returns true for every match, so we can use it to find the + * match count as well: + */ + while (matcher.find()) + { + ++matches; + } + System.out.println("Number of Matches = " + matches); + } + +} diff --git a/BasicJava/RegexDemo_metachars_slash_s/RegexDemo/.classpath b/BasicJava/RegexDemo_metachars_slash_s/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_metachars_slash_s/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_metachars_slash_s/RegexDemo/.project b/BasicJava/RegexDemo_metachars_slash_s/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_metachars_slash_s/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_metachars_slash_s/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_metachars_slash_s/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_metachars_slash_s/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_metachars_slash_s/RegexDemo/bin/RegexDemo1.class b/BasicJava/RegexDemo_metachars_slash_s/RegexDemo/bin/RegexDemo1.class new file mode 100644 index 000000000..5ef79948b Binary files /dev/null and b/BasicJava/RegexDemo_metachars_slash_s/RegexDemo/bin/RegexDemo1.class differ diff --git a/BasicJava/RegexDemo_metachars_slash_s/RegexDemo/bin/RegexDemo2.class b/BasicJava/RegexDemo_metachars_slash_s/RegexDemo/bin/RegexDemo2.class new file mode 100644 index 000000000..7ed1696ff Binary files /dev/null and b/BasicJava/RegexDemo_metachars_slash_s/RegexDemo/bin/RegexDemo2.class differ diff --git a/BasicJava/RegexDemo_metachars_slash_s/RegexDemo/src/RegexDemo1.java b/BasicJava/RegexDemo_metachars_slash_s/RegexDemo/src/RegexDemo1.java new file mode 100644 index 000000000..8d1ec9536 --- /dev/null +++ b/BasicJava/RegexDemo_metachars_slash_s/RegexDemo/src/RegexDemo1.java @@ -0,0 +1,41 @@ +import java.util.regex.Pattern; + +/** + * + * \s = Any whitespace character should come only one time, short for [\t\n\x0B\f\r] + * + */ + +public class RegexDemo1 +{ + public static void main(String[] args) + { + System.out.println("metacharacters s"); + /* + * Parameters: + * + * regex - The expression to be compiled + * + * input - The character sequence to be matched + * + * Returns: + * + * whether or not the regular expression matches on the input + * + */ + System.out.println(Pattern.matches("\\s", " "));//true [Only one whitespace can come] + System.out.println(Pattern.matches("\\s", "\t"));//true [Only one whitespace can come] + System.out.println(Pattern.matches("\\s", "\n"));//true [Only one whitespace can come] + System.out.println(Pattern.matches("\\s", "\f"));//true [Only one whitespace can come] + System.out.println(Pattern.matches("\\s", " "));//false [Only one whitespace can come, but more whitespaces] + System.out.println(Pattern.matches("\\s", "\t\t"));//false [Only one whitespace can come, but more whitespaces] + System.out.println(Pattern.matches("\\s", "ab"));//false [not a whitespace] + + System.out.println("----------------------------------"); + + System.out.println("metacharacters s with quantifier...."); + System.out.println(Pattern.matches("\\s*", " "));//true [more than one whitespace can come] + System.out.println(Pattern.matches("\\s*", "\r\r"));//true [more than one whitespace can come] + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_metachars_slash_s/RegexDemo/src/RegexDemo2.java b/BasicJava/RegexDemo_metachars_slash_s/RegexDemo/src/RegexDemo2.java new file mode 100644 index 000000000..297fab9a3 --- /dev/null +++ b/BasicJava/RegexDemo_metachars_slash_s/RegexDemo/src/RegexDemo2.java @@ -0,0 +1,40 @@ +import java.util.regex.Pattern; + +/** + * + * \S = Any non-whitespace character Should come only one time, short for [^\s] + * + */ + +public class RegexDemo2 +{ + public static void main(String[] args) + { + System.out.println("metacharacters S"); + /* + * Parameters: + * + * regex - The expression to be compiled + * + * input - The character sequence to be matched + * + * Returns: + * + * whether or not the regular expression matches on the input + * + */ + System.out.println(Pattern.matches("\\S", "a"));//true + System.out.println(Pattern.matches("\\S", "ab"));//false + System.out.println(Pattern.matches("\\S", " "));//false + System.out.println(Pattern.matches("\\S", "\t"));//false + System.out.println(Pattern.matches("\\S", "\n"));//false + System.out.println(Pattern.matches("\\S", "\f"));//false + + + System.out.println("----------------------------------"); + + System.out.println("metacharacters S with quantifier...."); + System.out.println(Pattern.matches("\\S*", "peter"));//true + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_metachars_slash_s/RegexDemo1_Output.txt b/BasicJava/RegexDemo_metachars_slash_s/RegexDemo1_Output.txt new file mode 100644 index 000000000..de9e84508 --- /dev/null +++ b/BasicJava/RegexDemo_metachars_slash_s/RegexDemo1_Output.txt @@ -0,0 +1,12 @@ +metacharacters s +true +true +true +true +false +false +false +---------------------------------- +metacharacters s with quantifier.... +true +true diff --git a/BasicJava/RegexDemo_metachars_slash_s/RegexDemo2_Output.txt b/BasicJava/RegexDemo_metachars_slash_s/RegexDemo2_Output.txt new file mode 100644 index 000000000..e3c75950c --- /dev/null +++ b/BasicJava/RegexDemo_metachars_slash_s/RegexDemo2_Output.txt @@ -0,0 +1,10 @@ +metacharacters S +true +false +false +false +false +false +---------------------------------- +metacharacters S with quantifier.... +true diff --git a/BasicJava/RegexDemo_metachars_slash_w/RegexDemo/.classpath b/BasicJava/RegexDemo_metachars_slash_w/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_metachars_slash_w/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_metachars_slash_w/RegexDemo/.project b/BasicJava/RegexDemo_metachars_slash_w/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_metachars_slash_w/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_metachars_slash_w/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_metachars_slash_w/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_metachars_slash_w/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_metachars_slash_w/RegexDemo/bin/RegexDemo1.class b/BasicJava/RegexDemo_metachars_slash_w/RegexDemo/bin/RegexDemo1.class new file mode 100644 index 000000000..780e4d511 Binary files /dev/null and b/BasicJava/RegexDemo_metachars_slash_w/RegexDemo/bin/RegexDemo1.class differ diff --git a/BasicJava/RegexDemo_metachars_slash_w/RegexDemo/bin/RegexDemo2.class b/BasicJava/RegexDemo_metachars_slash_w/RegexDemo/bin/RegexDemo2.class new file mode 100644 index 000000000..8cf1a06f5 Binary files /dev/null and b/BasicJava/RegexDemo_metachars_slash_w/RegexDemo/bin/RegexDemo2.class differ diff --git a/BasicJava/RegexDemo_metachars_slash_w/RegexDemo/src/RegexDemo1.java b/BasicJava/RegexDemo_metachars_slash_w/RegexDemo/src/RegexDemo1.java new file mode 100644 index 000000000..b9268336e --- /dev/null +++ b/BasicJava/RegexDemo_metachars_slash_w/RegexDemo/src/RegexDemo1.java @@ -0,0 +1,38 @@ +import java.util.regex.Pattern; + +/** + * + * \w = Any word character, short for [a-zA-Z_0-9] + * + */ + +public class RegexDemo1 +{ + public static void main(String[] args) + { + System.out.println("metacharacters w"); + /* + * Parameters: + * + * regex - The expression to be compiled + * + * input - The character sequence to be matched + * + * Returns: + * + * whether or not the regular expression matches on the input + * + */ + System.out.println(Pattern.matches("\\w", "a"));//true + System.out.println(Pattern.matches("\\w", "9"));//true + System.out.println(Pattern.matches("\\w", "_"));//true + System.out.println(Pattern.matches("\\w", "a9"));//false + + System.out.println("----------------------------------"); + + System.out.println("metacharacters w with quantifier...."); + System.out.println(Pattern.matches("\\w*", "peter_99"));//true + System.out.println(Pattern.matches("\\w*", "peter_99@"));//false + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_metachars_slash_w/RegexDemo/src/RegexDemo2.java b/BasicJava/RegexDemo_metachars_slash_w/RegexDemo/src/RegexDemo2.java new file mode 100644 index 000000000..c13b7bb9c --- /dev/null +++ b/BasicJava/RegexDemo_metachars_slash_w/RegexDemo/src/RegexDemo2.java @@ -0,0 +1,38 @@ +import java.util.regex.Pattern; + +/** + * + * \W = Any non-word character, short for [^\w] + * + */ + +public class RegexDemo2 +{ + public static void main(String[] args) + { + System.out.println("metacharacters W"); + /* + * Parameters: + * + * regex - The expression to be compiled + * + * input - The character sequence to be matched + * + * Returns: + * + * whether or not the regular expression matches on the input + * + */ + System.out.println(Pattern.matches("\\W", "@"));//true + System.out.println(Pattern.matches("\\W", "a"));//false + System.out.println(Pattern.matches("\\W", "9"));//false + System.out.println(Pattern.matches("\\W", "@@"));//false + + System.out.println("----------------------------------"); + + System.out.println("metacharacters W with quantifier...."); + System.out.println(Pattern.matches("\\W*", "@@"));//true + System.out.println(Pattern.matches("\\W*", "@@peter"));//false + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_metachars_slash_w/RegexDemo1_Output.txt b/BasicJava/RegexDemo_metachars_slash_w/RegexDemo1_Output.txt new file mode 100644 index 000000000..20da6361c --- /dev/null +++ b/BasicJava/RegexDemo_metachars_slash_w/RegexDemo1_Output.txt @@ -0,0 +1,9 @@ +metacharacters w +true +true +true +false +---------------------------------- +metacharacters w with quantifier.... +true +false diff --git a/BasicJava/RegexDemo_metachars_slash_w/RegexDemo2_Output.txt b/BasicJava/RegexDemo_metachars_slash_w/RegexDemo2_Output.txt new file mode 100644 index 000000000..63f24da49 --- /dev/null +++ b/BasicJava/RegexDemo_metachars_slash_w/RegexDemo2_Output.txt @@ -0,0 +1,9 @@ +metacharacters W +true +false +false +false +---------------------------------- +metacharacters W with quantifier.... +true +false diff --git a/BasicJava/RegexDemo_modify_phno/Output.txt b/BasicJava/RegexDemo_modify_phno/Output.txt new file mode 100644 index 000000000..fbfe0a851 --- /dev/null +++ b/BasicJava/RegexDemo_modify_phno/Output.txt @@ -0,0 +1,3 @@ +Masking: 9898988988 +Masking: 7777766555 +Peter PhoneNumber=***masked***. Juli PhoneNumber=***masked*** diff --git a/BasicJava/RegexDemo_modify_phno/RegexDemo/.classpath b/BasicJava/RegexDemo_modify_phno/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_modify_phno/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_modify_phno/RegexDemo/.project b/BasicJava/RegexDemo_modify_phno/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_modify_phno/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_modify_phno/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_modify_phno/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_modify_phno/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_modify_phno/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_modify_phno/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..e318e560e Binary files /dev/null and b/BasicJava/RegexDemo_modify_phno/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_modify_phno/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_modify_phno/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..f4e9a2f10 --- /dev/null +++ b/BasicJava/RegexDemo_modify_phno/RegexDemo/src/RegexDemo.java @@ -0,0 +1,33 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * Modifying/Substitution: + * + * Values in text can be replaced with new values, for example, you could + * replace all instances of the word ‘PhoneNumber=’, followed by a number, with a + * mask to hide the original text. + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + String inputCharSeq = "Peter PhoneNumber=9898988988. Juli PhoneNumber=7777766555"; + + Pattern pattern = Pattern.compile("(PhoneNumber=)(\\d+)"); + Matcher matcher = pattern.matcher(inputCharSeq); + + StringBuffer sb = new StringBuffer(); + while (matcher.find()) + { + System.out.println("Masking: " + matcher.group(2)); + matcher.appendReplacement(sb, matcher.group(1) + "***masked***"); + } + matcher.appendTail(sb); + System.out.println(sb); + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_multiline_flag/Output.txt b/BasicJava/RegexDemo_multiline_flag/Output.txt new file mode 100644 index 000000000..d2d534b44 --- /dev/null +++ b/BasicJava/RegexDemo_multiline_flag/Output.txt @@ -0,0 +1,3 @@ +This is a dog +this is a fox +Number of Matches = 1 diff --git a/BasicJava/RegexDemo_multiline_flag/RegexDemo/.classpath b/BasicJava/RegexDemo_multiline_flag/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_multiline_flag/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_multiline_flag/RegexDemo/.project b/BasicJava/RegexDemo_multiline_flag/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_multiline_flag/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_multiline_flag/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_multiline_flag/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_multiline_flag/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_multiline_flag/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_multiline_flag/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..3767a9296 Binary files /dev/null and b/BasicJava/RegexDemo_multiline_flag/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_multiline_flag/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_multiline_flag/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..438a2d7a4 --- /dev/null +++ b/BasicJava/RegexDemo_multiline_flag/RegexDemo/src/RegexDemo.java @@ -0,0 +1,55 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * Flags + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + + String inputText = "This is a dog" + + System.getProperty("line.separator") + "this is a fox"; + + System.out.println(inputText); + + /* + * Pattern.MULTILINE + * + * With out Pattern.MULTILINE flag The match fails because the + * matcher searches for dog at the end of the entire String + * but the dog is present at the end of the first line of the + * string. + * + * However, with the Pattern.MULTILINE flag, the same test + * will pass since the matcher now takes into account line + * terminators. So the String dog is found just before the + * line terminates, hence success: + */ + calculateMatches("dog$", inputText, Pattern.MULTILINE); + } + + private static void calculateMatches(String regex, String inputText, + int flag) + { + Pattern pattern = Pattern.compile(regex, flag); + Matcher matcher = pattern.matcher(inputText); + int matches = 0; + + /* + * The find method keeps advancing through the input text and + * returns true for every match, so we can use it to find the + * match count as well: + */ + while (matcher.find()) + { + ++matches; + } + System.out.println("Number of Matches = " + matches); + } + +} diff --git a/BasicJava/RegexDemo_multiple_occ_is/Output.txt b/BasicJava/RegexDemo_multiple_occ_is/Output.txt new file mode 100644 index 000000000..9396c5afb --- /dev/null +++ b/BasicJava/RegexDemo_multiple_occ_is/Output.txt @@ -0,0 +1,4 @@ +found: 1 : 2 - 4 +found: 2 : 5 - 7 +found: 3 : 23 - 25 +found: 4 : 70 - 72 diff --git a/BasicJava/RegexDemo_multiple_occ_is/RegexDemo/.classpath b/BasicJava/RegexDemo_multiple_occ_is/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_multiple_occ_is/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_multiple_occ_is/RegexDemo/.project b/BasicJava/RegexDemo_multiple_occ_is/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_multiple_occ_is/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_multiple_occ_is/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_multiple_occ_is/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_multiple_occ_is/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_multiple_occ_is/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_multiple_occ_is/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..8a665d2af Binary files /dev/null and b/BasicJava/RegexDemo_multiple_occ_is/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_multiple_occ_is/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_multiple_occ_is/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..0a7598818 --- /dev/null +++ b/BasicJava/RegexDemo_multiple_occ_is/RegexDemo/src/RegexDemo.java @@ -0,0 +1,42 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Java regex example which uses the Matcher class to locate multiple + * occurrences of the substring "is" inside a text: * + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + String inputCharSeq = "This is the text which is to be searched " + + "for occurrences of the word 'is'."; + + String regex = "is"; + + /* + * Compiles the given regular expression into a pattern. + */ + Pattern pattern = Pattern.compile(regex); + /* + * Returns:A new matcher for this pattern + */ + Matcher matcher = pattern.matcher(inputCharSeq); + + int count = 0; + /* + * Returns:true if, and only if, a subsequence of the input + * sequence matches this matcher's pattern + */ + while (matcher.find()) + { + count++; + System.out.println("found: " + count + " : " + + matcher.start() + " - " + matcher.end()); + } + + } + +} diff --git a/BasicJava/RegexDemo_nested_group_john/Output.txt b/BasicJava/RegexDemo_nested_group_john/Output.txt new file mode 100644 index 000000000..fbdbb68be --- /dev/null +++ b/BasicJava/RegexDemo_nested_group_john/Output.txt @@ -0,0 +1,12 @@ +Group1 = John writes +Group2 = John +Group3 = writes +-------------------------------- +Group1 = John Doe +Group2 = John +Group3 = Doe +-------------------------------- +Group1 = John Wayne +Group2 = John +Group3 = Wayne +-------------------------------- diff --git a/BasicJava/RegexDemo_nested_group_john/RegexDemo/.classpath b/BasicJava/RegexDemo_nested_group_john/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_nested_group_john/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_nested_group_john/RegexDemo/.project b/BasicJava/RegexDemo_nested_group_john/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_nested_group_john/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_nested_group_john/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_nested_group_john/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_nested_group_john/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_nested_group_john/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_nested_group_john/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..398802844 Binary files /dev/null and b/BasicJava/RegexDemo_nested_group_john/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_nested_group_john/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_nested_group_john/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..827e708bb --- /dev/null +++ b/BasicJava/RegexDemo_nested_group_john/RegexDemo/src/RegexDemo.java @@ -0,0 +1,47 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Groups Inside Groups + * + * It is possible to have groups inside group in a regular + * expression. + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + String text = "John writes about this, and John Doe writes about that," + + " and John Wayne writes about everything."; + + /* + * Notice how the two groups from the examples earlier are now + * nested inside a larger group. (again, you cannot see the + * space at the end of the expression, but it is there). + * + * When groups are nested inside each other, they are numbered + * based on when the left paranthesis of the group is met. + * Thus, group 1 is the big group. Group 2 is the group with + * the expression John inside. Group 3 is the group with the + * expression .+? inside. This is important to know when you + * need to reference the groups via the groups(int groupNo) + * method. + */ + + String regex = "((John) (.+?)) "; + + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(text); + + while (matcher.find()) + { + System.out.println("Group1 = "+matcher.group(1)); + System.out.println("Group2 = "+matcher.group(2)); + System.out.println("Group3 = "+matcher.group(3)); + System.out.println("--------------------------------"); + } + } + +} diff --git a/BasicJava/RegexDemo_password/Output.txt b/BasicJava/RegexDemo_password/Output.txt new file mode 100644 index 000000000..4ca0c8bb8 --- /dev/null +++ b/BasicJava/RegexDemo_password/Output.txt @@ -0,0 +1,9 @@ +'peter1AB@' is valid? = true +'peter4COW$' is valid? = true +'peter78Dog%#' is valid? = true +-------------------------------------------------- +'p1AB@' is valid? = false +'peter1@' is valid? = false +'peterAB2*' is valid? = false +'peterAB$' is valid? = false +'PETER2$' is valid? = false diff --git a/BasicJava/RegexDemo_password/RegexDemo/.classpath b/BasicJava/RegexDemo_password/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_password/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_password/RegexDemo/.project b/BasicJava/RegexDemo_password/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_password/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_password/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_password/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_password/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_password/RegexDemo/bin/PasswordValidator.class b/BasicJava/RegexDemo_password/RegexDemo/bin/PasswordValidator.class new file mode 100644 index 000000000..aa73a85d7 Binary files /dev/null and b/BasicJava/RegexDemo_password/RegexDemo/bin/PasswordValidator.class differ diff --git a/BasicJava/RegexDemo_password/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_password/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..d1e053bbd Binary files /dev/null and b/BasicJava/RegexDemo_password/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_password/RegexDemo/src/PasswordValidator.java b/BasicJava/RegexDemo_password/RegexDemo/src/PasswordValidator.java new file mode 100644 index 000000000..87da31559 --- /dev/null +++ b/BasicJava/RegexDemo_password/RegexDemo/src/PasswordValidator.java @@ -0,0 +1,34 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * How to validate password with regular expression + * + */ +public class PasswordValidator +{ + private Pattern pattern; + private Matcher matcher; + + private static final String PASSWORD_REGEX = + "((?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%]).{6,20})"; + + public PasswordValidator() + { + pattern = Pattern.compile(PASSWORD_REGEX); + } + + /** + * Validate password with regular expression + * + * @param password password for validation + * @return true valid password, false invalid password + */ + public boolean validate(final String password) + { + matcher = pattern.matcher(password); + return matcher.matches(); + } + +} diff --git a/BasicJava/RegexDemo_password/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_password/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..edb82f735 --- /dev/null +++ b/BasicJava/RegexDemo_password/RegexDemo/src/RegexDemo.java @@ -0,0 +1,49 @@ +/** + * + * How to validate password with regular expression + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + PasswordValidator passwordValidator = new PasswordValidator(); + + System.out.println("'peter1AB@' is valid? = "+passwordValidator.validate("peter1AB@")); + System.out.println("'peter4COW$' is valid? = "+passwordValidator.validate("peter4COW$")); + System.out.println("'peter78Dog%#' is valid? = "+passwordValidator.validate("peter78Dog%#")); + + System.out.println("--------------------------------------------------"); + + /* + * too short, minimum 6 characters + */ + System.out.println("'p1AB@' is valid? = "+passwordValidator.validate("p1AB@")); + + /* + * uppercase characters is required + */ + System.out.println("'peter1@' is valid? = "+passwordValidator.validate("peter1@")); + + + /* + * special symbol “*” is not allow here + */ + System.out.println("'peterAB2*' is valid? = "+passwordValidator.validate("peterAB2*")); + + /* + * digit is required + */ + System.out.println("'peterAB$' is valid? = "+passwordValidator.validate("peterAB$")); + + + /* + * lower case character is required + */ + System.out.println("'PETER2$' is valid? = "+passwordValidator.validate("PETER2$")); + + + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_pattern_matcher/RegexDemo/.classpath b/BasicJava/RegexDemo_pattern_matcher/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_pattern_matcher/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_pattern_matcher/RegexDemo/.project b/BasicJava/RegexDemo_pattern_matcher/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_pattern_matcher/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_pattern_matcher/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_pattern_matcher/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_pattern_matcher/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_pattern_matcher/RegexDemo/bin/RegexDemo1.class b/BasicJava/RegexDemo_pattern_matcher/RegexDemo/bin/RegexDemo1.class new file mode 100644 index 000000000..c2fb066c8 Binary files /dev/null and b/BasicJava/RegexDemo_pattern_matcher/RegexDemo/bin/RegexDemo1.class differ diff --git a/BasicJava/RegexDemo_pattern_matcher/RegexDemo/bin/RegexDemo2.class b/BasicJava/RegexDemo_pattern_matcher/RegexDemo/bin/RegexDemo2.class new file mode 100644 index 000000000..d97f178f7 Binary files /dev/null and b/BasicJava/RegexDemo_pattern_matcher/RegexDemo/bin/RegexDemo2.class differ diff --git a/BasicJava/RegexDemo_pattern_matcher/RegexDemo/bin/RegexDemo3.class b/BasicJava/RegexDemo_pattern_matcher/RegexDemo/bin/RegexDemo3.class new file mode 100644 index 000000000..ade068440 Binary files /dev/null and b/BasicJava/RegexDemo_pattern_matcher/RegexDemo/bin/RegexDemo3.class differ diff --git a/BasicJava/RegexDemo_pattern_matcher/RegexDemo/src/RegexDemo1.java b/BasicJava/RegexDemo_pattern_matcher/RegexDemo/src/RegexDemo1.java new file mode 100644 index 000000000..95fefd441 --- /dev/null +++ b/BasicJava/RegexDemo_pattern_matcher/RegexDemo/src/RegexDemo1.java @@ -0,0 +1,39 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class RegexDemo1 +{ + public static void main(String[] args) + { + /* + * . represents single character + * + * Parameters: + * + * regex - The expression to be compiled + * + * Returns: + * + * the given regular expression compiled into a pattern + */ + Pattern pattern = Pattern.compile(".r"); + /* + * Parameters: + * + * input - The character sequence to be matched + * + * Returns: + * + * A new matcher for this pattern + * + */ + Matcher matcher = pattern.matcher("br"); + /* + * Returns:true if, and only if, the entire region sequence + * matches this matcher's pattern + */ + boolean result = matcher.matches(); + System.out.println(result); + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_pattern_matcher/RegexDemo/src/RegexDemo2.java b/BasicJava/RegexDemo_pattern_matcher/RegexDemo/src/RegexDemo2.java new file mode 100644 index 000000000..a1cb7f3b4 --- /dev/null +++ b/BasicJava/RegexDemo_pattern_matcher/RegexDemo/src/RegexDemo2.java @@ -0,0 +1,11 @@ +import java.util.regex.Pattern; + +public class RegexDemo2 +{ + public static void main(String[] args) + { + boolean result=Pattern.compile(".r").matcher("ar").matches(); + System.out.println(result); + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_pattern_matcher/RegexDemo/src/RegexDemo3.java b/BasicJava/RegexDemo_pattern_matcher/RegexDemo/src/RegexDemo3.java new file mode 100644 index 000000000..7b114b7d4 --- /dev/null +++ b/BasicJava/RegexDemo_pattern_matcher/RegexDemo/src/RegexDemo3.java @@ -0,0 +1,30 @@ +import java.util.regex.Pattern; + +/** + * boolean java.util.regex.Pattern.matches(String regex, CharSequence + * input) + * + * Compiles the given regular expression and attempts to match the + * given input against it + */ +public class RegexDemo3 +{ + public static void main(String[] args) + { + /* + * Parameters: + * + * regex: The expression to be compiled + * + * input: The character sequence to be matched + * + * Returns: + * + * whether or not the regular expression matches on + * the input + */ + boolean result = Pattern.matches(".r", "ar"); + System.out.println(result); + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_pattern_matcher/RegexDemo1_Output.txt b/BasicJava/RegexDemo_pattern_matcher/RegexDemo1_Output.txt new file mode 100644 index 000000000..27ba77dda --- /dev/null +++ b/BasicJava/RegexDemo_pattern_matcher/RegexDemo1_Output.txt @@ -0,0 +1 @@ +true diff --git a/BasicJava/RegexDemo_pattern_matcher/RegexDemo2_Output.txt b/BasicJava/RegexDemo_pattern_matcher/RegexDemo2_Output.txt new file mode 100644 index 000000000..27ba77dda --- /dev/null +++ b/BasicJava/RegexDemo_pattern_matcher/RegexDemo2_Output.txt @@ -0,0 +1 @@ +true diff --git a/BasicJava/RegexDemo_pattern_matcher/RegexDemo3_Output.txt b/BasicJava/RegexDemo_pattern_matcher/RegexDemo3_Output.txt new file mode 100644 index 000000000..27ba77dda --- /dev/null +++ b/BasicJava/RegexDemo_pattern_matcher/RegexDemo3_Output.txt @@ -0,0 +1 @@ +true diff --git a/BasicJava/RegexDemo_phone_number/Output.txt b/BasicJava/RegexDemo_phone_number/Output.txt new file mode 100644 index 000000000..da29283aa --- /dev/null +++ b/BasicJava/RegexDemo_phone_number/Output.txt @@ -0,0 +1,2 @@ +true +false diff --git a/BasicJava/RegexDemo_phone_number/RegexDemo/.classpath b/BasicJava/RegexDemo_phone_number/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_phone_number/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_phone_number/RegexDemo/.project b/BasicJava/RegexDemo_phone_number/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_phone_number/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_phone_number/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_phone_number/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_phone_number/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_phone_number/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_phone_number/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..e71e9d164 Binary files /dev/null and b/BasicJava/RegexDemo_phone_number/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_phone_number/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_phone_number/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..6e14ecd7c --- /dev/null +++ b/BasicJava/RegexDemo_phone_number/RegexDemo/src/RegexDemo.java @@ -0,0 +1,18 @@ +/** + * Write a regular expression which matches any phone number + */ + +public class RegexDemo +{ + public static void main(String[] args) + { + String regex = "\\d\\d\\d([-]){1}\\d\\d\\d([-]){1}\\d\\d\\d\\d"; + + String phoneNum1 = "123-332-9999"; + System.out.println(phoneNum1.matches(regex));// true + + String phoneNum2 = "1233329999"; + System.out.println(phoneNum2.matches(regex));// false + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_predefined_class_d_D/Output.txt b/BasicJava/RegexDemo_predefined_class_d_D/Output.txt new file mode 100644 index 000000000..2c3a88903 --- /dev/null +++ b/BasicJava/RegexDemo_predefined_class_d_D/Output.txt @@ -0,0 +1,2 @@ +Number of Matches = 2 +Number of Matches = 4 diff --git a/BasicJava/RegexDemo_predefined_class_d_D/RegexDemo/.classpath b/BasicJava/RegexDemo_predefined_class_d_D/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_predefined_class_d_D/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_predefined_class_d_D/RegexDemo/.project b/BasicJava/RegexDemo_predefined_class_d_D/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_predefined_class_d_D/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_predefined_class_d_D/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_predefined_class_d_D/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_predefined_class_d_D/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_predefined_class_d_D/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_predefined_class_d_D/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..ce6be5839 Binary files /dev/null and b/BasicJava/RegexDemo_predefined_class_d_D/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_predefined_class_d_D/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_predefined_class_d_D/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..f8366a3fa --- /dev/null +++ b/BasicJava/RegexDemo_predefined_class_d_D/RegexDemo/src/RegexDemo.java @@ -0,0 +1,51 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * Predefined Character Classes + * + * The Java regex API also accepts predefined character classes.One + * special aspect of the Java version of this regex is the escape + * character. + * + * As we will see, most characters will start with a backslash, which + * has a special meaning in Java. For these to be compiled by the + * Pattern class – the leading backslash must be escaped i.e. \d + * becomes \\d. + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + /* + * Matching digits, equivalent to [0-9]: + */ + calculateMatches("\\d", "12abcd"); + /* + * Matching non-digits, equivalent to [^0-9]: + */ + calculateMatches("\\D", "12abcd"); + } + + private static void calculateMatches(String regex, String inputText) + { + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(inputText); + int matches = 0; + + /* + * The find method keeps advancing through the input text and + * returns true for every match, so we can use it to find the + * match count as well: + */ + while (matcher.find()) + { + ++matches; + } + System.out.println("Number of Matches = " + matches); + } + +} diff --git a/BasicJava/RegexDemo_predefined_class_s_S/Output.txt b/BasicJava/RegexDemo_predefined_class_s_S/Output.txt new file mode 100644 index 000000000..1d5c459b4 --- /dev/null +++ b/BasicJava/RegexDemo_predefined_class_s_S/Output.txt @@ -0,0 +1,2 @@ +Number of Matches = 4 +Number of Matches = 2 diff --git a/BasicJava/RegexDemo_predefined_class_s_S/RegexDemo/.classpath b/BasicJava/RegexDemo_predefined_class_s_S/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_predefined_class_s_S/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_predefined_class_s_S/RegexDemo/.project b/BasicJava/RegexDemo_predefined_class_s_S/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_predefined_class_s_S/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_predefined_class_s_S/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_predefined_class_s_S/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_predefined_class_s_S/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_predefined_class_s_S/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_predefined_class_s_S/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..f723b7a9b Binary files /dev/null and b/BasicJava/RegexDemo_predefined_class_s_S/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_predefined_class_s_S/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_predefined_class_s_S/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..4c9151f8a --- /dev/null +++ b/BasicJava/RegexDemo_predefined_class_s_S/RegexDemo/src/RegexDemo.java @@ -0,0 +1,51 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * Predefined Character Classes + * + * The Java regex API also accepts predefined character classes.One + * special aspect of the Java version of this regex is the escape + * character. + * + * As we will see, most characters will start with a backslash, which + * has a special meaning in Java. For these to be compiled by the + * Pattern class – the leading backslash must be escaped i.e. \s + * becomes \\s. + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + /* + * Matching white space: + */ + calculateMatches("\\s", "a c"); + /* + * Matching non-white space: + */ + calculateMatches("\\S", "a c"); + } + + private static void calculateMatches(String regex, String inputText) + { + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(inputText); + int matches = 0; + + /* + * The find method keeps advancing through the input text and + * returns true for every match, so we can use it to find the + * match count as well: + */ + while (matcher.find()) + { + ++matches; + } + System.out.println("Number of Matches = " + matches); + } + +} diff --git a/BasicJava/RegexDemo_predefined_class_w_W/Output.txt b/BasicJava/RegexDemo_predefined_class_w_W/Output.txt new file mode 100644 index 000000000..da66079b0 --- /dev/null +++ b/BasicJava/RegexDemo_predefined_class_w_W/Output.txt @@ -0,0 +1,2 @@ +Number of Matches = 3 +Number of Matches = 2 diff --git a/BasicJava/RegexDemo_predefined_class_w_W/RegexDemo/.classpath b/BasicJava/RegexDemo_predefined_class_w_W/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_predefined_class_w_W/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_predefined_class_w_W/RegexDemo/.project b/BasicJava/RegexDemo_predefined_class_w_W/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_predefined_class_w_W/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_predefined_class_w_W/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_predefined_class_w_W/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_predefined_class_w_W/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_predefined_class_w_W/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_predefined_class_w_W/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..67fc908cd Binary files /dev/null and b/BasicJava/RegexDemo_predefined_class_w_W/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_predefined_class_w_W/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_predefined_class_w_W/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..d7083bbba --- /dev/null +++ b/BasicJava/RegexDemo_predefined_class_w_W/RegexDemo/src/RegexDemo.java @@ -0,0 +1,51 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * Predefined Character Classes + * + * The Java regex API also accepts predefined character classes.One + * special aspect of the Java version of this regex is the escape + * character. + * + * As we will see, most characters will start with a backslash, which + * has a special meaning in Java. For these to be compiled by the + * Pattern class – the leading backslash must be escaped i.e. \w + * becomes \\w. + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + /* + * Matching a word character, equivalent to [a-zA-Z_0-9]: + */ + calculateMatches("\\w", "Hi9!#"); + /* + * Matching a non-word character: + */ + calculateMatches("\\W", "Hi9!#"); + } + + private static void calculateMatches(String regex, String inputText) + { + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(inputText); + int matches = 0; + + /* + * The find method keeps advancing through the input text and + * returns true for every match, so we can use it to find the + * match count as well: + */ + while (matcher.find()) + { + ++matches; + } + System.out.println("Number of Matches = " + matches); + } + +} diff --git a/BasicJava/RegexDemo_quantifers_a_3times/Output.txt b/BasicJava/RegexDemo_quantifers_a_3times/Output.txt new file mode 100644 index 000000000..0799291e9 --- /dev/null +++ b/BasicJava/RegexDemo_quantifers_a_3times/Output.txt @@ -0,0 +1,3 @@ +Regex = a{3} , InputText = aaa is matching? = true +Regex = a{3} , InputText = aa is matching? = false +Regex = a{3} , InputText = aaaaaa is matching? = false diff --git a/BasicJava/RegexDemo_quantifers_a_3times/RegexDemo/.classpath b/BasicJava/RegexDemo_quantifers_a_3times/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_quantifers_a_3times/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_quantifers_a_3times/RegexDemo/.project b/BasicJava/RegexDemo_quantifers_a_3times/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_quantifers_a_3times/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_quantifers_a_3times/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_quantifers_a_3times/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_quantifers_a_3times/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_quantifers_a_3times/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_quantifers_a_3times/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..d0de63c23 Binary files /dev/null and b/BasicJava/RegexDemo_quantifers_a_3times/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_quantifers_a_3times/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_quantifers_a_3times/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..ff044c039 --- /dev/null +++ b/BasicJava/RegexDemo_quantifers_a_3times/RegexDemo/src/RegexDemo.java @@ -0,0 +1,28 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * Quantifiers + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + isMatch("a{3}", "aaa"); + isMatch("a{3}", "aa"); + isMatch("a{3}", "aaaaaa"); + } + + private static void isMatch(String regex, String inputText) + { + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(inputText); + + System.out.println("Regex = " + regex + " , " + "InputText = " + + inputText + " is matching? = " + matcher.matches()); + } + +} diff --git a/BasicJava/RegexDemo_quantifiers_a_2_3/Output.txt b/BasicJava/RegexDemo_quantifiers_a_2_3/Output.txt new file mode 100644 index 000000000..7785fc11a --- /dev/null +++ b/BasicJava/RegexDemo_quantifiers_a_2_3/Output.txt @@ -0,0 +1,4 @@ +Regex = a{2,3} , InputText = aa is matching? = true +Regex = a{2,3} , InputText = aaa is matching? = true +Regex = a{2,3} , InputText = a is matching? = false +Regex = a{2,3} , InputText = aaaaaa is matching? = false diff --git a/BasicJava/RegexDemo_quantifiers_a_2_3/RegexDemo/.classpath b/BasicJava/RegexDemo_quantifiers_a_2_3/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_quantifiers_a_2_3/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_quantifiers_a_2_3/RegexDemo/.project b/BasicJava/RegexDemo_quantifiers_a_2_3/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_quantifiers_a_2_3/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_quantifiers_a_2_3/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_quantifiers_a_2_3/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_quantifiers_a_2_3/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_quantifiers_a_2_3/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_quantifiers_a_2_3/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..cf3996555 Binary files /dev/null and b/BasicJava/RegexDemo_quantifiers_a_2_3/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_quantifiers_a_2_3/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_quantifiers_a_2_3/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..fcf4f3a3c --- /dev/null +++ b/BasicJava/RegexDemo_quantifiers_a_2_3/RegexDemo/src/RegexDemo.java @@ -0,0 +1,35 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * Quantifiers + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + + /* + * We’ve specified at least two occurrences but not exceeding + * three. + */ + isMatch("a{2,3}", "aa"); + isMatch("a{2,3}", "aaa"); + isMatch("a{2,3}", "a"); + isMatch("a{2,3}", "aaaaaa"); + + } + + private static void isMatch(String regex, String inputText) + { + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(inputText); + + System.out.println("Regex = " + regex + " , " + "InputText = " + + inputText + " is matching? = " + matcher.matches()); + } + +} diff --git a/BasicJava/RegexDemo_quantifiers_details/RegexDemo/.classpath b/BasicJava/RegexDemo_quantifiers_details/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_quantifiers_details/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_quantifiers_details/RegexDemo/.project b/BasicJava/RegexDemo_quantifiers_details/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_quantifiers_details/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_quantifiers_details/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_quantifiers_details/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_quantifiers_details/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_quantifiers_details/RegexDemo/bin/RegexDemo1.class b/BasicJava/RegexDemo_quantifiers_details/RegexDemo/bin/RegexDemo1.class new file mode 100644 index 000000000..7e0153edc Binary files /dev/null and b/BasicJava/RegexDemo_quantifiers_details/RegexDemo/bin/RegexDemo1.class differ diff --git a/BasicJava/RegexDemo_quantifiers_details/RegexDemo/bin/RegexDemo2.class b/BasicJava/RegexDemo_quantifiers_details/RegexDemo/bin/RegexDemo2.class new file mode 100644 index 000000000..302b31e7e Binary files /dev/null and b/BasicJava/RegexDemo_quantifiers_details/RegexDemo/bin/RegexDemo2.class differ diff --git a/BasicJava/RegexDemo_quantifiers_details/RegexDemo/bin/RegexDemo3.class b/BasicJava/RegexDemo_quantifiers_details/RegexDemo/bin/RegexDemo3.class new file mode 100644 index 000000000..5d921fa86 Binary files /dev/null and b/BasicJava/RegexDemo_quantifiers_details/RegexDemo/bin/RegexDemo3.class differ diff --git a/BasicJava/RegexDemo_quantifiers_details/RegexDemo/src/RegexDemo1.java b/BasicJava/RegexDemo_quantifiers_details/RegexDemo/src/RegexDemo1.java new file mode 100644 index 000000000..e913f6c26 --- /dev/null +++ b/BasicJava/RegexDemo_quantifiers_details/RegexDemo/src/RegexDemo1.java @@ -0,0 +1,37 @@ +import java.util.regex.Pattern; + + +public class RegexDemo1 +{ + public static void main(String[] args) + { + /* + * * = Occurs zero or more times, is short for {0,} + */ + System.out.println(Pattern.matches("X*", "")); // true + System.out.println(Pattern.matches("X*", "XXXX")); // true + System.out.println(Pattern.matches("X*", "aaaa")); // false + + System.out.println("-------------------------------"); + + /* + * + = Occurs one or more times, is short for {1,} + */ + System.out.println(Pattern.matches("X+", "")); // false + System.out.println(Pattern.matches("X+", "X")); // true + System.out.println(Pattern.matches("X+", "XXXX")); // true + System.out.println(Pattern.matches("X+", "BBBB")); // false + + System.out.println("-------------------------------"); + + /* + * ? = Occurs no or one times, ? is short for {0,1}. + */ + System.out.println(Pattern.matches("X?", "")); // true + System.out.println(Pattern.matches("X?", "X")); // true + System.out.println(Pattern.matches("X?", "XXXX")); // false + System.out.println(Pattern.matches("X?", "BBBB")); // false + + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_quantifiers_details/RegexDemo/src/RegexDemo2.java b/BasicJava/RegexDemo_quantifiers_details/RegexDemo/src/RegexDemo2.java new file mode 100644 index 000000000..e49f50189 --- /dev/null +++ b/BasicJava/RegexDemo_quantifiers_details/RegexDemo/src/RegexDemo2.java @@ -0,0 +1,29 @@ +import java.util.regex.Pattern; + + +public class RegexDemo2 +{ + public static void main(String[] args) + { + /* + * {X} = Occurs X number of times, {} + * describes the order of the preceding liberal + */ + System.out.println(Pattern.matches("X{3}", "X")); // false + System.out.println(Pattern.matches("X{3}", "XXX")); // true + System.out.println(Pattern.matches("X{3}", "aaaa")); // false + + System.out.println("-------------------------------"); + + System.out.println(Pattern.matches("\\d{3}", "989")); // true + System.out.println(Pattern.matches("\\d{3}", "9898")); // false + + System.out.println("-------------------------------"); + + System.out.println(Pattern.matches(".{10}", "99999aaaaa")); // true + System.out.println(Pattern.matches(".{10}", "99999")); // false + + + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_quantifiers_details/RegexDemo/src/RegexDemo3.java b/BasicJava/RegexDemo_quantifiers_details/RegexDemo/src/RegexDemo3.java new file mode 100644 index 000000000..23edbbb1b --- /dev/null +++ b/BasicJava/RegexDemo_quantifiers_details/RegexDemo/src/RegexDemo3.java @@ -0,0 +1,17 @@ +import java.util.regex.Pattern; + + +public class RegexDemo3 +{ + public static void main(String[] args) + { + /* + * {X,Y} = Occurs between X and Y times + */ + System.out.println(Pattern.matches("\\d{1,4}", "9")); // true + System.out.println(Pattern.matches("\\d{1,4}", "98")); // true + System.out.println(Pattern.matches("\\d{1,4}", "9888")); // true + System.out.println(Pattern.matches("\\d{1,4}", "9898909")); // false + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_quantifiers_details/RegexDemo1_Output.txt b/BasicJava/RegexDemo_quantifiers_details/RegexDemo1_Output.txt new file mode 100644 index 000000000..792e44810 --- /dev/null +++ b/BasicJava/RegexDemo_quantifiers_details/RegexDemo1_Output.txt @@ -0,0 +1,13 @@ +true +true +false +------------------------------- +false +true +true +false +------------------------------- +true +true +false +false diff --git a/BasicJava/RegexDemo_quantifiers_details/RegexDemo2_Output.txt b/BasicJava/RegexDemo_quantifiers_details/RegexDemo2_Output.txt new file mode 100644 index 000000000..d89354aa3 --- /dev/null +++ b/BasicJava/RegexDemo_quantifiers_details/RegexDemo2_Output.txt @@ -0,0 +1,9 @@ +false +true +false +------------------------------- +true +false +------------------------------- +true +false diff --git a/BasicJava/RegexDemo_quantifiers_details/RegexDemo3_Output.txt b/BasicJava/RegexDemo_quantifiers_details/RegexDemo3_Output.txt new file mode 100644 index 000000000..6859f05a4 --- /dev/null +++ b/BasicJava/RegexDemo_quantifiers_details/RegexDemo3_Output.txt @@ -0,0 +1,4 @@ +true +true +true +false diff --git a/BasicJava/RegexDemo_quote/Output.txt b/BasicJava/RegexDemo_quote/Output.txt new file mode 100644 index 000000000..901f53571 --- /dev/null +++ b/BasicJava/RegexDemo_quote/Output.txt @@ -0,0 +1,2 @@ +regex = \Qdog$\E +The cat says meow All cat say meow. diff --git a/BasicJava/RegexDemo_quote/RegexDemo/.classpath b/BasicJava/RegexDemo_quote/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_quote/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_quote/RegexDemo/.project b/BasicJava/RegexDemo_quote/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_quote/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_quote/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_quote/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_quote/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_quote/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_quote/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..90bd69669 Binary files /dev/null and b/BasicJava/RegexDemo_quote/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_quote/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_quote/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..f1f5a2486 --- /dev/null +++ b/BasicJava/RegexDemo_quote/RegexDemo/src/RegexDemo.java @@ -0,0 +1,26 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class RegexDemo +{ + + private static String STRING_TO_BE_LITERALIZED = "dog$"; + private static String INPUT_CHAR_SEQ = "The dog$ says meow All dog$ say meow."; + private static String REPLACE_STR = "cat"; + + public static void main(String[] args) + { + /* + * Returns:A literal string replacement + */ + String regex = Pattern.quote(STRING_TO_BE_LITERALIZED); + System.out.println("regex = "+regex); + Pattern pattern = Pattern.compile(regex); + + // get a matcher object + Matcher matcher = pattern.matcher(INPUT_CHAR_SEQ); + INPUT_CHAR_SEQ = matcher.replaceAll(REPLACE_STR); + System.out.println(INPUT_CHAR_SEQ); + } + +} diff --git a/BasicJava/RegexDemo_replace/RegexDemo/.classpath b/BasicJava/RegexDemo_replace/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_replace/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_replace/RegexDemo/.project b/BasicJava/RegexDemo_replace/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_replace/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_replace/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_replace/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_replace/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_replace/RegexDemo/bin/RegexDemo1.class b/BasicJava/RegexDemo_replace/RegexDemo/bin/RegexDemo1.class new file mode 100644 index 000000000..f36b5aad7 Binary files /dev/null and b/BasicJava/RegexDemo_replace/RegexDemo/bin/RegexDemo1.class differ diff --git a/BasicJava/RegexDemo_replace/RegexDemo/bin/RegexDemo2.class b/BasicJava/RegexDemo_replace/RegexDemo/bin/RegexDemo2.class new file mode 100644 index 000000000..2e2490600 Binary files /dev/null and b/BasicJava/RegexDemo_replace/RegexDemo/bin/RegexDemo2.class differ diff --git a/BasicJava/RegexDemo_replace/RegexDemo/src/RegexDemo1.java b/BasicJava/RegexDemo_replace/RegexDemo/src/RegexDemo1.java new file mode 100644 index 000000000..bd6aa59f1 --- /dev/null +++ b/BasicJava/RegexDemo_replace/RegexDemo/src/RegexDemo1.java @@ -0,0 +1,29 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class RegexDemo1 +{ + private static String REGEX = "lion"; + private static String INPUT = "The lion says meow. All lions say meow."; + private static String REPLACE = "cat"; + + public static void main(String[] args) + { + Pattern pattern = Pattern.compile(REGEX); + Matcher matcher = pattern.matcher(INPUT); + /* + * Parameters: + * + * replacement - The replacement string + * + * Returns: + * + * The string constructed by replacing each matching + * subsequence by the replacement string, substituting + * captured subsequences as needed + */ + INPUT = matcher.replaceAll(REPLACE); + System.out.println(INPUT); + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_replace/RegexDemo/src/RegexDemo2.java b/BasicJava/RegexDemo_replace/RegexDemo/src/RegexDemo2.java new file mode 100644 index 000000000..2574ca7b1 --- /dev/null +++ b/BasicJava/RegexDemo_replace/RegexDemo/src/RegexDemo2.java @@ -0,0 +1,29 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class RegexDemo2 +{ + private static String REGEX = "lion"; + private static String INPUT = "The lion says meow. All lions say meow."; + private static String REPLACE = "cat"; + + public static void main(String[] args) + { + Pattern pattern = Pattern.compile(REGEX); + Matcher matcher = pattern.matcher(INPUT); + /* + * Parameters: + * + * replacement - The replacement string + * + * Returns: + * + * The string constructed by replacing the first matching + * subsequence by the replacement string, substituting + * captured subsequences as needed + */ + INPUT = matcher.replaceFirst(REPLACE); + System.out.println(INPUT); + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_replace/RegexDemo1_Output.txt b/BasicJava/RegexDemo_replace/RegexDemo1_Output.txt new file mode 100644 index 000000000..9912b859d --- /dev/null +++ b/BasicJava/RegexDemo_replace/RegexDemo1_Output.txt @@ -0,0 +1 @@ +The cat says meow. All cats say meow. diff --git a/BasicJava/RegexDemo_replace/RegexDemo2_Output.txt b/BasicJava/RegexDemo_replace/RegexDemo2_Output.txt new file mode 100644 index 000000000..52fa28339 --- /dev/null +++ b/BasicJava/RegexDemo_replace/RegexDemo2_Output.txt @@ -0,0 +1 @@ +The cat says meow. All lions say meow. diff --git a/BasicJava/RegexDemo_replace_group/Output.txt b/BasicJava/RegexDemo_replace_group/Output.txt new file mode 100644 index 000000000..8f8899d45 --- /dev/null +++ b/BasicJava/RegexDemo_replace_group/Output.txt @@ -0,0 +1,2 @@ +replaceAll = Steve peter about this, and Steve Doe writes about that, and Steve Wayne writes about everything. +replaceFirst = Steve peter about this, and John Doe writes about that, and John Wayne writes about everything. diff --git a/BasicJava/RegexDemo_replace_group/RegexDemo/.classpath b/BasicJava/RegexDemo_replace_group/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_replace_group/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_replace_group/RegexDemo/.project b/BasicJava/RegexDemo_replace_group/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_replace_group/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_replace_group/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_replace_group/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_replace_group/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_replace_group/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_replace_group/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..fda209002 Binary files /dev/null and b/BasicJava/RegexDemo_replace_group/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_replace_group/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_replace_group/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..d375a2e2f --- /dev/null +++ b/BasicJava/RegexDemo_replace_group/RegexDemo/src/RegexDemo.java @@ -0,0 +1,39 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * replaceAll() and replaceFirst(): + * + * The Matcher replaceAll() and replaceFirst() methods can be used to + * replace parts of the string the Matcher is searching through. + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + String text = "John peter about this, and John Doe writes about that," + + " and John Wayne writes about everything."; + + String regex = "(John)"; + + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(text); + + /* + * The replaceAll() method replaces all matches of the regular + * expression. + */ + String replaceAll = matcher.replaceAll("Steve"); + System.out.println("replaceAll = " + replaceAll); + + /* + * The replaceFirst() only replaces the first match. + */ + String replaceFirst = matcher.replaceFirst("Steve"); + System.out.println("replaceFirst = " + replaceFirst); + } + +} diff --git a/BasicJava/RegexDemo_replacement_methods_dog_cat/RegexDemo/.classpath b/BasicJava/RegexDemo_replacement_methods_dog_cat/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_replacement_methods_dog_cat/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_replacement_methods_dog_cat/RegexDemo/.project b/BasicJava/RegexDemo_replacement_methods_dog_cat/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_replacement_methods_dog_cat/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_replacement_methods_dog_cat/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_replacement_methods_dog_cat/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_replacement_methods_dog_cat/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_replacement_methods_dog_cat/RegexDemo/bin/RegexDemo1.class b/BasicJava/RegexDemo_replacement_methods_dog_cat/RegexDemo/bin/RegexDemo1.class new file mode 100644 index 000000000..9144a83bd Binary files /dev/null and b/BasicJava/RegexDemo_replacement_methods_dog_cat/RegexDemo/bin/RegexDemo1.class differ diff --git a/BasicJava/RegexDemo_replacement_methods_dog_cat/RegexDemo/bin/RegexDemo2.class b/BasicJava/RegexDemo_replacement_methods_dog_cat/RegexDemo/bin/RegexDemo2.class new file mode 100644 index 000000000..d2e7a2da8 Binary files /dev/null and b/BasicJava/RegexDemo_replacement_methods_dog_cat/RegexDemo/bin/RegexDemo2.class differ diff --git a/BasicJava/RegexDemo_replacement_methods_dog_cat/RegexDemo/src/RegexDemo1.java b/BasicJava/RegexDemo_replacement_methods_dog_cat/RegexDemo/src/RegexDemo1.java new file mode 100644 index 000000000..194de8e12 --- /dev/null +++ b/BasicJava/RegexDemo_replacement_methods_dog_cat/RegexDemo/src/RegexDemo1.java @@ -0,0 +1,31 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * Replacement Methods + * + */ +public class RegexDemo1 +{ + + public static void main(String[] args) + { + Pattern pattern = Pattern.compile("dog"); + Matcher matcher = pattern + .matcher("dogs are domestic animals, dogs are friendly"); + + /* + * Replacement methods are useful to replace text in an input + * string. The common ones are replaceFirst and replaceAll. + * + * The replaceFirst and replaceAll methods replace the text + * that matches a given regular expression. As their names + * indicate, replaceFirst replaces the first occurrence, and + * replaceAll replaces all occurrences. + */ + String newStr = matcher.replaceFirst("cat"); + System.out.println(newStr); + } + +} diff --git a/BasicJava/RegexDemo_replacement_methods_dog_cat/RegexDemo/src/RegexDemo2.java b/BasicJava/RegexDemo_replacement_methods_dog_cat/RegexDemo/src/RegexDemo2.java new file mode 100644 index 000000000..281188c1d --- /dev/null +++ b/BasicJava/RegexDemo_replacement_methods_dog_cat/RegexDemo/src/RegexDemo2.java @@ -0,0 +1,31 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * Replacement Methods + * + */ +public class RegexDemo2 +{ + + public static void main(String[] args) + { + Pattern pattern = Pattern.compile("dog"); + Matcher matcher = pattern + .matcher("dogs are domestic animals, dogs are friendly"); + + /* + * Replacement methods are useful to replace text in an input + * string. The common ones are replaceFirst and replaceAll. + * + * The replaceFirst and replaceAll methods replace the text + * that matches a given regular expression. As their names + * indicate, replaceFirst replaces the first occurrence, and + * replaceAll replaces all occurrences. + */ + String newStr = matcher.replaceAll("cat"); + System.out.println(newStr); + } + +} diff --git a/BasicJava/RegexDemo_replacement_methods_dog_cat/RegexDemo1_Output.txt b/BasicJava/RegexDemo_replacement_methods_dog_cat/RegexDemo1_Output.txt new file mode 100644 index 000000000..c82da99b6 --- /dev/null +++ b/BasicJava/RegexDemo_replacement_methods_dog_cat/RegexDemo1_Output.txt @@ -0,0 +1 @@ +cats are domestic animals, dogs are friendly diff --git a/BasicJava/RegexDemo_replacement_methods_dog_cat/RegexDemo2_Output.txt b/BasicJava/RegexDemo_replacement_methods_dog_cat/RegexDemo2_Output.txt new file mode 100644 index 000000000..7bbfa18ee --- /dev/null +++ b/BasicJava/RegexDemo_replacement_methods_dog_cat/RegexDemo2_Output.txt @@ -0,0 +1 @@ +cats are domestic animals, cats are friendly diff --git a/BasicJava/RegexDemo_spilt_hyphen/Output.txt b/BasicJava/RegexDemo_spilt_hyphen/Output.txt new file mode 100644 index 000000000..63d07aef0 --- /dev/null +++ b/BasicJava/RegexDemo_spilt_hyphen/Output.txt @@ -0,0 +1,6 @@ +stringArrry length = 5 +strValue = Hello +strValue = peter +strValue = how +strValue = are +strValue = you? diff --git a/BasicJava/RegexDemo_spilt_hyphen/RegexDemo/.classpath b/BasicJava/RegexDemo_spilt_hyphen/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_spilt_hyphen/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_spilt_hyphen/RegexDemo/.project b/BasicJava/RegexDemo_spilt_hyphen/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_spilt_hyphen/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_spilt_hyphen/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_spilt_hyphen/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_spilt_hyphen/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_spilt_hyphen/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_spilt_hyphen/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..92de39b44 Binary files /dev/null and b/BasicJava/RegexDemo_spilt_hyphen/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_spilt_hyphen/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_spilt_hyphen/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..758752cc4 --- /dev/null +++ b/BasicJava/RegexDemo_spilt_hyphen/RegexDemo/src/RegexDemo.java @@ -0,0 +1,29 @@ +import java.util.regex.Pattern; + +public class RegexDemo +{ + + public static void main(String[] args) + { + String inputCharSeq = "Hello-peter-how-are-you?"; + + String regex = "-"; + + Pattern pattern = Pattern.compile(regex); + + /* + * The split() method in the Pattern class can split a text + * into an array of String's, using the regular expression + * (the pattern) as delimiter. + */ + String[] stringArrry = pattern.split(inputCharSeq); + + System.out.println("stringArrry length = " + stringArrry.length); + + for (String strValue : stringArrry) + { + System.out.println("strValue = " + strValue); + } + } + +} diff --git a/BasicJava/RegexDemo_split/Output.txt b/BasicJava/RegexDemo_split/Output.txt new file mode 100644 index 000000000..0281acc2e --- /dev/null +++ b/BasicJava/RegexDemo_split/Output.txt @@ -0,0 +1,5 @@ +Peter +Welcome +to +india +Number of split strings: 4 diff --git a/BasicJava/RegexDemo_split/RegexDemo/.classpath b/BasicJava/RegexDemo_split/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_split/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_split/RegexDemo/.project b/BasicJava/RegexDemo_split/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_split/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_split/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_split/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_split/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_split/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_split/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..df5e2383d Binary files /dev/null and b/BasicJava/RegexDemo_split/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_split/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_split/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..d4b644cf3 --- /dev/null +++ b/BasicJava/RegexDemo_split/RegexDemo/src/RegexDemo.java @@ -0,0 +1,33 @@ +import java.util.regex.Pattern; + +/** + * + * To split a text into multiple strings based on a delimiter (Here delimiter + * would be specified using regex), we can use Pattern.split() method. + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + String inputCharSeq = "Peter_Welcome_to_india"; + + // Pattern for delimiter + String regex = "_"; + + Pattern pattern = Pattern.compile(regex); + /* + * Returns:The array of strings computed by splitting the input around + * matches of this pattern. + */ + String[] stringArray = pattern.split(inputCharSeq); + + for (String str : stringArray) + { + System.out.println(str); + } + System.out.println("Number of split strings: " + stringArray.length); + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_stringmatcher/Output.txt b/BasicJava/RegexDemo_stringmatcher/Output.txt new file mode 100644 index 000000000..cc23687a7 --- /dev/null +++ b/BasicJava/RegexDemo_stringmatcher/Output.txt @@ -0,0 +1,14 @@ +true +false +----------------------------- +true +true +false +----------------------------- +true +true +true +----------------------------- +true +true +false diff --git a/BasicJava/RegexDemo_stringmatcher/RegexDemo/.classpath b/BasicJava/RegexDemo_stringmatcher/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_stringmatcher/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_stringmatcher/RegexDemo/.project b/BasicJava/RegexDemo_stringmatcher/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_stringmatcher/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_stringmatcher/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_stringmatcher/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_stringmatcher/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_stringmatcher/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_stringmatcher/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..0f9547554 Binary files /dev/null and b/BasicJava/RegexDemo_stringmatcher/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_stringmatcher/RegexDemo/bin/StringMatcher.class b/BasicJava/RegexDemo_stringmatcher/RegexDemo/bin/StringMatcher.class new file mode 100644 index 000000000..c864f11ed Binary files /dev/null and b/BasicJava/RegexDemo_stringmatcher/RegexDemo/bin/StringMatcher.class differ diff --git a/BasicJava/RegexDemo_stringmatcher/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_stringmatcher/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..660cdf22f --- /dev/null +++ b/BasicJava/RegexDemo_stringmatcher/RegexDemo/src/RegexDemo.java @@ -0,0 +1,30 @@ +public class RegexDemo +{ + public static void main(String[] args) + { + StringMatcher stringMatcher = new StringMatcher(); + + System.out.println(stringMatcher.isTrue("true")); // true + System.out.println(stringMatcher.isTrue("True")); // false + + System.out.println("-----------------------------"); + + System.out.println(stringMatcher.isTrueVersion2("true")); // true + System.out.println(stringMatcher.isTrueVersion2("True")); // true + System.out.println(stringMatcher.isTrueVersion2("True1")); // false + + System.out.println("-----------------------------"); + + System.out.println(stringMatcher.isTrueOrYes("true")); // true + System.out.println(stringMatcher.isTrueOrYes("Yes")); // true + System.out.println(stringMatcher.isTrueOrYes("yes")); // true + + System.out.println("-----------------------------"); + + System.out.println(stringMatcher.containsTrue("Hellotrue")); // true + System.out.println(stringMatcher.containsTrue("WelcometrueWelcome")); // true + System.out.println(stringMatcher.containsTrue("WelcometrWelcome")); // false + + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_stringmatcher/RegexDemo/src/StringMatcher.java b/BasicJava/RegexDemo_stringmatcher/RegexDemo/src/StringMatcher.java new file mode 100644 index 000000000..2b7dd43dc --- /dev/null +++ b/BasicJava/RegexDemo_stringmatcher/RegexDemo/src/StringMatcher.java @@ -0,0 +1,37 @@ + +public class StringMatcher +{ + /* + * returns true if the string matches exactly "true" + */ + public boolean isTrue(String s) + { + return s.matches("true"); + } + + /* + * returns true if the string matches exactly "true" or "True" + */ + public boolean isTrueVersion2(String s) + { + return s.matches("[tT]rue"); + } + + /* + * returns true if the string matches exactly "true" or "True" or "yes" or + * "Yes" + */ + public boolean isTrueOrYes(String s) + { + return s.matches("[tT]rue|[yY]es"); + } + + /* + * returns true if the string contains "true" + */ + public boolean containsTrue(String s) + { + return s.matches(".*true.*"); + } + +} diff --git a/BasicJava/RegexDemo_study_methods/Output.txt b/BasicJava/RegexDemo_study_methods/Output.txt new file mode 100644 index 000000000..da29283aa --- /dev/null +++ b/BasicJava/RegexDemo_study_methods/Output.txt @@ -0,0 +1,2 @@ +true +false diff --git a/BasicJava/RegexDemo_study_methods/RegexDemo/.classpath b/BasicJava/RegexDemo_study_methods/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_study_methods/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_study_methods/RegexDemo/.project b/BasicJava/RegexDemo_study_methods/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_study_methods/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_study_methods/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_study_methods/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_study_methods/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_study_methods/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_study_methods/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..f949d9701 Binary files /dev/null and b/BasicJava/RegexDemo_study_methods/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_study_methods/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_study_methods/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..7bba1ba7a --- /dev/null +++ b/BasicJava/RegexDemo_study_methods/RegexDemo/src/RegexDemo.java @@ -0,0 +1,31 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * Study Methods + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + Pattern pattern = Pattern.compile("dog"); + Matcher matcher = pattern.matcher("dog is friendly"); + + /* + * Study methods go through the input String and return a + * boolean indicating whether or not the pattern is found. + * Commonly used are matches and lookingAt methods. + * + * The matches and lookingAt methods both attempt to match an + * input sequence against a pattern. The difference, is that + * matches requires the entire input sequence to be matched, + * while lookingAt does not. + */ + System.out.println(matcher.lookingAt()); + System.out.println(matcher.matches()); + } + +} diff --git a/BasicJava/RegexDemo_substraction_class/Output.txt b/BasicJava/RegexDemo_substraction_class/Output.txt new file mode 100644 index 000000000..b093d2b4c --- /dev/null +++ b/BasicJava/RegexDemo_substraction_class/Output.txt @@ -0,0 +1,2 @@ +Number of Matches = 8 +Number of Matches = 1 diff --git a/BasicJava/RegexDemo_substraction_class/RegexDemo/.classpath b/BasicJava/RegexDemo_substraction_class/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_substraction_class/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_substraction_class/RegexDemo/.project b/BasicJava/RegexDemo_substraction_class/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_substraction_class/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_substraction_class/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_substraction_class/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_substraction_class/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_substraction_class/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_substraction_class/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..e26b866ff Binary files /dev/null and b/BasicJava/RegexDemo_substraction_class/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_substraction_class/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_substraction_class/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..35d2e3782 --- /dev/null +++ b/BasicJava/RegexDemo_substraction_class/RegexDemo/src/RegexDemo.java @@ -0,0 +1,40 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * Subtraction Class + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + /* + * We will get 8 matches because the Subtraction of the two + * sets has only 8 elements. + */ + calculateMatches("[0-9&&[^12]]", "0123456789"); + calculateMatches("[0-9&&[^12]]", "123"); + } + + private static void calculateMatches(String regex, String inputText) + { + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(inputText); + int matches = 0; + + /* + * The find method keeps advancing through the input text and + * returns true for every match, so we can use it to find the + * match count as well: + */ + while (matcher.find()) + { + ++matches; + } + System.out.println("Number of Matches = " + matches); + } + +} diff --git a/BasicJava/RegexDemo_tim_tom/Output.txt b/BasicJava/RegexDemo_tim_tom/Output.txt new file mode 100644 index 000000000..5436d2804 --- /dev/null +++ b/BasicJava/RegexDemo_tim_tom/Output.txt @@ -0,0 +1,10 @@ +true +false +----------------------------- +true +true +false +----------------------------- +true +true +false diff --git a/BasicJava/RegexDemo_tim_tom/RegexDemo/.classpath b/BasicJava/RegexDemo_tim_tom/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_tim_tom/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_tim_tom/RegexDemo/.project b/BasicJava/RegexDemo_tim_tom/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_tim_tom/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_tim_tom/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_tim_tom/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_tim_tom/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_tim_tom/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_tim_tom/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..ac2c40037 Binary files /dev/null and b/BasicJava/RegexDemo_tim_tom/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_tim_tom/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_tim_tom/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..d56dcccfe --- /dev/null +++ b/BasicJava/RegexDemo_tim_tom/RegexDemo/src/RegexDemo.java @@ -0,0 +1,35 @@ +import java.util.regex.Pattern; + +public class RegexDemo +{ + + public static void main(String[] args) + { + /* + * It would return true if string matches exactly "Tom" + */ + System.out.println(Pattern.matches("Tom", "Tom")); // true + System.out.println(Pattern.matches("Tom", "tom")); // false + + System.out.println("-----------------------------"); + + /* + * returns true if the string matches exactly "tom" or "Tom" + */ + System.out.println(Pattern.matches("[Tt]om", "Tom")); // true + System.out.println(Pattern.matches("[Tt]om", "tom")); // true + System.out.println(Pattern.matches("[Tt]om", "Tome")); // false + + System.out.println("-----------------------------"); + + /* + * Returns true if the string matches exactly "tim" or "Tim" or "jin" or + * "Jin" + */ + System.out.println(Pattern.matches("[tT]im|[jJ]in", "Tim"));// true + System.out.println(Pattern.matches("[tT]im|[jJ]in", "jin"));// true + System.out.println(Pattern.matches("[tT]im|[jJ]in", "john"));// false + + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_time12hrs/Output.txt b/BasicJava/RegexDemo_time12hrs/Output.txt new file mode 100644 index 000000000..6662b3681 --- /dev/null +++ b/BasicJava/RegexDemo_time12hrs/Output.txt @@ -0,0 +1,8 @@ +2:00 am is Valid? = true +2:00 AM is Valid? = true +12:50 pm is Valid? = true +-------------------------------------- +0:00 am is Valid? = false +23:00 AM is Valid? = false +12:90 pm is Valid? = false +11:20 GM is Valid? = false diff --git a/BasicJava/RegexDemo_time12hrs/RegexDemo/.classpath b/BasicJava/RegexDemo_time12hrs/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_time12hrs/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_time12hrs/RegexDemo/.project b/BasicJava/RegexDemo_time12hrs/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_time12hrs/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_time12hrs/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_time12hrs/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_time12hrs/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_time12hrs/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_time12hrs/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..3b3599c0f Binary files /dev/null and b/BasicJava/RegexDemo_time12hrs/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_time12hrs/RegexDemo/bin/Time12HoursValidator.class b/BasicJava/RegexDemo_time12hrs/RegexDemo/bin/Time12HoursValidator.class new file mode 100644 index 000000000..3062ff0d9 Binary files /dev/null and b/BasicJava/RegexDemo_time12hrs/RegexDemo/bin/Time12HoursValidator.class differ diff --git a/BasicJava/RegexDemo_time12hrs/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_time12hrs/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..e81be6cc0 --- /dev/null +++ b/BasicJava/RegexDemo_time12hrs/RegexDemo/src/RegexDemo.java @@ -0,0 +1,40 @@ +import java.util.Arrays; +import java.util.List; + +/** + * + * How to validate Time in 12 Hours format with regular expression + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + List validTimeList = Arrays.asList("2:00 am", "2:00 AM", "12:50 pm"); + + Time12HoursValidator time12HoursValidator = new Time12HoursValidator(); + + + for (String time : validTimeList) + { + System.out.println( + time + " is Valid? = " + time12HoursValidator.validate(time)); + } + + + + System.out.println("--------------------------------------"); + + List inValidTimeList = Arrays.asList("0:00 am", "23:00 AM", "12:90 pm","11:20 GM"); + + for (String time : inValidTimeList) + { + System.out.println( + time + " is Valid? = " + time12HoursValidator.validate(time)); + } + + + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_time12hrs/RegexDemo/src/Time12HoursValidator.java b/BasicJava/RegexDemo_time12hrs/RegexDemo/src/Time12HoursValidator.java new file mode 100644 index 000000000..9f58ccb97 --- /dev/null +++ b/BasicJava/RegexDemo_time12hrs/RegexDemo/src/Time12HoursValidator.java @@ -0,0 +1,27 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * How to validate Time in 12 Hours format with regular expression + * + */ +public class Time12HoursValidator +{ + + private Pattern pattern; + private Matcher matcher; + + private static final String TIME12HOURS_REGEX = "(1[012]|[1-9]):[0-5][0-9](\\s)?(?i)(am|pm)"; + + public Time12HoursValidator() + { + pattern = Pattern.compile(TIME12HOURS_REGEX); + } + + public boolean validate(final String time) + { + matcher = pattern.matcher(time); + return matcher.matches(); + } +} diff --git a/BasicJava/RegexDemo_union_class/Output.txt b/BasicJava/RegexDemo_union_class/Output.txt new file mode 100644 index 000000000..87e108ad6 --- /dev/null +++ b/BasicJava/RegexDemo_union_class/Output.txt @@ -0,0 +1 @@ +Number of Matches = 6 diff --git a/BasicJava/RegexDemo_union_class/RegexDemo/.classpath b/BasicJava/RegexDemo_union_class/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_union_class/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_union_class/RegexDemo/.project b/BasicJava/RegexDemo_union_class/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_union_class/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_union_class/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_union_class/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_union_class/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_union_class/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_union_class/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..5411cba23 Binary files /dev/null and b/BasicJava/RegexDemo_union_class/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_union_class/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_union_class/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..0878f1597 --- /dev/null +++ b/BasicJava/RegexDemo_union_class/RegexDemo/src/RegexDemo.java @@ -0,0 +1,39 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * Union Class + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + /* + * This will only match 6 out of the 9 integers because the + * union set skips 4,5 and 6. + */ + calculateMatches("[1-3[7-9]]", "123456789"); + } + + private static void calculateMatches(String regex, String inputText) + { + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(inputText); + int matches = 0; + + /* + * The find method keeps advancing through the input text and + * returns true for every match, so we can use it to find the + * match count as well: + */ + while (matcher.find()) + { + ++matches; + } + System.out.println("Number of Matches = " + matches); + } + +} diff --git a/BasicJava/RegexDemo_username/Output.txt b/BasicJava/RegexDemo_username/Output.txt new file mode 100644 index 000000000..fb2c6d204 --- /dev/null +++ b/BasicJava/RegexDemo_username/Output.txt @@ -0,0 +1,7 @@ +'peter34' is valid userName? = true +'peter_34' is valid userName? = true +'peter-34' is valid userName? = true + +'pk' is valid userName? = false +'peter@89' is valid userName? = false +'peter11111323445' is valid userName? = false diff --git a/BasicJava/RegexDemo_username/RegexDemo/.classpath b/BasicJava/RegexDemo_username/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_username/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_username/RegexDemo/.project b/BasicJava/RegexDemo_username/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_username/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_username/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_username/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_username/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_username/RegexDemo/bin/RegexDemo.class b/BasicJava/RegexDemo_username/RegexDemo/bin/RegexDemo.class new file mode 100644 index 000000000..f1e2a0494 Binary files /dev/null and b/BasicJava/RegexDemo_username/RegexDemo/bin/RegexDemo.class differ diff --git a/BasicJava/RegexDemo_username/RegexDemo/bin/UserNameValidator.class b/BasicJava/RegexDemo_username/RegexDemo/bin/UserNameValidator.class new file mode 100644 index 000000000..3baacbd41 Binary files /dev/null and b/BasicJava/RegexDemo_username/RegexDemo/bin/UserNameValidator.class differ diff --git a/BasicJava/RegexDemo_username/RegexDemo/src/RegexDemo.java b/BasicJava/RegexDemo_username/RegexDemo/src/RegexDemo.java new file mode 100644 index 000000000..8060bf245 --- /dev/null +++ b/BasicJava/RegexDemo_username/RegexDemo/src/RegexDemo.java @@ -0,0 +1,34 @@ +/** + * + * How to validate username with regular expression + * + */ +public class RegexDemo +{ + + public static void main(String[] args) + { + UserNameValidator unValidator = new UserNameValidator(); + + System.out.println("'peter34' is valid userName? = "+unValidator.validate("peter34")); + System.out.println("'peter_34' is valid userName? = "+unValidator.validate("peter_34")); + System.out.println("'peter-34' is valid userName? = "+unValidator.validate("peter-34")); + + System.out.println(); + + /* + * too short, min 3 characters + */ + System.out.println("'pk' is valid userName? = "+unValidator.validate("pk")); + /* + * “@” character is not allow + */ + System.out.println("'peter@89' is valid userName? = "+unValidator.validate("peter@89")); + + /* + * too long, max characters of 15 + */ + System.out.println("'peter11111323445' is valid userName? = "+unValidator.validate("peter11111323445")); + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_username/RegexDemo/src/UserNameValidator.java b/BasicJava/RegexDemo_username/RegexDemo/src/UserNameValidator.java new file mode 100644 index 000000000..d445ddc6a --- /dev/null +++ b/BasicJava/RegexDemo_username/RegexDemo/src/UserNameValidator.java @@ -0,0 +1,35 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; +/** + * + * How to validate username with regular expression + * + */ +public class UserNameValidator +{ + private Pattern pattern; + private Matcher matcher; + + private static final String USERNAME_REGEX = "^[a-z0-9_-]{3,15}$"; + + public UserNameValidator() + { + pattern = Pattern.compile(USERNAME_REGEX); + } + + /* + * Validate username with regular expression + * + * @param username username for validation + * + * @return true valid username, false invalid username + */ + public boolean validate(final String username) + { + + matcher = pattern.matcher(username); + return matcher.matches(); + + } + +} diff --git a/BasicJava/RegexDemo_what_is_regex_caseinsensitive/RegexDemo/.classpath b/BasicJava/RegexDemo_what_is_regex_caseinsensitive/RegexDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RegexDemo_what_is_regex_caseinsensitive/RegexDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RegexDemo_what_is_regex_caseinsensitive/RegexDemo/.project b/BasicJava/RegexDemo_what_is_regex_caseinsensitive/RegexDemo/.project new file mode 100644 index 000000000..a56f77973 --- /dev/null +++ b/BasicJava/RegexDemo_what_is_regex_caseinsensitive/RegexDemo/.project @@ -0,0 +1,17 @@ + + + RegexDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RegexDemo_what_is_regex_caseinsensitive/RegexDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RegexDemo_what_is_regex_caseinsensitive/RegexDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RegexDemo_what_is_regex_caseinsensitive/RegexDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RegexDemo_what_is_regex_caseinsensitive/RegexDemo/bin/RegexDemo1.class b/BasicJava/RegexDemo_what_is_regex_caseinsensitive/RegexDemo/bin/RegexDemo1.class new file mode 100644 index 000000000..85b785f2d Binary files /dev/null and b/BasicJava/RegexDemo_what_is_regex_caseinsensitive/RegexDemo/bin/RegexDemo1.class differ diff --git a/BasicJava/RegexDemo_what_is_regex_caseinsensitive/RegexDemo/bin/RegexDemo2.class b/BasicJava/RegexDemo_what_is_regex_caseinsensitive/RegexDemo/bin/RegexDemo2.class new file mode 100644 index 000000000..d0e7f67e6 Binary files /dev/null and b/BasicJava/RegexDemo_what_is_regex_caseinsensitive/RegexDemo/bin/RegexDemo2.class differ diff --git a/BasicJava/RegexDemo_what_is_regex_caseinsensitive/RegexDemo/src/RegexDemo1.java b/BasicJava/RegexDemo_what_is_regex_caseinsensitive/RegexDemo/src/RegexDemo1.java new file mode 100644 index 000000000..e55aee4c4 --- /dev/null +++ b/BasicJava/RegexDemo_what_is_regex_caseinsensitive/RegexDemo/src/RegexDemo1.java @@ -0,0 +1,29 @@ +import java.util.regex.Pattern; + +public class RegexDemo1 +{ + + public static void main(String[] args) + { + String inputCharSeq = "Peter Welcome to India."; + + String regex = ".*Welcome.*"; + + /* + * Parameters: + * + * regex - The expression to be compiled + * + * input - The character sequence to be matched + * + * Returns: + * + * whether or not the regular expression matches on + * the input + * + */ + boolean isMatch = Pattern.matches(regex, inputCharSeq); + System.out.println("The text contains 'Welcome'? = " + isMatch); + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_what_is_regex_caseinsensitive/RegexDemo/src/RegexDemo2.java b/BasicJava/RegexDemo_what_is_regex_caseinsensitive/RegexDemo/src/RegexDemo2.java new file mode 100644 index 000000000..5fb782baa --- /dev/null +++ b/BasicJava/RegexDemo_what_is_regex_caseinsensitive/RegexDemo/src/RegexDemo2.java @@ -0,0 +1,48 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class RegexDemo2 +{ + + public static void main(String[] args) + { + String inputCharSeq = "Peter Welcome to India."; + + String regex = ".*WElCoMe.*"; + + /* + * Parameters: + * + * regex - The expression to be compiled + * * + * flags - Match flags, a bit mask that may include + * CASE_INSENSITIVE, MULTILINE, DOTALL, UNICODE_CASE, + * CANON_EQ, UNIX_LINES, LITERAL, UNICODE_CHARACTER_CLASS and + * COMMENTS + * + * Returns: + * + * the given regular expression compiled into a pattern with + * the given flags + * + */ + Pattern patternObj = Pattern.compile(regex, Pattern.CASE_INSENSITIVE); + /* + * Parameters: + * + * input - The character sequence to be matched + * + * Returns: + * + * A new matcher for this pattern + */ + Matcher matcher = patternObj.matcher(inputCharSeq); + /* + * Returns:true if, and only if, the entire region sequence matches this + * matcher's pattern + */ + boolean isMatched = matcher.matches(); + System.out.println("Is it a Match? = " + isMatched); + } + +} \ No newline at end of file diff --git a/BasicJava/RegexDemo_what_is_regex_caseinsensitive/RegexDemo1_Output.txt b/BasicJava/RegexDemo_what_is_regex_caseinsensitive/RegexDemo1_Output.txt new file mode 100644 index 000000000..703c2ff6e --- /dev/null +++ b/BasicJava/RegexDemo_what_is_regex_caseinsensitive/RegexDemo1_Output.txt @@ -0,0 +1 @@ +The text contains 'Welcome'? = true diff --git a/BasicJava/RegexDemo_what_is_regex_caseinsensitive/RegexDemo2_Output.txt b/BasicJava/RegexDemo_what_is_regex_caseinsensitive/RegexDemo2_Output.txt new file mode 100644 index 000000000..40174d2dd --- /dev/null +++ b/BasicJava/RegexDemo_what_is_regex_caseinsensitive/RegexDemo2_Output.txt @@ -0,0 +1 @@ +Is it a Match? = true diff --git a/BasicJava/RuntimeDemo_GC_App/Output.txt b/BasicJava/RuntimeDemo_GC_App/Output.txt new file mode 100644 index 000000000..4c3795982 --- /dev/null +++ b/BasicJava/RuntimeDemo_GC_App/Output.txt @@ -0,0 +1 @@ +Runs the Gargage collector.. diff --git a/BasicJava/RuntimeDemo_GC_App/RuntimeDemo/.classpath b/BasicJava/RuntimeDemo_GC_App/RuntimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RuntimeDemo_GC_App/RuntimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RuntimeDemo_GC_App/RuntimeDemo/.project b/BasicJava/RuntimeDemo_GC_App/RuntimeDemo/.project new file mode 100644 index 000000000..549048ad7 --- /dev/null +++ b/BasicJava/RuntimeDemo_GC_App/RuntimeDemo/.project @@ -0,0 +1,17 @@ + + + RuntimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RuntimeDemo_GC_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RuntimeDemo_GC_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RuntimeDemo_GC_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RuntimeDemo_GC_App/RuntimeDemo/bin/RuntimeDemo.class b/BasicJava/RuntimeDemo_GC_App/RuntimeDemo/bin/RuntimeDemo.class new file mode 100644 index 000000000..1cec2b6c2 Binary files /dev/null and b/BasicJava/RuntimeDemo_GC_App/RuntimeDemo/bin/RuntimeDemo.class differ diff --git a/BasicJava/RuntimeDemo_GC_App/RuntimeDemo/src/RuntimeDemo.java b/BasicJava/RuntimeDemo_GC_App/RuntimeDemo/src/RuntimeDemo.java new file mode 100644 index 000000000..030a16ee8 --- /dev/null +++ b/BasicJava/RuntimeDemo_GC_App/RuntimeDemo/src/RuntimeDemo.java @@ -0,0 +1,38 @@ +import java.io.IOException; + +public class RuntimeDemo +{ + + public static void main(String[] args) throws IOException + { + /* + * Returns the runtime object associated with the + * current Java application. + */ + Runtime runtime = Runtime.getRuntime(); + + System.out.println("Runs the Gargage collector.."); + /* + * Runs the garbage collector. + * + * Calling this method suggests that the Java + * virtual machine expend effort toward recycling + * unused objects in order to make the memory they + * currently occupy available for quick reuse. When + * control returns from the method call, the virtual + * machine has made its best effort to recycle all + * discarded objects. + * + * The name gc stands for "garbage collector". The + * virtual machine performs this recycling process + * automatically as needed, in a separate thread, + * even if the gc method is not invoked explicitly. + * + * The method System.gc() is the conventional and + * convenient means of invoking this method. + */ + runtime.gc(); + + } + +} diff --git a/BasicJava/RuntimeDemo_Intro_App/Output.txt b/BasicJava/RuntimeDemo_Intro_App/Output.txt new file mode 100644 index 000000000..9dc778694 --- /dev/null +++ b/BasicJava/RuntimeDemo_Intro_App/Output.txt @@ -0,0 +1 @@ +is process alive = true diff --git a/BasicJava/RuntimeDemo_Intro_App/RuntimeDemo/.classpath b/BasicJava/RuntimeDemo_Intro_App/RuntimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RuntimeDemo_Intro_App/RuntimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RuntimeDemo_Intro_App/RuntimeDemo/.project b/BasicJava/RuntimeDemo_Intro_App/RuntimeDemo/.project new file mode 100644 index 000000000..549048ad7 --- /dev/null +++ b/BasicJava/RuntimeDemo_Intro_App/RuntimeDemo/.project @@ -0,0 +1,17 @@ + + + RuntimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RuntimeDemo_Intro_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RuntimeDemo_Intro_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RuntimeDemo_Intro_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RuntimeDemo_Intro_App/RuntimeDemo/bin/RuntimeDemo.class b/BasicJava/RuntimeDemo_Intro_App/RuntimeDemo/bin/RuntimeDemo.class new file mode 100644 index 000000000..aa54630e0 Binary files /dev/null and b/BasicJava/RuntimeDemo_Intro_App/RuntimeDemo/bin/RuntimeDemo.class differ diff --git a/BasicJava/RuntimeDemo_Intro_App/RuntimeDemo/src/RuntimeDemo.java b/BasicJava/RuntimeDemo_Intro_App/RuntimeDemo/src/RuntimeDemo.java new file mode 100644 index 000000000..cc0c424a1 --- /dev/null +++ b/BasicJava/RuntimeDemo_Intro_App/RuntimeDemo/src/RuntimeDemo.java @@ -0,0 +1,32 @@ +import java.io.IOException; + +/* + * public Process exec(String command) throws + * IOException + * + * Parameters: + * ----------- + * + * command - a specified system command. + */ +public class RuntimeDemo +{ + public static void main(String[] args) throws IOException + { + /* + * Returns the runtime object associated with the + * current Java application. + */ + Runtime runtime = Runtime.getRuntime(); + + /* + * Executes the specified string command in a + * separate process. + * + * It will open a new notepad. + */ + Process process = runtime.exec("notepad.exe"); + System.out.println("is process alive = " + process.isAlive()); + } + +} diff --git a/BasicJava/RuntimeDemo_availableProcessors_App/Output.txt b/BasicJava/RuntimeDemo_availableProcessors_App/Output.txt new file mode 100644 index 000000000..f20340f59 --- /dev/null +++ b/BasicJava/RuntimeDemo_availableProcessors_App/Output.txt @@ -0,0 +1 @@ +availableProcessors = 4 diff --git a/BasicJava/RuntimeDemo_availableProcessors_App/RuntimeDemo/.classpath b/BasicJava/RuntimeDemo_availableProcessors_App/RuntimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RuntimeDemo_availableProcessors_App/RuntimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RuntimeDemo_availableProcessors_App/RuntimeDemo/.project b/BasicJava/RuntimeDemo_availableProcessors_App/RuntimeDemo/.project new file mode 100644 index 000000000..549048ad7 --- /dev/null +++ b/BasicJava/RuntimeDemo_availableProcessors_App/RuntimeDemo/.project @@ -0,0 +1,17 @@ + + + RuntimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RuntimeDemo_availableProcessors_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RuntimeDemo_availableProcessors_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RuntimeDemo_availableProcessors_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RuntimeDemo_availableProcessors_App/RuntimeDemo/bin/RuntimeDemo.class b/BasicJava/RuntimeDemo_availableProcessors_App/RuntimeDemo/bin/RuntimeDemo.class new file mode 100644 index 000000000..55cb40849 Binary files /dev/null and b/BasicJava/RuntimeDemo_availableProcessors_App/RuntimeDemo/bin/RuntimeDemo.class differ diff --git a/BasicJava/RuntimeDemo_availableProcessors_App/RuntimeDemo/src/RuntimeDemo.java b/BasicJava/RuntimeDemo_availableProcessors_App/RuntimeDemo/src/RuntimeDemo.java new file mode 100644 index 000000000..b0f9fd60a --- /dev/null +++ b/BasicJava/RuntimeDemo_availableProcessors_App/RuntimeDemo/src/RuntimeDemo.java @@ -0,0 +1,20 @@ +public class RuntimeDemo +{ + public static void main(String[] args) + { + /* + * Returns the runtime object associated with the + * current Java application. + */ + Runtime runtime = Runtime.getRuntime(); + + /* + * Returns: the maximum number of processors + * available to the virtual machine; never smaller + * than one + */ + int availableProcessors = runtime.availableProcessors(); + System.out.println("availableProcessors = "+availableProcessors); + } + +} diff --git a/BasicJava/RuntimeDemo_exec_cmd_envp_App/Output.txt b/BasicJava/RuntimeDemo_exec_cmd_envp_App/Output.txt new file mode 100644 index 000000000..9dc778694 --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_cmd_envp_App/Output.txt @@ -0,0 +1 @@ +is process alive = true diff --git a/BasicJava/RuntimeDemo_exec_cmd_envp_App/RuntimeDemo/.classpath b/BasicJava/RuntimeDemo_exec_cmd_envp_App/RuntimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_cmd_envp_App/RuntimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RuntimeDemo_exec_cmd_envp_App/RuntimeDemo/.project b/BasicJava/RuntimeDemo_exec_cmd_envp_App/RuntimeDemo/.project new file mode 100644 index 000000000..549048ad7 --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_cmd_envp_App/RuntimeDemo/.project @@ -0,0 +1,17 @@ + + + RuntimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RuntimeDemo_exec_cmd_envp_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RuntimeDemo_exec_cmd_envp_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_cmd_envp_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RuntimeDemo_exec_cmd_envp_App/RuntimeDemo/bin/RuntimeDemo.class b/BasicJava/RuntimeDemo_exec_cmd_envp_App/RuntimeDemo/bin/RuntimeDemo.class new file mode 100644 index 000000000..724c183d7 Binary files /dev/null and b/BasicJava/RuntimeDemo_exec_cmd_envp_App/RuntimeDemo/bin/RuntimeDemo.class differ diff --git a/BasicJava/RuntimeDemo_exec_cmd_envp_App/RuntimeDemo/src/RuntimeDemo.java b/BasicJava/RuntimeDemo_exec_cmd_envp_App/RuntimeDemo/src/RuntimeDemo.java new file mode 100644 index 000000000..73ad50b0c --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_cmd_envp_App/RuntimeDemo/src/RuntimeDemo.java @@ -0,0 +1,38 @@ +import java.io.IOException; + +/* + * public Process exec(String command, String[] envp) + * throws IOException + * + * Parameters: + * ----------- + * + * command - a specified system command. + * + * envp - array of strings, each element of which has + * environment variable settings in the format + * name=value, or null if the subprocess should inherit + * the environment of the current process. + */ +public class RuntimeDemo +{ + + public static void main(String[] args) throws IOException + { + /* + * Returns the runtime object associated with the + * current Java application. + */ + Runtime runtime = Runtime.getRuntime(); + + /* + * Executes the specified string command in a + * separate process with the specified environment. + * + * It will open a new notepad. + */ + Process process = runtime.exec("notepad.exe",null); + System.out.println("is process alive = " + process.isAlive()); + } + +} diff --git a/BasicJava/RuntimeDemo_exec_cmd_envp_dir_App/Output.txt b/BasicJava/RuntimeDemo_exec_cmd_envp_dir_App/Output.txt new file mode 100644 index 000000000..9dc778694 --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_cmd_envp_dir_App/Output.txt @@ -0,0 +1 @@ +is process alive = true diff --git a/BasicJava/RuntimeDemo_exec_cmd_envp_dir_App/RuntimeDemo/.classpath b/BasicJava/RuntimeDemo_exec_cmd_envp_dir_App/RuntimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_cmd_envp_dir_App/RuntimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RuntimeDemo_exec_cmd_envp_dir_App/RuntimeDemo/.project b/BasicJava/RuntimeDemo_exec_cmd_envp_dir_App/RuntimeDemo/.project new file mode 100644 index 000000000..549048ad7 --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_cmd_envp_dir_App/RuntimeDemo/.project @@ -0,0 +1,17 @@ + + + RuntimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RuntimeDemo_exec_cmd_envp_dir_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RuntimeDemo_exec_cmd_envp_dir_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_cmd_envp_dir_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RuntimeDemo_exec_cmd_envp_dir_App/RuntimeDemo/bin/RuntimeDemo.class b/BasicJava/RuntimeDemo_exec_cmd_envp_dir_App/RuntimeDemo/bin/RuntimeDemo.class new file mode 100644 index 000000000..fb16ddbcc Binary files /dev/null and b/BasicJava/RuntimeDemo_exec_cmd_envp_dir_App/RuntimeDemo/bin/RuntimeDemo.class differ diff --git a/BasicJava/RuntimeDemo_exec_cmd_envp_dir_App/RuntimeDemo/src/RuntimeDemo.java b/BasicJava/RuntimeDemo_exec_cmd_envp_dir_App/RuntimeDemo/src/RuntimeDemo.java new file mode 100644 index 000000000..300b3e172 --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_cmd_envp_dir_App/RuntimeDemo/src/RuntimeDemo.java @@ -0,0 +1,50 @@ +import java.io.File; +import java.io.IOException; + +/* + * public Process exec(String command, String[] envp, + * File dir) throws IOException + * + * Parameters: + * ----------- + * + * command - a specified system command. + * + * envp - array of strings, each element of which has + * environment variable settings in the format + * name=value, or null if the subprocess should inherit + * the environment of the current process. + * + * dir - the working directory of the subprocess, or + * null if the subprocess should inherit the working + * directory of the current process. + */ + +public class RuntimeDemo +{ + + public static void main(String[] args) throws IOException + { + /* + * Returns the runtime object associated with the + * current Java application. + */ + Runtime runtime = Runtime.getRuntime(); + + /* + * Create a file with the working directory we wish + */ + File dir = new File("D:/Work/"); + + /* + * Executes the specified string command in a + * separate process with the specified environment + * and working directory. + * + * It will open a new notepad. + */ + Process process = runtime.exec("notepad.exe", null, dir); + System.out.println("is process alive = " + process.isAlive()); + } + +} diff --git a/BasicJava/RuntimeDemo_exec_cmdarray_App/Output.txt b/BasicJava/RuntimeDemo_exec_cmdarray_App/Output.txt new file mode 100644 index 000000000..fce3753b5 --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_cmdarray_App/Output.txt @@ -0,0 +1,3 @@ +Executing notepad.exe and opening Hello.txt +is process alive = true +Hello.txt should now open. diff --git a/BasicJava/RuntimeDemo_exec_cmdarray_App/RuntimeDemo/.classpath b/BasicJava/RuntimeDemo_exec_cmdarray_App/RuntimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_cmdarray_App/RuntimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RuntimeDemo_exec_cmdarray_App/RuntimeDemo/.project b/BasicJava/RuntimeDemo_exec_cmdarray_App/RuntimeDemo/.project new file mode 100644 index 000000000..549048ad7 --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_cmdarray_App/RuntimeDemo/.project @@ -0,0 +1,17 @@ + + + RuntimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RuntimeDemo_exec_cmdarray_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RuntimeDemo_exec_cmdarray_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_cmdarray_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RuntimeDemo_exec_cmdarray_App/RuntimeDemo/Hello.txt b/BasicJava/RuntimeDemo_exec_cmdarray_App/RuntimeDemo/Hello.txt new file mode 100644 index 000000000..dffdd884c --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_cmdarray_App/RuntimeDemo/Hello.txt @@ -0,0 +1 @@ +Hello Peter, how are you? \ No newline at end of file diff --git a/BasicJava/RuntimeDemo_exec_cmdarray_App/RuntimeDemo/bin/RuntimeDemo.class b/BasicJava/RuntimeDemo_exec_cmdarray_App/RuntimeDemo/bin/RuntimeDemo.class new file mode 100644 index 000000000..2f7cacaa9 Binary files /dev/null and b/BasicJava/RuntimeDemo_exec_cmdarray_App/RuntimeDemo/bin/RuntimeDemo.class differ diff --git a/BasicJava/RuntimeDemo_exec_cmdarray_App/RuntimeDemo/src/RuntimeDemo.java b/BasicJava/RuntimeDemo_exec_cmdarray_App/RuntimeDemo/src/RuntimeDemo.java new file mode 100644 index 000000000..02d7c6c26 --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_cmdarray_App/RuntimeDemo/src/RuntimeDemo.java @@ -0,0 +1,45 @@ +import java.io.IOException; + +/* + * public Process exec(String[] cmdarray) throws + * IOException + * + * Parameters: + * ----------- + * + * cmdarray - array containing the command to call and + * its arguments. + */ +public class RuntimeDemo +{ + + public static void main(String[] args) throws IOException + { + + String[] cmdArray = new String[2]; + + cmdArray[0] = "notepad.exe"; + cmdArray[1] = "Hello.txt"; + + System.out.println("Executing notepad.exe and opening Hello.txt"); + + /* + * Returns the runtime object associated with the + * current Java application. + */ + Runtime runtime = Runtime.getRuntime(); + + /* + * Executes the specified command and arguments in a + * separate process. + * + * Returns: A new Process object for managing the + * subprocess + */ + Process process = runtime.exec(cmdArray); + + System.out.println("is process alive = " + process.isAlive()); + System.out.println(cmdArray[1] + " should now open."); + } + +} diff --git a/BasicJava/RuntimeDemo_exec_cmdarray_envp_App/Output.txt b/BasicJava/RuntimeDemo_exec_cmdarray_envp_App/Output.txt new file mode 100644 index 000000000..fce3753b5 --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_cmdarray_envp_App/Output.txt @@ -0,0 +1,3 @@ +Executing notepad.exe and opening Hello.txt +is process alive = true +Hello.txt should now open. diff --git a/BasicJava/RuntimeDemo_exec_cmdarray_envp_App/RuntimeDemo/.classpath b/BasicJava/RuntimeDemo_exec_cmdarray_envp_App/RuntimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_cmdarray_envp_App/RuntimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RuntimeDemo_exec_cmdarray_envp_App/RuntimeDemo/.project b/BasicJava/RuntimeDemo_exec_cmdarray_envp_App/RuntimeDemo/.project new file mode 100644 index 000000000..549048ad7 --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_cmdarray_envp_App/RuntimeDemo/.project @@ -0,0 +1,17 @@ + + + RuntimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RuntimeDemo_exec_cmdarray_envp_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RuntimeDemo_exec_cmdarray_envp_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_cmdarray_envp_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RuntimeDemo_exec_cmdarray_envp_App/RuntimeDemo/Hello.txt b/BasicJava/RuntimeDemo_exec_cmdarray_envp_App/RuntimeDemo/Hello.txt new file mode 100644 index 000000000..dffdd884c --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_cmdarray_envp_App/RuntimeDemo/Hello.txt @@ -0,0 +1 @@ +Hello Peter, how are you? \ No newline at end of file diff --git a/BasicJava/RuntimeDemo_exec_cmdarray_envp_App/RuntimeDemo/bin/RuntimeDemo.class b/BasicJava/RuntimeDemo_exec_cmdarray_envp_App/RuntimeDemo/bin/RuntimeDemo.class new file mode 100644 index 000000000..f19057463 Binary files /dev/null and b/BasicJava/RuntimeDemo_exec_cmdarray_envp_App/RuntimeDemo/bin/RuntimeDemo.class differ diff --git a/BasicJava/RuntimeDemo_exec_cmdarray_envp_App/RuntimeDemo/src/RuntimeDemo.java b/BasicJava/RuntimeDemo_exec_cmdarray_envp_App/RuntimeDemo/src/RuntimeDemo.java new file mode 100644 index 000000000..504be757c --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_cmdarray_envp_App/RuntimeDemo/src/RuntimeDemo.java @@ -0,0 +1,51 @@ +import java.io.IOException; + +/* + * public Process exec(String[] cmdarray, String[] envp) + * throws IOException + * + * Parameters: + * ----------- + * + * cmdarray - array containing the command to call and + * its arguments. + * + * envp - array of strings, each element + * of which has environment variable settings in the + * format name=value, or null if the subprocess should + * inherit the environment of the current process. + */ + +public class RuntimeDemo +{ + + public static void main(String[] args) throws IOException + { + + String[] cmdArray = new String[2]; + + cmdArray[0] = "notepad.exe"; + cmdArray[1] = "Hello.txt"; + + System.out.println("Executing notepad.exe and opening Hello.txt"); + + /* + * Returns the runtime object associated with the + * current Java application. + */ + Runtime runtime = Runtime.getRuntime(); + + /* + * Executes the specified command and arguments in a + * separate process with the specified environment. + * + * Returns: A new Process object for managing the + * subprocess + */ + Process process = runtime.exec(cmdArray, null); + + System.out.println("is process alive = " + process.isAlive()); + System.out.println(cmdArray[1] + " should now open."); + } + +} diff --git a/BasicJava/RuntimeDemo_exec_cmdarray_envp_dir_App/Output.txt b/BasicJava/RuntimeDemo_exec_cmdarray_envp_dir_App/Output.txt new file mode 100644 index 000000000..fce3753b5 --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_cmdarray_envp_dir_App/Output.txt @@ -0,0 +1,3 @@ +Executing notepad.exe and opening Hello.txt +is process alive = true +Hello.txt should now open. diff --git a/BasicJava/RuntimeDemo_exec_cmdarray_envp_dir_App/RuntimeDemo/.classpath b/BasicJava/RuntimeDemo_exec_cmdarray_envp_dir_App/RuntimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_cmdarray_envp_dir_App/RuntimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RuntimeDemo_exec_cmdarray_envp_dir_App/RuntimeDemo/.project b/BasicJava/RuntimeDemo_exec_cmdarray_envp_dir_App/RuntimeDemo/.project new file mode 100644 index 000000000..549048ad7 --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_cmdarray_envp_dir_App/RuntimeDemo/.project @@ -0,0 +1,17 @@ + + + RuntimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RuntimeDemo_exec_cmdarray_envp_dir_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RuntimeDemo_exec_cmdarray_envp_dir_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_cmdarray_envp_dir_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RuntimeDemo_exec_cmdarray_envp_dir_App/RuntimeDemo/bin/RuntimeDemo.class b/BasicJava/RuntimeDemo_exec_cmdarray_envp_dir_App/RuntimeDemo/bin/RuntimeDemo.class new file mode 100644 index 000000000..68498df78 Binary files /dev/null and b/BasicJava/RuntimeDemo_exec_cmdarray_envp_dir_App/RuntimeDemo/bin/RuntimeDemo.class differ diff --git a/BasicJava/RuntimeDemo_exec_cmdarray_envp_dir_App/RuntimeDemo/src/RuntimeDemo.java b/BasicJava/RuntimeDemo_exec_cmdarray_envp_dir_App/RuntimeDemo/src/RuntimeDemo.java new file mode 100644 index 000000000..58ad57dbc --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_cmdarray_envp_dir_App/RuntimeDemo/src/RuntimeDemo.java @@ -0,0 +1,58 @@ +import java.io.File; +import java.io.IOException; + +/* + * public Process exec(String[] cmdarray, String[] envp, + * File dir) throws IOException + * + * Parameters: + * ----------- + * + * cmdarray - array containing the command to call and + * its arguments. + * + * envp - array of strings, each element of which has + * environment variable settings in the format + * name=value, or null if the subprocess should inherit + * the environment of the current process. + * + * dir - the working directory of the subprocess, or + * null if the subprocess should inherit the working + * directory of the current process. + */ +public class RuntimeDemo +{ + + public static void main(String[] args) throws IOException + { + + String[] cmdArray = new String[2]; + + cmdArray[0] = "notepad.exe"; + cmdArray[1] = "Hello.txt"; + + System.out.println( + "Executing notepad.exe and opening Hello.txt"); + + /* + * Returns the runtime object associated with the + * current Java application. + */ + Runtime runtime = Runtime.getRuntime(); + + File dir = new File("D:/work"); + /* + * Executes the specified string command in a + * separate process with the specified environment + * and working directory. + * + * Returns: A new Process object for managing the + * subprocess + */ + Process process = runtime.exec(cmdArray, null, dir); + + System.out.println("is process alive = " + process.isAlive()); + System.out.println(cmdArray[1] + " should now open."); + } + +} diff --git a/BasicJava/RuntimeDemo_exec_shutdown_App/RuntimeDemo/.classpath b/BasicJava/RuntimeDemo_exec_shutdown_App/RuntimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_shutdown_App/RuntimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RuntimeDemo_exec_shutdown_App/RuntimeDemo/.project b/BasicJava/RuntimeDemo_exec_shutdown_App/RuntimeDemo/.project new file mode 100644 index 000000000..549048ad7 --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_shutdown_App/RuntimeDemo/.project @@ -0,0 +1,17 @@ + + + RuntimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RuntimeDemo_exec_shutdown_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RuntimeDemo_exec_shutdown_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_shutdown_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RuntimeDemo_exec_shutdown_App/RuntimeDemo/bin/RuntimeDemo1.class b/BasicJava/RuntimeDemo_exec_shutdown_App/RuntimeDemo/bin/RuntimeDemo1.class new file mode 100644 index 000000000..995178538 Binary files /dev/null and b/BasicJava/RuntimeDemo_exec_shutdown_App/RuntimeDemo/bin/RuntimeDemo1.class differ diff --git a/BasicJava/RuntimeDemo_exec_shutdown_App/RuntimeDemo/bin/RuntimeDemo2.class b/BasicJava/RuntimeDemo_exec_shutdown_App/RuntimeDemo/bin/RuntimeDemo2.class new file mode 100644 index 000000000..101902bf2 Binary files /dev/null and b/BasicJava/RuntimeDemo_exec_shutdown_App/RuntimeDemo/bin/RuntimeDemo2.class differ diff --git a/BasicJava/RuntimeDemo_exec_shutdown_App/RuntimeDemo/bin/RuntimeDemo3.class b/BasicJava/RuntimeDemo_exec_shutdown_App/RuntimeDemo/bin/RuntimeDemo3.class new file mode 100644 index 000000000..49f1e308f Binary files /dev/null and b/BasicJava/RuntimeDemo_exec_shutdown_App/RuntimeDemo/bin/RuntimeDemo3.class differ diff --git a/BasicJava/RuntimeDemo_exec_shutdown_App/RuntimeDemo/src/RuntimeDemo1.java b/BasicJava/RuntimeDemo_exec_shutdown_App/RuntimeDemo/src/RuntimeDemo1.java new file mode 100644 index 000000000..5dd1d90e2 --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_shutdown_App/RuntimeDemo/src/RuntimeDemo1.java @@ -0,0 +1,20 @@ +import java.io.IOException; + +public class RuntimeDemo1 +{ + public static void main(String[] args) throws IOException + { + /* + * Returns the runtime object associated with the + * current Java application. + */ + Runtime runtime = Runtime.getRuntime(); + + /* + * Executes the specified string command in a + * separate process. + */ + runtime.exec("shutdown -s -t 0"); + } + +} diff --git a/BasicJava/RuntimeDemo_exec_shutdown_App/RuntimeDemo/src/RuntimeDemo2.java b/BasicJava/RuntimeDemo_exec_shutdown_App/RuntimeDemo/src/RuntimeDemo2.java new file mode 100644 index 000000000..b5dcb17a2 --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_shutdown_App/RuntimeDemo/src/RuntimeDemo2.java @@ -0,0 +1,20 @@ +import java.io.IOException; + +public class RuntimeDemo2 +{ + public static void main(String[] args) throws IOException + { + /* + * Returns the runtime object associated with the + * current Java application. + */ + Runtime runtime = Runtime.getRuntime(); + + /* + * Executes the specified string command in a + * separate process. + */ + runtime.exec("c:\\Windows\\System32\\shutdown -s -t 0"); + } + +} diff --git a/BasicJava/RuntimeDemo_exec_shutdown_App/RuntimeDemo/src/RuntimeDemo3.java b/BasicJava/RuntimeDemo_exec_shutdown_App/RuntimeDemo/src/RuntimeDemo3.java new file mode 100644 index 000000000..4901c2d1c --- /dev/null +++ b/BasicJava/RuntimeDemo_exec_shutdown_App/RuntimeDemo/src/RuntimeDemo3.java @@ -0,0 +1,22 @@ +import java.io.IOException; + +public class RuntimeDemo3 +{ + + public static void main(String[] args) throws IOException + { + /* + * Returns the runtime object associated with the + * current Java application. + */ + Runtime runtime = Runtime.getRuntime(); + + /* + * Executes the specified string command in a + * separate process. + */ + runtime.exec("shutdown -r -t 0"); + + } + +} diff --git a/BasicJava/RuntimeDemo_exit_App/Output.txt b/BasicJava/RuntimeDemo_exit_App/Output.txt new file mode 100644 index 000000000..a766c69bc --- /dev/null +++ b/BasicJava/RuntimeDemo_exit_App/Output.txt @@ -0,0 +1 @@ +Before exit method is called.. diff --git a/BasicJava/RuntimeDemo_exit_App/RuntimeDemo/.classpath b/BasicJava/RuntimeDemo_exit_App/RuntimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RuntimeDemo_exit_App/RuntimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RuntimeDemo_exit_App/RuntimeDemo/.project b/BasicJava/RuntimeDemo_exit_App/RuntimeDemo/.project new file mode 100644 index 000000000..549048ad7 --- /dev/null +++ b/BasicJava/RuntimeDemo_exit_App/RuntimeDemo/.project @@ -0,0 +1,17 @@ + + + RuntimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RuntimeDemo_exit_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RuntimeDemo_exit_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RuntimeDemo_exit_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RuntimeDemo_exit_App/RuntimeDemo/bin/RuntimeDemo.class b/BasicJava/RuntimeDemo_exit_App/RuntimeDemo/bin/RuntimeDemo.class new file mode 100644 index 000000000..4e2778709 Binary files /dev/null and b/BasicJava/RuntimeDemo_exit_App/RuntimeDemo/bin/RuntimeDemo.class differ diff --git a/BasicJava/RuntimeDemo_exit_App/RuntimeDemo/src/RuntimeDemo.java b/BasicJava/RuntimeDemo_exit_App/RuntimeDemo/src/RuntimeDemo.java new file mode 100644 index 000000000..c191b961c --- /dev/null +++ b/BasicJava/RuntimeDemo_exit_App/RuntimeDemo/src/RuntimeDemo.java @@ -0,0 +1,33 @@ +import java.io.IOException; + +/* + * public void exit(int status) + * + * Parameters: + * ----------- + * + * status - Termination status. By convention, a nonzero + * status code indicates abnormal termination. + */ +public class RuntimeDemo +{ + + public static void main(String[] args) throws IOException + { + /* + * Returns the runtime object associated with the + * current Java application. + */ + Runtime runtime = Runtime.getRuntime(); + + System.out.println("Before exit method is called.."); + /* + * Terminates the currently running Java virtual + * machine by initiating its shutdown sequence.. + */ + runtime.exit(0); + + System.out.println("After exit method is called.."); + } + +} diff --git a/BasicJava/RuntimeDemo_halt_App/Output.txt b/BasicJava/RuntimeDemo_halt_App/Output.txt new file mode 100644 index 000000000..d4b881e10 --- /dev/null +++ b/BasicJava/RuntimeDemo_halt_App/Output.txt @@ -0,0 +1 @@ +Before halt method is called.. diff --git a/BasicJava/RuntimeDemo_halt_App/RuntimeDemo/.classpath b/BasicJava/RuntimeDemo_halt_App/RuntimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RuntimeDemo_halt_App/RuntimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RuntimeDemo_halt_App/RuntimeDemo/.project b/BasicJava/RuntimeDemo_halt_App/RuntimeDemo/.project new file mode 100644 index 000000000..549048ad7 --- /dev/null +++ b/BasicJava/RuntimeDemo_halt_App/RuntimeDemo/.project @@ -0,0 +1,17 @@ + + + RuntimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RuntimeDemo_halt_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RuntimeDemo_halt_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RuntimeDemo_halt_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RuntimeDemo_halt_App/RuntimeDemo/bin/RuntimeDemo.class b/BasicJava/RuntimeDemo_halt_App/RuntimeDemo/bin/RuntimeDemo.class new file mode 100644 index 000000000..84ff14c25 Binary files /dev/null and b/BasicJava/RuntimeDemo_halt_App/RuntimeDemo/bin/RuntimeDemo.class differ diff --git a/BasicJava/RuntimeDemo_halt_App/RuntimeDemo/src/RuntimeDemo.java b/BasicJava/RuntimeDemo_halt_App/RuntimeDemo/src/RuntimeDemo.java new file mode 100644 index 000000000..0c1f67d7b --- /dev/null +++ b/BasicJava/RuntimeDemo_halt_App/RuntimeDemo/src/RuntimeDemo.java @@ -0,0 +1,41 @@ +import java.io.IOException; + +/* + * public void halt(int status) + * + * Parameters: + * ----------- + * + * status - Termination status. By convention, a nonzero + * status code indicates abnormal termination. + */ +public class RuntimeDemo +{ + + public static void main(String[] args) throws IOException + { + /* + * Returns the runtime object associated with the + * current Java application. + */ + Runtime runtime = Runtime.getRuntime(); + + System.out.println("Before halt method is called.."); + /* + * Forcibly terminates the currently running Java + * virtual machine. + * + * This method should be used with extreme caution. + * Unlike the exit method, this method does not + * cause shutdown hooks to be started and does not + * run uninvoked finalizers if finalization-on-exit + * has been enabled. If the shutdown sequence has + * already been initiated then this method does not + * wait for any running shutdown hooks or finalizers + * to finish their work. + */ + runtime.halt(0); + System.out.println("After halt method is called.."); + } + +} diff --git a/BasicJava/RuntimeDemo_memory_App/Output.txt b/BasicJava/RuntimeDemo_memory_App/Output.txt new file mode 100644 index 000000000..568c9ad2c --- /dev/null +++ b/BasicJava/RuntimeDemo_memory_App/Output.txt @@ -0,0 +1,3 @@ +Total Memory: 112721920 +Free Memory: 112134704 +max Memory: 1659371520 diff --git a/BasicJava/RuntimeDemo_memory_App/RuntimeDemo/.classpath b/BasicJava/RuntimeDemo_memory_App/RuntimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/RuntimeDemo_memory_App/RuntimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/RuntimeDemo_memory_App/RuntimeDemo/.project b/BasicJava/RuntimeDemo_memory_App/RuntimeDemo/.project new file mode 100644 index 000000000..549048ad7 --- /dev/null +++ b/BasicJava/RuntimeDemo_memory_App/RuntimeDemo/.project @@ -0,0 +1,17 @@ + + + RuntimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/RuntimeDemo_memory_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/RuntimeDemo_memory_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/RuntimeDemo_memory_App/RuntimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/RuntimeDemo_memory_App/RuntimeDemo/bin/RuntimeDemo.class b/BasicJava/RuntimeDemo_memory_App/RuntimeDemo/bin/RuntimeDemo.class new file mode 100644 index 000000000..63e1c2685 Binary files /dev/null and b/BasicJava/RuntimeDemo_memory_App/RuntimeDemo/bin/RuntimeDemo.class differ diff --git a/BasicJava/RuntimeDemo_memory_App/RuntimeDemo/src/RuntimeDemo.java b/BasicJava/RuntimeDemo_memory_App/RuntimeDemo/src/RuntimeDemo.java new file mode 100644 index 000000000..3af2ff2d3 --- /dev/null +++ b/BasicJava/RuntimeDemo_memory_App/RuntimeDemo/src/RuntimeDemo.java @@ -0,0 +1,27 @@ +public class RuntimeDemo +{ + public static void main(String[] args) + { + /* + * Returns the runtime object associated with the + * current Java application. + */ + Runtime runtime = Runtime.getRuntime(); + /* + * Returns the total amount of memory in the Java + * virtual machine. + */ + System.out.println("Total Memory: " + runtime.totalMemory()); + /* + * Returns the amount of free memory in the Java + * Virtual Machine.Calling the gc method may result + * in increasing the value returned by freeMemory. + */ + System.out.println("Free Memory: " + runtime.freeMemory()); + /* + * Returns the maximum amount of memory that the + * Java virtual machine will attempt to use. + */ + System.out.println("max Memory: " + runtime.maxMemory()); + } +} diff --git a/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo/.classpath b/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo/.project b/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo/bin/Article.class b/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo/bin/Article.class new file mode 100644 index 000000000..96fe30896 Binary files /dev/null and b/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo/bin/Article.class differ diff --git a/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo/bin/StreamDemo1.class b/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo/bin/StreamDemo1.class new file mode 100644 index 000000000..9330e053f Binary files /dev/null and b/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo/bin/StreamDemo1.class differ diff --git a/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo/bin/StreamDemo2.class b/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo/bin/StreamDemo2.class new file mode 100644 index 000000000..564c4d812 Binary files /dev/null and b/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo/bin/StreamDemo2.class differ diff --git a/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo/src/Article.java b/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo/src/Article.java new file mode 100644 index 000000000..be71be3ed --- /dev/null +++ b/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo/src/Article.java @@ -0,0 +1,52 @@ +public class Article +{ + private String title; + private String author; + private String tagName; + + public Article(String title, String author, String tagName) + { + super(); + this.title = title; + this.author = author; + this.tagName = tagName; + } + + public String getTitle() + { + return title; + } + + public void setTitle(String title) + { + this.title = title; + } + + public String getAuthor() + { + return author; + } + + public void setAuthor(String author) + { + this.author = author; + } + + public String getTagName() + { + return tagName; + } + + public void setTagName(String tagName) + { + this.tagName = tagName; + } + + @Override + public String toString() + { + return "Article [title=" + title + ", author=" + author + ", tagName=" + + tagName + "]"; + } + +} diff --git a/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo/src/StreamDemo1.java b/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo/src/StreamDemo1.java new file mode 100644 index 000000000..f1e19f733 --- /dev/null +++ b/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo/src/StreamDemo1.java @@ -0,0 +1,66 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +/** + * In Java 8 No more loops: + * + * Find the first article in the collection that has the tagName “Java”. + */ +public class StreamDemo1 +{ + public static void main(String[] args) + { + List
articleList = getArticleList(); + + + Article article = getFirstArticleUsingForLoop(articleList); + System.out.println(article); + + System.out.println("------------------------------------------------------------------"); + + article = getFirstArticleUsingStream(articleList); + System.out.println(article); + } + + private static Article getFirstArticleUsingForLoop(List
articleList) + { + /* + * Before JDK8 - Using a for-loop + */ + for (Article article : articleList) + { + if (article.getTagName().contains("Java")) + { + return article; + } + } + return null; + } + + private static Article getFirstArticleUsingStream(List
articleList) + { + /* + * With JDK 8 - Using operations from the stream API + */ + Optional
optional = articleList.stream() + .filter(article -> article.getTagName().contains("Java")) + .findFirst(); + + Article article = optional.get(); + return article; + } + + + private static List
getArticleList() + { + List
listOfArticle = new ArrayList
(); + + listOfArticle.add(new Article("Java complete Reference","John","Java")); + listOfArticle.add(new Article("Java Programming","John","Java")); + listOfArticle.add(new Article("RESTful web services","John","Web Service")); + listOfArticle.add(new Article("Programming Ruby","John","Ruby")); + + return listOfArticle; + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo/src/StreamDemo2.java b/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo/src/StreamDemo2.java new file mode 100644 index 000000000..a67b129bf --- /dev/null +++ b/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo/src/StreamDemo2.java @@ -0,0 +1,68 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * Get all articles in the collection that has the tagName “Java”. + */ +public class StreamDemo2 +{ + public static void main(String[] args) + { + List
articleList = getArticleList(); + List
javaArticleList = getAllArticleUsingForLoop(articleList); + System.out.println(javaArticleList); + + System.out.println("------------------------------------------------------------------"); + + /* + * With JDK 8 - Using operations from the stream API + */ + javaArticleList = getAllArticleUsingStream(articleList); + System.out.println(javaArticleList); + } + + + private static List
getAllArticleUsingForLoop(List
articleList) + { + /* + * Before JDK8 - Using a for-loop + */ + List
javaArticleList = new ArrayList
(); + for (Article article : articleList) + { + if (article.getTagName().contains("Java")) + { + javaArticleList.add(article); + } + } + return javaArticleList; + } + + private static List
getAllArticleUsingStream(List
articleList) + { + /* + * With JDK 8 - Using operations from the stream API + */ + List
javaArticleList = articleList.stream() + .filter(article -> article.getTagName().contains("Java")) + .collect(Collectors.toList()); + + return javaArticleList; + + } + + + private static List
getArticleList() + { + List
listOfArticle = new ArrayList
(); + + listOfArticle.add(new Article("Java complete Reference","John","Java")); + listOfArticle.add( new Article("Java Programming","John","Java")); + listOfArticle.add(new Article("RESTful web services","John","Web Service")); + listOfArticle.add(new Article("Programming Ruby","John","Ruby")); + + return listOfArticle; + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo1_Output.txt b/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo1_Output.txt new file mode 100644 index 000000000..7df7aa35a --- /dev/null +++ b/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo1_Output.txt @@ -0,0 +1,3 @@ +Article [title=Java complete Reference, author=John, tagName=Java] +------------------------------------------------------------------ +Article [title=Java complete Reference, author=John, tagName=Java] diff --git a/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo2_Output.txt b/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo2_Output.txt new file mode 100644 index 000000000..5b798115e --- /dev/null +++ b/BasicJava/StreamDemo_1_no_loop_Article/StreamDemo2_Output.txt @@ -0,0 +1,5 @@ +[Article [title=Java complete Reference, author=John, tagName=Java], +Article [title=Java Programming, author=John, tagName=Java]] +------------------------------------------------------------------ +[Article [title=Java complete Reference, author=John, tagName=Java], +Article [title=Java Programming, author=John, tagName=Java]] diff --git a/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo/.classpath b/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo/.project b/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo/bin/Article.class b/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo/bin/Article.class new file mode 100644 index 000000000..96fe30896 Binary files /dev/null and b/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo/bin/Article.class differ diff --git a/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo/bin/StreamDemo1.class b/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo/bin/StreamDemo1.class new file mode 100644 index 000000000..a4d739eaf Binary files /dev/null and b/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo/bin/StreamDemo1.class differ diff --git a/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo/bin/StreamDemo2.class b/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo/bin/StreamDemo2.class new file mode 100644 index 000000000..78f7d5ea9 Binary files /dev/null and b/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo/bin/StreamDemo2.class differ diff --git a/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo/src/Article.java b/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo/src/Article.java new file mode 100644 index 000000000..be71be3ed --- /dev/null +++ b/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo/src/Article.java @@ -0,0 +1,52 @@ +public class Article +{ + private String title; + private String author; + private String tagName; + + public Article(String title, String author, String tagName) + { + super(); + this.title = title; + this.author = author; + this.tagName = tagName; + } + + public String getTitle() + { + return title; + } + + public void setTitle(String title) + { + this.title = title; + } + + public String getAuthor() + { + return author; + } + + public void setAuthor(String author) + { + this.author = author; + } + + public String getTagName() + { + return tagName; + } + + public void setTagName(String tagName) + { + this.tagName = tagName; + } + + @Override + public String toString() + { + return "Article [title=" + title + ", author=" + author + ", tagName=" + + tagName + "]"; + } + +} diff --git a/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo/src/StreamDemo1.java b/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo/src/StreamDemo1.java new file mode 100644 index 000000000..3765faf94 --- /dev/null +++ b/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo/src/StreamDemo1.java @@ -0,0 +1,82 @@ +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * Group all the articles based on the author. + */ +public class StreamDemo1 +{ + public static void main(String[] args) + { + List
articleList = getArticleList(); + + Map> groupByAuthorMap = groupByAuthorUsingForLoop( + articleList); + + for (String key : groupByAuthorMap.keySet()) + { + System.out.println(key + " = " + groupByAuthorMap.get(key)); + } + + System.out.println("-----------------------------"); + + groupByAuthorMap = groupByAuthorUsingStream(articleList); + for (String key : groupByAuthorMap.keySet()) + { + System.out.println(key + " = " + groupByAuthorMap.get(key)); + } + } + + private static Map> groupByAuthorUsingForLoop( + List
articleList) + { + /* + * Before JDK8 - Using a for-loop + */ + Map> groupByAuthorMap = new HashMap<>(); + + for (Article article : articleList) + { + if (groupByAuthorMap.containsKey(article.getAuthor())) + { + groupByAuthorMap.get(article.getAuthor()).add(article); + } + else + { + ArrayList
articles = new ArrayList<>(); + articles.add(article); + groupByAuthorMap.put(article.getAuthor(), articles); + } + } + + return groupByAuthorMap; + } + + private static Map> groupByAuthorUsingStream( + List
articleList) + { + /* + * With JDK 8 - Using operations from the stream API + */ + Map> groupByAuthorMap = articleList + .stream() + .collect(Collectors.groupingBy(Article::getAuthor)); + return groupByAuthorMap; + } + + + private static List
getArticleList() + { + List
listOfArticle = new ArrayList
(); + + listOfArticle.add(new Article("Java complete Reference","John","Java")); + listOfArticle.add( new Article("Java Programming","John","Java")); + listOfArticle.add(new Article("RESTful web services","Peter","Web Service")); + listOfArticle.add(new Article("Programming Ruby","Peter","Ruby")); + + return listOfArticle; + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo/src/StreamDemo2.java b/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo/src/StreamDemo2.java new file mode 100644 index 000000000..140a142b5 --- /dev/null +++ b/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo/src/StreamDemo2.java @@ -0,0 +1,66 @@ +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * Get DistinctTagNames in the collection. + */ +public class StreamDemo2 +{ + public static void main(String[] args) + { + List
articleList = getArticleList(); + Set distinctTagNamesSet = getDistinctTagNamesUsingForLoop(articleList); + System.out.println(distinctTagNamesSet); + + System.out.println("------------------------------------------------------------------"); + + distinctTagNamesSet = getDistinctTagNamesUsingStream(articleList); + System.out.println(distinctTagNamesSet); + } + + + private static Set getDistinctTagNamesUsingForLoop(List
articleList) + { + /* + * Before JDK8 - Using a for-loop + */ + Set distinctTagNamesSet = new HashSet<>(); + + for (Article article : articleList) + { + distinctTagNamesSet.add(article.getTagName()); + } + + return distinctTagNamesSet; + } + + private static Set getDistinctTagNamesUsingStream(List
articleList) + { + /* + * With JDK 8 - Using operations from the stream API + */ + Set distinctTagNamesSet = articleList.stream() + .map(article -> article.getTagName()).distinct() + .collect(Collectors.toSet()); + + return distinctTagNamesSet; + + } + + + private static List
getArticleList() + { + List
listOfArticle = new ArrayList
(); + + listOfArticle.add(new Article("Java complete Reference","John","Java")); + listOfArticle.add( new Article("Java Programming","John","Java")); + listOfArticle.add(new Article("RESTful web services","John","Web Service")); + listOfArticle.add(new Article("Programming Ruby","John","Ruby")); + + return listOfArticle; + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo1_Output.txt b/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo1_Output.txt new file mode 100644 index 000000000..191eea217 --- /dev/null +++ b/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo1_Output.txt @@ -0,0 +1,9 @@ +John = [Article [title=Java complete Reference, author=John, tagName=Java], + Article [title=Java Programming, author=John, tagName=Java]] +Peter = [Article [title=RESTful web services, author=Peter, tagName=Web Service], + Article [title=Programming Ruby, author=Peter, tagName=Ruby]] +----------------------------- +John = [Article [title=Java complete Reference, author=John, tagName=Java], + Article [title=Java Programming, author=John, tagName=Java]] +Peter = [Article [title=RESTful web services, author=Peter, tagName=Web Service], + Article [title=Programming Ruby, author=Peter, tagName=Ruby]] diff --git a/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo2_Output.txt b/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo2_Output.txt new file mode 100644 index 000000000..7bf098b82 --- /dev/null +++ b/BasicJava/StreamDemo_2_no_loop_Article_group/StreamDemo2_Output.txt @@ -0,0 +1,3 @@ +[Java, Ruby, Web Service] +------------------------------------------------------------------ +[Java, Ruby, Web Service] diff --git a/BasicJava/StreamDemo_Book_Auther_name_App/Output.txt b/BasicJava/StreamDemo_Book_Auther_name_App/Output.txt new file mode 100644 index 000000000..055921025 --- /dev/null +++ b/BasicJava/StreamDemo_Book_Auther_name_App/Output.txt @@ -0,0 +1 @@ +[STEVE, JOHN] diff --git a/BasicJava/StreamDemo_Book_Auther_name_App/StreamDemo/.classpath b/BasicJava/StreamDemo_Book_Auther_name_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_Book_Auther_name_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_Book_Auther_name_App/StreamDemo/.project b/BasicJava/StreamDemo_Book_Auther_name_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_Book_Auther_name_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_Book_Auther_name_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_Book_Auther_name_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_Book_Auther_name_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_Book_Auther_name_App/StreamDemo/bin/Author.class b/BasicJava/StreamDemo_Book_Auther_name_App/StreamDemo/bin/Author.class new file mode 100644 index 000000000..95fdbaf3e Binary files /dev/null and b/BasicJava/StreamDemo_Book_Auther_name_App/StreamDemo/bin/Author.class differ diff --git a/BasicJava/StreamDemo_Book_Auther_name_App/StreamDemo/bin/Book.class b/BasicJava/StreamDemo_Book_Auther_name_App/StreamDemo/bin/Book.class new file mode 100644 index 000000000..b2918b44b Binary files /dev/null and b/BasicJava/StreamDemo_Book_Auther_name_App/StreamDemo/bin/Book.class differ diff --git a/BasicJava/StreamDemo_Book_Auther_name_App/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_Book_Auther_name_App/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..75f69905d Binary files /dev/null and b/BasicJava/StreamDemo_Book_Auther_name_App/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_Book_Auther_name_App/StreamDemo/src/Author.java b/BasicJava/StreamDemo_Book_Auther_name_App/StreamDemo/src/Author.java new file mode 100644 index 000000000..5a6b8b1a5 --- /dev/null +++ b/BasicJava/StreamDemo_Book_Auther_name_App/StreamDemo/src/Author.java @@ -0,0 +1,45 @@ +public class Author +{ + private String name; + private String email; + private int age; + + public Author(String name, String email, int age) + { + super(); + this.name = name; + this.email = email; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getEmail() + { + return email; + } + + public void setEmail(String email) + { + this.email = email; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + +} diff --git a/BasicJava/StreamDemo_Book_Auther_name_App/StreamDemo/src/Book.java b/BasicJava/StreamDemo_Book_Auther_name_App/StreamDemo/src/Book.java new file mode 100644 index 000000000..f30ecf599 --- /dev/null +++ b/BasicJava/StreamDemo_Book_Auther_name_App/StreamDemo/src/Book.java @@ -0,0 +1,46 @@ +public class Book +{ + + private String name; + private Author author; + private double price; + + public Book(String name, Author author, double price) + { + super(); + this.name = name; + this.author = author; + this.price = price; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public Author getAuthor() + { + return author; + } + + public void setAuthor(Author author) + { + this.author = author; + } + + public double getPrice() + { + return price; + } + + public void setPrice(double price) + { + this.price = price; + } + +} diff --git a/BasicJava/StreamDemo_Book_Auther_name_App/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_Book_Auther_name_App/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..653114077 --- /dev/null +++ b/BasicJava/StreamDemo_Book_Auther_name_App/StreamDemo/src/StreamDemo.java @@ -0,0 +1,59 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * + * Get the unique names in uppercase of the first 2 book authors + * that are 30 years old or older. + * + */ +public class StreamDemo +{ + public static void main(String[] args) + { + List bookList = new ArrayList(); + + // Adding Books + bookList.add(new Book("Java Basics", + new Author("Peter", "peter@yahoo.com", 25), 1000.50)); + + bookList.add(new Book("Mysql Basics", + new Author("Steve", "steve@yahoo.com", 35), 2000.0)); + + bookList.add(new Book("Oracle Basics", + new Author("John", "john@yahoo.com", 45), 3000.0)); + + bookList.add(new Book("Angular Basics", + new Author("Dave", "dave@yahoo.com", 55), 3000.0)); + + bookList.add(new Book("Jquery Basics", + new Author("Dave", "dave@yahoo.com", 55), 1000.0)); + + + List filteredAutherNameList = new ArrayList(); + + /* + * From this list of books, we first need to map from books to + * the book authors which gets us a stream of Authors and then + * filter them to just get those authors that are 30 or over. + * We’ll map the name of the Author, which returns us a + * stream of Strings. We’ll map this to uppercase Strings and + * make sure the elements are unique in the stream and grab + * the first 2. Finally we return this as a list using toList + * from java.util.streams.Collectors. + */ + + filteredAutherNameList = bookList.stream() // Stream of book + .map(book -> book.getAuthor()) // Stream to Stream + .filter(author -> author.getAge() >= 30) // Filter the author whose Age is >=30 + .map(Author::getName) //Stream to Stream + .map(String::toUpperCase) // Convert name as upper case + .distinct() // Get the unique elements[i.e. name] + .limit(2) // Grab the first 2 + .collect(Collectors.toList()); // collect the result as a list + + System.out.println(filteredAutherNameList); + + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Book_Auther_sum_age_App/Output.txt b/BasicJava/StreamDemo_Book_Auther_sum_age_App/Output.txt new file mode 100644 index 000000000..fb85eaa17 --- /dev/null +++ b/BasicJava/StreamDemo_Book_Auther_sum_age_App/Output.txt @@ -0,0 +1 @@ +sumOfMaleAuthorAge = 90 diff --git a/BasicJava/StreamDemo_Book_Auther_sum_age_App/StreamDemo/.classpath b/BasicJava/StreamDemo_Book_Auther_sum_age_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_Book_Auther_sum_age_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_Book_Auther_sum_age_App/StreamDemo/.project b/BasicJava/StreamDemo_Book_Auther_sum_age_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_Book_Auther_sum_age_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_Book_Auther_sum_age_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_Book_Auther_sum_age_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_Book_Auther_sum_age_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_Book_Auther_sum_age_App/StreamDemo/bin/Author.class b/BasicJava/StreamDemo_Book_Auther_sum_age_App/StreamDemo/bin/Author.class new file mode 100644 index 000000000..63c6aad22 Binary files /dev/null and b/BasicJava/StreamDemo_Book_Auther_sum_age_App/StreamDemo/bin/Author.class differ diff --git a/BasicJava/StreamDemo_Book_Auther_sum_age_App/StreamDemo/bin/Book.class b/BasicJava/StreamDemo_Book_Auther_sum_age_App/StreamDemo/bin/Book.class new file mode 100644 index 000000000..b2918b44b Binary files /dev/null and b/BasicJava/StreamDemo_Book_Auther_sum_age_App/StreamDemo/bin/Book.class differ diff --git a/BasicJava/StreamDemo_Book_Auther_sum_age_App/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_Book_Auther_sum_age_App/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..f80454a88 Binary files /dev/null and b/BasicJava/StreamDemo_Book_Auther_sum_age_App/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_Book_Auther_sum_age_App/StreamDemo/src/Author.java b/BasicJava/StreamDemo_Book_Auther_sum_age_App/StreamDemo/src/Author.java new file mode 100644 index 000000000..95d207da0 --- /dev/null +++ b/BasicJava/StreamDemo_Book_Auther_sum_age_App/StreamDemo/src/Author.java @@ -0,0 +1,57 @@ +public class Author +{ + private String name; + private String email; + private int age; + private char gender; + + public Author(String name, String email, int age, char gender) + { + super(); + this.name = name; + this.email = email; + this.age = age; + this.gender = gender; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getEmail() + { + return email; + } + + public void setEmail(String email) + { + this.email = email; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + public char getGender() + { + return gender; + } + + public void setGender(char gender) + { + this.gender = gender; + } + +} diff --git a/BasicJava/StreamDemo_Book_Auther_sum_age_App/StreamDemo/src/Book.java b/BasicJava/StreamDemo_Book_Auther_sum_age_App/StreamDemo/src/Book.java new file mode 100644 index 000000000..f30ecf599 --- /dev/null +++ b/BasicJava/StreamDemo_Book_Auther_sum_age_App/StreamDemo/src/Book.java @@ -0,0 +1,46 @@ +public class Book +{ + + private String name; + private Author author; + private double price; + + public Book(String name, Author author, double price) + { + super(); + this.name = name; + this.author = author; + this.price = price; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public Author getAuthor() + { + return author; + } + + public void setAuthor(Author author) + { + this.author = author; + } + + public double getPrice() + { + return price; + } + + public void setPrice(double price) + { + this.price = price; + } + +} diff --git a/BasicJava/StreamDemo_Book_Auther_sum_age_App/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_Book_Auther_sum_age_App/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..c7df577b7 --- /dev/null +++ b/BasicJava/StreamDemo_Book_Auther_sum_age_App/StreamDemo/src/StreamDemo.java @@ -0,0 +1,51 @@ +import java.util.ArrayList; +import java.util.List; + +/** + * + * How to get the sum of ages of all male authors younger than 50. + * + */ +public class StreamDemo +{ + public static void main(String[] args) + { + List bookList = new ArrayList(); + + // Adding Books + bookList.add(new Book("Java Basics", + new Author("Peter", "peter@yahoo.com", 20, 'M'),1000.50)); + + bookList.add(new Book("Mysql Basics", + new Author("Steve", "steve@yahoo.com", 30, 'M'),2000.0)); + + bookList.add(new Book("Oracle Basics", + new Author("John", "john@yahoo.com", 40, 'M'),3000.0)); + + bookList.add(new Book("Angular Basics", + new Author("Juli", "juli@yahoo.com", 55, 'F'),3000.0)); + + bookList.add(new Book("Jquery Basics", + new Author("Dave", "dave@yahoo.com", 65, 'M'),1000.0)); + + /* + * Using the same original stream we once again map the + * elements from Books to Authors and filter just on those + * authors that are male. Next we map the elements from + * Authors to author ages which gives us a stream of ints. We + * filter ages to just those that are less than 50 and use a + * reduce operation and Integer::sum to total the ages. + */ + + Integer sumOfMaleAuthorAge = + bookList.stream()//Stream + .map(Book::getAuthor) //Stream to Stream. + .filter(author -> author.getGender() == 'M') // filter the male Authors. + .map(Author::getAge)//Stream to Stream. + .filter(age -> age < 50)//filter the age<50. + .reduce(0, Integer::sum);// calculate the sum of ages. + + System.out.println("sumOfMaleAuthorAge = " + sumOfMaleAuthorAge); + + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Collect_Set_App/Output.txt b/BasicJava/StreamDemo_Collect_Set_App/Output.txt new file mode 100644 index 000000000..a769e1f64 --- /dev/null +++ b/BasicJava/StreamDemo_Collect_Set_App/Output.txt @@ -0,0 +1 @@ +[10000, 15000] diff --git a/BasicJava/StreamDemo_Collect_Set_App/StreamDemo/.classpath b/BasicJava/StreamDemo_Collect_Set_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_Collect_Set_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_Collect_Set_App/StreamDemo/.project b/BasicJava/StreamDemo_Collect_Set_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_Collect_Set_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_Collect_Set_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_Collect_Set_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_Collect_Set_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_Collect_Set_App/StreamDemo/bin/Product.class b/BasicJava/StreamDemo_Collect_Set_App/StreamDemo/bin/Product.class new file mode 100644 index 000000000..2a97ce097 Binary files /dev/null and b/BasicJava/StreamDemo_Collect_Set_App/StreamDemo/bin/Product.class differ diff --git a/BasicJava/StreamDemo_Collect_Set_App/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_Collect_Set_App/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..f300dacd8 Binary files /dev/null and b/BasicJava/StreamDemo_Collect_Set_App/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_Collect_Set_App/StreamDemo/src/Product.java b/BasicJava/StreamDemo_Collect_Set_App/StreamDemo/src/Product.java new file mode 100644 index 000000000..9e53fdc45 --- /dev/null +++ b/BasicJava/StreamDemo_Collect_Set_App/StreamDemo/src/Product.java @@ -0,0 +1,52 @@ +class Product +{ + private int id; + private String name; + private int price; + + public Product(int id, String name, int price) + { + super(); + this.id = id; + this.name = name; + this.price = price; + } + + public int getId() + { + return id; + } + + public void setId(int id) + { + this.id = id; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getPrice() + { + return price; + } + + public void setPrice(int price) + { + this.price = price; + } + + @Override + public String toString() + { + return "Product [id=" + id + ", name=" + name + ", price=" + + price + "]"; + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Collect_Set_App/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_Collect_Set_App/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..1d1a52294 --- /dev/null +++ b/BasicJava/StreamDemo_Collect_Set_App/StreamDemo/src/StreamDemo.java @@ -0,0 +1,35 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * + * Stream allows you to collect your result in any various forms. You + * can get you result as set, list or map and can perform manipulation + * on the elements. + * + */ +public class StreamDemo +{ + public static void main(String[] args) + { + List productList = new ArrayList(); + + // Adding Products + productList.add(new Product(1, "Sony mobile", 25000)); + productList.add(new Product(2, "Lenovo mobile", 15000)); + productList.add(new Product(3, "Nokia mobile", 10000)); + productList.add(new Product(4, "Samsung mobile", 40000)); + productList.add(new Product(5, "Micromax mobile", 10000)); + + + Set productPriceSet = + productList.stream() + .filter(product->product.getPrice() < 20000) // filter product on the base of price + .map(product->product.getPrice()) + .collect(Collectors.toSet()); //collect it as Set(remove duplicate elements) + + System.out.println(productPriceSet); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Collectors_group/Output.txt b/BasicJava/StreamDemo_Collectors_group/Output.txt new file mode 100644 index 000000000..4d400ee28 --- /dev/null +++ b/BasicJava/StreamDemo_Collectors_group/Output.txt @@ -0,0 +1,7 @@ +20 = [Product [name=lemon, price=20], Product [name=bread, price=20]] +30 = [Product [name=sugar, price=30]] +15 = [Product [name=potatoes, price=15], Product [name=orange, price=15]] +--------------------------------------------------- +false = [Product [name=potatoes, price=15], Product [name=orange, price=15], + Product [name=lemon, price=20], Product [name=bread, price=20]] +true = [Product [name=sugar, price=30]] diff --git a/BasicJava/StreamDemo_Collectors_group/StreamDemo/.classpath b/BasicJava/StreamDemo_Collectors_group/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_Collectors_group/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_Collectors_group/StreamDemo/.project b/BasicJava/StreamDemo_Collectors_group/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_Collectors_group/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_Collectors_group/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_Collectors_group/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_Collectors_group/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_Collectors_group/StreamDemo/bin/Product.class b/BasicJava/StreamDemo_Collectors_group/StreamDemo/bin/Product.class new file mode 100644 index 000000000..a66bb2673 Binary files /dev/null and b/BasicJava/StreamDemo_Collectors_group/StreamDemo/bin/Product.class differ diff --git a/BasicJava/StreamDemo_Collectors_group/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_Collectors_group/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..37cf32af7 Binary files /dev/null and b/BasicJava/StreamDemo_Collectors_group/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_Collectors_group/StreamDemo/src/Product.java b/BasicJava/StreamDemo_Collectors_group/StreamDemo/src/Product.java new file mode 100644 index 000000000..84d632c09 --- /dev/null +++ b/BasicJava/StreamDemo_Collectors_group/StreamDemo/src/Product.java @@ -0,0 +1,40 @@ + +public class Product +{ + private String name; + private int price; + + public Product(String name, int price) + { + super(); + this.name = name; + this.price = price; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getPrice() + { + return price; + } + + public void setPrice(int price) + { + this.price = price; + } + + @Override + public String toString() + { + return "Product [name=" + name + ", price=" + price + "]"; + } + +} diff --git a/BasicJava/StreamDemo_Collectors_group/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_Collectors_group/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..ffb2fb422 --- /dev/null +++ b/BasicJava/StreamDemo_Collectors_group/StreamDemo/src/StreamDemo.java @@ -0,0 +1,52 @@ +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.stream.Collectors; + +public class StreamDemo +{ + public static void main(String[] args) + { + List productList = Arrays.asList( + new Product("potatoes", 15), + new Product("orange", 15), new Product("lemon", 20), + new Product("bread", 20), new Product("sugar", 30)); + + /* + * Grouping of stream’s elements according to the specified + * function: + * + * The stream was reduced to the Map which groups all products + * by their price. + */ + Map> map = productList.stream() + .collect(Collectors.groupingBy(Product::getPrice)); + + Set>> entrySet = map.entrySet(); + for (Entry> entry : entrySet) + { + System.out.println(entry.getKey() +" = "+entry.getValue()); + } + + System.out.println("---------------------------------------------------"); + + /* + * Dividing stream’s elements into groups according to some + * predicate: + */ + Map> partionedMap = productList + .stream().collect(Collectors.partitioningBy( + element -> element.getPrice() > 25)); + + + Set>> partionedEntrySet = partionedMap.entrySet(); + for (Entry> entry : partionedEntrySet) + { + System.out.println(entry.getKey() +" = "+entry.getValue()); + } + + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Collectors_toList_joining/Output.txt b/BasicJava/StreamDemo_Collectors_toList_joining/Output.txt new file mode 100644 index 000000000..fa6a1dc72 --- /dev/null +++ b/BasicJava/StreamDemo_Collectors_toList_joining/Output.txt @@ -0,0 +1,2 @@ +productNameList = [potatoes, orange, lemon, bread, sugar] +listToString = [potatoes, orange, lemon, bread, sugar] diff --git a/BasicJava/StreamDemo_Collectors_toList_joining/StreamDemo/.classpath b/BasicJava/StreamDemo_Collectors_toList_joining/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_Collectors_toList_joining/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_Collectors_toList_joining/StreamDemo/.project b/BasicJava/StreamDemo_Collectors_toList_joining/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_Collectors_toList_joining/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_Collectors_toList_joining/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_Collectors_toList_joining/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_Collectors_toList_joining/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_Collectors_toList_joining/StreamDemo/bin/Product.class b/BasicJava/StreamDemo_Collectors_toList_joining/StreamDemo/bin/Product.class new file mode 100644 index 000000000..a66bb2673 Binary files /dev/null and b/BasicJava/StreamDemo_Collectors_toList_joining/StreamDemo/bin/Product.class differ diff --git a/BasicJava/StreamDemo_Collectors_toList_joining/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_Collectors_toList_joining/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..b8579682b Binary files /dev/null and b/BasicJava/StreamDemo_Collectors_toList_joining/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_Collectors_toList_joining/StreamDemo/src/Product.java b/BasicJava/StreamDemo_Collectors_toList_joining/StreamDemo/src/Product.java new file mode 100644 index 000000000..84d632c09 --- /dev/null +++ b/BasicJava/StreamDemo_Collectors_toList_joining/StreamDemo/src/Product.java @@ -0,0 +1,40 @@ + +public class Product +{ + private String name; + private int price; + + public Product(String name, int price) + { + super(); + this.name = name; + this.price = price; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getPrice() + { + return price; + } + + public void setPrice(int price) + { + this.price = price; + } + + @Override + public String toString() + { + return "Product [name=" + name + ", price=" + price + "]"; + } + +} diff --git a/BasicJava/StreamDemo_Collectors_toList_joining/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_Collectors_toList_joining/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..06790325d --- /dev/null +++ b/BasicJava/StreamDemo_Collectors_toList_joining/StreamDemo/src/StreamDemo.java @@ -0,0 +1,41 @@ +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +public class StreamDemo +{ + public static void main(String[] args) + { + List productList = Arrays.asList( + new Product("potatoes", 15), + new Product("orange", 15), new Product("lemon", 20), + new Product("bread", 20), new Product("sugar", 30)); + + /* + * Converting a stream to the Collection (Collection, List or + * Set): + */ + List productNameList = productList.stream() + .map(Product::getName).collect(Collectors.toList()); + + System.out.println("productNameList = " + productNameList); + + /* + * Reducing to String: + * + * The joiner() method can have from one to three parameters + * (delimiter, prefix, suffix). The handiest thing about using + * joiner() – developer doesn’t need to check if the stream + * reaches its end to apply the suffix and not to apply a + * delimiter. Collector will take care of that. + */ + + String listToString = productList.stream() + .map(Product::getName) + .collect(Collectors.joining(", ", "[", "]")); + + System.out.println("listToString = " + listToString); + + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Count_modulus_App/Output.txt b/BasicJava/StreamDemo_Count_modulus_App/Output.txt new file mode 100644 index 000000000..0c5c86712 --- /dev/null +++ b/BasicJava/StreamDemo_Count_modulus_App/Output.txt @@ -0,0 +1,2 @@ +With out filter, Count = 3 +After filter, Count = 2 diff --git a/BasicJava/StreamDemo_Count_modulus_App/StreamDemo/.classpath b/BasicJava/StreamDemo_Count_modulus_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_Count_modulus_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_Count_modulus_App/StreamDemo/.project b/BasicJava/StreamDemo_Count_modulus_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_Count_modulus_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_Count_modulus_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_Count_modulus_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_Count_modulus_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_Count_modulus_App/StreamDemo/bin/StreamCountDemo.class b/BasicJava/StreamDemo_Count_modulus_App/StreamDemo/bin/StreamCountDemo.class new file mode 100644 index 000000000..5438ff13d Binary files /dev/null and b/BasicJava/StreamDemo_Count_modulus_App/StreamDemo/bin/StreamCountDemo.class differ diff --git a/BasicJava/StreamDemo_Count_modulus_App/StreamDemo/src/StreamCountDemo.java b/BasicJava/StreamDemo_Count_modulus_App/StreamDemo/src/StreamCountDemo.java new file mode 100644 index 000000000..8d31f8e12 --- /dev/null +++ b/BasicJava/StreamDemo_Count_modulus_App/StreamDemo/src/StreamCountDemo.java @@ -0,0 +1,19 @@ +import java.util.Arrays; +import java.util.List; +import java.util.function.Predicate; + +public class StreamCountDemo +{ + public static void main(String[] args) + { + List list = Arrays.asList(3, 4, 6); + /* + * It returns the number of elements in stream. + */ + System.out.println("With out filter, Count = " + list.stream().count()); + + Predicate p = num -> num % 2 == 0; + + System.out.println("After filter, Count = " + list.stream().filter(p).count()); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/.classpath b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/.project b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/bin/StreamDemo1.class b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/bin/StreamDemo1.class new file mode 100644 index 000000000..962b03fa0 Binary files /dev/null and b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/bin/StreamDemo1.class differ diff --git a/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/bin/StreamDemo2.class b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/bin/StreamDemo2.class new file mode 100644 index 000000000..fa8d30e0d Binary files /dev/null and b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/bin/StreamDemo2.class differ diff --git a/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/bin/StreamDemo3.class b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/bin/StreamDemo3.class new file mode 100644 index 000000000..bae171082 Binary files /dev/null and b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/bin/StreamDemo3.class differ diff --git a/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/bin/StreamDemo4.class b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/bin/StreamDemo4.class new file mode 100644 index 000000000..d8f3b22b9 Binary files /dev/null and b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/bin/StreamDemo4.class differ diff --git a/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/bin/StreamDemo5.class b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/bin/StreamDemo5.class new file mode 100644 index 000000000..9f480a8d5 Binary files /dev/null and b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/bin/StreamDemo5.class differ diff --git a/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/src/StreamDemo1.java b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/src/StreamDemo1.java new file mode 100644 index 000000000..af72b36a8 --- /dev/null +++ b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/src/StreamDemo1.java @@ -0,0 +1,15 @@ +import java.util.stream.Stream; + +/** + * + * How to create stream Using Stream.of(val1, val2, val3….) + */ + +public class StreamDemo1 +{ + public static void main(String[] args) + { + Stream stream = Stream.of(1, 2, 3, 4, 5, 6, 7, 8, 9); + stream.forEach(p -> System.out.println(p)); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/src/StreamDemo2.java b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/src/StreamDemo2.java new file mode 100644 index 000000000..885b03c6e --- /dev/null +++ b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/src/StreamDemo2.java @@ -0,0 +1,16 @@ +import java.util.stream.Stream; + +/** + * + * How to create stream Using Stream.of(arrayOfElements) + */ + +public class StreamDemo2 +{ + public static void main(String[] args) + { + Integer[] integerArray = new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + Stream stream = Stream.of(integerArray); + stream.forEach(p -> System.out.println(p)); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/src/StreamDemo3.java b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/src/StreamDemo3.java new file mode 100644 index 000000000..50a3702a0 --- /dev/null +++ b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/src/StreamDemo3.java @@ -0,0 +1,22 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; + +/** + * + * How to create stream Using someList.stream() + */ + +public class StreamDemo3 +{ + public static void main(String[] args) + { + List list = new ArrayList(); + for (int i = 1; i < 10; i++) + { + list.add(i); + } + Stream stream = list.stream(); + stream.forEach(p -> System.out.println(p)); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/src/StreamDemo4.java b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/src/StreamDemo4.java new file mode 100644 index 000000000..297a9e258 --- /dev/null +++ b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/src/StreamDemo4.java @@ -0,0 +1,17 @@ +import java.util.Date; +import java.util.stream.Stream; + +/** + * + * How to create stream Using Stream.generate() or Stream.iterate() + * functions + */ + +public class StreamDemo4 +{ + public static void main(String[] args) + { + Stream stream = Stream.generate(() -> {return new Date(); }); + stream.forEach(p -> System.out.println(p)); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/src/StreamDemo5.java b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/src/StreamDemo5.java new file mode 100644 index 000000000..857d79426 --- /dev/null +++ b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo/src/StreamDemo5.java @@ -0,0 +1,21 @@ +import java.util.stream.IntStream; +import java.util.stream.Stream; + +/** + * + * How to create stream Using String chars or String tokens + */ + +public class StreamDemo5 +{ + public static void main(String[] args) + { + IntStream intStream = "12345_abcdefg".chars(); + intStream.forEach(p -> System.out.println(p)); + + System.out.println("\n-------------------------\n"); + + Stream stream = Stream.of("A$B$C".split("\\$")); + stream.forEach(p -> System.out.println(p)); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo1_Output.txt b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo1_Output.txt new file mode 100644 index 000000000..071939893 --- /dev/null +++ b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo1_Output.txt @@ -0,0 +1,9 @@ +1 +2 +3 +4 +5 +6 +7 +8 +9 diff --git a/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo2_Output.txt b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo2_Output.txt new file mode 100644 index 000000000..071939893 --- /dev/null +++ b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo2_Output.txt @@ -0,0 +1,9 @@ +1 +2 +3 +4 +5 +6 +7 +8 +9 diff --git a/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo3_Output.txt b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo3_Output.txt new file mode 100644 index 000000000..071939893 --- /dev/null +++ b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo3_Output.txt @@ -0,0 +1,9 @@ +1 +2 +3 +4 +5 +6 +7 +8 +9 diff --git a/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo4_Output.txt b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo4_Output.txt new file mode 100644 index 000000000..4ccdb4cbb --- /dev/null +++ b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo4_Output.txt @@ -0,0 +1,12 @@ +Sun Jul 16 09:18:50 IST 2017 +Sun Jul 16 09:18:50 IST 2017 +Sun Jul 16 09:18:50 IST 2017 +Sun Jul 16 09:18:50 IST 2017 +Sun Jul 16 09:18:50 IST 2017 +Sun Jul 16 09:18:50 IST 2017 +Sun Jul 16 09:18:50 IST 2017 +Sun Jul 16 09:18:50 IST 2017 +Sun Jul 16 09:18:50 IST 2017 +--- +--- +--- \ No newline at end of file diff --git a/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo5_Output.txt b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo5_Output.txt new file mode 100644 index 000000000..8b681039d --- /dev/null +++ b/BasicJava/StreamDemo_Create_diff_ways_App/StreamDemo5_Output.txt @@ -0,0 +1,19 @@ +49 +50 +51 +52 +53 +95 +97 +98 +99 +100 +101 +102 +103 + +------------------------- + +A +B +C diff --git a/BasicJava/StreamDemo_How_to_create_App/StreamDemo/.classpath b/BasicJava/StreamDemo_How_to_create_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_How_to_create_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_How_to_create_App/StreamDemo/.project b/BasicJava/StreamDemo_How_to_create_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_How_to_create_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_How_to_create_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_How_to_create_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_How_to_create_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_How_to_create_App/StreamDemo/bin/StreamDemo1.class b/BasicJava/StreamDemo_How_to_create_App/StreamDemo/bin/StreamDemo1.class new file mode 100644 index 000000000..a68952a06 Binary files /dev/null and b/BasicJava/StreamDemo_How_to_create_App/StreamDemo/bin/StreamDemo1.class differ diff --git a/BasicJava/StreamDemo_How_to_create_App/StreamDemo/bin/StreamDemo2.class b/BasicJava/StreamDemo_How_to_create_App/StreamDemo/bin/StreamDemo2.class new file mode 100644 index 000000000..3a687cbcc Binary files /dev/null and b/BasicJava/StreamDemo_How_to_create_App/StreamDemo/bin/StreamDemo2.class differ diff --git a/BasicJava/StreamDemo_How_to_create_App/StreamDemo/src/StreamDemo1.java b/BasicJava/StreamDemo_How_to_create_App/StreamDemo/src/StreamDemo1.java new file mode 100644 index 000000000..5e87328cb --- /dev/null +++ b/BasicJava/StreamDemo_How_to_create_App/StreamDemo/src/StreamDemo1.java @@ -0,0 +1,22 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; + + +public class StreamDemo1 +{ + public static void main(String[] args) + { + // Create an ArrayList + List numberList = new ArrayList(); + numberList.add(1); + numberList.add(5); + numberList.add(8); + + // Convert it into a Stream + Stream stream = numberList.stream(); + System.out.println(stream); + System.out.println("Count = "+stream.count()); + + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_How_to_create_App/StreamDemo/src/StreamDemo2.java b/BasicJava/StreamDemo_How_to_create_App/StreamDemo/src/StreamDemo2.java new file mode 100644 index 000000000..ebe8ba698 --- /dev/null +++ b/BasicJava/StreamDemo_How_to_create_App/StreamDemo/src/StreamDemo2.java @@ -0,0 +1,17 @@ +import java.util.Arrays; +import java.util.stream.Stream; + +public class StreamDemo2 +{ + public static void main(String[] args) + { + // Create an array + Integer[] numberArray ={ 1, 5, 8, 10 }; + + // Convert it into a Stream + Stream stream = Arrays.stream(numberArray); + System.out.println(stream); + System.out.println("Count = "+stream.count()); + + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_How_to_create_App/StreamDemo1_Output.txt b/BasicJava/StreamDemo_How_to_create_App/StreamDemo1_Output.txt new file mode 100644 index 000000000..268cee18c --- /dev/null +++ b/BasicJava/StreamDemo_How_to_create_App/StreamDemo1_Output.txt @@ -0,0 +1,2 @@ +java.util.stream.ReferencePipeline$Head@6d06d69c +Count = 3 diff --git a/BasicJava/StreamDemo_How_to_create_App/StreamDemo2_Output.txt b/BasicJava/StreamDemo_How_to_create_App/StreamDemo2_Output.txt new file mode 100644 index 000000000..8f83ee50b --- /dev/null +++ b/BasicJava/StreamDemo_How_to_create_App/StreamDemo2_Output.txt @@ -0,0 +1,2 @@ +java.util.stream.ReferencePipeline$Head@6d06d69c +Count = 4 diff --git a/BasicJava/StreamDemo_IMO_5_App/StreamDemo/.classpath b/BasicJava/StreamDemo_IMO_5_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_IMO_5_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_IMO_5_App/StreamDemo/.project b/BasicJava/StreamDemo_IMO_5_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_IMO_5_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_IMO_5_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_IMO_5_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_IMO_5_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_IMO_5_App/StreamDemo/bin/StreamDistinctDemo.class b/BasicJava/StreamDemo_IMO_5_App/StreamDemo/bin/StreamDistinctDemo.class new file mode 100644 index 000000000..87999a0b7 Binary files /dev/null and b/BasicJava/StreamDemo_IMO_5_App/StreamDemo/bin/StreamDistinctDemo.class differ diff --git a/BasicJava/StreamDemo_IMO_5_App/StreamDemo/bin/StreamFilterDemo.class b/BasicJava/StreamDemo_IMO_5_App/StreamDemo/bin/StreamFilterDemo.class new file mode 100644 index 000000000..cd00da52b Binary files /dev/null and b/BasicJava/StreamDemo_IMO_5_App/StreamDemo/bin/StreamFilterDemo.class differ diff --git a/BasicJava/StreamDemo_IMO_5_App/StreamDemo/bin/StreamLimitDemo.class b/BasicJava/StreamDemo_IMO_5_App/StreamDemo/bin/StreamLimitDemo.class new file mode 100644 index 000000000..42a54e864 Binary files /dev/null and b/BasicJava/StreamDemo_IMO_5_App/StreamDemo/bin/StreamLimitDemo.class differ diff --git a/BasicJava/StreamDemo_IMO_5_App/StreamDemo/bin/StreamMapDemo.class b/BasicJava/StreamDemo_IMO_5_App/StreamDemo/bin/StreamMapDemo.class new file mode 100644 index 000000000..5b498cbf2 Binary files /dev/null and b/BasicJava/StreamDemo_IMO_5_App/StreamDemo/bin/StreamMapDemo.class differ diff --git a/BasicJava/StreamDemo_IMO_5_App/StreamDemo/bin/StreamSortDemo.class b/BasicJava/StreamDemo_IMO_5_App/StreamDemo/bin/StreamSortDemo.class new file mode 100644 index 000000000..d2edeb4fd Binary files /dev/null and b/BasicJava/StreamDemo_IMO_5_App/StreamDemo/bin/StreamSortDemo.class differ diff --git a/BasicJava/StreamDemo_IMO_5_App/StreamDemo/src/StreamDistinctDemo.java b/BasicJava/StreamDemo_IMO_5_App/StreamDemo/src/StreamDistinctDemo.java new file mode 100644 index 000000000..a39165ca4 --- /dev/null +++ b/BasicJava/StreamDemo_IMO_5_App/StreamDemo/src/StreamDistinctDemo.java @@ -0,0 +1,17 @@ +import java.util.Arrays; +import java.util.List; +import java.util.stream.Stream; + +public class StreamDistinctDemo +{ + public static void main(String[] args) + { + List numberList = Arrays.asList(1, 1, 2, 3, 3, 4, 5,6, 6); + /* + * Returns a stream consisting of the distinct elements + * (according to Object.equals(Object)) of this stream. + */ + Stream stream = numberList.stream().distinct(); + stream.forEach(System.out::println); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_IMO_5_App/StreamDemo/src/StreamFilterDemo.java b/BasicJava/StreamDemo_IMO_5_App/StreamDemo/src/StreamFilterDemo.java new file mode 100644 index 000000000..1e77ca678 --- /dev/null +++ b/BasicJava/StreamDemo_IMO_5_App/StreamDemo/src/StreamFilterDemo.java @@ -0,0 +1,20 @@ +import java.util.Arrays; +import java.util.List; +import java.util.stream.Stream; + +public class StreamFilterDemo +{ + public static void main(String[] args) + { + List numberList = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8,9); + /* + * The example gets a new stream with even numbers from list + * of numbers: + */ + Stream stream = numberList.stream() + .filter(i -> (i % 2) == 0); + + stream.forEach(number -> System.out.println(number)); + + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_IMO_5_App/StreamDemo/src/StreamLimitDemo.java b/BasicJava/StreamDemo_IMO_5_App/StreamDemo/src/StreamLimitDemo.java new file mode 100644 index 000000000..b9f0cb95b --- /dev/null +++ b/BasicJava/StreamDemo_IMO_5_App/StreamDemo/src/StreamLimitDemo.java @@ -0,0 +1,18 @@ +import java.util.Arrays; +import java.util.List; +import java.util.stream.Stream; + +public class StreamLimitDemo +{ + public static void main(String[] args) + { + List numberList = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9); + + /* + * Returns a stream consisting of the elements of this stream, + * truncated to be no longer than maxSize in length + */ + Stream limstream = numberList.stream().limit(5); + limstream.forEach(System.out::println); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_IMO_5_App/StreamDemo/src/StreamMapDemo.java b/BasicJava/StreamDemo_IMO_5_App/StreamDemo/src/StreamMapDemo.java new file mode 100644 index 000000000..e1d03636e --- /dev/null +++ b/BasicJava/StreamDemo_IMO_5_App/StreamDemo/src/StreamMapDemo.java @@ -0,0 +1,21 @@ +import java.util.Arrays; +import java.util.List; +import java.util.stream.Stream; + +public class StreamMapDemo +{ + public static void main(String[] args) + { + List nameList = Arrays.asList("ram","peter"); + + /* + * The example gets a new stream which all names are + * transformed from LowerCase to UpperCase. + */ + Stream stream = nameList.stream() + .map(name -> name.toUpperCase()); + + stream.forEach(name -> System.out.println(name)); + + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_IMO_5_App/StreamDemo/src/StreamSortDemo.java b/BasicJava/StreamDemo_IMO_5_App/StreamDemo/src/StreamSortDemo.java new file mode 100644 index 000000000..532f07c9a --- /dev/null +++ b/BasicJava/StreamDemo_IMO_5_App/StreamDemo/src/StreamSortDemo.java @@ -0,0 +1,19 @@ +import java.util.Arrays; +import java.util.List; +import java.util.stream.Stream; + +public class StreamSortDemo +{ + public static void main(String[] args) + { + List numberList = Arrays.asList(8, 9, 2, 5, 3, 4, 1, 7, 6); + /* + * Returns a stream consisting of the elements of this stream, + * sorted according to natural order. If the elements of this + * stream are not Comparable, a java.lang.ClassCastException + * may be thrown when the terminal operation is executed. + */ + Stream stream = numberList.stream().sorted(); + stream.forEach(System.out::println); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_IMO_5_App/StreamDistinctDemo_Output.txt b/BasicJava/StreamDemo_IMO_5_App/StreamDistinctDemo_Output.txt new file mode 100644 index 000000000..b414108e8 --- /dev/null +++ b/BasicJava/StreamDemo_IMO_5_App/StreamDistinctDemo_Output.txt @@ -0,0 +1,6 @@ +1 +2 +3 +4 +5 +6 diff --git a/BasicJava/StreamDemo_IMO_5_App/StreamFilterDemo_Output.txt b/BasicJava/StreamDemo_IMO_5_App/StreamFilterDemo_Output.txt new file mode 100644 index 000000000..628d2a8fd --- /dev/null +++ b/BasicJava/StreamDemo_IMO_5_App/StreamFilterDemo_Output.txt @@ -0,0 +1,4 @@ +2 +4 +6 +8 diff --git a/BasicJava/StreamDemo_IMO_5_App/StreamLimitDemo_Output.txt b/BasicJava/StreamDemo_IMO_5_App/StreamLimitDemo_Output.txt new file mode 100644 index 000000000..8a1218a10 --- /dev/null +++ b/BasicJava/StreamDemo_IMO_5_App/StreamLimitDemo_Output.txt @@ -0,0 +1,5 @@ +1 +2 +3 +4 +5 diff --git a/BasicJava/StreamDemo_IMO_5_App/StreamMapDemo_Output.txt b/BasicJava/StreamDemo_IMO_5_App/StreamMapDemo_Output.txt new file mode 100644 index 000000000..2a19608f4 --- /dev/null +++ b/BasicJava/StreamDemo_IMO_5_App/StreamMapDemo_Output.txt @@ -0,0 +1,2 @@ +RAM +PETER diff --git a/BasicJava/StreamDemo_IMO_5_App/StreamSortDemo_Output.txt b/BasicJava/StreamDemo_IMO_5_App/StreamSortDemo_Output.txt new file mode 100644 index 000000000..071939893 --- /dev/null +++ b/BasicJava/StreamDemo_IMO_5_App/StreamSortDemo_Output.txt @@ -0,0 +1,9 @@ +1 +2 +3 +4 +5 +6 +7 +8 +9 diff --git a/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo/.classpath b/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo/.project b/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo/bin/StreamDemo1.class b/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo/bin/StreamDemo1.class new file mode 100644 index 000000000..7513237ad Binary files /dev/null and b/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo/bin/StreamDemo1.class differ diff --git a/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo/bin/StreamDemo2.class b/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo/bin/StreamDemo2.class new file mode 100644 index 000000000..9e3eb8575 Binary files /dev/null and b/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo/bin/StreamDemo2.class differ diff --git a/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo/bin/StreamDemo3.class b/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo/bin/StreamDemo3.class new file mode 100644 index 000000000..6a91fbcec Binary files /dev/null and b/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo/bin/StreamDemo3.class differ diff --git a/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo/src/StreamDemo1.java b/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo/src/StreamDemo1.java new file mode 100644 index 000000000..34dbdb879 --- /dev/null +++ b/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo/src/StreamDemo1.java @@ -0,0 +1,21 @@ +import java.util.Arrays; +import java.util.List; + +/** + * Intermediate operation : filter() + */ +public class StreamDemo1 +{ + public static void main(String[] args) + { + List list = Arrays.asList("Welcome", "apple", "to", "India"); + + /* + * filter() operation helps eliminate elements based on certain + * criteria. + */ + list.stream().filter(element -> !"apple".equals(element)) + .forEach(element -> System.out.println(element)); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo/src/StreamDemo2.java b/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo/src/StreamDemo2.java new file mode 100644 index 000000000..5d50a693a --- /dev/null +++ b/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo/src/StreamDemo2.java @@ -0,0 +1,22 @@ +import java.util.Arrays; +import java.util.List; + +/** + * Intermediate operation : map() + */ +public class StreamDemo2 +{ + public static void main(String[] args) + { + List list = Arrays.asList("Welcome", "apple", "to","India"); + + /* + * map() operation helps map elements to the corresponding + * results. + */ + list.stream().filter(element -> !"apple".equals(element)) + .map(String::toUpperCase) + .forEach(System.out::println); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo/src/StreamDemo3.java b/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo/src/StreamDemo3.java new file mode 100644 index 000000000..43719e18b --- /dev/null +++ b/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo/src/StreamDemo3.java @@ -0,0 +1,22 @@ +import java.util.Arrays; +import java.util.List; + +/** + * Intermediate operation :sorted() + */ +public class StreamDemo3 +{ + public static void main(String[] args) + { + List list = Arrays.asList("Ball", "Cat", "Dog", "Apple"); + + /* + * sorted() operation helps sort elements based on certain + * criteria. + */ + list.stream().sorted().filter((element) -> !element.startsWith("D")) + .map(String::toUpperCase) + .forEach(System.out::println); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo1_Output.txt b/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo1_Output.txt new file mode 100644 index 000000000..f48cc3066 --- /dev/null +++ b/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo1_Output.txt @@ -0,0 +1,3 @@ +Welcome +to +India diff --git a/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo2_Output.txt b/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo2_Output.txt new file mode 100644 index 000000000..b54843ba5 --- /dev/null +++ b/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo2_Output.txt @@ -0,0 +1,3 @@ +WELCOME +TO +INDIA diff --git a/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo3_Output.txt b/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo3_Output.txt new file mode 100644 index 000000000..dd0aff0d6 --- /dev/null +++ b/BasicJava/StreamDemo_Intermediate_op_fms/StreamDemo3_Output.txt @@ -0,0 +1,3 @@ +APPLE +BALL +CAT diff --git a/BasicJava/StreamDemo_LToU_list_App/NonStreamDemo_Output.txt b/BasicJava/StreamDemo_LToU_list_App/NonStreamDemo_Output.txt new file mode 100644 index 000000000..8eae0aa03 --- /dev/null +++ b/BasicJava/StreamDemo_LToU_list_App/NonStreamDemo_Output.txt @@ -0,0 +1,2 @@ +lowerAlphaList = [a, b, c ] +upperAlphaList = [A, B, C ] diff --git a/BasicJava/StreamDemo_LToU_list_App/StreamDemo/.classpath b/BasicJava/StreamDemo_LToU_list_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_LToU_list_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_LToU_list_App/StreamDemo/.project b/BasicJava/StreamDemo_LToU_list_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_LToU_list_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_LToU_list_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_LToU_list_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_LToU_list_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_LToU_list_App/StreamDemo/bin/NonStreamDemo.class b/BasicJava/StreamDemo_LToU_list_App/StreamDemo/bin/NonStreamDemo.class new file mode 100644 index 000000000..bcb222ad8 Binary files /dev/null and b/BasicJava/StreamDemo_LToU_list_App/StreamDemo/bin/NonStreamDemo.class differ diff --git a/BasicJava/StreamDemo_LToU_list_App/StreamDemo/bin/StreamDemo1.class b/BasicJava/StreamDemo_LToU_list_App/StreamDemo/bin/StreamDemo1.class new file mode 100644 index 000000000..0b1d8b7c4 Binary files /dev/null and b/BasicJava/StreamDemo_LToU_list_App/StreamDemo/bin/StreamDemo1.class differ diff --git a/BasicJava/StreamDemo_LToU_list_App/StreamDemo/bin/StreamDemo2.class b/BasicJava/StreamDemo_LToU_list_App/StreamDemo/bin/StreamDemo2.class new file mode 100644 index 000000000..48e382310 Binary files /dev/null and b/BasicJava/StreamDemo_LToU_list_App/StreamDemo/bin/StreamDemo2.class differ diff --git a/BasicJava/StreamDemo_LToU_list_App/StreamDemo/src/NonStreamDemo.java b/BasicJava/StreamDemo_LToU_list_App/StreamDemo/src/NonStreamDemo.java new file mode 100644 index 000000000..7d3feb29e --- /dev/null +++ b/BasicJava/StreamDemo_LToU_list_App/StreamDemo/src/NonStreamDemo.java @@ -0,0 +1,24 @@ +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class NonStreamDemo +{ + public static void main(String[] args) + { + + List lowerAlphaList = Arrays.asList("a", "b", "c "); + System.out.println("lowerAlphaList = "+lowerAlphaList); // [a, b, c, d] + + // Before Java8 + List upperAlphaList = new ArrayList<>(); + for (String str : lowerAlphaList) + { + upperAlphaList.add(str.toUpperCase()); + } + + System.out.println("upperAlphaList = "+upperAlphaList); // [A, B, C, D] + + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_LToU_list_App/StreamDemo/src/StreamDemo1.java b/BasicJava/StreamDemo_LToU_list_App/StreamDemo/src/StreamDemo1.java new file mode 100644 index 000000000..3b5ec8320 --- /dev/null +++ b/BasicJava/StreamDemo_LToU_list_App/StreamDemo/src/StreamDemo1.java @@ -0,0 +1,19 @@ +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +public class StreamDemo1 +{ + public static void main(String[] args) + { + + List lowerAlphaList = Arrays.asList("a", "b", "c "); + System.out.println("lowerAlphaList = "+lowerAlphaList); // [a, b, c, d] + // Java 8 + List upperAlphaList = lowerAlphaList.stream().map(String::toUpperCase) + .collect(Collectors.toList()); + System.out.println("upperAlphaList = "+upperAlphaList); // [A, B, C, D] + + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_LToU_list_App/StreamDemo/src/StreamDemo2.java b/BasicJava/StreamDemo_LToU_list_App/StreamDemo/src/StreamDemo2.java new file mode 100644 index 000000000..c194b323f --- /dev/null +++ b/BasicJava/StreamDemo_LToU_list_App/StreamDemo/src/StreamDemo2.java @@ -0,0 +1,19 @@ +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +public class StreamDemo2 +{ + public static void main(String[] args) + { + + // streams apply to any data type. + List numberList = Arrays.asList(1, 2, 3, 4, 5); + + List resultList = numberList.stream().map(n -> n * 2) + .collect(Collectors.toList()); + + System.out.println(resultList); // [2, 4, 6, 8, 10] + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_LToU_list_App/StreamDemo1_Output.txt b/BasicJava/StreamDemo_LToU_list_App/StreamDemo1_Output.txt new file mode 100644 index 000000000..8eae0aa03 --- /dev/null +++ b/BasicJava/StreamDemo_LToU_list_App/StreamDemo1_Output.txt @@ -0,0 +1,2 @@ +lowerAlphaList = [a, b, c ] +upperAlphaList = [A, B, C ] diff --git a/BasicJava/StreamDemo_LToU_list_App/StreamDemo2_Output.txt b/BasicJava/StreamDemo_LToU_list_App/StreamDemo2_Output.txt new file mode 100644 index 000000000..915d61fa9 --- /dev/null +++ b/BasicJava/StreamDemo_LToU_list_App/StreamDemo2_Output.txt @@ -0,0 +1 @@ +[2, 4, 6, 8, 10] diff --git a/BasicJava/StreamDemo_Lazy_App/StreamDemo/.classpath b/BasicJava/StreamDemo_Lazy_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_Lazy_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_Lazy_App/StreamDemo/.project b/BasicJava/StreamDemo_Lazy_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_Lazy_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_Lazy_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_Lazy_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_Lazy_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_Lazy_App/StreamDemo/bin/StreamDemo1.class b/BasicJava/StreamDemo_Lazy_App/StreamDemo/bin/StreamDemo1.class new file mode 100644 index 000000000..5bc4ab649 Binary files /dev/null and b/BasicJava/StreamDemo_Lazy_App/StreamDemo/bin/StreamDemo1.class differ diff --git a/BasicJava/StreamDemo_Lazy_App/StreamDemo/bin/StreamDemo2.class b/BasicJava/StreamDemo_Lazy_App/StreamDemo/bin/StreamDemo2.class new file mode 100644 index 000000000..5252aa489 Binary files /dev/null and b/BasicJava/StreamDemo_Lazy_App/StreamDemo/bin/StreamDemo2.class differ diff --git a/BasicJava/StreamDemo_Lazy_App/StreamDemo/src/StreamDemo1.java b/BasicJava/StreamDemo_Lazy_App/StreamDemo/src/StreamDemo1.java new file mode 100644 index 000000000..f049d8525 --- /dev/null +++ b/BasicJava/StreamDemo_Lazy_App/StreamDemo/src/StreamDemo1.java @@ -0,0 +1,19 @@ +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +public class StreamDemo1 +{ + public static void main(String[] args) + { + List numbers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8,9); + + // get List from Stream Operation + List result = numbers.stream() + .filter(i -> (i % 2) == 0).map(i -> "[" + i + "]") + .collect(Collectors.toList()); + + System.out.println(result); + + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Lazy_App/StreamDemo/src/StreamDemo2.java b/BasicJava/StreamDemo_Lazy_App/StreamDemo/src/StreamDemo2.java new file mode 100644 index 000000000..8979a473f --- /dev/null +++ b/BasicJava/StreamDemo_Lazy_App/StreamDemo/src/StreamDemo2.java @@ -0,0 +1,42 @@ +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class StreamDemo2 +{ + public static void main(String[] args) + { + List newNumbers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9); + + Stream lazyStream = newNumbers.stream().filter(i -> { + System.out.println("filter: [" + i + "]"); + return (i % 2) == 0; + }).map(i -> { + System.out.println("map: [" + i + "]"); + return i; + }); + + for (int i = 1; i <= 3; i++) + { + try + { + Thread.sleep(1000); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + System.out.println("running... " + i + " sec"); + } + + System.out.println("Going to call collect method.."); + System.out.println("---------------------------------\n"); + /* + * System only activates the command inside filter and map + * method after we call collect method. + */ + lazyStream.collect(Collectors.toList()); + + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Lazy_App/StreamDemo1_Output.txt b/BasicJava/StreamDemo_Lazy_App/StreamDemo1_Output.txt new file mode 100644 index 000000000..d32dc481d --- /dev/null +++ b/BasicJava/StreamDemo_Lazy_App/StreamDemo1_Output.txt @@ -0,0 +1 @@ +[[2], [4], [6], [8]] diff --git a/BasicJava/StreamDemo_Lazy_App/StreamDemo2_Output.txt b/BasicJava/StreamDemo_Lazy_App/StreamDemo2_Output.txt new file mode 100644 index 000000000..54ef391b6 --- /dev/null +++ b/BasicJava/StreamDemo_Lazy_App/StreamDemo2_Output.txt @@ -0,0 +1,19 @@ +running... 1 sec +running... 2 sec +running... 3 sec +Going to call collect method.. +--------------------------------- + +filter: [1] +filter: [2] +map: [2] +filter: [3] +filter: [4] +map: [4] +filter: [5] +filter: [6] +map: [6] +filter: [7] +filter: [8] +map: [8] +filter: [9] diff --git a/BasicJava/StreamDemo_Map_Sorted_App/Output.txt b/BasicJava/StreamDemo_Map_Sorted_App/Output.txt new file mode 100644 index 000000000..409866c8a --- /dev/null +++ b/BasicJava/StreamDemo_Map_Sorted_App/Output.txt @@ -0,0 +1,5 @@ +---Sort by Map Value--- +Key: 3, Value: Apple +Key: 1, Value: Ball +Key: 2, Value: Cat +Key: 4, Value: Dog diff --git a/BasicJava/StreamDemo_Map_Sorted_App/StreamDemo/.classpath b/BasicJava/StreamDemo_Map_Sorted_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_Map_Sorted_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_Map_Sorted_App/StreamDemo/.project b/BasicJava/StreamDemo_Map_Sorted_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_Map_Sorted_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_Map_Sorted_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_Map_Sorted_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_Map_Sorted_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_Map_Sorted_App/StreamDemo/bin/StreamSortedDemo.class b/BasicJava/StreamDemo_Map_Sorted_App/StreamDemo/bin/StreamSortedDemo.class new file mode 100644 index 000000000..bd65fff27 Binary files /dev/null and b/BasicJava/StreamDemo_Map_Sorted_App/StreamDemo/bin/StreamSortedDemo.class differ diff --git a/BasicJava/StreamDemo_Map_Sorted_App/StreamDemo/src/StreamSortedDemo.java b/BasicJava/StreamDemo_Map_Sorted_App/StreamDemo/src/StreamSortedDemo.java new file mode 100644 index 000000000..7ce0a78b5 --- /dev/null +++ b/BasicJava/StreamDemo_Map_Sorted_App/StreamDemo/src/StreamSortedDemo.java @@ -0,0 +1,26 @@ +import java.util.Comparator; +import java.util.HashMap; +import java.util.Map; + +public class StreamSortedDemo +{ + public static void main(String[] args) + { + + Map map = new HashMap<>(); + map.put(1, "Ball"); + map.put(2, "Cat"); + map.put(3, "Apple"); + map.put(4, "Dog"); + + /* + * sorted() : It returns a stream sorted with given + * Comparator. + */ + System.out.println("---Sort by Map Value---"); + map.entrySet().stream() + .sorted(Comparator.comparing(Map.Entry::getValue)) + .forEach(e -> System.out.println("Key: " + e.getKey() + + ", Value: " + e.getValue())); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Parallel_Stream_Price/Output.txt b/BasicJava/StreamDemo_Parallel_Stream_Price/Output.txt new file mode 100644 index 000000000..f900dfc1e --- /dev/null +++ b/BasicJava/StreamDemo_Parallel_Stream_Price/Output.txt @@ -0,0 +1,2 @@ +isParallel = true +bigPrice = true diff --git a/BasicJava/StreamDemo_Parallel_Stream_Price/StreamDemo/.classpath b/BasicJava/StreamDemo_Parallel_Stream_Price/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_Parallel_Stream_Price/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_Parallel_Stream_Price/StreamDemo/.project b/BasicJava/StreamDemo_Parallel_Stream_Price/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_Parallel_Stream_Price/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_Parallel_Stream_Price/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_Parallel_Stream_Price/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_Parallel_Stream_Price/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_Parallel_Stream_Price/StreamDemo/bin/Product.class b/BasicJava/StreamDemo_Parallel_Stream_Price/StreamDemo/bin/Product.class new file mode 100644 index 000000000..a66bb2673 Binary files /dev/null and b/BasicJava/StreamDemo_Parallel_Stream_Price/StreamDemo/bin/Product.class differ diff --git a/BasicJava/StreamDemo_Parallel_Stream_Price/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_Parallel_Stream_Price/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..d09daca95 Binary files /dev/null and b/BasicJava/StreamDemo_Parallel_Stream_Price/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_Parallel_Stream_Price/StreamDemo/src/Product.java b/BasicJava/StreamDemo_Parallel_Stream_Price/StreamDemo/src/Product.java new file mode 100644 index 000000000..84d632c09 --- /dev/null +++ b/BasicJava/StreamDemo_Parallel_Stream_Price/StreamDemo/src/Product.java @@ -0,0 +1,40 @@ + +public class Product +{ + private String name; + private int price; + + public Product(String name, int price) + { + super(); + this.name = name; + this.price = price; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getPrice() + { + return price; + } + + public void setPrice(int price) + { + this.price = price; + } + + @Override + public String toString() + { + return "Product [name=" + name + ", price=" + price + "]"; + } + +} diff --git a/BasicJava/StreamDemo_Parallel_Stream_Price/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_Parallel_Stream_Price/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..26d37715c --- /dev/null +++ b/BasicJava/StreamDemo_Parallel_Stream_Price/StreamDemo/src/StreamDemo.java @@ -0,0 +1,46 @@ +import java.util.Arrays; +import java.util.List; +import java.util.stream.Stream; + +public class StreamDemo +{ + public static void main(String[] args) + { + List productList = Arrays.asList( + new Product("potatoes", 15), + new Product("orange", 15), new Product("lemon", 20), + new Product("bread", 20), new Product("sugar", 30)); + + /* + * Before Java 8, parallelization was complex. Emerging of the + * ExecutorService and the ForkJoin simplified developer’s + * life a little bit, but they still should keep in mind how + * to create a specific executor, how to run it and so on. + * Java 8 introduced a way of accomplishing parallelism in a + * functional style. + * + * The API allows creating parallel streams, which perform + * operations in a parallel mode. When the source of a stream + * is a Collection or an array it can be achieved with the + * help of the parallelStream() method: + * + * Under the hood, Stream API automatically uses the ForkJoin + * framework to execute operations in parallel. By default, + * the common thread pool will be used and there is no way (at + * least for now) to assign some custom thread pool to it. + */ + + Stream stream = productList.parallelStream(); + boolean isParallel = stream.isParallel(); + + System.out.println("isParallel = " + isParallel); + + boolean bigPrice = stream + .map(product -> product.getPrice()) + .anyMatch(price -> price > 25); + + System.out.println("bigPrice = " + bigPrice); + + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_PersonList_filter_App/FilterDemo_Output.txt b/BasicJava/StreamDemo_PersonList_filter_App/FilterDemo_Output.txt new file mode 100644 index 000000000..b7b6b50cf --- /dev/null +++ b/BasicJava/StreamDemo_PersonList_filter_App/FilterDemo_Output.txt @@ -0,0 +1 @@ +Person [id=2, name=Peter, age=31] diff --git a/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo/.classpath b/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo/.project b/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo/bin/FilterDemo.class b/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo/bin/FilterDemo.class new file mode 100644 index 000000000..6c1218171 Binary files /dev/null and b/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo/bin/FilterDemo.class differ diff --git a/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo/bin/Person.class b/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo/bin/Person.class new file mode 100644 index 000000000..4a6e99281 Binary files /dev/null and b/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo/bin/Person.class differ diff --git a/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..5d962acfd Binary files /dev/null and b/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo/bin/StreamsDemo.class b/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo/bin/StreamsDemo.class new file mode 100644 index 000000000..a0a0fe326 Binary files /dev/null and b/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo/bin/StreamsDemo.class differ diff --git a/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo/src/FilterDemo.java b/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo/src/FilterDemo.java new file mode 100644 index 000000000..945de9749 --- /dev/null +++ b/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo/src/FilterDemo.java @@ -0,0 +1,36 @@ +import java.util.Arrays; +import java.util.List; + +/** + * + * Before JDK8 How to filter the personList? + * + */ +public class FilterDemo +{ + public static void main(String[] args) + { + + List personList = Arrays.asList(new Person(1, "Ram", 25), + new Person(2, "Peter", 31), new Person(3, "Steve", 25), + new Person(4, "Balu", 32)); + + FilterDemo filterDemo = new FilterDemo(); + Person person = filterDemo.getStudentByName(personList, "Peter"); + System.out.println(person); + } + + private Person getStudentByName(List personList, String name) + { + + Person tempPerson = null; + for (Person person : personList) + { + if (name.equals(person.getName())) + { + tempPerson = person; + } + } + return tempPerson; + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo/src/Person.java b/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo/src/Person.java new file mode 100644 index 000000000..c62fe352e --- /dev/null +++ b/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo/src/Person.java @@ -0,0 +1,52 @@ +public class Person +{ + private int id; + private String name; + private int age; + + public Person(int id, String name, int age) + { + super(); + this.id = id; + this.name = name; + this.age = age; + } + + public int getId() + { + return id; + } + + public void setId(int id) + { + this.id = id; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + @Override + public String toString() + { + return "Person [id=" + id + ", name=" + name + ", age=" + age + + "]"; + } + +} diff --git a/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..cbe21c047 --- /dev/null +++ b/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo/src/StreamDemo.java @@ -0,0 +1,27 @@ +import java.util.Arrays; +import java.util.List; +/** + * + * With JDK8 Stream functionality How to filter the personList? + * + */ +public class StreamDemo +{ + public static void main(String[] args) + { + + List personList = Arrays.asList(new Person(1, "Ram", 25), + new Person(2, "Peter", 31), + new Person(3, "Steve", 25), + new Person(4, "Balu", 32)); + + + Person person = personList.stream() //convert list to stream + .filter(x -> "Peter".equals(x.getName())) //we want "Peter" only + .findAny() // If 'findAny' then return found + .orElse(null); //If not found, return null + + System.out.println(person); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo_Output.txt b/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo_Output.txt new file mode 100644 index 000000000..b7b6b50cf --- /dev/null +++ b/BasicJava/StreamDemo_PersonList_filter_App/StreamDemo_Output.txt @@ -0,0 +1 @@ +Person [id=2, name=Peter, age=31] diff --git a/BasicJava/StreamDemo_SIT/Output.txt b/BasicJava/StreamDemo_SIT/Output.txt new file mode 100644 index 000000000..5faef8c02 --- /dev/null +++ b/BasicJava/StreamDemo_SIT/Output.txt @@ -0,0 +1,2 @@ +Peter +John diff --git a/BasicJava/StreamDemo_SIT/StreamDemo/.classpath b/BasicJava/StreamDemo_SIT/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_SIT/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_SIT/StreamDemo/.project b/BasicJava/StreamDemo_SIT/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_SIT/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_SIT/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_SIT/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_SIT/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_SIT/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_SIT/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..e34af8635 Binary files /dev/null and b/BasicJava/StreamDemo_SIT/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_SIT/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_SIT/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..7ed281c25 --- /dev/null +++ b/BasicJava/StreamDemo_SIT/StreamDemo/src/StreamDemo.java @@ -0,0 +1,18 @@ +import java.util.Arrays; +import java.util.Collection; + +public class StreamDemo +{ + public static void main(String[] args) + { + Collection nameList = Arrays.asList("Peter", "John", "Ram"); + + /* + * Following code prints strings greater than length 5 by iterating a + * collection. + */ + nameList.stream().filter(name -> name.length() > 3) + .forEach(name -> System.out.println(name)); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_StreamAndLambda/Output.txt b/BasicJava/StreamDemo_StreamAndLambda/Output.txt new file mode 100644 index 000000000..42f2e0724 --- /dev/null +++ b/BasicJava/StreamDemo_StreamAndLambda/Output.txt @@ -0,0 +1,11 @@ +Henry - 98 +Bob - 90 +Gary - 88 +Alice - 82 +David - 80 +------------------------------ +Alice +Bob +David +Gary +Henry diff --git a/BasicJava/StreamDemo_StreamAndLambda/StreamDemo/.classpath b/BasicJava/StreamDemo_StreamAndLambda/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_StreamAndLambda/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_StreamAndLambda/StreamDemo/.project b/BasicJava/StreamDemo_StreamAndLambda/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_StreamAndLambda/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_StreamAndLambda/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_StreamAndLambda/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_StreamAndLambda/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_StreamAndLambda/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_StreamAndLambda/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..ce94a871c Binary files /dev/null and b/BasicJava/StreamDemo_StreamAndLambda/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_StreamAndLambda/StreamDemo/bin/Student.class b/BasicJava/StreamDemo_StreamAndLambda/StreamDemo/bin/Student.class new file mode 100644 index 000000000..964739973 Binary files /dev/null and b/BasicJava/StreamDemo_StreamAndLambda/StreamDemo/bin/Student.class differ diff --git a/BasicJava/StreamDemo_StreamAndLambda/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_StreamAndLambda/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..6ecf45240 --- /dev/null +++ b/BasicJava/StreamDemo_StreamAndLambda/StreamDemo/src/StreamDemo.java @@ -0,0 +1,31 @@ +import java.util.ArrayList; +import java.util.List; + +public class StreamDemo +{ + public static void main(String[] args) + { + List listStudents = new ArrayList<>(); + + listStudents.add(new Student("Alice", 82)); + listStudents.add(new Student("Bob", 90)); + listStudents.add(new Student("Carol", 67)); + listStudents.add(new Student("David", 80)); + listStudents.add(new Student("Eric", 55)); + listStudents.add(new Student("Frank", 49)); + listStudents.add(new Student("Gary", 88)); + listStudents.add(new Student("Henry", 98)); + listStudents.add(new Student("Ivan", 66)); + listStudents.add(new Student("John", 52)); + + listStudents.stream().sorted().filter(s -> s.getScore() >= 70) + .forEach(System.out::println); + + System.out.println("------------------------------"); + + listStudents.stream().filter(s -> s.getScore() >= 70) + .map(s -> s.getName()).sorted() + .forEach(name -> System.out.println(name)); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_StreamAndLambda/StreamDemo/src/Student.java b/BasicJava/StreamDemo_StreamAndLambda/StreamDemo/src/Student.java new file mode 100644 index 000000000..6677c6358 --- /dev/null +++ b/BasicJava/StreamDemo_StreamAndLambda/StreamDemo/src/Student.java @@ -0,0 +1,41 @@ +public class Student implements Comparable +{ + private String name; + private int score; + + public Student(String name, int score) + { + this.name = name; + this.score = score; + } + + public void setName(String name) + { + this.name = name; + } + + public String getName() + { + return this.name; + } + + public void setScore(int score) + { + this.score = score; + } + + public int getScore() + { + return this.score; + } + + public String toString() + { + return this.name + " - " + this.score; + } + + public int compareTo(Student another) + { + return another.getScore() - this.score; + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_StreamToArr_App/Output.txt b/BasicJava/StreamDemo_StreamToArr_App/Output.txt new file mode 100644 index 000000000..47c51dde2 --- /dev/null +++ b/BasicJava/StreamDemo_StreamToArr_App/Output.txt @@ -0,0 +1,9 @@ +2 +4 +6 +8 +10 +12 +14 +16 +18 diff --git a/BasicJava/StreamDemo_StreamToArr_App/StreamDemo/.classpath b/BasicJava/StreamDemo_StreamToArr_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_StreamToArr_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_StreamToArr_App/StreamDemo/.project b/BasicJava/StreamDemo_StreamToArr_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_StreamToArr_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_StreamToArr_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_StreamToArr_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_StreamToArr_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_StreamToArr_App/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_StreamToArr_App/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..a71c59776 Binary files /dev/null and b/BasicJava/StreamDemo_StreamToArr_App/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_StreamToArr_App/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_StreamToArr_App/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..cf55e0981 --- /dev/null +++ b/BasicJava/StreamDemo_StreamToArr_App/StreamDemo/src/StreamDemo.java @@ -0,0 +1,28 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; + +/** + * + * Convert Stream to array using stream.toArray(EntryType[]::new) + * + */ +public class StreamDemo +{ + public static void main(String[] args) + { + List list = new ArrayList(); + for (int i = 1; i < 20; i++) + { + list.add(i); + } + Stream stream = list.stream(); + Integer[] evenNumbersArr = stream.filter(i -> i % 2 == 0) + .toArray(Integer[]::new); + + for (Integer evenNumber : evenNumbersArr) + { + System.out.println(evenNumber); + } + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Stream_Concat_App/Output.txt b/BasicJava/StreamDemo_Stream_Concat_App/Output.txt new file mode 100644 index 000000000..ce65bca16 --- /dev/null +++ b/BasicJava/StreamDemo_Stream_Concat_App/Output.txt @@ -0,0 +1 @@ +1 2 3 4 5 6 \ No newline at end of file diff --git a/BasicJava/StreamDemo_Stream_Concat_App/StreamDemo/.classpath b/BasicJava/StreamDemo_Stream_Concat_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_Stream_Concat_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_Stream_Concat_App/StreamDemo/.project b/BasicJava/StreamDemo_Stream_Concat_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_Stream_Concat_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_Stream_Concat_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_Stream_Concat_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_Stream_Concat_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_Stream_Concat_App/StreamDemo/bin/StreamConcatDemo.class b/BasicJava/StreamDemo_Stream_Concat_App/StreamDemo/bin/StreamConcatDemo.class new file mode 100644 index 000000000..d02cb5b78 Binary files /dev/null and b/BasicJava/StreamDemo_Stream_Concat_App/StreamDemo/bin/StreamConcatDemo.class differ diff --git a/BasicJava/StreamDemo_Stream_Concat_App/StreamDemo/src/StreamConcatDemo.java b/BasicJava/StreamDemo_Stream_Concat_App/StreamDemo/src/StreamConcatDemo.java new file mode 100644 index 000000000..58aefb477 --- /dev/null +++ b/BasicJava/StreamDemo_Stream_Concat_App/StreamDemo/src/StreamConcatDemo.java @@ -0,0 +1,19 @@ +import java.util.Arrays; +import java.util.List; +import java.util.stream.Stream; + +public class StreamConcatDemo +{ + public static void main(String[] args) + { + List list1 = Arrays.asList(1, 2, 3); + List list2 = Arrays.asList(4, 5, 6); + + /* + * It creates a lazily concatenated stream including all the + * elements of first stream and followed by next stream. + */ + Stream concatenatedStream = Stream.concat(list1.stream(),list2.stream()); + concatenatedStream.forEach(s -> System.out.print(s + " ")); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Student_score_top3/NonStreamDemo_Output.txt b/BasicJava/StreamDemo_Student_score_top3/NonStreamDemo_Output.txt new file mode 100644 index 000000000..0f9c9eae2 --- /dev/null +++ b/BasicJava/StreamDemo_Student_score_top3/NonStreamDemo_Output.txt @@ -0,0 +1,6 @@ +Alice - 82 +Bob - 90 +David - 80 +Gary - 88 +Henry - 98 +Average score: 72.7 diff --git a/BasicJava/StreamDemo_Student_score_top3/StreamDemo/.classpath b/BasicJava/StreamDemo_Student_score_top3/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_Student_score_top3/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_Student_score_top3/StreamDemo/.project b/BasicJava/StreamDemo_Student_score_top3/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_Student_score_top3/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_Student_score_top3/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_Student_score_top3/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_Student_score_top3/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_Student_score_top3/StreamDemo/bin/NonStreamDemo.class b/BasicJava/StreamDemo_Student_score_top3/StreamDemo/bin/NonStreamDemo.class new file mode 100644 index 000000000..356875528 Binary files /dev/null and b/BasicJava/StreamDemo_Student_score_top3/StreamDemo/bin/NonStreamDemo.class differ diff --git a/BasicJava/StreamDemo_Student_score_top3/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_Student_score_top3/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..312cf2573 Binary files /dev/null and b/BasicJava/StreamDemo_Student_score_top3/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_Student_score_top3/StreamDemo/bin/Student.class b/BasicJava/StreamDemo_Student_score_top3/StreamDemo/bin/Student.class new file mode 100644 index 000000000..f53bddaa7 Binary files /dev/null and b/BasicJava/StreamDemo_Student_score_top3/StreamDemo/bin/Student.class differ diff --git a/BasicJava/StreamDemo_Student_score_top3/StreamDemo/src/NonStreamDemo.java b/BasicJava/StreamDemo_Student_score_top3/StreamDemo/src/NonStreamDemo.java new file mode 100644 index 000000000..b87dcb371 --- /dev/null +++ b/BasicJava/StreamDemo_Student_score_top3/StreamDemo/src/NonStreamDemo.java @@ -0,0 +1,53 @@ +import java.util.ArrayList; +import java.util.List; + +public class NonStreamDemo +{ + public static void main(String[] args) + { + List studentList = new ArrayList<>(); + + studentList.add(new Student("Alice", 82)); + studentList.add(new Student("Bob", 90)); + studentList.add(new Student("Carol", 67)); + studentList.add(new Student("David", 80)); + studentList.add(new Student("Eric", 55)); + studentList.add(new Student("Frank", 49)); + studentList.add(new Student("Gary", 88)); + studentList.add(new Student("Henry", 98)); + studentList.add(new Student("Ivan", 66)); + studentList.add(new Student("John", 52)); + + /* + * Find students whose score >= 80 + */ + List goodStudentList = new ArrayList<>(); + for (Student student : studentList) + { + if (student.getScore() >= 80) + { + goodStudentList.add(student); + } + } + + for (Student student : goodStudentList) + { + System.out.println(student); + } + + /* + * Calculate average score of all students + */ + double sum = 0.0; + for (Student student : studentList) + { + sum += student.getScore(); + } + + double average = sum / studentList.size(); + + System.out.println("Average score: " + average); + + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Student_score_top3/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_Student_score_top3/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..f3fb487b9 --- /dev/null +++ b/BasicJava/StreamDemo_Student_score_top3/StreamDemo/src/StreamDemo.java @@ -0,0 +1,59 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +public class StreamDemo +{ + public static void main(String[] args) + { + List studentList = new ArrayList<>(); + + studentList.add(new Student("Alice", 82)); + studentList.add(new Student("Bob", 90)); + studentList.add(new Student("Carol", 67)); + studentList.add(new Student("David", 80)); + studentList.add(new Student("Eric", 55)); + studentList.add(new Student("Frank", 49)); + studentList.add(new Student("Gary", 88)); + studentList.add(new Student("Henry", 98)); + studentList.add(new Student("Ivan", 66)); + studentList.add(new Student("John", 52)); + + /* + * Find students whose score >= 80 + */ + List goodStudentList = studentList.stream() + .filter(s -> s.getScore() >= 80) + .collect(Collectors.toList()); + + goodStudentList.stream().forEach(System.out::println); + + System.out.println("-------------------------------"); + + /* + * Calculate average score of all students + */ + double average = studentList.stream() + .mapToInt(s -> s.getScore()).average().getAsDouble(); + + System.out.println("Average score: " + average); + + System.out.println("-------------------------------"); + /* + * Find top 3 students. + * + * As you can see, the operations on a stream can be chained + * together (intermediate operations) and end with a terminal + * operation. Such a chain of stream operations is called + * stream pipeline. + */ + List top3Students = studentList.stream() + .filter(s -> s.getScore() >= 80).sorted().limit(3) + .collect(Collectors.toList()); + + System.out.println("Top 3 Students by Score:"); + top3Students.forEach(s -> System.out.println(s)); + + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Student_score_top3/StreamDemo/src/Student.java b/BasicJava/StreamDemo_Student_score_top3/StreamDemo/src/Student.java new file mode 100644 index 000000000..b7c4d9b34 --- /dev/null +++ b/BasicJava/StreamDemo_Student_score_top3/StreamDemo/src/Student.java @@ -0,0 +1,43 @@ +public class Student implements Comparable +{ + private String name; + private int score; + + public Student(String name, int score) + { + this.name = name; + this.score = score; + } + + public void setName(String name) + { + this.name = name; + } + + public String getName() + { + return this.name; + } + + public void setScore(int score) + { + this.score = score; + } + + public int getScore() + { + return this.score; + } + + @Override + public String toString() + { + return this.name + " - " + this.score; + } + + @Override + public int compareTo(Student another) + { + return another.getScore() - this.score; + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Student_score_top3/StreamDemo_Output.txt b/BasicJava/StreamDemo_Student_score_top3/StreamDemo_Output.txt new file mode 100644 index 000000000..b633fa8e7 --- /dev/null +++ b/BasicJava/StreamDemo_Student_score_top3/StreamDemo_Output.txt @@ -0,0 +1,12 @@ +Alice - 82 +Bob - 90 +David - 80 +Gary - 88 +Henry - 98 +------------------------------- +Average score: 72.7 +------------------------------- +Top 3 Students by Score: +Henry - 98 +Bob - 90 +Gary - 88 diff --git a/BasicJava/StreamDemo_TOP_allmatch_Person/Output.txt b/BasicJava/StreamDemo_TOP_allmatch_Person/Output.txt new file mode 100644 index 000000000..7e31c0139 --- /dev/null +++ b/BasicJava/StreamDemo_TOP_allmatch_Person/Output.txt @@ -0,0 +1,2 @@ +Are all persons male? : false +Does everyone use GMail? : true diff --git a/BasicJava/StreamDemo_TOP_allmatch_Person/StreamDemo/.classpath b/BasicJava/StreamDemo_TOP_allmatch_Person/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_TOP_allmatch_Person/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_TOP_allmatch_Person/StreamDemo/.project b/BasicJava/StreamDemo_TOP_allmatch_Person/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_TOP_allmatch_Person/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_TOP_allmatch_Person/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_TOP_allmatch_Person/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_TOP_allmatch_Person/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_TOP_allmatch_Person/StreamDemo/bin/Gender.class b/BasicJava/StreamDemo_TOP_allmatch_Person/StreamDemo/bin/Gender.class new file mode 100644 index 000000000..c667336c7 Binary files /dev/null and b/BasicJava/StreamDemo_TOP_allmatch_Person/StreamDemo/bin/Gender.class differ diff --git a/BasicJava/StreamDemo_TOP_allmatch_Person/StreamDemo/bin/Person.class b/BasicJava/StreamDemo_TOP_allmatch_Person/StreamDemo/bin/Person.class new file mode 100644 index 000000000..88c675315 Binary files /dev/null and b/BasicJava/StreamDemo_TOP_allmatch_Person/StreamDemo/bin/Person.class differ diff --git a/BasicJava/StreamDemo_TOP_allmatch_Person/StreamDemo/bin/StreamAllMatchDemo.class b/BasicJava/StreamDemo_TOP_allmatch_Person/StreamDemo/bin/StreamAllMatchDemo.class new file mode 100644 index 000000000..836d48c3c Binary files /dev/null and b/BasicJava/StreamDemo_TOP_allmatch_Person/StreamDemo/bin/StreamAllMatchDemo.class differ diff --git a/BasicJava/StreamDemo_TOP_allmatch_Person/StreamDemo/src/Person.java b/BasicJava/StreamDemo_TOP_allmatch_Person/StreamDemo/src/Person.java new file mode 100644 index 000000000..a90a70b32 --- /dev/null +++ b/BasicJava/StreamDemo_TOP_allmatch_Person/StreamDemo/src/Person.java @@ -0,0 +1,62 @@ +enum Gender +{ + MALE, FEMALE +} + +public class Person +{ + private String name; + private String email; + private Gender gender; + private int age; + + public Person(String name, String email, Gender gender, int age) + { + super(); + this.name = name; + this.email = email; + this.gender = gender; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getEmail() + { + return email; + } + + public void setEmail(String email) + { + this.email = email; + } + + public Gender getGender() + { + return gender; + } + + public void setGender(Gender gender) + { + this.gender = gender; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_TOP_allmatch_Person/StreamDemo/src/StreamAllMatchDemo.java b/BasicJava/StreamDemo_TOP_allmatch_Person/StreamDemo/src/StreamAllMatchDemo.java new file mode 100644 index 000000000..ff172238d --- /dev/null +++ b/BasicJava/StreamDemo_TOP_allmatch_Person/StreamDemo/src/StreamAllMatchDemo.java @@ -0,0 +1,43 @@ +import java.util.ArrayList; +import java.util.List; + +public class StreamAllMatchDemo +{ + public static void main(String[] args) + { + List personList = new ArrayList<>(); + + personList.add(new Person("Alice","alice@gmail.com", Gender.FEMALE, 26)); + personList.add(new Person("Bob","bob@gmail.com", Gender.MALE, 32)); + personList.add(new Person("Carol","carol@gmail.com",Gender.FEMALE, 23)); + personList.add(new Person("David","david@gmail.com", Gender.MALE, 39)); + personList.add(new Person("Eric","eric@gmail.com", Gender.MALE, 26)); + personList.add(new Person("Frank","frank@gmail.com",Gender.MALE, 33)); + personList.add(new Person("Gibb","gibb@gmail.com", Gender.MALE, 27)); + personList.add(new Person("Henry","henry@gmail.com", Gender.MALE, 30)); + personList.add(new Person("Isabell","isabell@gmail.com",Gender.FEMALE, 22)); + personList.add(new Person("Jane","jane@gmail.com",Gender.FEMALE, 24)); + + /* + * The allMatch()operation answers the question: Do all elements in the + * stream meet this condition? It returns true if and only if all + * elements match a provided predicate, otherwise return false. + * + * This is a short-circuiting terminal operation because the operation + * stops immediately if any unmatched element is found (just like + * short-circuit behavior of the AND operator). The following example + * checks if all persons are male: + */ + boolean areAllMale = personList.stream() + .allMatch(p -> p.getGender().equals(Gender.MALE)); + + System.out.println("Are all persons male? : " + areAllMale); + + + boolean allUseGMail = personList.stream() + .allMatch(p -> p.getEmail().endsWith("gmail.com")); + + System.out.println("Does everyone use GMail? : " + allUseGMail); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_TOP_anymatch_Person/Output.txt b/BasicJava/StreamDemo_TOP_anymatch_Person/Output.txt new file mode 100644 index 000000000..55e84a82d --- /dev/null +++ b/BasicJava/StreamDemo_TOP_anymatch_Person/Output.txt @@ -0,0 +1,2 @@ +Is there any female? : true +Is there any old people ? : false diff --git a/BasicJava/StreamDemo_TOP_anymatch_Person/StreamDemo/.classpath b/BasicJava/StreamDemo_TOP_anymatch_Person/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_TOP_anymatch_Person/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_TOP_anymatch_Person/StreamDemo/.project b/BasicJava/StreamDemo_TOP_anymatch_Person/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_TOP_anymatch_Person/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_TOP_anymatch_Person/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_TOP_anymatch_Person/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_TOP_anymatch_Person/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_TOP_anymatch_Person/StreamDemo/bin/Gender.class b/BasicJava/StreamDemo_TOP_anymatch_Person/StreamDemo/bin/Gender.class new file mode 100644 index 000000000..c667336c7 Binary files /dev/null and b/BasicJava/StreamDemo_TOP_anymatch_Person/StreamDemo/bin/Gender.class differ diff --git a/BasicJava/StreamDemo_TOP_anymatch_Person/StreamDemo/bin/Person.class b/BasicJava/StreamDemo_TOP_anymatch_Person/StreamDemo/bin/Person.class new file mode 100644 index 000000000..88c675315 Binary files /dev/null and b/BasicJava/StreamDemo_TOP_anymatch_Person/StreamDemo/bin/Person.class differ diff --git a/BasicJava/StreamDemo_TOP_anymatch_Person/StreamDemo/bin/StreamAnyMatchDemo.class b/BasicJava/StreamDemo_TOP_anymatch_Person/StreamDemo/bin/StreamAnyMatchDemo.class new file mode 100644 index 000000000..873558c78 Binary files /dev/null and b/BasicJava/StreamDemo_TOP_anymatch_Person/StreamDemo/bin/StreamAnyMatchDemo.class differ diff --git a/BasicJava/StreamDemo_TOP_anymatch_Person/StreamDemo/src/Person.java b/BasicJava/StreamDemo_TOP_anymatch_Person/StreamDemo/src/Person.java new file mode 100644 index 000000000..a90a70b32 --- /dev/null +++ b/BasicJava/StreamDemo_TOP_anymatch_Person/StreamDemo/src/Person.java @@ -0,0 +1,62 @@ +enum Gender +{ + MALE, FEMALE +} + +public class Person +{ + private String name; + private String email; + private Gender gender; + private int age; + + public Person(String name, String email, Gender gender, int age) + { + super(); + this.name = name; + this.email = email; + this.gender = gender; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getEmail() + { + return email; + } + + public void setEmail(String email) + { + this.email = email; + } + + public Gender getGender() + { + return gender; + } + + public void setGender(Gender gender) + { + this.gender = gender; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_TOP_anymatch_Person/StreamDemo/src/StreamAnyMatchDemo.java b/BasicJava/StreamDemo_TOP_anymatch_Person/StreamDemo/src/StreamAnyMatchDemo.java new file mode 100644 index 000000000..37f2a9199 --- /dev/null +++ b/BasicJava/StreamDemo_TOP_anymatch_Person/StreamDemo/src/StreamAnyMatchDemo.java @@ -0,0 +1,40 @@ +import java.util.ArrayList; +import java.util.List; + +public class StreamAnyMatchDemo +{ + public static void main(String[] args) + { + List personList = new ArrayList<>(); + + personList.add(new Person("Alice","alice@gmail.com", Gender.FEMALE, 26)); + personList.add(new Person("Bob","bob@gmail.com", Gender.MALE, 32)); + personList.add(new Person("Carol","carol@gmail.com",Gender.FEMALE, 23)); + personList.add(new Person("David","david@gmail.com", Gender.MALE, 39)); + personList.add(new Person("Eric","eric@gmail.com", Gender.MALE, 26)); + personList.add(new Person("Frank","frank@gmail.com",Gender.MALE, 33)); + personList.add(new Person("Gibb","gibb@gmail.com", Gender.MALE, 27)); + personList.add(new Person("Henry","henry@gmail.com", Gender.MALE, 30)); + personList.add(new Person("Isabell","isabell@gmail.com",Gender.FEMALE, 22)); + personList.add(new Person("Jane","jane@gmail.com",Gender.FEMALE, 24)); + + /* + * The anyMatch() operation returns true if any element in the stream + * matches a provided predicate. In other words, it answers the + * following question: Is there any element that meets this condition? + * * + * The following example checks whether the list has any female: + */ + boolean anyFemale = personList.stream() + .anyMatch(p -> p.getGender().equals(Gender.FEMALE)); + + System.out.println("Is there any female? : " + anyFemale); + + + boolean anyOldPeople = personList.stream() + .anyMatch(p -> p.getAge() > 60); + + System.out.println("Is there any old people ? : " + anyOldPeople); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_TOP_nonematch_Person/Output.txt b/BasicJava/StreamDemo_TOP_nonematch_Person/Output.txt new file mode 100644 index 000000000..63832fa49 --- /dev/null +++ b/BasicJava/StreamDemo_TOP_nonematch_Person/Output.txt @@ -0,0 +1,2 @@ +No one uses Yahoo mail? : true +No one is less than 50? : false diff --git a/BasicJava/StreamDemo_TOP_nonematch_Person/StreamDemo/.classpath b/BasicJava/StreamDemo_TOP_nonematch_Person/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_TOP_nonematch_Person/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_TOP_nonematch_Person/StreamDemo/.project b/BasicJava/StreamDemo_TOP_nonematch_Person/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_TOP_nonematch_Person/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_TOP_nonematch_Person/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_TOP_nonematch_Person/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_TOP_nonematch_Person/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_TOP_nonematch_Person/StreamDemo/bin/Gender.class b/BasicJava/StreamDemo_TOP_nonematch_Person/StreamDemo/bin/Gender.class new file mode 100644 index 000000000..c667336c7 Binary files /dev/null and b/BasicJava/StreamDemo_TOP_nonematch_Person/StreamDemo/bin/Gender.class differ diff --git a/BasicJava/StreamDemo_TOP_nonematch_Person/StreamDemo/bin/Person.class b/BasicJava/StreamDemo_TOP_nonematch_Person/StreamDemo/bin/Person.class new file mode 100644 index 000000000..88c675315 Binary files /dev/null and b/BasicJava/StreamDemo_TOP_nonematch_Person/StreamDemo/bin/Person.class differ diff --git a/BasicJava/StreamDemo_TOP_nonematch_Person/StreamDemo/bin/StreamNoneMatchDemo.class b/BasicJava/StreamDemo_TOP_nonematch_Person/StreamDemo/bin/StreamNoneMatchDemo.class new file mode 100644 index 000000000..1d3d47300 Binary files /dev/null and b/BasicJava/StreamDemo_TOP_nonematch_Person/StreamDemo/bin/StreamNoneMatchDemo.class differ diff --git a/BasicJava/StreamDemo_TOP_nonematch_Person/StreamDemo/src/Person.java b/BasicJava/StreamDemo_TOP_nonematch_Person/StreamDemo/src/Person.java new file mode 100644 index 000000000..a90a70b32 --- /dev/null +++ b/BasicJava/StreamDemo_TOP_nonematch_Person/StreamDemo/src/Person.java @@ -0,0 +1,62 @@ +enum Gender +{ + MALE, FEMALE +} + +public class Person +{ + private String name; + private String email; + private Gender gender; + private int age; + + public Person(String name, String email, Gender gender, int age) + { + super(); + this.name = name; + this.email = email; + this.gender = gender; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getEmail() + { + return email; + } + + public void setEmail(String email) + { + this.email = email; + } + + public Gender getGender() + { + return gender; + } + + public void setGender(Gender gender) + { + this.gender = gender; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_TOP_nonematch_Person/StreamDemo/src/StreamNoneMatchDemo.java b/BasicJava/StreamDemo_TOP_nonematch_Person/StreamDemo/src/StreamNoneMatchDemo.java new file mode 100644 index 000000000..d26780832 --- /dev/null +++ b/BasicJava/StreamDemo_TOP_nonematch_Person/StreamDemo/src/StreamNoneMatchDemo.java @@ -0,0 +1,39 @@ +import java.util.ArrayList; +import java.util.List; + +public class StreamNoneMatchDemo +{ + public static void main(String[] args) + { + List personList = new ArrayList<>(); + + personList.add(new Person("Alice","alice@gmail.com", Gender.FEMALE, 26)); + personList.add(new Person("Bob","bob@gmail.com", Gender.MALE, 32)); + personList.add(new Person("Carol","carol@gmail.com",Gender.FEMALE, 23)); + personList.add(new Person("David","david@gmail.com", Gender.MALE, 39)); + personList.add(new Person("Eric","eric@gmail.com", Gender.MALE, 26)); + personList.add(new Person("Frank","frank@gmail.com",Gender.MALE, 33)); + personList.add(new Person("Gibb","gibb@gmail.com", Gender.MALE, 27)); + personList.add(new Person("Henry","henry@gmail.com", Gender.MALE, 30)); + personList.add(new Person("Isabell","isabell@gmail.com",Gender.FEMALE, 22)); + personList.add(new Person("Jane","jane@gmail.com",Gender.FEMALE, 24)); + + /* + * In contrast to the allMatch() operation, the noneMatch() operation + * returns true if no elements in the stream match a provided predicate. + * In other words, it answers the question: Does no element meet this + * condition? + */ + boolean noYahooMail = personList.stream() + .noneMatch(p -> p.getEmail().endsWith("yahoo.com")); + + System.out.println("No one uses Yahoo mail? : " + noYahooMail); + + + boolean lessThan50 = personList.stream() + .noneMatch(p -> p.getAge() < 50 ); + + System.out.println("No one is less than 50? : " + lessThan50); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Ter_Op_collect_App/StreamCollectorDemo1_Output.txt b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamCollectorDemo1_Output.txt new file mode 100644 index 000000000..5c27ae1b9 --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamCollectorDemo1_Output.txt @@ -0,0 +1 @@ +[Customer [firstName=Peter, lastName=John], Customer [firstName=Dave, lastName=John]] diff --git a/BasicJava/StreamDemo_Ter_Op_collect_App/StreamCollectorDemo2_Output.txt b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamCollectorDemo2_Output.txt new file mode 100644 index 000000000..53274141c --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamCollectorDemo2_Output.txt @@ -0,0 +1,3 @@ +Smith: [Customer [firstName=Steve, lastName=Smith]] +John: [Customer [firstName=Peter, lastName=John], Customer [firstName=Dave, lastName=John]] +pattinson: [Customer [firstName=Robert, lastName=pattinson]] diff --git a/BasicJava/StreamDemo_Ter_Op_collect_App/StreamCollectorDemo3_Output.txt b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamCollectorDemo3_Output.txt new file mode 100644 index 000000000..b7785f74b --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamCollectorDemo3_Output.txt @@ -0,0 +1 @@ +{Smith=Steve, John=Peter,Dave, pattinson=Robert} diff --git a/BasicJava/StreamDemo_Ter_Op_collect_App/StreamCollectorDemo4_Output.txt b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamCollectorDemo4_Output.txt new file mode 100644 index 000000000..51a015949 --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamCollectorDemo4_Output.txt @@ -0,0 +1 @@ +In customerList: [Peter, Dave] have the same lastName John. diff --git a/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/.classpath b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/.project b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/bin/Customer.class b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/bin/Customer.class new file mode 100644 index 000000000..ffedd25c5 Binary files /dev/null and b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/bin/Customer.class differ diff --git a/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/bin/StreamCollectorDemo1.class b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/bin/StreamCollectorDemo1.class new file mode 100644 index 000000000..c03f4aa59 Binary files /dev/null and b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/bin/StreamCollectorDemo1.class differ diff --git a/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/bin/StreamCollectorDemo2.class b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/bin/StreamCollectorDemo2.class new file mode 100644 index 000000000..294169892 Binary files /dev/null and b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/bin/StreamCollectorDemo2.class differ diff --git a/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/bin/StreamCollectorDemo3.class b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/bin/StreamCollectorDemo3.class new file mode 100644 index 000000000..73e97adc6 Binary files /dev/null and b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/bin/StreamCollectorDemo3.class differ diff --git a/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/bin/StreamCollectorDemo4.class b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/bin/StreamCollectorDemo4.class new file mode 100644 index 000000000..8652c013d Binary files /dev/null and b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/bin/StreamCollectorDemo4.class differ diff --git a/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/src/Customer.java b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/src/Customer.java new file mode 100644 index 000000000..e7c357475 --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/src/Customer.java @@ -0,0 +1,41 @@ + +public class Customer +{ + private String firstName; + private String lastName; + + public Customer(String firstName, String lastName) + { + super(); + this.firstName = firstName; + this.lastName = lastName; + } + + public String getFirstName() + { + return firstName; + } + + public void setFirstName(String firstName) + { + this.firstName = firstName; + } + + public String getLastName() + { + return lastName; + } + + public void setLastName(String lastName) + { + this.lastName = lastName; + } + + @Override + public String toString() + { + return "Customer [firstName=" + firstName + ", lastName=" + + lastName + "]"; + } + +} diff --git a/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/src/StreamCollectorDemo1.java b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/src/StreamCollectorDemo1.java new file mode 100644 index 000000000..0a2ca5215 --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/src/StreamCollectorDemo1.java @@ -0,0 +1,22 @@ +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +public class StreamCollectorDemo1 +{ + public static void main(String[] args) + { + List customerList = Arrays.asList( + new Customer("Peter", "John"), + new Customer("Steve", "Smith"), + new Customer("Dave", "John"), + new Customer("Robert", "pattinson")); + + List filteredList = customerList.stream() + .filter(c -> c.getLastName().startsWith("John")) + .collect(Collectors.toList()); + + System.out.println(filteredList); + + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/src/StreamCollectorDemo2.java b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/src/StreamCollectorDemo2.java new file mode 100644 index 000000000..23966fc90 --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/src/StreamCollectorDemo2.java @@ -0,0 +1,23 @@ +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class StreamCollectorDemo2 +{ + public static void main(String[] args) + { + List customerList = Arrays.asList( + new Customer("Peter", "John"), + new Customer("Steve", "Smith"), + new Customer("Dave", "John"), + new Customer("Robert", "pattinson")); + + Map> groupMap = customerList.stream() + .collect(Collectors.groupingBy(c -> c.getLastName())); + + groupMap.forEach( + (lastName, customer) -> System.out.println(lastName + ": " + customer)); + + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/src/StreamCollectorDemo3.java b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/src/StreamCollectorDemo3.java new file mode 100644 index 000000000..ae24f03a8 --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/src/StreamCollectorDemo3.java @@ -0,0 +1,26 @@ +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class StreamCollectorDemo3 +{ + public static void main(String[] args) + { + List customerList = Arrays.asList( + new Customer("Peter", "John"), + new Customer("Steve", "Smith"), + new Customer("Dave", "John"), + new Customer("Robert", "pattinson")); + + Map lastNameMap = customerList.stream() + .collect(Collectors.toMap( + c -> c.getLastName(), c -> c + .getFirstName(), + (firstName1, firstName2) -> firstName1 + "," + + firstName2)); + + System.out.println(lastNameMap); + + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/src/StreamCollectorDemo4.java b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/src/StreamCollectorDemo4.java new file mode 100644 index 000000000..e0fbba252 --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_collect_App/StreamDemo/src/StreamCollectorDemo4.java @@ -0,0 +1,25 @@ +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +public class StreamCollectorDemo4 +{ + public static void main(String[] args) + { + List customerList = Arrays.asList( + new Customer("Peter", "John"), + new Customer("Steve", "Smith"), + new Customer("Dave", "John"), + new Customer("Robert", "pattinson")); + + String joining = customerList.stream() + .filter(c -> c.getLastName().contains("John")) + .map(c -> c.getFirstName()) + .collect(Collectors.joining(", ", + "In customerList: [", + "] have the same lastName John.")); + + System.out.println(joining); + + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Ter_Op_match_App/Output.txt b/BasicJava/StreamDemo_Ter_Op_match_App/Output.txt new file mode 100644 index 000000000..dac32ecf1 --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_match_App/Output.txt @@ -0,0 +1,3 @@ +false +true +true diff --git a/BasicJava/StreamDemo_Ter_Op_match_App/StreamDemo/.classpath b/BasicJava/StreamDemo_Ter_Op_match_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_match_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_Ter_Op_match_App/StreamDemo/.project b/BasicJava/StreamDemo_Ter_Op_match_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_match_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_Ter_Op_match_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_Ter_Op_match_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_match_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_Ter_Op_match_App/StreamDemo/bin/StreamMatchDemo.class b/BasicJava/StreamDemo_Ter_Op_match_App/StreamDemo/bin/StreamMatchDemo.class new file mode 100644 index 000000000..e97ddebdd Binary files /dev/null and b/BasicJava/StreamDemo_Ter_Op_match_App/StreamDemo/bin/StreamMatchDemo.class differ diff --git a/BasicJava/StreamDemo_Ter_Op_match_App/StreamDemo/src/StreamMatchDemo.java b/BasicJava/StreamDemo_Ter_Op_match_App/StreamDemo/src/StreamMatchDemo.java new file mode 100644 index 000000000..e81f91c98 --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_match_App/StreamDemo/src/StreamMatchDemo.java @@ -0,0 +1,34 @@ +import java.util.Arrays; +import java.util.List; + +public class StreamMatchDemo +{ + public static void main(String[] args) + { + List numberList = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9); + + /* + * Returns:true if either all elements of the stream match the + * provided predicate or the stream is empty, otherwise false + */ + boolean isAllNumbersLargerThanFive = numberList.stream() + .allMatch(i -> i > 5); + System.out.println(isAllNumbersLargerThanFive); // false + + /* + * Returns:true if any elements of the stream match the + * provided predicate, otherwise false + */ + boolean hasNumberLargerThanFive = numberList.stream() + .anyMatch(i -> i > 5); + System.out.println(hasNumberLargerThanFive); // true + + /* + * Returns:true if either no elements of the stream match the + * provided predicate or the stream is empty, otherwise false + */ + boolean isNoneNumberLargerThanTen = numberList.stream() + .noneMatch(i -> i > 10); + System.out.println(isNoneNumberLargerThanTen); // true + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Ter_Op_match_modulus_App/Output.txt b/BasicJava/StreamDemo_Ter_Op_match_modulus_App/Output.txt new file mode 100644 index 000000000..bbe54cea2 --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_match_modulus_App/Output.txt @@ -0,0 +1,3 @@ +allMatch = false +anyMatch = true +noneMatch = false diff --git a/BasicJava/StreamDemo_Ter_Op_match_modulus_App/StreamDemo/.classpath b/BasicJava/StreamDemo_Ter_Op_match_modulus_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_match_modulus_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_Ter_Op_match_modulus_App/StreamDemo/.project b/BasicJava/StreamDemo_Ter_Op_match_modulus_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_match_modulus_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_Ter_Op_match_modulus_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_Ter_Op_match_modulus_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_match_modulus_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_Ter_Op_match_modulus_App/StreamDemo/bin/StreamMatchDemo.class b/BasicJava/StreamDemo_Ter_Op_match_modulus_App/StreamDemo/bin/StreamMatchDemo.class new file mode 100644 index 000000000..26823010d Binary files /dev/null and b/BasicJava/StreamDemo_Ter_Op_match_modulus_App/StreamDemo/bin/StreamMatchDemo.class differ diff --git a/BasicJava/StreamDemo_Ter_Op_match_modulus_App/StreamDemo/src/StreamMatchDemo.java b/BasicJava/StreamDemo_Ter_Op_match_modulus_App/StreamDemo/src/StreamMatchDemo.java new file mode 100644 index 000000000..f77980684 --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_match_modulus_App/StreamDemo/src/StreamMatchDemo.java @@ -0,0 +1,32 @@ +import java.util.Arrays; +import java.util.List; +import java.util.function.Predicate; + +public class StreamMatchDemo +{ + public static void main(String[] args) + { + + List list = Arrays.asList(3, 5, 6); + + Predicate p = num -> num % 2 == 0; + + /* + * allMatch(): It returns true if all elements of stream + * matches the given Predicate. + */ + System.out.println("allMatch = " + list.stream().allMatch(p)); + + /* + * anyMatch(): It returns true if any element of stream + * matches the given Predicate. + */ + System.out.println("anyMatch = " + list.stream().anyMatch(p)); + + /* + * noneMatch(): It returns true if none of the elements of + * stream matches the given Predicate. + */ + System.out.println("noneMatch = " + list.stream().noneMatch(p)); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamDemo/.classpath b/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamDemo/.project b/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamDemo/bin/StreamMaxDemo$1.class b/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamDemo/bin/StreamMaxDemo$1.class new file mode 100644 index 000000000..5ef59bb7e Binary files /dev/null and b/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamDemo/bin/StreamMaxDemo$1.class differ diff --git a/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamDemo/bin/StreamMaxDemo.class b/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamDemo/bin/StreamMaxDemo.class new file mode 100644 index 000000000..50a49ddee Binary files /dev/null and b/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamDemo/bin/StreamMaxDemo.class differ diff --git a/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamDemo/bin/StreamMinMaxDemo$1.class b/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamDemo/bin/StreamMinMaxDemo$1.class new file mode 100644 index 000000000..5ca48e8ad Binary files /dev/null and b/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamDemo/bin/StreamMinMaxDemo$1.class differ diff --git a/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamDemo/bin/StreamMinMaxDemo.class b/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamDemo/bin/StreamMinMaxDemo.class new file mode 100644 index 000000000..8200b8594 Binary files /dev/null and b/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamDemo/bin/StreamMinMaxDemo.class differ diff --git a/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamDemo/src/StreamMaxDemo.java b/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamDemo/src/StreamMaxDemo.java new file mode 100644 index 000000000..e79f77a59 --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamDemo/src/StreamMaxDemo.java @@ -0,0 +1,22 @@ +import java.util.Comparator; +import java.util.Optional; +import java.util.stream.Stream; + +public class StreamMaxDemo +{ + public static void main(String[] args) + { + + Optional optional = Stream.of("A", "B", "C") + .max(new Comparator() + { + @Override + public int compare(String o1, String o2) + { + return o1.compareTo(o2); + } + }); + System.out.println("optional = "+optional); + System.out.println("Max = "+optional.get()); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamDemo/src/StreamMinMaxDemo.java b/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamDemo/src/StreamMinMaxDemo.java new file mode 100644 index 000000000..75ab2699d --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamDemo/src/StreamMinMaxDemo.java @@ -0,0 +1,17 @@ +import java.util.OptionalInt; +import java.util.stream.IntStream; + +public class StreamMinMaxDemo +{ + public static void main(String[] args) + { + OptionalInt optionalIntMin = IntStream.of(1, 2, 3).min(); + System.out.println("optionalIntMin = " + optionalIntMin); + System.out.println("min = " + optionalIntMin.getAsInt()); + + OptionalInt optionalIntMax = IntStream.of(1, 2, 3).max(); + System.out.println("optionalIntMax = " + optionalIntMax); + System.out.println("max = " + optionalIntMax.getAsInt()); + + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamMaxDemo_Output.txt b/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamMaxDemo_Output.txt new file mode 100644 index 000000000..0e1c86193 --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamMaxDemo_Output.txt @@ -0,0 +1,2 @@ +optional = Optional[C] +Max = C diff --git a/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamMinMaxDemo_Output.txt b/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamMinMaxDemo_Output.txt new file mode 100644 index 000000000..04a220dee --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_min_max__App/StreamMinMaxDemo_Output.txt @@ -0,0 +1,4 @@ +optionalIntMin = OptionalInt[1] +min = 1 +optionalIntMax = OptionalInt[3] +max = 3 diff --git a/BasicJava/StreamDemo_Ter_Op_reduce_App/Output.txt b/BasicJava/StreamDemo_Ter_Op_reduce_App/Output.txt new file mode 100644 index 000000000..4c4870943 --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_reduce_App/Output.txt @@ -0,0 +1,2 @@ +max: 9 +total: 45 diff --git a/BasicJava/StreamDemo_Ter_Op_reduce_App/StreamDemo/.classpath b/BasicJava/StreamDemo_Ter_Op_reduce_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_reduce_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_Ter_Op_reduce_App/StreamDemo/.project b/BasicJava/StreamDemo_Ter_Op_reduce_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_reduce_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_Ter_Op_reduce_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_Ter_Op_reduce_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_reduce_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_Ter_Op_reduce_App/StreamDemo/bin/StreamReduceDemo.class b/BasicJava/StreamDemo_Ter_Op_reduce_App/StreamDemo/bin/StreamReduceDemo.class new file mode 100644 index 000000000..41d4de906 Binary files /dev/null and b/BasicJava/StreamDemo_Ter_Op_reduce_App/StreamDemo/bin/StreamReduceDemo.class differ diff --git a/BasicJava/StreamDemo_Ter_Op_reduce_App/StreamDemo/src/StreamReduceDemo.java b/BasicJava/StreamDemo_Ter_Op_reduce_App/StreamDemo/src/StreamReduceDemo.java new file mode 100644 index 000000000..1105fdda7 --- /dev/null +++ b/BasicJava/StreamDemo_Ter_Op_reduce_App/StreamDemo/src/StreamReduceDemo.java @@ -0,0 +1,21 @@ +import java.util.Arrays; +import java.util.List; + +public class StreamReduceDemo +{ + public static void main(String[] args) + { + List numberList = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9); + + /* + * reduce processes all elements of the stream and produces a + * single result. + */ + numberList.stream().reduce((i1, i2) -> i1 > i2 ? i1 : i2) + .ifPresent(i -> System.out.println("max: " + i)); + + Integer total = numberList.stream().reduce(0,(i1, i2) -> i1 + i2); + + System.out.println("total: " + total); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_Ter_op_Collect_summingint_App/Output.txt b/BasicJava/StreamDemo_Ter_op_Collect_summingint_App/Output.txt new file mode 100644 index 000000000..a044b2479 --- /dev/null +++ b/BasicJava/StreamDemo_Ter_op_Collect_summingint_App/Output.txt @@ -0,0 +1 @@ +Sum: 20 diff --git a/BasicJava/StreamDemo_Ter_op_Collect_summingint_App/StreamDemo/.classpath b/BasicJava/StreamDemo_Ter_op_Collect_summingint_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_Ter_op_Collect_summingint_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_Ter_op_Collect_summingint_App/StreamDemo/.project b/BasicJava/StreamDemo_Ter_op_Collect_summingint_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_Ter_op_Collect_summingint_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_Ter_op_Collect_summingint_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_Ter_op_Collect_summingint_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_Ter_op_Collect_summingint_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_Ter_op_Collect_summingint_App/StreamDemo/bin/StreamCollectDemo.class b/BasicJava/StreamDemo_Ter_op_Collect_summingint_App/StreamDemo/bin/StreamCollectDemo.class new file mode 100644 index 000000000..b08b2c731 Binary files /dev/null and b/BasicJava/StreamDemo_Ter_op_Collect_summingint_App/StreamDemo/bin/StreamCollectDemo.class differ diff --git a/BasicJava/StreamDemo_Ter_op_Collect_summingint_App/StreamDemo/src/StreamCollectDemo.java b/BasicJava/StreamDemo_Ter_op_Collect_summingint_App/StreamDemo/src/StreamCollectDemo.java new file mode 100644 index 000000000..3855378dc --- /dev/null +++ b/BasicJava/StreamDemo_Ter_op_Collect_summingint_App/StreamDemo/src/StreamCollectDemo.java @@ -0,0 +1,17 @@ +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +public class StreamCollectDemo +{ + public static void main(String[] args) + { + List list = Arrays.asList(5, 5, 10); + /* + * It performs mutable reduction operation with java 8 + * Collector. + */ + int sum = list.stream().collect(Collectors.summingInt(i -> i)); + System.out.println("Sum: " + sum); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_convert_list_array/StreamDemo/.classpath b/BasicJava/StreamDemo_convert_list_array/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_convert_list_array/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_convert_list_array/StreamDemo/.project b/BasicJava/StreamDemo_convert_list_array/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_convert_list_array/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_convert_list_array/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_convert_list_array/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_convert_list_array/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_convert_list_array/StreamDemo/bin/StreamDemo1.class b/BasicJava/StreamDemo_convert_list_array/StreamDemo/bin/StreamDemo1.class new file mode 100644 index 000000000..258ca8d5c Binary files /dev/null and b/BasicJava/StreamDemo_convert_list_array/StreamDemo/bin/StreamDemo1.class differ diff --git a/BasicJava/StreamDemo_convert_list_array/StreamDemo/bin/StreamDemo2.class b/BasicJava/StreamDemo_convert_list_array/StreamDemo/bin/StreamDemo2.class new file mode 100644 index 000000000..e614ffe02 Binary files /dev/null and b/BasicJava/StreamDemo_convert_list_array/StreamDemo/bin/StreamDemo2.class differ diff --git a/BasicJava/StreamDemo_convert_list_array/StreamDemo/src/StreamDemo1.java b/BasicJava/StreamDemo_convert_list_array/StreamDemo/src/StreamDemo1.java new file mode 100644 index 000000000..fc8bc822e --- /dev/null +++ b/BasicJava/StreamDemo_convert_list_array/StreamDemo/src/StreamDemo1.java @@ -0,0 +1,21 @@ +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/** + * Convert Streams to Other DataStructures + * + * Get Collections using stream.collect(Collectors.toList()). + */ +public class StreamDemo1 +{ + public static void main(String[] args) + { + Stream stream = Stream.of("Peter", "John", "Ram"); + + List nameList = stream.collect(Collectors.toList()); + + System.out.println(nameList); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_convert_list_array/StreamDemo/src/StreamDemo2.java b/BasicJava/StreamDemo_convert_list_array/StreamDemo/src/StreamDemo2.java new file mode 100644 index 000000000..ea2014031 --- /dev/null +++ b/BasicJava/StreamDemo_convert_list_array/StreamDemo/src/StreamDemo2.java @@ -0,0 +1,28 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; + +/** + * Convert Streams to Other DataStructures + * + * Get arrays using stream.toArray(EntryType[]::new) + */ +public class StreamDemo2 +{ + public static void main(String[] args) + { + List numberList = new ArrayList<>(); + numberList.add(1); + numberList.add(2); + numberList.add(3); + numberList.add(4); + + Stream stream = numberList.stream(); + Integer[] evenArray = stream.filter(i -> i % 2 == 0).toArray(Integer[]::new); + for (Integer integer : evenArray) + { + System.out.println(integer); + } + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_convert_list_array/StreamDemo1_Output.txt b/BasicJava/StreamDemo_convert_list_array/StreamDemo1_Output.txt new file mode 100644 index 000000000..cedfd3bf8 --- /dev/null +++ b/BasicJava/StreamDemo_convert_list_array/StreamDemo1_Output.txt @@ -0,0 +1 @@ +[Peter, John, Ram] diff --git a/BasicJava/StreamDemo_convert_list_array/StreamDemo2_Output.txt b/BasicJava/StreamDemo_convert_list_array/StreamDemo2_Output.txt new file mode 100644 index 000000000..da7f84740 --- /dev/null +++ b/BasicJava/StreamDemo_convert_list_array/StreamDemo2_Output.txt @@ -0,0 +1,2 @@ +2 +4 diff --git a/BasicJava/StreamDemo_diff_way_collect/Output.txt b/BasicJava/StreamDemo_diff_way_collect/Output.txt new file mode 100644 index 000000000..f81c16ed0 --- /dev/null +++ b/BasicJava/StreamDemo_diff_way_collect/Output.txt @@ -0,0 +1,5 @@ +emailList = [alice@gmail.com, bob@gmail.com, carol@gmail.com, david@gmail.com, eric@gmail.com] +setEmails = [alice@gmail.com, bob@gmail.com, carol@gmail.com, david@gmail.com, eric@gmail.com] +Groups by gender = {FEMALE=[Person [name=Alice], Person [name=Carol]], + MALE=[Person [name=Bob], Person [name=David], Person [name=Eric]]} +names = Alice, Bob, Carol, David, Eric diff --git a/BasicJava/StreamDemo_diff_way_collect/StreamDemo/.classpath b/BasicJava/StreamDemo_diff_way_collect/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_diff_way_collect/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_diff_way_collect/StreamDemo/.project b/BasicJava/StreamDemo_diff_way_collect/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_diff_way_collect/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_diff_way_collect/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_diff_way_collect/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_diff_way_collect/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_diff_way_collect/StreamDemo/bin/Gender.class b/BasicJava/StreamDemo_diff_way_collect/StreamDemo/bin/Gender.class new file mode 100644 index 000000000..c667336c7 Binary files /dev/null and b/BasicJava/StreamDemo_diff_way_collect/StreamDemo/bin/Gender.class differ diff --git a/BasicJava/StreamDemo_diff_way_collect/StreamDemo/bin/Person.class b/BasicJava/StreamDemo_diff_way_collect/StreamDemo/bin/Person.class new file mode 100644 index 000000000..eda7e7dcb Binary files /dev/null and b/BasicJava/StreamDemo_diff_way_collect/StreamDemo/bin/Person.class differ diff --git a/BasicJava/StreamDemo_diff_way_collect/StreamDemo/bin/StreamCollectDemo.class b/BasicJava/StreamDemo_diff_way_collect/StreamDemo/bin/StreamCollectDemo.class new file mode 100644 index 000000000..86aa68cdc Binary files /dev/null and b/BasicJava/StreamDemo_diff_way_collect/StreamDemo/bin/StreamCollectDemo.class differ diff --git a/BasicJava/StreamDemo_diff_way_collect/StreamDemo/src/Person.java b/BasicJava/StreamDemo_diff_way_collect/StreamDemo/src/Person.java new file mode 100644 index 000000000..0e39eeb00 --- /dev/null +++ b/BasicJava/StreamDemo_diff_way_collect/StreamDemo/src/Person.java @@ -0,0 +1,68 @@ +enum Gender +{ + MALE, FEMALE +} + +public class Person +{ + private String name; + private String email; + private Gender gender; + private int age; + + public Person(String name, String email, Gender gender, int age) + { + super(); + this.name = name; + this.email = email; + this.gender = gender; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getEmail() + { + return email; + } + + public void setEmail(String email) + { + this.email = email; + } + + public Gender getGender() + { + return gender; + } + + public void setGender(Gender gender) + { + this.gender = gender; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + @Override + public String toString() + { + return "Person [name=" + name + "]"; + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_diff_way_collect/StreamDemo/src/StreamCollectDemo.java b/BasicJava/StreamDemo_diff_way_collect/StreamDemo/src/StreamCollectDemo.java new file mode 100644 index 000000000..d0be43eb1 --- /dev/null +++ b/BasicJava/StreamDemo_diff_way_collect/StreamDemo/src/StreamCollectDemo.java @@ -0,0 +1,68 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; +import java.util.stream.Collectors; + +public class StreamCollectDemo +{ + public static void main(String[] args) + { + List personList = new ArrayList<>(); + + personList.add(new Person("Alice","alice@gmail.com",Gender.FEMALE, 26)); + personList.add(new Person("Bob","bob@gmail.com", Gender.MALE, 32)); + personList.add(new Person("Carol","carol@gmail.com",Gender.FEMALE, 23)); + personList.add(new Person("David","david@gmail.com", Gender.MALE, 39)); + personList.add(new Person("Eric","eric@gmail.com", Gender.MALE, 26)); + + /* + * The collect() operation accumulates elements in a stream into a + * container such as a collection. It performs mutable reduction + * operation in which the reduced (final) value is a mutable result + * container such as an ArrayList. This method takes a Collector + * implementation that provides useful reduction operations. The + * Collectors class is a common implementation in the JDK. And we are + * going to see how it is used in the following examples. + * + * The following code accumulates emails of the persons into a list + * collection: + */ + List emailList = personList.stream() // Stream + .map(p -> p.getEmail()) // Stream + .collect(Collectors.toList()); + + System.out.println("emailList = "+ emailList); + + /* + * We can specify exactly which type of collection as the result. For + * example, the following code collects emails into a TreeSet: + */ + Set setEmails = personList.stream() // Stream + .map(p -> p.getEmail()) // Stream + .collect(Collectors.toCollection(TreeSet::new)); + + System.out.println("setEmails = "+ setEmails); + + /* + * The following code groups the person by gender: + */ + Map> byGenderMap = personList.stream() + .collect(Collectors.groupingBy(p -> p.getGender())); + + System.out.println("Groups by gender = " + byGenderMap); + + /* + * The following code accumulates names and concatenates them into + * a String, separated by commas: + */ + String names = personList.stream() //Stream + .map(p -> p.getName()) // Stream + .collect(Collectors.joining(", ")); + + System.out.println("names = "+names); + + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_distinct_count_App/Output.txt b/BasicJava/StreamDemo_distinct_count_App/Output.txt new file mode 100644 index 000000000..0012a9ddb --- /dev/null +++ b/BasicJava/StreamDemo_distinct_count_App/Output.txt @@ -0,0 +1 @@ +Distinct Count: 3 diff --git a/BasicJava/StreamDemo_distinct_count_App/StreamDemo/.classpath b/BasicJava/StreamDemo_distinct_count_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_distinct_count_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_distinct_count_App/StreamDemo/.project b/BasicJava/StreamDemo_distinct_count_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_distinct_count_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_distinct_count_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_distinct_count_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_distinct_count_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_distinct_count_App/StreamDemo/bin/StreamDistinctDemo.class b/BasicJava/StreamDemo_distinct_count_App/StreamDemo/bin/StreamDistinctDemo.class new file mode 100644 index 000000000..76bac6476 Binary files /dev/null and b/BasicJava/StreamDemo_distinct_count_App/StreamDemo/bin/StreamDistinctDemo.class differ diff --git a/BasicJava/StreamDemo_distinct_count_App/StreamDemo/src/StreamDistinctDemo.java b/BasicJava/StreamDemo_distinct_count_App/StreamDemo/src/StreamDistinctDemo.java new file mode 100644 index 000000000..8d37855c9 --- /dev/null +++ b/BasicJava/StreamDemo_distinct_count_App/StreamDemo/src/StreamDistinctDemo.java @@ -0,0 +1,18 @@ +import java.util.Arrays; +import java.util.List; + +public class StreamDistinctDemo +{ + public static void main(String[] args) + { + List list = Arrays.asList(3, 4, 4, 6, 6, 4); + + /* + * Stream.distinct() + * + * It returns stream with distinct elements. + */ + System.out.println("Distinct Count: " + + list.stream().distinct().count()); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_distinct_sort_name_age/StreamDemo/.classpath b/BasicJava/StreamDemo_distinct_sort_name_age/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_distinct_sort_name_age/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_distinct_sort_name_age/StreamDemo/.project b/BasicJava/StreamDemo_distinct_sort_name_age/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_distinct_sort_name_age/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_distinct_sort_name_age/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_distinct_sort_name_age/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_distinct_sort_name_age/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_distinct_sort_name_age/StreamDemo/bin/Gender.class b/BasicJava/StreamDemo_distinct_sort_name_age/StreamDemo/bin/Gender.class new file mode 100644 index 000000000..c667336c7 Binary files /dev/null and b/BasicJava/StreamDemo_distinct_sort_name_age/StreamDemo/bin/Gender.class differ diff --git a/BasicJava/StreamDemo_distinct_sort_name_age/StreamDemo/bin/Person.class b/BasicJava/StreamDemo_distinct_sort_name_age/StreamDemo/bin/Person.class new file mode 100644 index 000000000..2c56c3967 Binary files /dev/null and b/BasicJava/StreamDemo_distinct_sort_name_age/StreamDemo/bin/Person.class differ diff --git a/BasicJava/StreamDemo_distinct_sort_name_age/StreamDemo/bin/StreamDistinctDemo1.class b/BasicJava/StreamDemo_distinct_sort_name_age/StreamDemo/bin/StreamDistinctDemo1.class new file mode 100644 index 000000000..d8f12cb09 Binary files /dev/null and b/BasicJava/StreamDemo_distinct_sort_name_age/StreamDemo/bin/StreamDistinctDemo1.class differ diff --git a/BasicJava/StreamDemo_distinct_sort_name_age/StreamDemo/bin/StreamDistinctDemo2.class b/BasicJava/StreamDemo_distinct_sort_name_age/StreamDemo/bin/StreamDistinctDemo2.class new file mode 100644 index 000000000..70c59abf3 Binary files /dev/null and b/BasicJava/StreamDemo_distinct_sort_name_age/StreamDemo/bin/StreamDistinctDemo2.class differ diff --git a/BasicJava/StreamDemo_distinct_sort_name_age/StreamDemo/src/Person.java b/BasicJava/StreamDemo_distinct_sort_name_age/StreamDemo/src/Person.java new file mode 100644 index 000000000..21b811070 --- /dev/null +++ b/BasicJava/StreamDemo_distinct_sort_name_age/StreamDemo/src/Person.java @@ -0,0 +1,74 @@ +enum Gender +{ + MALE, FEMALE +} + +public class Person implements Comparable +{ + private String name; + private String email; + private Gender gender; + private int age; + + public Person(String name, String email, Gender gender, int age) + { + super(); + this.name = name; + this.email = email; + this.gender = gender; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getEmail() + { + return email; + } + + public void setEmail(String email) + { + this.email = email; + } + + public Gender getGender() + { + return gender; + } + + public void setGender(Gender gender) + { + this.gender = gender; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + public int compareTo(Person another) + { + return this.age - another.getAge(); + } + + @Override + public String toString() + { + return "Person [name=" + name + ", gender=" + gender + ", age=" + age + + "]"; + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_distinct_sort_name_age/StreamDemo/src/StreamDistinctDemo1.java b/BasicJava/StreamDemo_distinct_sort_name_age/StreamDemo/src/StreamDistinctDemo1.java new file mode 100644 index 000000000..b7f64e040 --- /dev/null +++ b/BasicJava/StreamDemo_distinct_sort_name_age/StreamDemo/src/StreamDistinctDemo1.java @@ -0,0 +1,30 @@ +import java.util.ArrayList; +import java.util.List; + +public class StreamDistinctDemo1 +{ + public static void main(String[] args) + { + List personList = new ArrayList<>(); + + personList.add(new Person("Alice", "alice@gmail.com", Gender.FEMALE, 15)); + personList.add(new Person("Bob", "bob@gmail.com", Gender.MALE, 15)); + personList.add(new Person("Carol", "carol@gmail.com", Gender.FEMALE, 23)); + personList.add(new Person("David", "david@gmail.com", Gender.MALE, 19)); + personList.add(new Person("Eric", "eric@gmail.com", Gender.MALE, 15)); + + /* + * The distinct() operation returns a stream consisting of the distinct + * elements (no duplicates) by comparing objects via their equals() + * method. + * + * Combining with the map and sorted operations, the following code + * shows distinct age of the persons in the above list, and sorts them + * in asc order: + * + */ + personList.stream().mapToInt(p -> p.getAge()).distinct().sorted() + .forEach(System.out::println); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_distinct_sort_name_age/StreamDemo/src/StreamDistinctDemo2.java b/BasicJava/StreamDemo_distinct_sort_name_age/StreamDemo/src/StreamDistinctDemo2.java new file mode 100644 index 000000000..feb412ea4 --- /dev/null +++ b/BasicJava/StreamDemo_distinct_sort_name_age/StreamDemo/src/StreamDistinctDemo2.java @@ -0,0 +1,17 @@ +import java.util.Arrays; + +public class StreamDistinctDemo2 +{ + public static void main(String[] args) + { + int[] numberArray = { 10, 10, 20, 20, 20 }; + + /* + * The following code returns a stream of distinct numbers from an + * array source + */ + Arrays.stream(numberArray).distinct() + .forEach(i -> System.out.print(i + " ")); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_distinct_sort_name_age/StreamDistinctDemo1_Output.txt b/BasicJava/StreamDemo_distinct_sort_name_age/StreamDistinctDemo1_Output.txt new file mode 100644 index 000000000..498f3e2e8 --- /dev/null +++ b/BasicJava/StreamDemo_distinct_sort_name_age/StreamDistinctDemo1_Output.txt @@ -0,0 +1,3 @@ +15 +19 +23 diff --git a/BasicJava/StreamDemo_distinct_sort_name_age/StreamDistinctDemo2_Output.txt b/BasicJava/StreamDemo_distinct_sort_name_age/StreamDistinctDemo2_Output.txt new file mode 100644 index 000000000..d628ce4c0 --- /dev/null +++ b/BasicJava/StreamDemo_distinct_sort_name_age/StreamDistinctDemo2_Output.txt @@ -0,0 +1 @@ +10 20 \ No newline at end of file diff --git a/BasicJava/StreamDemo_filter_PL_name_age_App/Output.txt b/BasicJava/StreamDemo_filter_PL_name_age_App/Output.txt new file mode 100644 index 000000000..b7b6b50cf --- /dev/null +++ b/BasicJava/StreamDemo_filter_PL_name_age_App/Output.txt @@ -0,0 +1 @@ +Person [id=2, name=Peter, age=31] diff --git a/BasicJava/StreamDemo_filter_PL_name_age_App/StreamDemo/.classpath b/BasicJava/StreamDemo_filter_PL_name_age_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_filter_PL_name_age_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_filter_PL_name_age_App/StreamDemo/.project b/BasicJava/StreamDemo_filter_PL_name_age_App/StreamDemo/.project new file mode 100644 index 000000000..b6dfe7639 --- /dev/null +++ b/BasicJava/StreamDemo_filter_PL_name_age_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamsDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_filter_PL_name_age_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_filter_PL_name_age_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_filter_PL_name_age_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_filter_PL_name_age_App/StreamDemo/bin/Person.class b/BasicJava/StreamDemo_filter_PL_name_age_App/StreamDemo/bin/Person.class new file mode 100644 index 000000000..4a6e99281 Binary files /dev/null and b/BasicJava/StreamDemo_filter_PL_name_age_App/StreamDemo/bin/Person.class differ diff --git a/BasicJava/StreamDemo_filter_PL_name_age_App/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_filter_PL_name_age_App/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..e09308660 Binary files /dev/null and b/BasicJava/StreamDemo_filter_PL_name_age_App/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_filter_PL_name_age_App/StreamDemo/src/Person.java b/BasicJava/StreamDemo_filter_PL_name_age_App/StreamDemo/src/Person.java new file mode 100644 index 000000000..c62fe352e --- /dev/null +++ b/BasicJava/StreamDemo_filter_PL_name_age_App/StreamDemo/src/Person.java @@ -0,0 +1,52 @@ +public class Person +{ + private int id; + private String name; + private int age; + + public Person(int id, String name, int age) + { + super(); + this.id = id; + this.name = name; + this.age = age; + } + + public int getId() + { + return id; + } + + public void setId(int id) + { + this.id = id; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + @Override + public String toString() + { + return "Person [id=" + id + ", name=" + name + ", age=" + age + + "]"; + } + +} diff --git a/BasicJava/StreamDemo_filter_PL_name_age_App/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_filter_PL_name_age_App/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..74ffbf471 --- /dev/null +++ b/BasicJava/StreamDemo_filter_PL_name_age_App/StreamDemo/src/StreamDemo.java @@ -0,0 +1,29 @@ +import java.util.Arrays; +import java.util.List; + +/** + * + * How to filter the person object from personList based on Name and + * age? + * + */ +public class StreamDemo +{ + public static void main(String[] args) + { + + List personList = Arrays.asList(new Person(1, "Ram", 25), + new Person(2, "Peter", 31), + new Person(3, "Steve", 25), + new Person(4, "Balu", 32)); + + + Person person = personList.stream() //convert list to stream + .filter(x -> "Peter".equals(x.getName()) && 31 ==x.getAge() ) // we want "Peter" with age 31 only + .findAny() // If 'findAny' then return found + .orElse(null); // If not found, return null + + System.out.println(person); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_filter_fruits_map/Output.txt b/BasicJava/StreamDemo_filter_fruits_map/Output.txt new file mode 100644 index 000000000..2a2d65d84 --- /dev/null +++ b/BasicJava/StreamDemo_filter_fruits_map/Output.txt @@ -0,0 +1,2 @@ +Before Java 8 : Orange +With Java 8 : Orange diff --git a/BasicJava/StreamDemo_filter_fruits_map/StreamDemo/.classpath b/BasicJava/StreamDemo_filter_fruits_map/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_filter_fruits_map/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_filter_fruits_map/StreamDemo/.project b/BasicJava/StreamDemo_filter_fruits_map/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_filter_fruits_map/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_filter_fruits_map/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_filter_fruits_map/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_filter_fruits_map/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_filter_fruits_map/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_filter_fruits_map/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..e2e985ab3 Binary files /dev/null and b/BasicJava/StreamDemo_filter_fruits_map/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_filter_fruits_map/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_filter_fruits_map/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..b7404ca39 --- /dev/null +++ b/BasicJava/StreamDemo_filter_fruits_map/StreamDemo/src/StreamDemo.java @@ -0,0 +1,39 @@ +import java.util.HashMap; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * + * Example to filter a Map and return a value. + */ +public class StreamDemo +{ + public static void main(String[] args) + { + + Map fruitsMap = new HashMap<>(); + fruitsMap.put(1, "Apple"); + fruitsMap.put(2, "Orange"); + fruitsMap.put(3, "Banana"); + + String result = ""; + for (Map.Entry entry : fruitsMap.entrySet()) + { + if (2 == entry.getKey()) + { + result = entry.getValue(); + } + } + System.out.println("Before Java 8 : " + result); + + // Map -> Stream -> Filter -> String + result = fruitsMap.entrySet().stream() + .filter(map -> 2 == map.getKey()) + .map(map -> map.getValue()) + .collect(Collectors.joining()); + + System.out.println("With Java 8 : " + result); + + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_filter_fruits_map_return_map/Output.txt b/BasicJava/StreamDemo_filter_fruits_map_return_map/Output.txt new file mode 100644 index 000000000..9174ed8e5 --- /dev/null +++ b/BasicJava/StreamDemo_filter_fruits_map_return_map/Output.txt @@ -0,0 +1 @@ +{2=Orange} diff --git a/BasicJava/StreamDemo_filter_fruits_map_return_map/StreamDemo/.classpath b/BasicJava/StreamDemo_filter_fruits_map_return_map/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_filter_fruits_map_return_map/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_filter_fruits_map_return_map/StreamDemo/.project b/BasicJava/StreamDemo_filter_fruits_map_return_map/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_filter_fruits_map_return_map/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_filter_fruits_map_return_map/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_filter_fruits_map_return_map/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_filter_fruits_map_return_map/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_filter_fruits_map_return_map/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_filter_fruits_map_return_map/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..d0c2dd3e4 Binary files /dev/null and b/BasicJava/StreamDemo_filter_fruits_map_return_map/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_filter_fruits_map_return_map/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_filter_fruits_map_return_map/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..6c189c7ff --- /dev/null +++ b/BasicJava/StreamDemo_filter_fruits_map_return_map/StreamDemo/src/StreamDemo.java @@ -0,0 +1,28 @@ +import java.util.HashMap; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * + * Example to filter a Map and return a map. + */ +public class StreamDemo +{ + public static void main(String[] args) + { + + Map fruitsMap = new HashMap<>(); + fruitsMap.put(1, "Apple"); + fruitsMap.put(2, "Orange"); + fruitsMap.put(3, "Banana"); + + //Map -> Stream -> Filter -> Map + Map filteredMap = fruitsMap.entrySet().stream() + .filter(map -> map.getKey() == 2) + .collect(Collectors.toMap(p -> p.getKey(), p -> p.getValue())); + + System.out.println(filteredMap); + + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_filter_modulus_App/Output.txt b/BasicJava/StreamDemo_filter_modulus_App/Output.txt new file mode 100644 index 000000000..0bfcbc33a --- /dev/null +++ b/BasicJava/StreamDemo_filter_modulus_App/Output.txt @@ -0,0 +1 @@ +4 6 \ No newline at end of file diff --git a/BasicJava/StreamDemo_filter_modulus_App/StreamDemo/.classpath b/BasicJava/StreamDemo_filter_modulus_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_filter_modulus_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_filter_modulus_App/StreamDemo/.project b/BasicJava/StreamDemo_filter_modulus_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_filter_modulus_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_filter_modulus_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_filter_modulus_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_filter_modulus_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_filter_modulus_App/StreamDemo/bin/StreamFilterDemo.class b/BasicJava/StreamDemo_filter_modulus_App/StreamDemo/bin/StreamFilterDemo.class new file mode 100644 index 000000000..63098687f Binary files /dev/null and b/BasicJava/StreamDemo_filter_modulus_App/StreamDemo/bin/StreamFilterDemo.class differ diff --git a/BasicJava/StreamDemo_filter_modulus_App/StreamDemo/src/StreamFilterDemo.java b/BasicJava/StreamDemo_filter_modulus_App/StreamDemo/src/StreamFilterDemo.java new file mode 100644 index 000000000..15116c352 --- /dev/null +++ b/BasicJava/StreamDemo_filter_modulus_App/StreamDemo/src/StreamFilterDemo.java @@ -0,0 +1,21 @@ +import java.util.Arrays; +import java.util.List; +import java.util.function.Predicate; + +public class StreamFilterDemo +{ + public static void main(String[] args) + { + List list = Arrays.asList(3, 4, 6); + + /* + * Stream.filter() + * + * It returns the stream with the elements that matches the + * given Predicate. + */ + Predicate p = num -> num % 2 == 0; + list.stream().filter(p) + .forEach(e -> System.out.print(e + " ")); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_filter_name_gt_4_App/Output.txt b/BasicJava/StreamDemo_filter_name_gt_4_App/Output.txt new file mode 100644 index 000000000..a2b2d7c47 --- /dev/null +++ b/BasicJava/StreamDemo_filter_name_gt_4_App/Output.txt @@ -0,0 +1,2 @@ +Peter +Steve diff --git a/BasicJava/StreamDemo_filter_name_gt_4_App/StreamDemo/.classpath b/BasicJava/StreamDemo_filter_name_gt_4_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_filter_name_gt_4_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_filter_name_gt_4_App/StreamDemo/.project b/BasicJava/StreamDemo_filter_name_gt_4_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_filter_name_gt_4_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_filter_name_gt_4_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_filter_name_gt_4_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_filter_name_gt_4_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_filter_name_gt_4_App/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_filter_name_gt_4_App/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..9b726ed3e Binary files /dev/null and b/BasicJava/StreamDemo_filter_name_gt_4_App/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_filter_name_gt_4_App/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_filter_name_gt_4_App/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..dc4ad7cbb --- /dev/null +++ b/BasicJava/StreamDemo_filter_name_gt_4_App/StreamDemo/src/StreamDemo.java @@ -0,0 +1,36 @@ +import java.util.Arrays; +import java.util.stream.Stream; + +/** + * If you have an array of strings, and you want to create a subset of + * it which contains only those strings whose length is more than four + * characters,then use below program. + * + * How to filter the names whose length is greater than 4? + */ +public class StreamDemo +{ + public static void main(String[] args) + { + String[] nameArray = new String[] { "Peter", "Steve", "paul","Ram" }; + + Stream stream = Arrays.stream(nameArray); + + /* + * The filter method expects a lambda expression as its + * argument. However, the lambda expression passed to it must + * always return a boolean value, which determines whether or + * not the processed element should belong to the resulting + * Stream object. + */ + Stream filteredStream = stream.filter(name -> name.length() > 4); + + String[] filteredNameArray = filteredStream.toArray(String[]::new); + + for (String name : filteredNameArray) + { + System.out.println(name); + } + + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_filter_person_male_age/Output.txt b/BasicJava/StreamDemo_filter_person_male_age/Output.txt new file mode 100644 index 000000000..3a042e1ca --- /dev/null +++ b/BasicJava/StreamDemo_filter_person_male_age/Output.txt @@ -0,0 +1,7 @@ +--------Filterd based on FEMALE-------- +Person [name=Alice, gender=FEMALE, age=16] +Person [name=Carol, gender=FEMALE, age=23] + +--------Filterd based on Male and Age<=25-------- +Person [name=Bob, gender=MALE, age=15] +Person [name=David, gender=MALE, age=19] diff --git a/BasicJava/StreamDemo_filter_person_male_age/StreamDemo/.classpath b/BasicJava/StreamDemo_filter_person_male_age/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_filter_person_male_age/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_filter_person_male_age/StreamDemo/.project b/BasicJava/StreamDemo_filter_person_male_age/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_filter_person_male_age/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_filter_person_male_age/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_filter_person_male_age/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_filter_person_male_age/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_filter_person_male_age/StreamDemo/bin/Gender.class b/BasicJava/StreamDemo_filter_person_male_age/StreamDemo/bin/Gender.class new file mode 100644 index 000000000..c667336c7 Binary files /dev/null and b/BasicJava/StreamDemo_filter_person_male_age/StreamDemo/bin/Gender.class differ diff --git a/BasicJava/StreamDemo_filter_person_male_age/StreamDemo/bin/Person.class b/BasicJava/StreamDemo_filter_person_male_age/StreamDemo/bin/Person.class new file mode 100644 index 000000000..71efbdf36 Binary files /dev/null and b/BasicJava/StreamDemo_filter_person_male_age/StreamDemo/bin/Person.class differ diff --git a/BasicJava/StreamDemo_filter_person_male_age/StreamDemo/bin/StreamFilterDemo.class b/BasicJava/StreamDemo_filter_person_male_age/StreamDemo/bin/StreamFilterDemo.class new file mode 100644 index 000000000..dca2993e4 Binary files /dev/null and b/BasicJava/StreamDemo_filter_person_male_age/StreamDemo/bin/StreamFilterDemo.class differ diff --git a/BasicJava/StreamDemo_filter_person_male_age/StreamDemo/src/Person.java b/BasicJava/StreamDemo_filter_person_male_age/StreamDemo/src/Person.java new file mode 100644 index 000000000..578960566 --- /dev/null +++ b/BasicJava/StreamDemo_filter_person_male_age/StreamDemo/src/Person.java @@ -0,0 +1,69 @@ +enum Gender +{ + MALE, FEMALE +} + +public class Person +{ + private String name; + private String email; + private Gender gender; + private int age; + + public Person(String name, String email, Gender gender, int age) + { + super(); + this.name = name; + this.email = email; + this.gender = gender; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getEmail() + { + return email; + } + + public void setEmail(String email) + { + this.email = email; + } + + public Gender getGender() + { + return gender; + } + + public void setGender(Gender gender) + { + this.gender = gender; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + @Override + public String toString() + { + return "Person [name=" + name + ", gender=" + gender + ", age=" + age + + "]"; + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_filter_person_male_age/StreamDemo/src/StreamFilterDemo.java b/BasicJava/StreamDemo_filter_person_male_age/StreamDemo/src/StreamFilterDemo.java new file mode 100644 index 000000000..b8d96abb9 --- /dev/null +++ b/BasicJava/StreamDemo_filter_person_male_age/StreamDemo/src/StreamFilterDemo.java @@ -0,0 +1,39 @@ +import java.util.ArrayList; +import java.util.List; + +public class StreamFilterDemo +{ + public static void main(String[] args) + { + List personList = new ArrayList<>(); + + personList.add(new Person("Alice","alice@gmail.com",Gender.FEMALE, 16)); + personList.add(new Person("Bob","bob@gmail.com", Gender.MALE, 15)); + personList.add(new Person("Carol","carol@gmail.com",Gender.FEMALE, 23)); + personList.add(new Person("David","david@gmail.com", Gender.MALE, 19)); + personList.add(new Person("Eric","eric@gmail.com", Gender.MALE, 26)); + + System.out.println("--------Filterd based on FEMALE--------"); + + /* + * The filter() operation returns a new stream that consists elements + * matching a given condition which is typically a boolean test in form + * of a Lambda expression. + * + * The following code lists only female persons: + */ + personList.stream().filter(p -> p.getGender().equals(Gender.FEMALE)) + .forEach(System.out::println); + + + System.out.println("\n--------Filterd based on Male and Age<=25--------"); + + /* + * The following code shows only male who are under 25: + */ + personList.stream().filter(p -> p.getGender().equals(Gender.MALE) && p.getAge() <= 25) + .forEach(System.out::println); + + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_filter_productList_app/FilterDemo_Output.txt b/BasicJava/StreamDemo_filter_productList_app/FilterDemo_Output.txt new file mode 100644 index 000000000..2a259dfc9 --- /dev/null +++ b/BasicJava/StreamDemo_filter_productList_app/FilterDemo_Output.txt @@ -0,0 +1 @@ +[Product [id=2, name=Lenovo mobile, price=15000], Product [id=3, name=Nokia mobile, price=10000]] diff --git a/BasicJava/StreamDemo_filter_productList_app/StreamDemo/.classpath b/BasicJava/StreamDemo_filter_productList_app/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_filter_productList_app/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_filter_productList_app/StreamDemo/.project b/BasicJava/StreamDemo_filter_productList_app/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_filter_productList_app/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_filter_productList_app/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_filter_productList_app/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_filter_productList_app/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_filter_productList_app/StreamDemo/bin/FilterDemo.class b/BasicJava/StreamDemo_filter_productList_app/StreamDemo/bin/FilterDemo.class new file mode 100644 index 000000000..b8a19d79b Binary files /dev/null and b/BasicJava/StreamDemo_filter_productList_app/StreamDemo/bin/FilterDemo.class differ diff --git a/BasicJava/StreamDemo_filter_productList_app/StreamDemo/bin/Product.class b/BasicJava/StreamDemo_filter_productList_app/StreamDemo/bin/Product.class new file mode 100644 index 000000000..2a97ce097 Binary files /dev/null and b/BasicJava/StreamDemo_filter_productList_app/StreamDemo/bin/Product.class differ diff --git a/BasicJava/StreamDemo_filter_productList_app/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_filter_productList_app/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..591156ad5 Binary files /dev/null and b/BasicJava/StreamDemo_filter_productList_app/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_filter_productList_app/StreamDemo/src/FilterDemo.java b/BasicJava/StreamDemo_filter_productList_app/StreamDemo/src/FilterDemo.java new file mode 100644 index 000000000..d2109392b --- /dev/null +++ b/BasicJava/StreamDemo_filter_productList_app/StreamDemo/src/FilterDemo.java @@ -0,0 +1,44 @@ +import java.util.ArrayList; +import java.util.List; + +/** + * Filtering Collection without using Stream: + * + * In this example, We are filtering data without using + * stream. This approach we are used before the stream package was + * released. + * + */ + +public class FilterDemo +{ + public static void main(String[] args) + { + List productList = new ArrayList(); + + // Adding Products + productList.add(new Product(1, "Sony mobile", 25000)); + productList.add(new Product(2, "Lenovo mobile", 15000)); + productList.add(new Product(3, "Nokia mobile", 10000)); + productList.add(new Product(4, "Samsung mobile", 40000)); + + List filteredProductList = new ArrayList(); + + for (Product product : productList) + { + + /* + * Filter the product, whose price is less than 20000 and + * add the product in filteredProductList. + * + */ + if (product.getPrice() < 20000) + { + // Adding product + filteredProductList.add(product); + } + } + System.out.println(filteredProductList); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_filter_productList_app/StreamDemo/src/Product.java b/BasicJava/StreamDemo_filter_productList_app/StreamDemo/src/Product.java new file mode 100644 index 000000000..9e53fdc45 --- /dev/null +++ b/BasicJava/StreamDemo_filter_productList_app/StreamDemo/src/Product.java @@ -0,0 +1,52 @@ +class Product +{ + private int id; + private String name; + private int price; + + public Product(int id, String name, int price) + { + super(); + this.id = id; + this.name = name; + this.price = price; + } + + public int getId() + { + return id; + } + + public void setId(int id) + { + this.id = id; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getPrice() + { + return price; + } + + public void setPrice(int price) + { + this.price = price; + } + + @Override + public String toString() + { + return "Product [id=" + id + ", name=" + name + ", price=" + + price + "]"; + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_filter_productList_app/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_filter_productList_app/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..60b4aa896 --- /dev/null +++ b/BasicJava/StreamDemo_filter_productList_app/StreamDemo/src/StreamDemo.java @@ -0,0 +1,32 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * Filtering Collection using Stream: + * + * Here, we are filtering data by using stream. You can see that code + * is optimized and maintained. Stream provides fast execution. + * + */ + +public class StreamDemo +{ + public static void main(String[] args) + { + List productList = new ArrayList(); + + // Adding Products + productList.add(new Product(1, "Sony mobile", 25000)); + productList.add(new Product(2, "Lenovo mobile", 15000)); + productList.add(new Product(3, "Nokia mobile", 10000)); + productList.add(new Product(4, "Samsung mobile", 40000)); + + List filteredProductList = productList.stream() + .filter(p -> p.getPrice() < 20000)// Filter the product, whose price is less than 20000 + .collect(Collectors.toList()); // collecting as list + + filteredProductList.forEach(product -> System.out.println(product)); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_filter_productList_app/StreamDemo_Output.txt b/BasicJava/StreamDemo_filter_productList_app/StreamDemo_Output.txt new file mode 100644 index 000000000..00af8e05f --- /dev/null +++ b/BasicJava/StreamDemo_filter_productList_app/StreamDemo_Output.txt @@ -0,0 +1,2 @@ +Product [id=2, name=Lenovo mobile, price=15000] +Product [id=3, name=Nokia mobile, price=10000] diff --git a/BasicJava/StreamDemo_filter_productList_count_app/Output.txt b/BasicJava/StreamDemo_filter_productList_count_app/Output.txt new file mode 100644 index 000000000..15fdf8e4d --- /dev/null +++ b/BasicJava/StreamDemo_filter_productList_count_app/Output.txt @@ -0,0 +1 @@ +CountOfProducts = 2 diff --git a/BasicJava/StreamDemo_filter_productList_count_app/StreamDemo/.classpath b/BasicJava/StreamDemo_filter_productList_count_app/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_filter_productList_count_app/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_filter_productList_count_app/StreamDemo/.project b/BasicJava/StreamDemo_filter_productList_count_app/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_filter_productList_count_app/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_filter_productList_count_app/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_filter_productList_count_app/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_filter_productList_count_app/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_filter_productList_count_app/StreamDemo/bin/Product.class b/BasicJava/StreamDemo_filter_productList_count_app/StreamDemo/bin/Product.class new file mode 100644 index 000000000..2a97ce097 Binary files /dev/null and b/BasicJava/StreamDemo_filter_productList_count_app/StreamDemo/bin/Product.class differ diff --git a/BasicJava/StreamDemo_filter_productList_count_app/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_filter_productList_count_app/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..5be511416 Binary files /dev/null and b/BasicJava/StreamDemo_filter_productList_count_app/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_filter_productList_count_app/StreamDemo/src/Product.java b/BasicJava/StreamDemo_filter_productList_count_app/StreamDemo/src/Product.java new file mode 100644 index 000000000..9e53fdc45 --- /dev/null +++ b/BasicJava/StreamDemo_filter_productList_count_app/StreamDemo/src/Product.java @@ -0,0 +1,52 @@ +class Product +{ + private int id; + private String name; + private int price; + + public Product(int id, String name, int price) + { + super(); + this.id = id; + this.name = name; + this.price = price; + } + + public int getId() + { + return id; + } + + public void setId(int id) + { + this.id = id; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getPrice() + { + return price; + } + + public void setPrice(int price) + { + this.price = price; + } + + @Override + public String toString() + { + return "Product [id=" + id + ", name=" + name + ", price=" + + price + "]"; + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_filter_productList_count_app/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_filter_productList_count_app/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..3878f4449 --- /dev/null +++ b/BasicJava/StreamDemo_filter_productList_count_app/StreamDemo/src/StreamDemo.java @@ -0,0 +1,23 @@ +import java.util.ArrayList; +import java.util.List; + +public class StreamDemo +{ + public static void main(String[] args) + { + List productList = new ArrayList(); + + // Adding Products + productList.add(new Product(1, "Sony mobile", 25000)); + productList.add(new Product(2, "Lenovo mobile", 15000)); + productList.add(new Product(3, "Nokia mobile", 10000)); + productList.add(new Product(4, "Samsung mobile", 40000)); + + long countOfProducts = productList.stream() + .filter(p -> p.getPrice() < 20000)// Filter the product, whose price is less than 20000 + .count(); // Returns the count of elements in this stream. + + System.out.println("CountOfProducts = " + countOfProducts); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_filter_productList_map_app/FilterDemo_Output.txt b/BasicJava/StreamDemo_filter_productList_map_app/FilterDemo_Output.txt new file mode 100644 index 000000000..18918ac76 --- /dev/null +++ b/BasicJava/StreamDemo_filter_productList_map_app/FilterDemo_Output.txt @@ -0,0 +1 @@ +[Lenovo mobile, Nokia mobile] diff --git a/BasicJava/StreamDemo_filter_productList_map_app/StreamDemo/.classpath b/BasicJava/StreamDemo_filter_productList_map_app/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_filter_productList_map_app/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_filter_productList_map_app/StreamDemo/.project b/BasicJava/StreamDemo_filter_productList_map_app/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_filter_productList_map_app/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_filter_productList_map_app/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_filter_productList_map_app/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_filter_productList_map_app/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_filter_productList_map_app/StreamDemo/bin/FilterDemo.class b/BasicJava/StreamDemo_filter_productList_map_app/StreamDemo/bin/FilterDemo.class new file mode 100644 index 000000000..d07235340 Binary files /dev/null and b/BasicJava/StreamDemo_filter_productList_map_app/StreamDemo/bin/FilterDemo.class differ diff --git a/BasicJava/StreamDemo_filter_productList_map_app/StreamDemo/bin/Product.class b/BasicJava/StreamDemo_filter_productList_map_app/StreamDemo/bin/Product.class new file mode 100644 index 000000000..83acccf17 Binary files /dev/null and b/BasicJava/StreamDemo_filter_productList_map_app/StreamDemo/bin/Product.class differ diff --git a/BasicJava/StreamDemo_filter_productList_map_app/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_filter_productList_map_app/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..20fe0fc08 Binary files /dev/null and b/BasicJava/StreamDemo_filter_productList_map_app/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_filter_productList_map_app/StreamDemo/src/FilterDemo.java b/BasicJava/StreamDemo_filter_productList_map_app/StreamDemo/src/FilterDemo.java new file mode 100644 index 000000000..4dbbf076d --- /dev/null +++ b/BasicJava/StreamDemo_filter_productList_map_app/StreamDemo/src/FilterDemo.java @@ -0,0 +1,44 @@ +import java.util.ArrayList; +import java.util.List; + +/** + * Filtering Collection without using Stream: + * + * In this example, We are filtering data without using + * stream. This approach we are used before the stream package was + * released. + * + */ + +public class FilterDemo +{ + public static void main(String[] args) + { + List productList = new ArrayList(); + + // Adding Products + productList.add(new Product(1, "Sony mobile", 25000)); + productList.add(new Product(2, "Lenovo mobile", 15000)); + productList.add(new Product(3, "Nokia mobile", 10000)); + productList.add(new Product(4, "Samsung mobile", 40000)); + + List filteredProductList = new ArrayList(); + + for (Product product : productList) + { + + /* + * Filter the product, whose price is less than 20000 and + * add the product name in filteredProductList. + * + */ + if (product.getPrice() < 20000) + { + // Adding product name + filteredProductList.add(product.getName()); + } + } + System.out.println(filteredProductList); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_filter_productList_map_app/StreamDemo/src/Product.java b/BasicJava/StreamDemo_filter_productList_map_app/StreamDemo/src/Product.java new file mode 100644 index 000000000..7d65fcc32 --- /dev/null +++ b/BasicJava/StreamDemo_filter_productList_map_app/StreamDemo/src/Product.java @@ -0,0 +1,45 @@ +class Product +{ + private int id; + private String name; + private int price; + + public Product(int id, String name, int price) + { + super(); + this.id = id; + this.name = name; + this.price = price; + } + + public int getId() + { + return id; + } + + public void setId(int id) + { + this.id = id; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getPrice() + { + return price; + } + + public void setPrice(int price) + { + this.price = price; + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_filter_productList_map_app/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_filter_productList_map_app/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..f00467a49 --- /dev/null +++ b/BasicJava/StreamDemo_filter_productList_map_app/StreamDemo/src/StreamDemo.java @@ -0,0 +1,33 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * Filtering Collection by using Stream: + * + * Here, we are filtering data by using stream. You can see that code + * is optimized and maintained. Stream provides fast execution. + * + */ + +public class StreamDemo +{ + public static void main(String[] args) + { + List productList = new ArrayList(); + + // Adding Products + productList.add(new Product(1, "Sony mobile", 25000)); + productList.add(new Product(2, "Lenovo mobile", 15000)); + productList.add(new Product(3, "Nokia mobile", 10000)); + productList.add(new Product(4, "Samsung mobile", 40000)); + + List filteredProductList = productList.stream() + .filter(p -> p.getPrice() < 20000)// Filter the product, whose price is less than 20000 + .map(p -> p.getName()) // fetching Name + .collect(Collectors.toList()); // collecting as list + + System.out.println(filteredProductList); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_filter_productList_map_app/StreamDemo_Output.txt b/BasicJava/StreamDemo_filter_productList_map_app/StreamDemo_Output.txt new file mode 100644 index 000000000..18918ac76 --- /dev/null +++ b/BasicJava/StreamDemo_filter_productList_map_app/StreamDemo_Output.txt @@ -0,0 +1 @@ +[Lenovo mobile, Nokia mobile] diff --git a/BasicJava/StreamDemo_filter_productList_price_20k_App/Output.txt b/BasicJava/StreamDemo_filter_productList_price_20k_App/Output.txt new file mode 100644 index 000000000..5a5da1732 --- /dev/null +++ b/BasicJava/StreamDemo_filter_productList_price_20k_App/Output.txt @@ -0,0 +1 @@ +[Product [id=1, name=Sony mobile, price=25000], Product [id=4, name=Samsung mobile, price=40000]] diff --git a/BasicJava/StreamDemo_filter_productList_price_20k_App/StreamDemo/.classpath b/BasicJava/StreamDemo_filter_productList_price_20k_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_filter_productList_price_20k_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_filter_productList_price_20k_App/StreamDemo/.project b/BasicJava/StreamDemo_filter_productList_price_20k_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_filter_productList_price_20k_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_filter_productList_price_20k_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_filter_productList_price_20k_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_filter_productList_price_20k_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_filter_productList_price_20k_App/StreamDemo/bin/Product.class b/BasicJava/StreamDemo_filter_productList_price_20k_App/StreamDemo/bin/Product.class new file mode 100644 index 000000000..2a97ce097 Binary files /dev/null and b/BasicJava/StreamDemo_filter_productList_price_20k_App/StreamDemo/bin/Product.class differ diff --git a/BasicJava/StreamDemo_filter_productList_price_20k_App/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_filter_productList_price_20k_App/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..4db6f089e Binary files /dev/null and b/BasicJava/StreamDemo_filter_productList_price_20k_App/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_filter_productList_price_20k_App/StreamDemo/src/Product.java b/BasicJava/StreamDemo_filter_productList_price_20k_App/StreamDemo/src/Product.java new file mode 100644 index 000000000..9e53fdc45 --- /dev/null +++ b/BasicJava/StreamDemo_filter_productList_price_20k_App/StreamDemo/src/Product.java @@ -0,0 +1,52 @@ +class Product +{ + private int id; + private String name; + private int price; + + public Product(int id, String name, int price) + { + super(); + this.id = id; + this.name = name; + this.price = price; + } + + public int getId() + { + return id; + } + + public void setId(int id) + { + this.id = id; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getPrice() + { + return price; + } + + public void setPrice(int price) + { + this.price = price; + } + + @Override + public String toString() + { + return "Product [id=" + id + ", name=" + name + ", price=" + + price + "]"; + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_filter_productList_price_20k_App/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_filter_productList_price_20k_App/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..3b6b55cfd --- /dev/null +++ b/BasicJava/StreamDemo_filter_productList_price_20k_App/StreamDemo/src/StreamDemo.java @@ -0,0 +1,26 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +public class StreamDemo +{ + public static void main(String[] args) + { + List productList = new ArrayList(); + + // Adding Products + productList.add(new Product(1, "Sony mobile", 25000)); + productList.add(new Product(2, "Lenovo mobile", 15000)); + productList.add(new Product(3, "Nokia mobile", 10000)); + productList.add(new Product(4, "Samsung mobile", 40000)); + productList.add(new Product(5, "Micromax mobile", 10000)); + + List filteredProductList = productList.stream() + .filter(p -> p.getPrice() > 20000) // filtering data + .collect(Collectors.toList()); // collecting as list + + + System.out.println(filteredProductList); + + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_find_App/Output.txt b/BasicJava/StreamDemo_find_App/Output.txt new file mode 100644 index 000000000..0deac0970 --- /dev/null +++ b/BasicJava/StreamDemo_find_App/Output.txt @@ -0,0 +1,2 @@ +FindAny: G +FindFirst: G diff --git a/BasicJava/StreamDemo_find_App/StreamDemo/.classpath b/BasicJava/StreamDemo_find_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_find_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_find_App/StreamDemo/.project b/BasicJava/StreamDemo_find_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_find_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_find_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_find_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_find_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_find_App/StreamDemo/bin/StreamFindDemo.class b/BasicJava/StreamDemo_find_App/StreamDemo/bin/StreamFindDemo.class new file mode 100644 index 000000000..795979c6b Binary files /dev/null and b/BasicJava/StreamDemo_find_App/StreamDemo/bin/StreamFindDemo.class differ diff --git a/BasicJava/StreamDemo_find_App/StreamDemo/src/StreamFindDemo.java b/BasicJava/StreamDemo_find_App/StreamDemo/src/StreamFindDemo.java new file mode 100644 index 000000000..51d6a0c9e --- /dev/null +++ b/BasicJava/StreamDemo_find_App/StreamDemo/src/StreamFindDemo.java @@ -0,0 +1,28 @@ +import java.util.Arrays; +import java.util.List; + +public class StreamFindDemo +{ + public static void main(String[] args) + { + List list = Arrays.asList("G", "B", "F", "E"); + + /* + * findAny(): + * + * Returns:an Optional describing some element of this stream, + * or an empty Optional if the stream is empty + */ + String any = list.stream().findAny().get(); + System.out.println("FindAny: " + any); + + /* + * findFirst(): + * + * Returns:an Optional describing the first element of this + * stream, or an empty Optional if the stream is empty + */ + String first = list.stream().findFirst().get(); + System.out.println("FindFirst: " + first); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_flatMap/FlatMapDemo_Output.txt b/BasicJava/StreamDemo_flatMap/FlatMapDemo_Output.txt new file mode 100644 index 000000000..f2ad6c76f --- /dev/null +++ b/BasicJava/StreamDemo_flatMap/FlatMapDemo_Output.txt @@ -0,0 +1 @@ +c diff --git a/BasicJava/StreamDemo_flatMap/NonFlatMapDemo_Output.txt b/BasicJava/StreamDemo_flatMap/NonFlatMapDemo_Output.txt new file mode 100644 index 000000000..f5f144ce4 --- /dev/null +++ b/BasicJava/StreamDemo_flatMap/NonFlatMapDemo_Output.txt @@ -0,0 +1 @@ +//Output is empty... \ No newline at end of file diff --git a/BasicJava/StreamDemo_flatMap/StreamDemo/.classpath b/BasicJava/StreamDemo_flatMap/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_flatMap/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_flatMap/StreamDemo/.project b/BasicJava/StreamDemo_flatMap/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_flatMap/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_flatMap/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_flatMap/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_flatMap/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_flatMap/StreamDemo/bin/FlatMapDemo.class b/BasicJava/StreamDemo_flatMap/StreamDemo/bin/FlatMapDemo.class new file mode 100644 index 000000000..5d1930b80 Binary files /dev/null and b/BasicJava/StreamDemo_flatMap/StreamDemo/bin/FlatMapDemo.class differ diff --git a/BasicJava/StreamDemo_flatMap/StreamDemo/bin/NonFlatMapDemo.class b/BasicJava/StreamDemo_flatMap/StreamDemo/bin/NonFlatMapDemo.class new file mode 100644 index 000000000..dd0f6b234 Binary files /dev/null and b/BasicJava/StreamDemo_flatMap/StreamDemo/bin/NonFlatMapDemo.class differ diff --git a/BasicJava/StreamDemo_flatMap/StreamDemo/src/FlatMapDemo.java b/BasicJava/StreamDemo_flatMap/StreamDemo/src/FlatMapDemo.java new file mode 100644 index 000000000..f5f6f87f0 --- /dev/null +++ b/BasicJava/StreamDemo_flatMap/StreamDemo/src/FlatMapDemo.java @@ -0,0 +1,24 @@ +import java.util.Arrays; +import java.util.stream.Stream; + +public class FlatMapDemo +{ + public static void main(String[] args) + { + + String[][] strArray = new String[][] { { "a", "b" }, { "c", "d" }, { "e", "f" } }; + + // Stream + Stream strArrayStream = Arrays.stream(strArray); + + //Convert Stream to Stream + Stream strStream = strArrayStream.flatMap((x -> Arrays.stream(x))); + + // filter a stream of string + Stream filterdStream = strStream + .filter(x -> "c".equals(x.toString())); + + filterdStream.forEach(System.out::println); //Output is c + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_flatMap/StreamDemo/src/NonFlatMapDemo.java b/BasicJava/StreamDemo_flatMap/StreamDemo/src/NonFlatMapDemo.java new file mode 100644 index 000000000..ca40253e3 --- /dev/null +++ b/BasicJava/StreamDemo_flatMap/StreamDemo/src/NonFlatMapDemo.java @@ -0,0 +1,27 @@ +import java.util.Arrays; +import java.util.stream.Stream; + +/** + * + * This example will print an empty result, because filter() has + * no idea how to filter a stream of String[]. + * + */ +public class NonFlatMapDemo +{ + public static void main(String[] args) + { + + String[][] strArray = new String[][] { { "a", "b" }, { "c", "d" },{ "e", "f" } }; + + // Stream + Stream strArrayStream = Arrays.stream(strArray); + + // filter a stream of string[], and return a string[]? + Stream filterdStream = strArrayStream + .filter(x -> "c".equals(x.toString())); + + filterdStream.forEach(System.out::println); //Output is empty... + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_flatmap_App/StreamDemo/.classpath b/BasicJava/StreamDemo_flatmap_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_flatmap_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_flatmap_App/StreamDemo/.project b/BasicJava/StreamDemo_flatmap_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_flatmap_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_flatmap_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_flatmap_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_flatmap_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_flatmap_App/StreamDemo/bin/StreamFlatMapDemo1.class b/BasicJava/StreamDemo_flatmap_App/StreamDemo/bin/StreamFlatMapDemo1.class new file mode 100644 index 000000000..64e2699ee Binary files /dev/null and b/BasicJava/StreamDemo_flatmap_App/StreamDemo/bin/StreamFlatMapDemo1.class differ diff --git a/BasicJava/StreamDemo_flatmap_App/StreamDemo/bin/StreamFlatMapDemo2.class b/BasicJava/StreamDemo_flatmap_App/StreamDemo/bin/StreamFlatMapDemo2.class new file mode 100644 index 000000000..ac7002e9e Binary files /dev/null and b/BasicJava/StreamDemo_flatmap_App/StreamDemo/bin/StreamFlatMapDemo2.class differ diff --git a/BasicJava/StreamDemo_flatmap_App/StreamDemo/src/StreamFlatMapDemo1.java b/BasicJava/StreamDemo_flatmap_App/StreamDemo/src/StreamFlatMapDemo1.java new file mode 100644 index 000000000..60d0685da --- /dev/null +++ b/BasicJava/StreamDemo_flatmap_App/StreamDemo/src/StreamFlatMapDemo1.java @@ -0,0 +1,18 @@ +import java.util.Arrays; + +public class StreamFlatMapDemo1 +{ + public static void main(String[] args) + { + Integer[][] integerArray = { { 1, 2 }, { 3, 4 }, { 5, 6 } }; + + /* + * Stream.flatMap() + * + * It returns a stream of object after applying mapping + * function on each element and then flattens the result. + */ + Arrays.stream(integerArray).flatMap(row -> Arrays.stream(row)) + .forEach(s -> System.out.print(s + " ")); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_flatmap_App/StreamDemo/src/StreamFlatMapDemo2.java b/BasicJava/StreamDemo_flatmap_App/StreamDemo/src/StreamFlatMapDemo2.java new file mode 100644 index 000000000..430222799 --- /dev/null +++ b/BasicJava/StreamDemo_flatmap_App/StreamDemo/src/StreamFlatMapDemo2.java @@ -0,0 +1,19 @@ +import java.util.Arrays; + +public class StreamFlatMapDemo2 +{ + public static void main(String[] args) + { + Integer[][] integerArray = { { 1, 2 }, { 3, 4 }, { 5, 6 } }; + + /* + * Stream.flatMap() + * + * It returns a stream of object after applying mapping + * function on each element and then flattens the result. + */ + Arrays.stream(integerArray).flatMap(row -> Arrays.stream(row)) + .filter(num -> num % 2 == 1) + .forEach(s -> System.out.print(s + " ")); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_flatmap_App/StreamFlatMapDemo1_Output.txt b/BasicJava/StreamDemo_flatmap_App/StreamFlatMapDemo1_Output.txt new file mode 100644 index 000000000..ce65bca16 --- /dev/null +++ b/BasicJava/StreamDemo_flatmap_App/StreamFlatMapDemo1_Output.txt @@ -0,0 +1 @@ +1 2 3 4 5 6 \ No newline at end of file diff --git a/BasicJava/StreamDemo_flatmap_App/StreamFlatMapDemo2_Output.txt b/BasicJava/StreamDemo_flatmap_App/StreamFlatMapDemo2_Output.txt new file mode 100644 index 000000000..32ebfce73 --- /dev/null +++ b/BasicJava/StreamDemo_flatmap_App/StreamFlatMapDemo2_Output.txt @@ -0,0 +1 @@ +1 3 5 \ No newline at end of file diff --git a/BasicJava/StreamDemo_flatmap_intarray/Output.txt b/BasicJava/StreamDemo_flatmap_intarray/Output.txt new file mode 100644 index 000000000..b414108e8 --- /dev/null +++ b/BasicJava/StreamDemo_flatmap_intarray/Output.txt @@ -0,0 +1,6 @@ +1 +2 +3 +4 +5 +6 diff --git a/BasicJava/StreamDemo_flatmap_intarray/StreamDemo/.classpath b/BasicJava/StreamDemo_flatmap_intarray/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_flatmap_intarray/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_flatmap_intarray/StreamDemo/.project b/BasicJava/StreamDemo_flatmap_intarray/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_flatmap_intarray/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_flatmap_intarray/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_flatmap_intarray/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_flatmap_intarray/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_flatmap_intarray/StreamDemo/bin/FlatMapDemo.class b/BasicJava/StreamDemo_flatmap_intarray/StreamDemo/bin/FlatMapDemo.class new file mode 100644 index 000000000..e9239d3c5 Binary files /dev/null and b/BasicJava/StreamDemo_flatmap_intarray/StreamDemo/bin/FlatMapDemo.class differ diff --git a/BasicJava/StreamDemo_flatmap_intarray/StreamDemo/src/FlatMapDemo.java b/BasicJava/StreamDemo_flatmap_intarray/StreamDemo/src/FlatMapDemo.java new file mode 100644 index 000000000..4ba00db6f --- /dev/null +++ b/BasicJava/StreamDemo_flatmap_intarray/StreamDemo/src/FlatMapDemo.java @@ -0,0 +1,21 @@ +import java.util.Arrays; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class FlatMapDemo +{ + public static void main(String[] args) + { + + int[][] intArray = {{1, 2, 3}, {4,5,6}}; + + //1. Stream + Stream arrayStream = Stream.of(intArray); + + //2. Stream -> flatMap -> IntStream + IntStream intStream = arrayStream.flatMapToInt(x -> Arrays.stream(x)); + + intStream.forEach(x -> System.out.println(x)); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_flatmap_streamofset/FlatMapDemo1_Output.txt b/BasicJava/StreamDemo_flatmap_streamofset/FlatMapDemo1_Output.txt new file mode 100644 index 000000000..fac28f42b --- /dev/null +++ b/BasicJava/StreamDemo_flatmap_streamofset/FlatMapDemo1_Output.txt @@ -0,0 +1,4 @@ +Ruby in Action +Java in Action +Spring in Action +Learning Java Script diff --git a/BasicJava/StreamDemo_flatmap_streamofset/FlatMapDemo2_Output.txt b/BasicJava/StreamDemo_flatmap_streamofset/FlatMapDemo2_Output.txt new file mode 100644 index 000000000..fac28f42b --- /dev/null +++ b/BasicJava/StreamDemo_flatmap_streamofset/FlatMapDemo2_Output.txt @@ -0,0 +1,4 @@ +Ruby in Action +Java in Action +Spring in Action +Learning Java Script diff --git a/BasicJava/StreamDemo_flatmap_streamofset/StreamDemo/.classpath b/BasicJava/StreamDemo_flatmap_streamofset/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_flatmap_streamofset/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_flatmap_streamofset/StreamDemo/.project b/BasicJava/StreamDemo_flatmap_streamofset/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_flatmap_streamofset/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_flatmap_streamofset/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_flatmap_streamofset/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_flatmap_streamofset/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_flatmap_streamofset/StreamDemo/bin/FlatMapDemo1.class b/BasicJava/StreamDemo_flatmap_streamofset/StreamDemo/bin/FlatMapDemo1.class new file mode 100644 index 000000000..ad417ede0 Binary files /dev/null and b/BasicJava/StreamDemo_flatmap_streamofset/StreamDemo/bin/FlatMapDemo1.class differ diff --git a/BasicJava/StreamDemo_flatmap_streamofset/StreamDemo/bin/FlatMapDemo2.class b/BasicJava/StreamDemo_flatmap_streamofset/StreamDemo/bin/FlatMapDemo2.class new file mode 100644 index 000000000..dd85e8a17 Binary files /dev/null and b/BasicJava/StreamDemo_flatmap_streamofset/StreamDemo/bin/FlatMapDemo2.class differ diff --git a/BasicJava/StreamDemo_flatmap_streamofset/StreamDemo/bin/Student.class b/BasicJava/StreamDemo_flatmap_streamofset/StreamDemo/bin/Student.class new file mode 100644 index 000000000..db509c7ad Binary files /dev/null and b/BasicJava/StreamDemo_flatmap_streamofset/StreamDemo/bin/Student.class differ diff --git a/BasicJava/StreamDemo_flatmap_streamofset/StreamDemo/src/FlatMapDemo1.java b/BasicJava/StreamDemo_flatmap_streamofset/StreamDemo/src/FlatMapDemo1.java new file mode 100644 index 000000000..9ff10d795 --- /dev/null +++ b/BasicJava/StreamDemo_flatmap_streamofset/StreamDemo/src/FlatMapDemo1.java @@ -0,0 +1,45 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class FlatMapDemo1 +{ + public static void main(String[] args) + { + + Student student1 = new Student(); + student1.setName("Peter"); + student1.addBook("Java in Action"); + student1.addBook("Spring in Action"); + student1.addBook("Ruby in Action"); + + Student student2 = new Student(); + student2.setName("John"); + student2.addBook("Java in Action"); + student2.addBook("Learning Java Script"); + + List studentList = new ArrayList<>(); + studentList.add(student1); + studentList.add(student2); + + /* + * Stream> + */ + Stream> setStream = studentList.stream() + .map(student -> student.getBookSet()); + + /* + * Stream> to Stream + */ + Stream stringStream = setStream // Stream> + .flatMap(student -> student.stream()); // Stream + + List bookList = stringStream.distinct() + .collect(Collectors.toList()); + + bookList.forEach(bookName -> System.out.println(bookName)); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_flatmap_streamofset/StreamDemo/src/FlatMapDemo2.java b/BasicJava/StreamDemo_flatmap_streamofset/StreamDemo/src/FlatMapDemo2.java new file mode 100644 index 000000000..d2533fda9 --- /dev/null +++ b/BasicJava/StreamDemo_flatmap_streamofset/StreamDemo/src/FlatMapDemo2.java @@ -0,0 +1,32 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +public class FlatMapDemo2 +{ + public static void main(String[] args) + { + Student student1 = new Student(); + student1.setName("Peter"); + student1.addBook("Java in Action"); + student1.addBook("Spring in Action"); + student1.addBook("Ruby in Action"); + + Student student2 = new Student(); + student2.setName("John"); + student2.addBook("Java in Action"); + student2.addBook("Learning Java Script"); + + List studentList = new ArrayList<>(); + studentList.add(student1); + studentList.add(student2); + + List bookList = studentList.stream() + .map(student -> student.getBookSet()) // Stream> + .flatMap(student -> student.stream()) // Stream + .distinct().collect(Collectors.toList()); + + bookList.forEach(bookName -> System.out.println(bookName)); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_flatmap_streamofset/StreamDemo/src/Student.java b/BasicJava/StreamDemo_flatmap_streamofset/StreamDemo/src/Student.java new file mode 100644 index 000000000..af900958e --- /dev/null +++ b/BasicJava/StreamDemo_flatmap_streamofset/StreamDemo/src/Student.java @@ -0,0 +1,38 @@ +import java.util.HashSet; +import java.util.Set; + +public class Student +{ + private String name; + private Set bookSet; + + public void addBook(String bookName) + { + if (this.bookSet == null) + { + this.bookSet = new HashSet<>(); + } + this.bookSet.add(bookName); + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public Set getBookSet() + { + return bookSet; + } + + public void setBookSet(Set bookSet) + { + this.bookSet = bookSet; + } + +} diff --git a/BasicJava/StreamDemo_foreach_female_operation/Output.txt b/BasicJava/StreamDemo_foreach_female_operation/Output.txt new file mode 100644 index 000000000..9552af64d --- /dev/null +++ b/BasicJava/StreamDemo_foreach_female_operation/Output.txt @@ -0,0 +1,2 @@ +Person [name=Alice] +Person [name=Carol] diff --git a/BasicJava/StreamDemo_foreach_female_operation/StreamDemo/.classpath b/BasicJava/StreamDemo_foreach_female_operation/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_foreach_female_operation/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_foreach_female_operation/StreamDemo/.project b/BasicJava/StreamDemo_foreach_female_operation/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_foreach_female_operation/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_foreach_female_operation/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_foreach_female_operation/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_foreach_female_operation/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_foreach_female_operation/StreamDemo/bin/Gender.class b/BasicJava/StreamDemo_foreach_female_operation/StreamDemo/bin/Gender.class new file mode 100644 index 000000000..c667336c7 Binary files /dev/null and b/BasicJava/StreamDemo_foreach_female_operation/StreamDemo/bin/Gender.class differ diff --git a/BasicJava/StreamDemo_foreach_female_operation/StreamDemo/bin/Person.class b/BasicJava/StreamDemo_foreach_female_operation/StreamDemo/bin/Person.class new file mode 100644 index 000000000..eda7e7dcb Binary files /dev/null and b/BasicJava/StreamDemo_foreach_female_operation/StreamDemo/bin/Person.class differ diff --git a/BasicJava/StreamDemo_foreach_female_operation/StreamDemo/bin/StreamCollectDemo.class b/BasicJava/StreamDemo_foreach_female_operation/StreamDemo/bin/StreamCollectDemo.class new file mode 100644 index 000000000..5d368d0dc Binary files /dev/null and b/BasicJava/StreamDemo_foreach_female_operation/StreamDemo/bin/StreamCollectDemo.class differ diff --git a/BasicJava/StreamDemo_foreach_female_operation/StreamDemo/bin/StreamForEachDemo.class b/BasicJava/StreamDemo_foreach_female_operation/StreamDemo/bin/StreamForEachDemo.class new file mode 100644 index 000000000..20f671244 Binary files /dev/null and b/BasicJava/StreamDemo_foreach_female_operation/StreamDemo/bin/StreamForEachDemo.class differ diff --git a/BasicJava/StreamDemo_foreach_female_operation/StreamDemo/src/Person.java b/BasicJava/StreamDemo_foreach_female_operation/StreamDemo/src/Person.java new file mode 100644 index 000000000..0e39eeb00 --- /dev/null +++ b/BasicJava/StreamDemo_foreach_female_operation/StreamDemo/src/Person.java @@ -0,0 +1,68 @@ +enum Gender +{ + MALE, FEMALE +} + +public class Person +{ + private String name; + private String email; + private Gender gender; + private int age; + + public Person(String name, String email, Gender gender, int age) + { + super(); + this.name = name; + this.email = email; + this.gender = gender; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getEmail() + { + return email; + } + + public void setEmail(String email) + { + this.email = email; + } + + public Gender getGender() + { + return gender; + } + + public void setGender(Gender gender) + { + this.gender = gender; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + @Override + public String toString() + { + return "Person [name=" + name + "]"; + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_foreach_female_operation/StreamDemo/src/StreamForEachDemo.java b/BasicJava/StreamDemo_foreach_female_operation/StreamDemo/src/StreamForEachDemo.java new file mode 100644 index 000000000..0fdb1698d --- /dev/null +++ b/BasicJava/StreamDemo_foreach_female_operation/StreamDemo/src/StreamForEachDemo.java @@ -0,0 +1,26 @@ +import java.util.ArrayList; +import java.util.List; + +public class StreamForEachDemo +{ + public static void main(String[] args) + { + List personList = new ArrayList<>(); + + personList.add(new Person("Alice","alice@gmail.com", Gender.FEMALE, 26)); + personList.add(new Person("Bob","bob@gmail.com", Gender.MALE, 32)); + personList.add(new Person("Carol","carol@gmail.com",Gender.FEMALE, 23)); + personList.add(new Person("David","david@gmail.com", Gender.MALE, 39)); + personList.add(new Person("Eric","eric@gmail.com", Gender.MALE, 26)); + + /* + * The forEach() operation performs an action for each element in the + * stream, thus creating a side effect, such as print out information of + * each female person as shown in the following code: + */ + personList.stream().filter(p -> p.getGender().equals(Gender.FEMALE)) + .forEach(System.out::println); + + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_foreach_modulus_App/Output.txt b/BasicJava/StreamDemo_foreach_modulus_App/Output.txt new file mode 100644 index 000000000..1712f164f --- /dev/null +++ b/BasicJava/StreamDemo_foreach_modulus_App/Output.txt @@ -0,0 +1 @@ +1 3 5 7 \ No newline at end of file diff --git a/BasicJava/StreamDemo_foreach_modulus_App/StreamDemo/.classpath b/BasicJava/StreamDemo_foreach_modulus_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_foreach_modulus_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_foreach_modulus_App/StreamDemo/.project b/BasicJava/StreamDemo_foreach_modulus_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_foreach_modulus_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_foreach_modulus_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_foreach_modulus_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_foreach_modulus_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_foreach_modulus_App/StreamDemo/bin/StreamFindDemo.class b/BasicJava/StreamDemo_foreach_modulus_App/StreamDemo/bin/StreamFindDemo.class new file mode 100644 index 000000000..e40907a26 Binary files /dev/null and b/BasicJava/StreamDemo_foreach_modulus_App/StreamDemo/bin/StreamFindDemo.class differ diff --git a/BasicJava/StreamDemo_foreach_modulus_App/StreamDemo/bin/StreamForEachDemo.class b/BasicJava/StreamDemo_foreach_modulus_App/StreamDemo/bin/StreamForEachDemo.class new file mode 100644 index 000000000..749b4d2bd Binary files /dev/null and b/BasicJava/StreamDemo_foreach_modulus_App/StreamDemo/bin/StreamForEachDemo.class differ diff --git a/BasicJava/StreamDemo_foreach_modulus_App/StreamDemo/src/StreamForEachDemo.java b/BasicJava/StreamDemo_foreach_modulus_App/StreamDemo/src/StreamForEachDemo.java new file mode 100644 index 000000000..c2e7ea2bf --- /dev/null +++ b/BasicJava/StreamDemo_foreach_modulus_App/StreamDemo/src/StreamForEachDemo.java @@ -0,0 +1,15 @@ +import java.util.Arrays; + +public class StreamForEachDemo +{ + public static void main(String[] args) + { + Integer[] integerArray = { 1, 2, 3, 4, 5, 6, 7 }; + + /* + * forEach(): It performs an action on each element of stream. + */ + Arrays.stream(integerArray).filter(num -> num % 2 == 1) + .forEach(s -> System.out.print(s + " ")); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_generate_array_collection/StreamDemo/.classpath b/BasicJava/StreamDemo_generate_array_collection/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_generate_array_collection/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_generate_array_collection/StreamDemo/.project b/BasicJava/StreamDemo_generate_array_collection/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_generate_array_collection/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_generate_array_collection/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_generate_array_collection/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_generate_array_collection/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_generate_array_collection/StreamDemo/bin/StreamDemo1.class b/BasicJava/StreamDemo_generate_array_collection/StreamDemo/bin/StreamDemo1.class new file mode 100644 index 000000000..6f65eca39 Binary files /dev/null and b/BasicJava/StreamDemo_generate_array_collection/StreamDemo/bin/StreamDemo1.class differ diff --git a/BasicJava/StreamDemo_generate_array_collection/StreamDemo/bin/StreamDemo2.class b/BasicJava/StreamDemo_generate_array_collection/StreamDemo/bin/StreamDemo2.class new file mode 100644 index 000000000..8c848909e Binary files /dev/null and b/BasicJava/StreamDemo_generate_array_collection/StreamDemo/bin/StreamDemo2.class differ diff --git a/BasicJava/StreamDemo_generate_array_collection/StreamDemo/src/StreamDemo1.java b/BasicJava/StreamDemo_generate_array_collection/StreamDemo/src/StreamDemo1.java new file mode 100644 index 000000000..de9228981 --- /dev/null +++ b/BasicJava/StreamDemo_generate_array_collection/StreamDemo/src/StreamDemo1.java @@ -0,0 +1,23 @@ +import java.util.Arrays; +import java.util.stream.Stream; +/** + * Generate Streams from Arrays using .stream or Stream.of. + */ +public class StreamDemo1 +{ + public static void main(String[] args) + { + String[] strArray = { "Apple", "Ball", "Cat", "Dog", "Eagle" }; + + // Get Stream using the Arrays.stream + Stream stream1 = Arrays.stream(strArray); + stream1.forEach(x -> System.out.println(x)); + + System.out.println("---------------------------------"); + + // Get Stream using the Stream.of + Stream stream2 = Stream.of(strArray); + stream2.forEach(x -> System.out.println(x)); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_generate_array_collection/StreamDemo/src/StreamDemo2.java b/BasicJava/StreamDemo_generate_array_collection/StreamDemo/src/StreamDemo2.java new file mode 100644 index 000000000..f2791ccca --- /dev/null +++ b/BasicJava/StreamDemo_generate_array_collection/StreamDemo/src/StreamDemo2.java @@ -0,0 +1,19 @@ +import java.util.ArrayList; +import java.util.List; +/** + * Generate Streams from Collections. + */ +public class StreamDemo2 +{ + public static void main(String[] args) + { + List itemList = new ArrayList<>(); + itemList.add("Apple"); + itemList.add("Ball"); + itemList.add("Cat"); + itemList.add("Dog"); + + itemList.stream().forEach(item -> System.out.println(item)); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_generate_array_collection/StreamDemo1_Output.txt b/BasicJava/StreamDemo_generate_array_collection/StreamDemo1_Output.txt new file mode 100644 index 000000000..ddeb5ad81 --- /dev/null +++ b/BasicJava/StreamDemo_generate_array_collection/StreamDemo1_Output.txt @@ -0,0 +1,11 @@ +Apple +Ball +Cat +Dog +Eagle +--------------------------------- +Apple +Ball +Cat +Dog +Eagle diff --git a/BasicJava/StreamDemo_generate_array_collection/StreamDemo2_Output.txt b/BasicJava/StreamDemo_generate_array_collection/StreamDemo2_Output.txt new file mode 100644 index 000000000..f0bc41fa6 --- /dev/null +++ b/BasicJava/StreamDemo_generate_array_collection/StreamDemo2_Output.txt @@ -0,0 +1,4 @@ +Apple +Ball +Cat +Dog diff --git a/BasicJava/StreamDemo_generate_hw_App/StreamDemo/.classpath b/BasicJava/StreamDemo_generate_hw_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_generate_hw_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_generate_hw_App/StreamDemo/.project b/BasicJava/StreamDemo_generate_hw_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_generate_hw_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_generate_hw_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_generate_hw_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_generate_hw_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_generate_hw_App/StreamDemo/bin/StreamFindDemo.class b/BasicJava/StreamDemo_generate_hw_App/StreamDemo/bin/StreamFindDemo.class new file mode 100644 index 000000000..cf198870d Binary files /dev/null and b/BasicJava/StreamDemo_generate_hw_App/StreamDemo/bin/StreamFindDemo.class differ diff --git a/BasicJava/StreamDemo_generate_hw_App/StreamDemo/bin/StreamGenerateDemo1.class b/BasicJava/StreamDemo_generate_hw_App/StreamDemo/bin/StreamGenerateDemo1.class new file mode 100644 index 000000000..0b287a80d Binary files /dev/null and b/BasicJava/StreamDemo_generate_hw_App/StreamDemo/bin/StreamGenerateDemo1.class differ diff --git a/BasicJava/StreamDemo_generate_hw_App/StreamDemo/bin/StreamGenerateDemo2.class b/BasicJava/StreamDemo_generate_hw_App/StreamDemo/bin/StreamGenerateDemo2.class new file mode 100644 index 000000000..97de400e6 Binary files /dev/null and b/BasicJava/StreamDemo_generate_hw_App/StreamDemo/bin/StreamGenerateDemo2.class differ diff --git a/BasicJava/StreamDemo_generate_hw_App/StreamDemo/src/StreamGenerateDemo1.java b/BasicJava/StreamDemo_generate_hw_App/StreamDemo/src/StreamGenerateDemo1.java new file mode 100644 index 000000000..ae762fddf --- /dev/null +++ b/BasicJava/StreamDemo_generate_hw_App/StreamDemo/src/StreamGenerateDemo1.java @@ -0,0 +1,19 @@ +import java.util.stream.Stream; + +public class StreamGenerateDemo1 +{ + public static void main(String[] args) + { + String str = "Hello World!"; + + /* + * generate(): We need to pass Supplier to this method and it + * will return an infinite sequential unordered stream. This + * is suitable for generating constant streams, streams of + * random elements, etc. + */ + + Stream stream = Stream.generate(str::toString); + stream.forEach(s -> System.out.println(s)); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_generate_hw_App/StreamDemo/src/StreamGenerateDemo2.java b/BasicJava/StreamDemo_generate_hw_App/StreamDemo/src/StreamGenerateDemo2.java new file mode 100644 index 000000000..bff4753d3 --- /dev/null +++ b/BasicJava/StreamDemo_generate_hw_App/StreamDemo/src/StreamGenerateDemo2.java @@ -0,0 +1,23 @@ +import java.util.stream.Stream; + +public class StreamGenerateDemo2 +{ + public static void main(String[] args) + { + String str = "Hello World!"; + + /* + * generate(): We need to pass Supplier to this method and it + * will return an infinite sequential unordered stream. This + * is suitable for generating constant streams, streams of + * random elements, etc. + * + * limit(): We need to pass a max value and it returns the + * stream up to the max number of elements. + */ + + Stream stream = Stream.generate(str::toString) + .limit(4); + stream.forEach(s -> System.out.println(s)); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_generate_hw_App/StreamGenerateDemo1_Output.txt b/BasicJava/StreamDemo_generate_hw_App/StreamGenerateDemo1_Output.txt new file mode 100644 index 000000000..371d9289c --- /dev/null +++ b/BasicJava/StreamDemo_generate_hw_App/StreamGenerateDemo1_Output.txt @@ -0,0 +1,17 @@ +Hello World! +Hello World! +Hello World! +Hello World! +Hello World! +Hello World! +Hello World! +Hello World! +Hello World! +Hello World! +Hello World! +Hello World! +Hello World! +... +... +... +.. diff --git a/BasicJava/StreamDemo_generate_hw_App/StreamGenerateDemo2_Output.txt b/BasicJava/StreamDemo_generate_hw_App/StreamGenerateDemo2_Output.txt new file mode 100644 index 000000000..be6eaae62 --- /dev/null +++ b/BasicJava/StreamDemo_generate_hw_App/StreamGenerateDemo2_Output.txt @@ -0,0 +1,4 @@ +Hello World! +Hello World! +Hello World! +Hello World! diff --git a/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo/.classpath b/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo/.project b/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo/bin/StreamDemo1.class b/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo/bin/StreamDemo1.class new file mode 100644 index 000000000..0f0137bf2 Binary files /dev/null and b/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo/bin/StreamDemo1.class differ diff --git a/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo/bin/StreamDemo2.class b/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo/bin/StreamDemo2.class new file mode 100644 index 000000000..5ed32c5b7 Binary files /dev/null and b/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo/bin/StreamDemo2.class differ diff --git a/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo/bin/StreamDemo3.class b/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo/bin/StreamDemo3.class new file mode 100644 index 000000000..d85d5d626 Binary files /dev/null and b/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo/bin/StreamDemo3.class differ diff --git a/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo/src/StreamDemo1.java b/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo/src/StreamDemo1.java new file mode 100644 index 000000000..d850733d5 --- /dev/null +++ b/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo/src/StreamDemo1.java @@ -0,0 +1,15 @@ +import java.util.Arrays; +import java.util.stream.Stream; +/** + * Generate Stream using Stream.generate() + */ +public class StreamDemo1 +{ + public static void main(String[] args) + { + Stream stream = Stream.generate(() -> "welcome").limit(5); + String[] strArr = stream.toArray(String[]::new); + System.out.println(Arrays.toString(strArr)); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo/src/StreamDemo2.java b/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo/src/StreamDemo2.java new file mode 100644 index 000000000..b4bbd7262 --- /dev/null +++ b/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo/src/StreamDemo2.java @@ -0,0 +1,13 @@ +import java.util.stream.Stream; +/** + * Generate Stream using Stream.iterate(). + */ +public class StreamDemo2 +{ + public static void main(String[] args) + { + Stream iterateNumbers = Stream.iterate(1L, n -> n + 10).limit(5); + iterateNumbers.forEach(System.out::println); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo/src/StreamDemo3.java b/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo/src/StreamDemo3.java new file mode 100644 index 000000000..414045328 --- /dev/null +++ b/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo/src/StreamDemo3.java @@ -0,0 +1,13 @@ +import java.util.regex.Pattern; +/** + * Generate Stream from APIs like Regex. + */ +public class StreamDemo3 +{ + public static void main(String[] args) + { + String str = "Welcome,to,India"; + Pattern.compile(",").splitAsStream(str).forEach(System.out::println); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo1_Output.txt b/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo1_Output.txt new file mode 100644 index 000000000..f8740e6d1 --- /dev/null +++ b/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo1_Output.txt @@ -0,0 +1 @@ +[welcome, welcome, welcome, welcome, welcome] diff --git a/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo2_Output.txt b/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo2_Output.txt new file mode 100644 index 000000000..e23c29bfe --- /dev/null +++ b/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo2_Output.txt @@ -0,0 +1,5 @@ +1 +11 +21 +31 +41 diff --git a/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo3_Output.txt b/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo3_Output.txt new file mode 100644 index 000000000..f48cc3066 --- /dev/null +++ b/BasicJava/StreamDemo_generate_iterate_regex/StreamDemo3_Output.txt @@ -0,0 +1,3 @@ +Welcome +to +India diff --git a/BasicJava/StreamDemo_groupBy_level/StreamDemo/.classpath b/BasicJava/StreamDemo_groupBy_level/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_groupBy_level/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_groupBy_level/StreamDemo/.project b/BasicJava/StreamDemo_groupBy_level/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_groupBy_level/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_groupBy_level/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_groupBy_level/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_groupBy_level/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_groupBy_level/StreamDemo/bin/StreamGroupByDemo1.class b/BasicJava/StreamDemo_groupBy_level/StreamDemo/bin/StreamGroupByDemo1.class new file mode 100644 index 000000000..149a7f0a1 Binary files /dev/null and b/BasicJava/StreamDemo_groupBy_level/StreamDemo/bin/StreamGroupByDemo1.class differ diff --git a/BasicJava/StreamDemo_groupBy_level/StreamDemo/bin/StreamGroupByDemo2.class b/BasicJava/StreamDemo_groupBy_level/StreamDemo/bin/StreamGroupByDemo2.class new file mode 100644 index 000000000..1612cf162 Binary files /dev/null and b/BasicJava/StreamDemo_groupBy_level/StreamDemo/bin/StreamGroupByDemo2.class differ diff --git a/BasicJava/StreamDemo_groupBy_level/StreamDemo/bin/StreamGroupByDemo3.class b/BasicJava/StreamDemo_groupBy_level/StreamDemo/bin/StreamGroupByDemo3.class new file mode 100644 index 000000000..9d339900b Binary files /dev/null and b/BasicJava/StreamDemo_groupBy_level/StreamDemo/bin/StreamGroupByDemo3.class differ diff --git a/BasicJava/StreamDemo_groupBy_level/StreamDemo/bin/Student.class b/BasicJava/StreamDemo_groupBy_level/StreamDemo/bin/Student.class new file mode 100644 index 000000000..0ea5748dc Binary files /dev/null and b/BasicJava/StreamDemo_groupBy_level/StreamDemo/bin/Student.class differ diff --git a/BasicJava/StreamDemo_groupBy_level/StreamDemo/src/StreamGroupByDemo1.java b/BasicJava/StreamDemo_groupBy_level/StreamDemo/src/StreamGroupByDemo1.java new file mode 100644 index 000000000..1e091c123 --- /dev/null +++ b/BasicJava/StreamDemo_groupBy_level/StreamDemo/src/StreamGroupByDemo1.java @@ -0,0 +1,55 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * Group by teacher name: + * + * SELECT column_name, count(column_name) + * FROM table + * GROUP BY column_name; + * + * This example will show how to "group classes by a teacher's name". Here you + * will pass the groupingBy method a function in the form of a method reference + * extracting each teacher name to the corresponding Student which will return 1 + * key to many elements. This is similar to guava's Multimap collection which + * allows for easy mapping of a single key to multiple values. + * + */ +public class StreamGroupByDemo1 +{ + public static void main(String[] args) + { + List studentList = getStudentList(); + + Map> groupByTeachersMap = studentList.stream() + .collect(Collectors.groupingBy(Student::getTeacherName)); + + for (Map.Entry> entry : groupByTeachersMap + .entrySet()) + { + System.out.println("Teacher Name : " + entry.getKey()); + + List list = entry.getValue(); + for (Student student : list) + { + System.out.println(student); + } + System.out.println("-------------------------------------"); + } + + } + + private static List getStudentList() + { + List studentList = new ArrayList(); + studentList.add(new Student("Peter", "Mr.John", 1, "Java Basics")); + studentList.add(new Student("Ram", "Mr.John", 1, "Webservice Basics")); + studentList.add(new Student("Juli", "Mr.John", 2, "Advance Java")); + studentList.add(new Student("Dave", "Mr.Kumar", 1, "Ruby basics")); + studentList.add(new Student("Raja", "Mr.Kumar", 2, "Advance Ruby")); + return studentList; + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_groupBy_level/StreamDemo/src/StreamGroupByDemo2.java b/BasicJava/StreamDemo_groupBy_level/StreamDemo/src/StreamGroupByDemo2.java new file mode 100644 index 000000000..f2ca93837 --- /dev/null +++ b/BasicJava/StreamDemo_groupBy_level/StreamDemo/src/StreamGroupByDemo2.java @@ -0,0 +1,51 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * Group by class level: + * + * SELECT column_name, count(column_name) + * FROM table + * GROUP BY column_name; + * + * This example will show "show all classes by level". + * + */ +public class StreamGroupByDemo2 +{ + public static void main(String[] args) + { + List studentList = getStudentList(); + + Map> groupByLevelMap = studentList.stream() + .collect(Collectors.groupingBy(Student::getLevel)); + + for (Map.Entry> entry : groupByLevelMap + .entrySet()) + { + System.out.println("Level : " + entry.getKey()); + + List list = entry.getValue(); + for (Student student : list) + { + System.out.println(student); + } + System.out.println("----------------------------------"); + } + + } + + private static List getStudentList() + { + List studentList = new ArrayList(); + studentList.add(new Student("Peter", "Mr.John", 1, "Java Basics")); + studentList.add(new Student("Ram", "Mr.John", 1, "Webservice Basics")); + studentList.add(new Student("Juli", "Mr.John", 2, "Advance Java")); + studentList.add(new Student("Dave", "Mr.Kumar", 1, "Ruby basics")); + studentList.add(new Student("Raja", "Mr.Kumar", 2, "Advance Ruby")); + return studentList; + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_groupBy_level/StreamDemo/src/StreamGroupByDemo3.java b/BasicJava/StreamDemo_groupBy_level/StreamDemo/src/StreamGroupByDemo3.java new file mode 100644 index 000000000..9465ca264 --- /dev/null +++ b/BasicJava/StreamDemo_groupBy_level/StreamDemo/src/StreamGroupByDemo3.java @@ -0,0 +1,50 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * GroupBy aggregate: + * + * SELECT LEVEL, count(LEVEL) + * FROM STUDENT + * GROUP BY LEVEL; + * + * This example will "count the number of classes per level": + * + */ +public class StreamGroupByDemo3 +{ + public static void main(String[] args) + { + List studentList = getStudentList(); + + /* + * In an overloaded groupingBy method, you can pass a second collector. + * Collectors have various reduce operations which can be passed, in + * this case Collectors.counting which will count the number of classes + * in each level. + */ + Map groupByLevelMap = studentList.stream() + .collect(Collectors.groupingBy(Student::getLevel,Collectors.counting())); + + for (Map.Entry entry : groupByLevelMap.entrySet()) + { + System.out.println("Level = " + entry.getKey() + ", Count = " + + entry.getValue()); + } + + } + + private static List getStudentList() + { + List studentList = new ArrayList(); + studentList.add(new Student("Peter", "Mr.John", 1, "Java Basics")); + studentList.add(new Student("Ram", "Mr.John", 1, "Webservice Basics")); + studentList.add(new Student("Juli", "Mr.John", 2, "Advance Java")); + studentList.add(new Student("Dave", "Mr.Kumar", 1, "Ruby basics")); + studentList.add(new Student("Raja", "Mr.Kumar", 2, "Advance Ruby")); + return studentList; + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_groupBy_level/StreamDemo/src/Student.java b/BasicJava/StreamDemo_groupBy_level/StreamDemo/src/Student.java new file mode 100644 index 000000000..b7a717902 --- /dev/null +++ b/BasicJava/StreamDemo_groupBy_level/StreamDemo/src/Student.java @@ -0,0 +1,66 @@ +public class Student +{ + private String studentName; + private String teacherName; + private int level; + private String className; + + public Student(String studentName, String teacherName, int level, + String className) + { + super(); + this.studentName = studentName; + this.teacherName = teacherName; + this.level = level; + this.className = className; + } + + public String getStudentName() + { + return studentName; + } + + public void setStudentName(String studentName) + { + this.studentName = studentName; + } + + public String getTeacherName() + { + return teacherName; + } + + public void setTeacherName(String teacherName) + { + this.teacherName = teacherName; + } + + public int getLevel() + { + return level; + } + + public void setLevel(int level) + { + this.level = level; + } + + public String getClassName() + { + return className; + } + + public void setClassName(String className) + { + this.className = className; + } + + @Override + public String toString() + { + return "Student [studentName=" + studentName + ", teacherName=" + + teacherName + ", level=" + level + ", className=" + className + + "]"; + } + +} diff --git a/BasicJava/StreamDemo_groupBy_level/StreamGroupByDemo1_Output.txt b/BasicJava/StreamDemo_groupBy_level/StreamGroupByDemo1_Output.txt new file mode 100644 index 000000000..d35e55346 --- /dev/null +++ b/BasicJava/StreamDemo_groupBy_level/StreamGroupByDemo1_Output.txt @@ -0,0 +1,9 @@ +Teacher Name : Mr.John +Student [studentName=Peter, teacherName=Mr.John, level=1, className=Java Basics] +Student [studentName=Ram, teacherName=Mr.John, level=1, className=Webservice Basics] +Student [studentName=Juli, teacherName=Mr.John, level=2, className=Advance Java] +------------------------------------- +Teacher Name : Mr.Kumar +Student [studentName=Dave, teacherName=Mr.Kumar, level=1, className=Ruby basics] +Student [studentName=Raja, teacherName=Mr.Kumar, level=2, className=Advance Ruby] +------------------------------------- diff --git a/BasicJava/StreamDemo_groupBy_level/StreamGroupByDemo2_Output.txt b/BasicJava/StreamDemo_groupBy_level/StreamGroupByDemo2_Output.txt new file mode 100644 index 000000000..9488deb91 --- /dev/null +++ b/BasicJava/StreamDemo_groupBy_level/StreamGroupByDemo2_Output.txt @@ -0,0 +1,9 @@ +Level : 1 +Student [studentName=Peter, teacherName=Mr.John, level=1, className=Java Basics] +Student [studentName=Ram, teacherName=Mr.John, level=1, className=Webservice Basics] +Student [studentName=Dave, teacherName=Mr.Kumar, level=1, className=Ruby basics] +---------------------------------- +Level : 2 +Student [studentName=Juli, teacherName=Mr.John, level=2, className=Advance Java] +Student [studentName=Raja, teacherName=Mr.Kumar, level=2, className=Advance Ruby] +---------------------------------- diff --git a/BasicJava/StreamDemo_groupBy_level/StreamGroupByDemo3_Output.txt b/BasicJava/StreamDemo_groupBy_level/StreamGroupByDemo3_Output.txt new file mode 100644 index 000000000..2c2e922b8 --- /dev/null +++ b/BasicJava/StreamDemo_groupBy_level/StreamGroupByDemo3_Output.txt @@ -0,0 +1,2 @@ +Level = 1, Count = 3 +Level = 2, Count = 2 diff --git a/BasicJava/StreamDemo_how_many_male_count/Output.txt b/BasicJava/StreamDemo_how_many_male_count/Output.txt new file mode 100644 index 000000000..39a4e293c --- /dev/null +++ b/BasicJava/StreamDemo_how_many_male_count/Output.txt @@ -0,0 +1 @@ +Total male = 3 diff --git a/BasicJava/StreamDemo_how_many_male_count/StreamDemo/.classpath b/BasicJava/StreamDemo_how_many_male_count/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_how_many_male_count/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_how_many_male_count/StreamDemo/.project b/BasicJava/StreamDemo_how_many_male_count/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_how_many_male_count/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_how_many_male_count/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_how_many_male_count/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_how_many_male_count/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_how_many_male_count/StreamDemo/bin/Gender.class b/BasicJava/StreamDemo_how_many_male_count/StreamDemo/bin/Gender.class new file mode 100644 index 000000000..c667336c7 Binary files /dev/null and b/BasicJava/StreamDemo_how_many_male_count/StreamDemo/bin/Gender.class differ diff --git a/BasicJava/StreamDemo_how_many_male_count/StreamDemo/bin/Person.class b/BasicJava/StreamDemo_how_many_male_count/StreamDemo/bin/Person.class new file mode 100644 index 000000000..eda7e7dcb Binary files /dev/null and b/BasicJava/StreamDemo_how_many_male_count/StreamDemo/bin/Person.class differ diff --git a/BasicJava/StreamDemo_how_many_male_count/StreamDemo/bin/StreamCountDemo.class b/BasicJava/StreamDemo_how_many_male_count/StreamDemo/bin/StreamCountDemo.class new file mode 100644 index 000000000..b503c7acf Binary files /dev/null and b/BasicJava/StreamDemo_how_many_male_count/StreamDemo/bin/StreamCountDemo.class differ diff --git a/BasicJava/StreamDemo_how_many_male_count/StreamDemo/src/Person.java b/BasicJava/StreamDemo_how_many_male_count/StreamDemo/src/Person.java new file mode 100644 index 000000000..0e39eeb00 --- /dev/null +++ b/BasicJava/StreamDemo_how_many_male_count/StreamDemo/src/Person.java @@ -0,0 +1,68 @@ +enum Gender +{ + MALE, FEMALE +} + +public class Person +{ + private String name; + private String email; + private Gender gender; + private int age; + + public Person(String name, String email, Gender gender, int age) + { + super(); + this.name = name; + this.email = email; + this.gender = gender; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getEmail() + { + return email; + } + + public void setEmail(String email) + { + this.email = email; + } + + public Gender getGender() + { + return gender; + } + + public void setGender(Gender gender) + { + this.gender = gender; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + @Override + public String toString() + { + return "Person [name=" + name + "]"; + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_how_many_male_count/StreamDemo/src/StreamCountDemo.java b/BasicJava/StreamDemo_how_many_male_count/StreamDemo/src/StreamCountDemo.java new file mode 100644 index 000000000..771bdb99d --- /dev/null +++ b/BasicJava/StreamDemo_how_many_male_count/StreamDemo/src/StreamCountDemo.java @@ -0,0 +1,28 @@ +import java.util.ArrayList; +import java.util.List; + +public class StreamCountDemo +{ + public static void main(String[] args) + { + List personList = new ArrayList<>(); + + personList.add(new Person("Alice","alice@gmail.com", Gender.FEMALE, 26)); + personList.add(new Person("Bob","bob@gmail.com", Gender.MALE, 32)); + personList.add(new Person("Carol","carol@gmail.com",Gender.FEMALE, 23)); + personList.add(new Person("David","david@gmail.com", Gender.MALE, 39)); + personList.add(new Person("Eric","eric@gmail.com", Gender.MALE, 26)); + + /* + * The count() operation simply returns total number of elements in the + * stream. + * + * The following code finds how many people are male: + */ + long totalMale = personList.stream() + .filter(p -> p.getGender().equals(Gender.MALE)).count(); + System.out.println("Total male = " + totalMale); + + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_illegal_exe_App/Output.txt b/BasicJava/StreamDemo_illegal_exe_App/Output.txt new file mode 100644 index 000000000..af8becce9 --- /dev/null +++ b/BasicJava/StreamDemo_illegal_exe_App/Output.txt @@ -0,0 +1,7 @@ +Peter +Steve +Juli +Exception in thread "main" java.lang.IllegalStateException: stream has already been operated upon or closed + at java.util.stream.AbstractPipeline.sourceStageSpliterator(Unknown Source) + at java.util.stream.ReferencePipeline$Head.forEach(Unknown Source) + at StreamDemo.main(StreamDemo.java:18) diff --git a/BasicJava/StreamDemo_illegal_exe_App/StreamDemo/.classpath b/BasicJava/StreamDemo_illegal_exe_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_illegal_exe_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_illegal_exe_App/StreamDemo/.project b/BasicJava/StreamDemo_illegal_exe_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_illegal_exe_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_illegal_exe_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_illegal_exe_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_illegal_exe_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_illegal_exe_App/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_illegal_exe_App/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..7e0ec9c70 Binary files /dev/null and b/BasicJava/StreamDemo_illegal_exe_App/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_illegal_exe_App/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_illegal_exe_App/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..e2eb1a67d --- /dev/null +++ b/BasicJava/StreamDemo_illegal_exe_App/StreamDemo/src/StreamDemo.java @@ -0,0 +1,21 @@ +import java.util.Arrays; +import java.util.List; +import java.util.stream.Stream; + +public class StreamDemo +{ + public static void main(String[] args) + { + List nameList = Arrays.asList("Peter", "Steve", "Juli"); + + Stream stream = nameList.stream(); + + // perform terminal operation by forEach method + stream.forEach(System.out::println); + + // the stream is already closed, so this code will throw + // exception at runtime + stream.forEach(System.out::print); + + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_im_op_examples_App/StreamDemo/.classpath b/BasicJava/StreamDemo_im_op_examples_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_im_op_examples_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_im_op_examples_App/StreamDemo/.project b/BasicJava/StreamDemo_im_op_examples_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_im_op_examples_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_im_op_examples_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_im_op_examples_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_im_op_examples_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_im_op_examples_App/StreamDemo/bin/StreamDemo1.class b/BasicJava/StreamDemo_im_op_examples_App/StreamDemo/bin/StreamDemo1.class new file mode 100644 index 000000000..aabb4c597 Binary files /dev/null and b/BasicJava/StreamDemo_im_op_examples_App/StreamDemo/bin/StreamDemo1.class differ diff --git a/BasicJava/StreamDemo_im_op_examples_App/StreamDemo/bin/StreamDemo2.class b/BasicJava/StreamDemo_im_op_examples_App/StreamDemo/bin/StreamDemo2.class new file mode 100644 index 000000000..98fa91f60 Binary files /dev/null and b/BasicJava/StreamDemo_im_op_examples_App/StreamDemo/bin/StreamDemo2.class differ diff --git a/BasicJava/StreamDemo_im_op_examples_App/StreamDemo/bin/StreamDemo3.class b/BasicJava/StreamDemo_im_op_examples_App/StreamDemo/bin/StreamDemo3.class new file mode 100644 index 000000000..1cce49b02 Binary files /dev/null and b/BasicJava/StreamDemo_im_op_examples_App/StreamDemo/bin/StreamDemo3.class differ diff --git a/BasicJava/StreamDemo_im_op_examples_App/StreamDemo/src/StreamDemo1.java b/BasicJava/StreamDemo_im_op_examples_App/StreamDemo/src/StreamDemo1.java new file mode 100644 index 000000000..c1928f7d2 --- /dev/null +++ b/BasicJava/StreamDemo_im_op_examples_App/StreamDemo/src/StreamDemo1.java @@ -0,0 +1,32 @@ +import java.util.ArrayList; +import java.util.List; + +/** + * + * Intermediate operations return the stream itself so you can chain + * multiple method calls in a row. + * + */ +public class StreamDemo1 +{ + public static void main(String[] args) + { + List nameList = new ArrayList<>(); + nameList.add("Amitabh"); + nameList.add("Shekhar"); + nameList.add("Aman"); + nameList.add("Rahul"); + nameList.add("Shahrukh"); + nameList.add("Salman"); + nameList.add("Yana"); + nameList.add("Lokesh"); + + /* + * Filter accepts a predicate to filter all elements of the + * stream. This operation is intermediate which enables us to + * call another stream operation (e.g. forEach) on the result. + */ + nameList.stream().filter((s) -> s.startsWith("A")) + .forEach(System.out::println); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_im_op_examples_App/StreamDemo/src/StreamDemo2.java b/BasicJava/StreamDemo_im_op_examples_App/StreamDemo/src/StreamDemo2.java new file mode 100644 index 000000000..df08b63a8 --- /dev/null +++ b/BasicJava/StreamDemo_im_op_examples_App/StreamDemo/src/StreamDemo2.java @@ -0,0 +1,35 @@ +import java.util.ArrayList; +import java.util.List; + +/** + * + * Intermediate operations return the stream itself so you can chain + * multiple method calls in a row. + * + */ +public class StreamDemo2 +{ + public static void main(String[] args) + { + List nameList = new ArrayList<>(); + nameList.add("Amitabh"); + nameList.add("Shekhar"); + nameList.add("Aman"); + nameList.add("Rahul"); + nameList.add("Shahrukh"); + nameList.add("Salman"); + nameList.add("Yana"); + nameList.add("Lokesh"); + + /* + * The intermediate operation map converts each element into + * another object via the given function. The following + * example converts each string into an upper-cased string. + * But you can also use map to transform each object into + * another type. + */ + nameList.stream().filter((s) -> s.startsWith("S")) + .map(String::toUpperCase) + .forEach(System.out::println); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_im_op_examples_App/StreamDemo/src/StreamDemo3.java b/BasicJava/StreamDemo_im_op_examples_App/StreamDemo/src/StreamDemo3.java new file mode 100644 index 000000000..e7cc7305a --- /dev/null +++ b/BasicJava/StreamDemo_im_op_examples_App/StreamDemo/src/StreamDemo3.java @@ -0,0 +1,36 @@ +import java.util.ArrayList; +import java.util.List; + +/** + * + * Intermediate operations return the stream itself so you can chain + * multiple method calls in a row. + * + */ +public class StreamDemo3 +{ + public static void main(String[] args) + { + List nameList = new ArrayList<>(); + nameList.add("Amitabh"); + nameList.add("Shekhar"); + nameList.add("Aman"); + nameList.add("Rahul"); + nameList.add("Shahrukh"); + nameList.add("Salman"); + nameList.add("Yana"); + nameList.add("Lokesh"); + + /* + * Sorted is an intermediate operation which returns a sorted + * view of the stream. The elements are sorted in natural + * order unless you pass a custom Comparator. + * + * Keep in mind that sorted does only create a sorted view of + * the stream without manipulating the ordering of the backed + * collection. The ordering of memberNames is untouched. + */ + nameList.stream().sorted().map(String::toUpperCase) + .forEach(System.out::println); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_im_op_examples_App/StreamDemo1_Output.txt b/BasicJava/StreamDemo_im_op_examples_App/StreamDemo1_Output.txt new file mode 100644 index 000000000..eccbf233d --- /dev/null +++ b/BasicJava/StreamDemo_im_op_examples_App/StreamDemo1_Output.txt @@ -0,0 +1,2 @@ +Amitabh +Aman diff --git a/BasicJava/StreamDemo_im_op_examples_App/StreamDemo2_Output.txt b/BasicJava/StreamDemo_im_op_examples_App/StreamDemo2_Output.txt new file mode 100644 index 000000000..02fa4f1a3 --- /dev/null +++ b/BasicJava/StreamDemo_im_op_examples_App/StreamDemo2_Output.txt @@ -0,0 +1,3 @@ +SHEKHAR +SHAHRUKH +SALMAN diff --git a/BasicJava/StreamDemo_im_op_examples_App/StreamDemo3_Output.txt b/BasicJava/StreamDemo_im_op_examples_App/StreamDemo3_Output.txt new file mode 100644 index 000000000..563d8a7d9 --- /dev/null +++ b/BasicJava/StreamDemo_im_op_examples_App/StreamDemo3_Output.txt @@ -0,0 +1,8 @@ +AMAN +AMITABH +LOKESH +RAHUL +SALMAN +SHAHRUKH +SHEKHAR +YANA diff --git a/BasicJava/StreamDemo_iterate_method_App/StreamDemo/.classpath b/BasicJava/StreamDemo_iterate_method_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_iterate_method_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_iterate_method_App/StreamDemo/.project b/BasicJava/StreamDemo_iterate_method_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_iterate_method_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_iterate_method_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_iterate_method_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_iterate_method_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_iterate_method_App/StreamDemo/bin/StreamDemo1.class b/BasicJava/StreamDemo_iterate_method_App/StreamDemo/bin/StreamDemo1.class new file mode 100644 index 000000000..a45bd577e Binary files /dev/null and b/BasicJava/StreamDemo_iterate_method_App/StreamDemo/bin/StreamDemo1.class differ diff --git a/BasicJava/StreamDemo_iterate_method_App/StreamDemo/bin/StreamDemo2.class b/BasicJava/StreamDemo_iterate_method_App/StreamDemo/bin/StreamDemo2.class new file mode 100644 index 000000000..79f2e4dc5 Binary files /dev/null and b/BasicJava/StreamDemo_iterate_method_App/StreamDemo/bin/StreamDemo2.class differ diff --git a/BasicJava/StreamDemo_iterate_method_App/StreamDemo/src/StreamDemo1.java b/BasicJava/StreamDemo_iterate_method_App/StreamDemo/src/StreamDemo1.java new file mode 100644 index 000000000..4b3068ce8 --- /dev/null +++ b/BasicJava/StreamDemo_iterate_method_App/StreamDemo/src/StreamDemo1.java @@ -0,0 +1,16 @@ +import java.util.stream.Stream; + +/** + * + * We can use stream to iterate any number of times. Stream provides + * predefined methods to deal with the logic you implement. + * + */ +public class StreamDemo1 +{ + public static void main(String[] args) + { + Stream.iterate(1, element -> element + 1) + .forEach(System.out::println); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_iterate_method_App/StreamDemo/src/StreamDemo2.java b/BasicJava/StreamDemo_iterate_method_App/StreamDemo/src/StreamDemo2.java new file mode 100644 index 000000000..39a9f86a2 --- /dev/null +++ b/BasicJava/StreamDemo_iterate_method_App/StreamDemo/src/StreamDemo2.java @@ -0,0 +1,20 @@ +import java.util.stream.Stream; + +/** + * + * We can use stream to iterate any number of times. Stream provides + * predefined methods to deal with the logic you implement. In the + * following example, we are iterating, filtering and passed a limit + * to fix the iteration. + * + */ +public class StreamDemo2 +{ + public static void main(String[] args) + { + Stream.iterate(1, element -> element + 1) + .filter(element -> element % 10 == 0).limit(5) + .forEach(System.out::println); + + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_iterate_method_App/StreamDemo1_Output.txt b/BasicJava/StreamDemo_iterate_method_App/StreamDemo1_Output.txt new file mode 100644 index 000000000..4eadfbdfe --- /dev/null +++ b/BasicJava/StreamDemo_iterate_method_App/StreamDemo1_Output.txt @@ -0,0 +1,15 @@ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +.. +.. +.. +.. \ No newline at end of file diff --git a/BasicJava/StreamDemo_iterate_method_App/StreamDemo2_Output.txt b/BasicJava/StreamDemo_iterate_method_App/StreamDemo2_Output.txt new file mode 100644 index 000000000..dd76fe42c --- /dev/null +++ b/BasicJava/StreamDemo_iterate_method_App/StreamDemo2_Output.txt @@ -0,0 +1,5 @@ +10 +20 +30 +40 +50 diff --git a/BasicJava/StreamDemo_list_to_map_App/Output.txt b/BasicJava/StreamDemo_list_to_map_App/Output.txt new file mode 100644 index 000000000..f7d60fe83 --- /dev/null +++ b/BasicJava/StreamDemo_list_to_map_App/Output.txt @@ -0,0 +1 @@ +{Nokia mobile=10000, Lenovo mobile=15000, Samsung mobile=40000, Micromax mobile=10000, Sony mobile=25000} diff --git a/BasicJava/StreamDemo_list_to_map_App/StreamDemo/.classpath b/BasicJava/StreamDemo_list_to_map_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_list_to_map_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_list_to_map_App/StreamDemo/.project b/BasicJava/StreamDemo_list_to_map_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_list_to_map_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_list_to_map_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_list_to_map_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_list_to_map_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_list_to_map_App/StreamDemo/bin/Product.class b/BasicJava/StreamDemo_list_to_map_App/StreamDemo/bin/Product.class new file mode 100644 index 000000000..2a97ce097 Binary files /dev/null and b/BasicJava/StreamDemo_list_to_map_App/StreamDemo/bin/Product.class differ diff --git a/BasicJava/StreamDemo_list_to_map_App/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_list_to_map_App/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..26c9549b4 Binary files /dev/null and b/BasicJava/StreamDemo_list_to_map_App/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_list_to_map_App/StreamDemo/src/Product.java b/BasicJava/StreamDemo_list_to_map_App/StreamDemo/src/Product.java new file mode 100644 index 000000000..9e53fdc45 --- /dev/null +++ b/BasicJava/StreamDemo_list_to_map_App/StreamDemo/src/Product.java @@ -0,0 +1,52 @@ +class Product +{ + private int id; + private String name; + private int price; + + public Product(int id, String name, int price) + { + super(); + this.id = id; + this.name = name; + this.price = price; + } + + public int getId() + { + return id; + } + + public void setId(int id) + { + this.id = id; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getPrice() + { + return price; + } + + public void setPrice(int price) + { + this.price = price; + } + + @Override + public String toString() + { + return "Product [id=" + id + ", name=" + name + ", price=" + + price + "]"; + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_list_to_map_App/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_list_to_map_App/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..54a3a4ea0 --- /dev/null +++ b/BasicJava/StreamDemo_list_to_map_App/StreamDemo/src/StreamDemo.java @@ -0,0 +1,31 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * + * Convert List into Map. + * + */ +public class StreamDemo +{ + public static void main(String[] args) + { + List productList = new ArrayList(); + + // Adding Products + productList.add(new Product(1, "Sony mobile", 25000)); + productList.add(new Product(2, "Lenovo mobile", 15000)); + productList.add(new Product(3, "Nokia mobile", 10000)); + productList.add(new Product(4, "Samsung mobile", 40000)); + productList.add(new Product(5, "Micromax mobile", 10000)); + + // Converting Product List into a Map + Map productPriceMap = productList.stream() + .collect(Collectors.toMap(p -> p.getName(), p -> p.getPrice())); + + System.out.println(productPriceMap); + + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_map_app/Output.txt b/BasicJava/StreamDemo_map_app/Output.txt new file mode 100644 index 000000000..5089231f7 --- /dev/null +++ b/BasicJava/StreamDemo_map_app/Output.txt @@ -0,0 +1 @@ +Peter diff --git a/BasicJava/StreamDemo_map_app/StreamDemo/.classpath b/BasicJava/StreamDemo_map_app/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_map_app/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_map_app/StreamDemo/.project b/BasicJava/StreamDemo_map_app/StreamDemo/.project new file mode 100644 index 000000000..b6dfe7639 --- /dev/null +++ b/BasicJava/StreamDemo_map_app/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamsDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_map_app/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_map_app/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_map_app/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_map_app/StreamDemo/bin/Person.class b/BasicJava/StreamDemo_map_app/StreamDemo/bin/Person.class new file mode 100644 index 000000000..4a6e99281 Binary files /dev/null and b/BasicJava/StreamDemo_map_app/StreamDemo/bin/Person.class differ diff --git a/BasicJava/StreamDemo_map_app/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_map_app/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..9e4cd4923 Binary files /dev/null and b/BasicJava/StreamDemo_map_app/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_map_app/StreamDemo/src/Person.java b/BasicJava/StreamDemo_map_app/StreamDemo/src/Person.java new file mode 100644 index 000000000..c62fe352e --- /dev/null +++ b/BasicJava/StreamDemo_map_app/StreamDemo/src/Person.java @@ -0,0 +1,52 @@ +public class Person +{ + private int id; + private String name; + private int age; + + public Person(int id, String name, int age) + { + super(); + this.id = id; + this.name = name; + this.age = age; + } + + public int getId() + { + return id; + } + + public void setId(int id) + { + this.id = id; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + @Override + public String toString() + { + return "Person [id=" + id + ", name=" + name + ", age=" + age + + "]"; + } + +} diff --git a/BasicJava/StreamDemo_map_app/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_map_app/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..f4f242727 --- /dev/null +++ b/BasicJava/StreamDemo_map_app/StreamDemo/src/StreamDemo.java @@ -0,0 +1,30 @@ +import java.util.Arrays; +import java.util.List; + +/** + * + * How to convert Stream to Stream using map method of + * Stream. + * + */ +public class StreamDemo +{ + public static void main(String[] args) + { + + List personList = Arrays.asList(new Person(1, "Ram", 25), + new Person(2, "Peter", 31), + new Person(3, "Steve", 25), + new Person(4, "Balu", 32)); + + + String name = personList.stream() //convert list to stream + .filter(x -> "Peter".equals(x.getName())) // we want "Peter" only + .map(Person::getName) //convert Stream to Stream + .findAny() // If 'findAny' then return found + .orElse(null); // If not found, return null + + System.out.println(name); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_map_methods_App/Output.txt b/BasicJava/StreamDemo_map_methods_App/Output.txt new file mode 100644 index 000000000..9bb5139e9 --- /dev/null +++ b/BasicJava/StreamDemo_map_methods_App/Output.txt @@ -0,0 +1,4 @@ +Stream = 1 4 9 16 +DoubleStream = 1.0 4.0 9.0 16.0 +LongStream = 1 4 9 16 +IntStream = 1 4 9 16 \ No newline at end of file diff --git a/BasicJava/StreamDemo_map_methods_App/StreamDemo/.classpath b/BasicJava/StreamDemo_map_methods_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_map_methods_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_map_methods_App/StreamDemo/.project b/BasicJava/StreamDemo_map_methods_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_map_methods_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_map_methods_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_map_methods_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_map_methods_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_map_methods_App/StreamDemo/bin/StreamGenerateDemo.class b/BasicJava/StreamDemo_map_methods_App/StreamDemo/bin/StreamGenerateDemo.class new file mode 100644 index 000000000..f5234fae1 Binary files /dev/null and b/BasicJava/StreamDemo_map_methods_App/StreamDemo/bin/StreamGenerateDemo.class differ diff --git a/BasicJava/StreamDemo_map_methods_App/StreamDemo/bin/StreamMapDemo.class b/BasicJava/StreamDemo_map_methods_App/StreamDemo/bin/StreamMapDemo.class new file mode 100644 index 000000000..e59aefc1a Binary files /dev/null and b/BasicJava/StreamDemo_map_methods_App/StreamDemo/bin/StreamMapDemo.class differ diff --git a/BasicJava/StreamDemo_map_methods_App/StreamDemo/src/StreamMapDemo.java b/BasicJava/StreamDemo_map_methods_App/StreamDemo/src/StreamMapDemo.java new file mode 100644 index 000000000..2b7bd3d07 --- /dev/null +++ b/BasicJava/StreamDemo_map_methods_App/StreamDemo/src/StreamMapDemo.java @@ -0,0 +1,49 @@ +import java.util.Arrays; +import java.util.List; +import java.util.stream.DoubleStream; +import java.util.stream.IntStream; +import java.util.stream.LongStream; +import java.util.stream.Stream; + +public class StreamMapDemo +{ + public static void main(String[] args) + { + List list = Arrays.asList(1, 2, 3, 4); + System.out.print("\nStream = "); + + /* + * Stream.map(): It returns a stream after applying given + * function to each element of the stream. + */ + Stream stream = list.stream().map(i -> i * i); + stream.forEach(s -> System.out.print(s + " ")); + + System.out.print("\nDoubleStream = "); + + /* + * mapToDouble(): It returns DoubleStream after applying the + * given function. + */ + DoubleStream doubleStream = list.stream().mapToDouble(i -> i * i); + doubleStream.forEach(s -> System.out.print(s + " ")); + + System.out.print("\nLongStream = "); + + /* + * mapToLong(): It returns LongStream after applying the given + * function. + */ + LongStream longStream = list.stream().mapToLong(i -> i * i); + longStream.forEach(s -> System.out.print(s + " ")); + + System.out.print("\nIntStream = "); + + /* + * mapToInt(): It returns IntStream after applying the given + * function. + */ + IntStream intStream = list.stream().mapToInt(i -> i * i); + intStream.forEach(s -> System.out.print(s + " ")); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_map_person_name_age/Output.txt b/BasicJava/StreamDemo_map_person_name_age/Output.txt new file mode 100644 index 000000000..3a5ee41af --- /dev/null +++ b/BasicJava/StreamDemo_map_person_name_age/Output.txt @@ -0,0 +1,21 @@ +alice@gmail.com +bob@gmail.com +carol@gmail.com +david@gmail.com +eric@gmail.com + +---------------------- + +ALICE +BOB +CAROL +DAVID +ERIC + +---------------------- + +16 +15 +23 +19 +26 diff --git a/BasicJava/StreamDemo_map_person_name_age/StreamDemo/.classpath b/BasicJava/StreamDemo_map_person_name_age/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_map_person_name_age/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_map_person_name_age/StreamDemo/.project b/BasicJava/StreamDemo_map_person_name_age/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_map_person_name_age/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_map_person_name_age/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_map_person_name_age/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_map_person_name_age/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_map_person_name_age/StreamDemo/bin/Gender.class b/BasicJava/StreamDemo_map_person_name_age/StreamDemo/bin/Gender.class new file mode 100644 index 000000000..c667336c7 Binary files /dev/null and b/BasicJava/StreamDemo_map_person_name_age/StreamDemo/bin/Gender.class differ diff --git a/BasicJava/StreamDemo_map_person_name_age/StreamDemo/bin/Person.class b/BasicJava/StreamDemo_map_person_name_age/StreamDemo/bin/Person.class new file mode 100644 index 000000000..71efbdf36 Binary files /dev/null and b/BasicJava/StreamDemo_map_person_name_age/StreamDemo/bin/Person.class differ diff --git a/BasicJava/StreamDemo_map_person_name_age/StreamDemo/bin/StreamMapDemo.class b/BasicJava/StreamDemo_map_person_name_age/StreamDemo/bin/StreamMapDemo.class new file mode 100644 index 000000000..32973c731 Binary files /dev/null and b/BasicJava/StreamDemo_map_person_name_age/StreamDemo/bin/StreamMapDemo.class differ diff --git a/BasicJava/StreamDemo_map_person_name_age/StreamDemo/src/Person.java b/BasicJava/StreamDemo_map_person_name_age/StreamDemo/src/Person.java new file mode 100644 index 000000000..578960566 --- /dev/null +++ b/BasicJava/StreamDemo_map_person_name_age/StreamDemo/src/Person.java @@ -0,0 +1,69 @@ +enum Gender +{ + MALE, FEMALE +} + +public class Person +{ + private String name; + private String email; + private Gender gender; + private int age; + + public Person(String name, String email, Gender gender, int age) + { + super(); + this.name = name; + this.email = email; + this.gender = gender; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getEmail() + { + return email; + } + + public void setEmail(String email) + { + this.email = email; + } + + public Gender getGender() + { + return gender; + } + + public void setGender(Gender gender) + { + this.gender = gender; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + @Override + public String toString() + { + return "Person [name=" + name + ", gender=" + gender + ", age=" + age + + "]"; + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_map_person_name_age/StreamDemo/src/StreamMapDemo.java b/BasicJava/StreamDemo_map_person_name_age/StreamDemo/src/StreamMapDemo.java new file mode 100644 index 000000000..c1eff4705 --- /dev/null +++ b/BasicJava/StreamDemo_map_person_name_age/StreamDemo/src/StreamMapDemo.java @@ -0,0 +1,56 @@ +import java.util.ArrayList; +import java.util.List; + +public class StreamMapDemo +{ + public static void main(String[] args) + { + List personList = new ArrayList<>(); + + personList.add(new Person("Alice", "alice@gmail.com", Gender.FEMALE, 16)); + personList.add(new Person("Bob", "bob@gmail.com", Gender.MALE, 15)); + personList.add(new Person("Carol", "carol@gmail.com", Gender.FEMALE, 23)); + personList.add(new Person("David", "david@gmail.com", Gender.MALE, 19)); + personList.add(new Person("Eric", "eric@gmail.com", Gender.MALE, 26)); + + /* + * The map operation returns a new stream consisting of elements which + * are the results of applying a given function to the elements of the + * current stream. For example, converting a stream of Objects to a + * stream of String or a stream of primitive numbers. + * + * The Stream API provides 4 methods for the map operation: + * + * map(): transforms a stream of objects of type T to a stream of + * objects of type R. + * + * mapToInt(): transforms a stream of objects to a stream of int + * primitives. + * + * mapToLong(): transforms a stream of objects to a stream of long + * primitives. + * + * mapToDouble(): transforms a stream of objects to a stream of double + * primitives. + * + */ + + personList.stream() // Stream + .map(p -> p.getEmail()) // Stream + .forEach(System.out::println); + + System.out.println("\n----------------------\n"); + + personList.stream() // Stream + .map(p -> p.getName().toUpperCase()) // Stream + .forEach(System.out::println); + + System.out.println("\n----------------------\n"); + + personList.stream() // Stream + .mapToInt(p -> p.getAge()) //IntStream + .forEach(age -> System.out.println(age)); + + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_map_uppercase_App/Output.txt b/BasicJava/StreamDemo_map_uppercase_App/Output.txt new file mode 100644 index 000000000..4c9b8c70e --- /dev/null +++ b/BasicJava/StreamDemo_map_uppercase_App/Output.txt @@ -0,0 +1,4 @@ +PETER +STEVE +PAUL +RAM diff --git a/BasicJava/StreamDemo_map_uppercase_App/StreamDemo/.classpath b/BasicJava/StreamDemo_map_uppercase_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_map_uppercase_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_map_uppercase_App/StreamDemo/.project b/BasicJava/StreamDemo_map_uppercase_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_map_uppercase_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_map_uppercase_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_map_uppercase_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_map_uppercase_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_map_uppercase_App/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_map_uppercase_App/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..294dde54c Binary files /dev/null and b/BasicJava/StreamDemo_map_uppercase_App/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_map_uppercase_App/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_map_uppercase_App/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..5dd114eaa --- /dev/null +++ b/BasicJava/StreamDemo_map_uppercase_App/StreamDemo/src/StreamDemo.java @@ -0,0 +1,39 @@ +import java.util.Arrays; +import java.util.stream.Stream; + +/** + * Once you have a Stream object, you can use a variety of methods to + * transform it into another Stream object. The first such method + * we’re going to look at is the map method. It takes a lambda + * expression as its only argument, and uses it to change every + * individual element in the stream. Its return value is a new Stream + * object containing the changed elements. + * + * How to use map to convert all elements in an array of strings to + * uppercase. + */ +public class StreamDemo +{ + public static void main(String[] args) + { + String[] nameArray = new String[] { "Peter", "Steve", "paul", "Ram" }; + + Stream stream = Arrays.stream(nameArray); + + /* + * passing a lambda expression, one which can convert a string + * to uppercase. + * + * The Stream object returned contains the changed strings. + */ + Stream upperCaseStream = stream.map(name -> name.toUpperCase()); + + String[] upperCaseNameArray = upperCaseStream.toArray(String[]::new); + + for (String name : upperCaseNameArray) + { + System.out.println(name); + } + + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_max_min_comp_App/Output.txt b/BasicJava/StreamDemo_max_min_comp_App/Output.txt new file mode 100644 index 000000000..e00be81d9 --- /dev/null +++ b/BasicJava/StreamDemo_max_min_comp_App/Output.txt @@ -0,0 +1,2 @@ +Max:Z +Min:B diff --git a/BasicJava/StreamDemo_max_min_comp_App/StreamDemo/.classpath b/BasicJava/StreamDemo_max_min_comp_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_max_min_comp_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_max_min_comp_App/StreamDemo/.project b/BasicJava/StreamDemo_max_min_comp_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_max_min_comp_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_max_min_comp_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_max_min_comp_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_max_min_comp_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_max_min_comp_App/StreamDemo/bin/StreamMaxMinDemo.class b/BasicJava/StreamDemo_max_min_comp_App/StreamDemo/bin/StreamMaxMinDemo.class new file mode 100644 index 000000000..700d376c5 Binary files /dev/null and b/BasicJava/StreamDemo_max_min_comp_App/StreamDemo/bin/StreamMaxMinDemo.class differ diff --git a/BasicJava/StreamDemo_max_min_comp_App/StreamDemo/src/StreamMaxMinDemo.java b/BasicJava/StreamDemo_max_min_comp_App/StreamDemo/src/StreamMaxMinDemo.java new file mode 100644 index 000000000..cd1b5c578 --- /dev/null +++ b/BasicJava/StreamDemo_max_min_comp_App/StreamDemo/src/StreamMaxMinDemo.java @@ -0,0 +1,27 @@ +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; + +public class StreamMaxMinDemo +{ + public static void main(String[] args) + { + List list = Arrays.asList("Z", "B", "I", "E"); + + /* + * max(): It finds maximum element for the given Comparator. + */ + String max = list.stream() + .max(Comparator.comparing(String::valueOf)).get(); + + System.out.println("Max:" + max); + + /* + * min(): It finds minimum element for the given Comparator. + */ + String min = list.stream() + .min(Comparator.comparing(String::valueOf)).get(); + + System.out.println("Min:" + min); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_max_oldestman/Output.txt b/BasicJava/StreamDemo_max_oldestman/Output.txt new file mode 100644 index 000000000..12149ca0b --- /dev/null +++ b/BasicJava/StreamDemo_max_oldestman/Output.txt @@ -0,0 +1 @@ +The oldest man is: David (39) diff --git a/BasicJava/StreamDemo_max_oldestman/StreamDemo/.classpath b/BasicJava/StreamDemo_max_oldestman/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_max_oldestman/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_max_oldestman/StreamDemo/.project b/BasicJava/StreamDemo_max_oldestman/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_max_oldestman/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_max_oldestman/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_max_oldestman/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_max_oldestman/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_max_oldestman/StreamDemo/bin/Gender.class b/BasicJava/StreamDemo_max_oldestman/StreamDemo/bin/Gender.class new file mode 100644 index 000000000..c667336c7 Binary files /dev/null and b/BasicJava/StreamDemo_max_oldestman/StreamDemo/bin/Gender.class differ diff --git a/BasicJava/StreamDemo_max_oldestman/StreamDemo/bin/Person.class b/BasicJava/StreamDemo_max_oldestman/StreamDemo/bin/Person.class new file mode 100644 index 000000000..eda7e7dcb Binary files /dev/null and b/BasicJava/StreamDemo_max_oldestman/StreamDemo/bin/Person.class differ diff --git a/BasicJava/StreamDemo_max_oldestman/StreamDemo/bin/StreamMaxDemo.class b/BasicJava/StreamDemo_max_oldestman/StreamDemo/bin/StreamMaxDemo.class new file mode 100644 index 000000000..99562269a Binary files /dev/null and b/BasicJava/StreamDemo_max_oldestman/StreamDemo/bin/StreamMaxDemo.class differ diff --git a/BasicJava/StreamDemo_max_oldestman/StreamDemo/src/Person.java b/BasicJava/StreamDemo_max_oldestman/StreamDemo/src/Person.java new file mode 100644 index 000000000..0e39eeb00 --- /dev/null +++ b/BasicJava/StreamDemo_max_oldestman/StreamDemo/src/Person.java @@ -0,0 +1,68 @@ +enum Gender +{ + MALE, FEMALE +} + +public class Person +{ + private String name; + private String email; + private Gender gender; + private int age; + + public Person(String name, String email, Gender gender, int age) + { + super(); + this.name = name; + this.email = email; + this.gender = gender; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getEmail() + { + return email; + } + + public void setEmail(String email) + { + this.email = email; + } + + public Gender getGender() + { + return gender; + } + + public void setGender(Gender gender) + { + this.gender = gender; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + @Override + public String toString() + { + return "Person [name=" + name + "]"; + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_max_oldestman/StreamDemo/src/StreamMaxDemo.java b/BasicJava/StreamDemo_max_oldestman/StreamDemo/src/StreamMaxDemo.java new file mode 100644 index 000000000..1746c5116 --- /dev/null +++ b/BasicJava/StreamDemo_max_oldestman/StreamDemo/src/StreamMaxDemo.java @@ -0,0 +1,36 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +public class StreamMaxDemo +{ + public static void main(String[] args) + { + List personList = new ArrayList<>(); + + personList.add(new Person("Alice","alice@gmail.com", Gender.FEMALE, 26)); + personList.add(new Person("Bob","bob@gmail.com", Gender.MALE, 32)); + personList.add(new Person("Carol","carol@gmail.com",Gender.FEMALE, 23)); + personList.add(new Person("David","david@gmail.com", Gender.MALE, 39)); + personList.add(new Person("Eric","eric@gmail.com", Gender.MALE, 26)); + + /* + * Similar to the min() operation, the max() is a special reduction + * operation that returns the maximum element in the stream according to + * the specified comparator. + * + * The following code finds the oldest male person in the list: + */ + Optional optional = personList.stream() + .filter(p -> p.getGender().equals(Gender.MALE)) + .max((p1, p2) -> p1.getAge() - p2.getAge()); + if (optional.isPresent()) + { + Person oldestMan = optional.get(); + System.out.println("The oldest man is: " + oldestMan.getName() + + " (" + oldestMan.getAge() + ")"); + } + + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_method_ref_App/Output.txt b/BasicJava/StreamDemo_method_ref_App/Output.txt new file mode 100644 index 000000000..0b5391027 --- /dev/null +++ b/BasicJava/StreamDemo_method_ref_App/Output.txt @@ -0,0 +1 @@ +[Sony mobile, Samsung mobile] diff --git a/BasicJava/StreamDemo_method_ref_App/StreamDemo/.classpath b/BasicJava/StreamDemo_method_ref_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_method_ref_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_method_ref_App/StreamDemo/.project b/BasicJava/StreamDemo_method_ref_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_method_ref_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_method_ref_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_method_ref_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_method_ref_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_method_ref_App/StreamDemo/bin/Product.class b/BasicJava/StreamDemo_method_ref_App/StreamDemo/bin/Product.class new file mode 100644 index 000000000..2a97ce097 Binary files /dev/null and b/BasicJava/StreamDemo_method_ref_App/StreamDemo/bin/Product.class differ diff --git a/BasicJava/StreamDemo_method_ref_App/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_method_ref_App/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..e13c5a4a4 Binary files /dev/null and b/BasicJava/StreamDemo_method_ref_App/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_method_ref_App/StreamDemo/src/Product.java b/BasicJava/StreamDemo_method_ref_App/StreamDemo/src/Product.java new file mode 100644 index 000000000..9e53fdc45 --- /dev/null +++ b/BasicJava/StreamDemo_method_ref_App/StreamDemo/src/Product.java @@ -0,0 +1,52 @@ +class Product +{ + private int id; + private String name; + private int price; + + public Product(int id, String name, int price) + { + super(); + this.id = id; + this.name = name; + this.price = price; + } + + public int getId() + { + return id; + } + + public void setId(int id) + { + this.id = id; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getPrice() + { + return price; + } + + public void setPrice(int price) + { + this.price = price; + } + + @Override + public String toString() + { + return "Product [id=" + id + ", name=" + name + ", price=" + + price + "]"; + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_method_ref_App/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_method_ref_App/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..bef4015f5 --- /dev/null +++ b/BasicJava/StreamDemo_method_ref_App/StreamDemo/src/StreamDemo.java @@ -0,0 +1,31 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * + * Method Reference in stream. + * + */ +public class StreamDemo +{ + public static void main(String[] args) + { + List productList = new ArrayList(); + + // Adding Products + productList.add(new Product(1, "Sony mobile", 25000)); + productList.add(new Product(2, "Lenovo mobile", 15000)); + productList.add(new Product(3, "Nokia mobile", 10000)); + productList.add(new Product(4, "Samsung mobile", 40000)); + productList.add(new Product(5, "Micromax mobile", 10000)); + + List productNameList = productList.stream() + .filter(p -> p.getPrice() > 20000) // filtering data + .map(Product::getName) // fetching Name by referring getName method + .collect(Collectors.toList()); // collecting as list + + System.out.println(productNameList); + + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_min_youngestgirl/Output.txt b/BasicJava/StreamDemo_min_youngestgirl/Output.txt new file mode 100644 index 000000000..f1092692f --- /dev/null +++ b/BasicJava/StreamDemo_min_youngestgirl/Output.txt @@ -0,0 +1 @@ +The youngest girl is: Carol (23) diff --git a/BasicJava/StreamDemo_min_youngestgirl/StreamDemo/.classpath b/BasicJava/StreamDemo_min_youngestgirl/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_min_youngestgirl/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_min_youngestgirl/StreamDemo/.project b/BasicJava/StreamDemo_min_youngestgirl/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_min_youngestgirl/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_min_youngestgirl/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_min_youngestgirl/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_min_youngestgirl/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_min_youngestgirl/StreamDemo/bin/Gender.class b/BasicJava/StreamDemo_min_youngestgirl/StreamDemo/bin/Gender.class new file mode 100644 index 000000000..c667336c7 Binary files /dev/null and b/BasicJava/StreamDemo_min_youngestgirl/StreamDemo/bin/Gender.class differ diff --git a/BasicJava/StreamDemo_min_youngestgirl/StreamDemo/bin/Person.class b/BasicJava/StreamDemo_min_youngestgirl/StreamDemo/bin/Person.class new file mode 100644 index 000000000..eda7e7dcb Binary files /dev/null and b/BasicJava/StreamDemo_min_youngestgirl/StreamDemo/bin/Person.class differ diff --git a/BasicJava/StreamDemo_min_youngestgirl/StreamDemo/bin/StreamMinDemo.class b/BasicJava/StreamDemo_min_youngestgirl/StreamDemo/bin/StreamMinDemo.class new file mode 100644 index 000000000..8a5d7a1dc Binary files /dev/null and b/BasicJava/StreamDemo_min_youngestgirl/StreamDemo/bin/StreamMinDemo.class differ diff --git a/BasicJava/StreamDemo_min_youngestgirl/StreamDemo/src/Person.java b/BasicJava/StreamDemo_min_youngestgirl/StreamDemo/src/Person.java new file mode 100644 index 000000000..0e39eeb00 --- /dev/null +++ b/BasicJava/StreamDemo_min_youngestgirl/StreamDemo/src/Person.java @@ -0,0 +1,68 @@ +enum Gender +{ + MALE, FEMALE +} + +public class Person +{ + private String name; + private String email; + private Gender gender; + private int age; + + public Person(String name, String email, Gender gender, int age) + { + super(); + this.name = name; + this.email = email; + this.gender = gender; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getEmail() + { + return email; + } + + public void setEmail(String email) + { + this.email = email; + } + + public Gender getGender() + { + return gender; + } + + public void setGender(Gender gender) + { + this.gender = gender; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + @Override + public String toString() + { + return "Person [name=" + name + "]"; + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_min_youngestgirl/StreamDemo/src/StreamMinDemo.java b/BasicJava/StreamDemo_min_youngestgirl/StreamDemo/src/StreamMinDemo.java new file mode 100644 index 000000000..5b928c891 --- /dev/null +++ b/BasicJava/StreamDemo_min_youngestgirl/StreamDemo/src/StreamMinDemo.java @@ -0,0 +1,39 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +public class StreamMinDemo +{ + public static void main(String[] args) + { + List personList = new ArrayList<>(); + + personList.add(new Person("Alice","alice@gmail.com", Gender.FEMALE, 26)); + personList.add(new Person("Bob","bob@gmail.com", Gender.MALE, 32)); + personList.add(new Person("Carol","carol@gmail.com",Gender.FEMALE, 23)); + personList.add(new Person("David","david@gmail.com", Gender.MALE, 39)); + personList.add(new Person("Eric","eric@gmail.com", Gender.MALE, 26)); + + /* + * The min(comparator) is a special reduction operation that returns the + * minimum element in the stream according to the provided comparator. + * It returns an Optional which is a container object that contains the + * value. + * + * For example, the following code snippet finds the youngest + * female person in the list: + */ + Optional optional = personList.stream() + .filter(p -> p.getGender().equals(Gender.FEMALE)) + .min((p1, p2) -> p1.getAge() - p2.getAge()); + + if (optional.isPresent()) + { + Person youngestGirl = optional.get(); + System.out.println("The youngest girl is: " + youngestGirl.getName() + + " (" + youngestGirl.getAge() + ")"); + } + + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_nameList_filter_App/FilterDemo_Output.txt b/BasicJava/StreamDemo_nameList_filter_App/FilterDemo_Output.txt new file mode 100644 index 000000000..b4fe68afc --- /dev/null +++ b/BasicJava/StreamDemo_nameList_filter_App/FilterDemo_Output.txt @@ -0,0 +1,2 @@ +Peter +Pradeep diff --git a/BasicJava/StreamDemo_nameList_filter_App/StreamDemo/.classpath b/BasicJava/StreamDemo_nameList_filter_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_nameList_filter_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_nameList_filter_App/StreamDemo/.project b/BasicJava/StreamDemo_nameList_filter_App/StreamDemo/.project new file mode 100644 index 000000000..87b82a633 --- /dev/null +++ b/BasicJava/StreamDemo_nameList_filter_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + LambdaDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_nameList_filter_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_nameList_filter_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_nameList_filter_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_nameList_filter_App/StreamDemo/bin/FilterDemo.class b/BasicJava/StreamDemo_nameList_filter_App/StreamDemo/bin/FilterDemo.class new file mode 100644 index 000000000..0daa83a19 Binary files /dev/null and b/BasicJava/StreamDemo_nameList_filter_App/StreamDemo/bin/FilterDemo.class differ diff --git a/BasicJava/StreamDemo_nameList_filter_App/StreamDemo/bin/StreamDemo1.class b/BasicJava/StreamDemo_nameList_filter_App/StreamDemo/bin/StreamDemo1.class new file mode 100644 index 000000000..495886361 Binary files /dev/null and b/BasicJava/StreamDemo_nameList_filter_App/StreamDemo/bin/StreamDemo1.class differ diff --git a/BasicJava/StreamDemo_nameList_filter_App/StreamDemo/bin/StreamDemo2.class b/BasicJava/StreamDemo_nameList_filter_App/StreamDemo/bin/StreamDemo2.class new file mode 100644 index 000000000..483b88515 Binary files /dev/null and b/BasicJava/StreamDemo_nameList_filter_App/StreamDemo/bin/StreamDemo2.class differ diff --git a/BasicJava/StreamDemo_nameList_filter_App/StreamDemo/src/FilterDemo.java b/BasicJava/StreamDemo_nameList_filter_App/StreamDemo/src/FilterDemo.java new file mode 100644 index 000000000..e824f71ad --- /dev/null +++ b/BasicJava/StreamDemo_nameList_filter_App/StreamDemo/src/FilterDemo.java @@ -0,0 +1,30 @@ +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class FilterDemo +{ + public static void main(String[] args) + { + List namesList = Arrays.asList("Ram", "Peter","Pradeep", "Steve"); + + List filteredNameList = getFilterOutput(namesList, "P"); + for (String name : filteredNameList) + { + System.out.println(name); + } + } + + private static List getFilterOutput(List namesList, String filter) + { + List filteredNameList = new ArrayList<>(); + for (String name : namesList) + { + if (name.startsWith("P")) + { + filteredNameList.add(name); + } + } + return filteredNameList; + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_nameList_filter_App/StreamDemo/src/StreamDemo1.java b/BasicJava/StreamDemo_nameList_filter_App/StreamDemo/src/StreamDemo1.java new file mode 100644 index 000000000..2c2b7e1ce --- /dev/null +++ b/BasicJava/StreamDemo_nameList_filter_App/StreamDemo/src/StreamDemo1.java @@ -0,0 +1,38 @@ +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class StreamDemo1 +{ + public static void main(String[] args) + { + List namesList = Arrays.asList("Ram", "Peter","Pradeep", "Steve"); + + /* + * Convert list to stream. + * + * Returns a sequential Stream with this collection as its + * source. + */ + Stream stream = namesList.stream(); + /* + * filters the name, starts with "P". + * + * Returns a stream consisting of the elements of this stream + * that match the given predicate. + */ + stream = stream.filter(name -> name.startsWith("P")); + + /* + * Collect the output and convert streams to a List. + * + * Performs a mutable reduction operation on the elements of + * this stream using a Collector. + */ + List filteredNameList = stream.collect(Collectors.toList()); + + filteredNameList.forEach(System.out::println); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_nameList_filter_App/StreamDemo/src/StreamDemo2.java b/BasicJava/StreamDemo_nameList_filter_App/StreamDemo/src/StreamDemo2.java new file mode 100644 index 000000000..a3618a613 --- /dev/null +++ b/BasicJava/StreamDemo_nameList_filter_App/StreamDemo/src/StreamDemo2.java @@ -0,0 +1,20 @@ +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +public class StreamDemo2 +{ + public static void main(String[] args) + { + List namesList = Arrays.asList("Ram", "Peter","Pradeep", "Steve"); + + + List filteredNameList = namesList.stream() //convert list to stream + .filter(name -> name.startsWith("P")) //filters the name, starts with "P". + .collect(Collectors.toList()); //collect the output and convert streams to a List + + + filteredNameList.forEach(System.out::println); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_nameList_filter_App/StreamDemo1_Output.txt b/BasicJava/StreamDemo_nameList_filter_App/StreamDemo1_Output.txt new file mode 100644 index 000000000..b4fe68afc --- /dev/null +++ b/BasicJava/StreamDemo_nameList_filter_App/StreamDemo1_Output.txt @@ -0,0 +1,2 @@ +Peter +Pradeep diff --git a/BasicJava/StreamDemo_nameList_filter_App/StreamDemo2_Output.txt b/BasicJava/StreamDemo_nameList_filter_App/StreamDemo2_Output.txt new file mode 100644 index 000000000..b4fe68afc --- /dev/null +++ b/BasicJava/StreamDemo_nameList_filter_App/StreamDemo2_Output.txt @@ -0,0 +1,2 @@ +Peter +Pradeep diff --git a/BasicJava/StreamDemo_name_swl_stream_App/Output.txt b/BasicJava/StreamDemo_name_swl_stream_App/Output.txt new file mode 100644 index 000000000..2e3d8ea62 --- /dev/null +++ b/BasicJava/StreamDemo_name_swl_stream_App/Output.txt @@ -0,0 +1,2 @@ +[Ram, Peter, Jai] +[Ram, Peter, Jai] diff --git a/BasicJava/StreamDemo_name_swl_stream_App/StreamDemo/.classpath b/BasicJava/StreamDemo_name_swl_stream_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_name_swl_stream_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_name_swl_stream_App/StreamDemo/.project b/BasicJava/StreamDemo_name_swl_stream_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_name_swl_stream_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_name_swl_stream_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_name_swl_stream_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_name_swl_stream_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_name_swl_stream_App/StreamDemo/bin/SoftwareEngineer.class b/BasicJava/StreamDemo_name_swl_stream_App/StreamDemo/bin/SoftwareEngineer.class new file mode 100644 index 000000000..215ba379b Binary files /dev/null and b/BasicJava/StreamDemo_name_swl_stream_App/StreamDemo/bin/SoftwareEngineer.class differ diff --git a/BasicJava/StreamDemo_name_swl_stream_App/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_name_swl_stream_App/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..d3e162f1f Binary files /dev/null and b/BasicJava/StreamDemo_name_swl_stream_App/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_name_swl_stream_App/StreamDemo/src/SoftwareEngineer.java b/BasicJava/StreamDemo_name_swl_stream_App/StreamDemo/src/SoftwareEngineer.java new file mode 100644 index 000000000..9b39fe56a --- /dev/null +++ b/BasicJava/StreamDemo_name_swl_stream_App/StreamDemo/src/SoftwareEngineer.java @@ -0,0 +1,45 @@ +public class SoftwareEngineer +{ + private String name; + private int age; + private int salary; + + public SoftwareEngineer(String name, int age, int salary) + { + super(); + this.name = name; + this.age = age; + this.salary = salary; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + public int getSalary() + { + return salary; + } + + public void setSalary(int salary) + { + this.salary = salary; + } + +} diff --git a/BasicJava/StreamDemo_name_swl_stream_App/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_name_swl_stream_App/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..d41d17dcf --- /dev/null +++ b/BasicJava/StreamDemo_name_swl_stream_App/StreamDemo/src/StreamDemo.java @@ -0,0 +1,37 @@ +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** +List of objects -> List of String +Get all the name values from a list of the SoftwareEngineer objects. +*/ + +public class StreamDemo +{ + public static void main(String[] args) + { + + List softwareEngineerList = Arrays.asList( + new SoftwareEngineer("Ram", 30, 10000), + new SoftwareEngineer("Peter", 27, 20000), + new SoftwareEngineer("Jai", 33, 30000)); + + // Before Java 8 + List nameList = new ArrayList(); + for (SoftwareEngineer softwareEngineer : softwareEngineerList) + { + nameList.add(softwareEngineer.getName()); + } + System.out.println(nameList); + + // Java 8 + List collectNameList = softwareEngineerList.stream() + .map(softwareEngineer -> softwareEngineer.getName()) + .collect(Collectors.toList()); + System.out.println(collectNameList); + + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_parallel_array_filter_App/Output.txt b/BasicJava/StreamDemo_parallel_array_filter_App/Output.txt new file mode 100644 index 000000000..47c51dde2 --- /dev/null +++ b/BasicJava/StreamDemo_parallel_array_filter_App/Output.txt @@ -0,0 +1,9 @@ +2 +4 +6 +8 +10 +12 +14 +16 +18 diff --git a/BasicJava/StreamDemo_parallel_array_filter_App/StreamDemo/.classpath b/BasicJava/StreamDemo_parallel_array_filter_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_parallel_array_filter_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_parallel_array_filter_App/StreamDemo/.project b/BasicJava/StreamDemo_parallel_array_filter_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_parallel_array_filter_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_parallel_array_filter_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_parallel_array_filter_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_parallel_array_filter_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_parallel_array_filter_App/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_parallel_array_filter_App/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..017001414 Binary files /dev/null and b/BasicJava/StreamDemo_parallel_array_filter_App/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_parallel_array_filter_App/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_parallel_array_filter_App/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..4415511af --- /dev/null +++ b/BasicJava/StreamDemo_parallel_array_filter_App/StreamDemo/src/StreamDemo.java @@ -0,0 +1,37 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; + +/** + * + * To enable parallelism, all you have to do is to create a parallel + * stream, instead of sequential stream. And to surprise you, this is + * really very easy. + * + * Anytime you want to particular job using multiple threads in + * parallel cores, all you have to call method parallelStream() method + * instead of stream() method. + * + */ +public class StreamDemo +{ + public static void main(String[] args) + { + List numberList = new ArrayList(); + + for (int i = 1; i < 20; i++) + { + numberList.add(i); + } + + // Here creating a parallel stream + Stream parallelStream = numberList.parallelStream(); + Integer[] evenNumbersArray = parallelStream.filter(i -> i % 2 == 0) + .toArray(Integer[]::new); + + for (Integer evenNumber : evenNumbersArray) + { + System.out.println(evenNumber); + } + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_peek_App/Output.txt b/BasicJava/StreamDemo_peek_App/Output.txt new file mode 100644 index 000000000..8f0ed7e8c --- /dev/null +++ b/BasicJava/StreamDemo_peek_App/Output.txt @@ -0,0 +1,4 @@ +Filtered value: three +Mapped value: THREE +Filtered value: four +Mapped value: FOUR diff --git a/BasicJava/StreamDemo_peek_App/StreamDemo/.classpath b/BasicJava/StreamDemo_peek_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_peek_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_peek_App/StreamDemo/.project b/BasicJava/StreamDemo_peek_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_peek_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_peek_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_peek_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_peek_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_peek_App/StreamDemo/bin/StreamPeekDemo.class b/BasicJava/StreamDemo_peek_App/StreamDemo/bin/StreamPeekDemo.class new file mode 100644 index 000000000..3a660ec21 Binary files /dev/null and b/BasicJava/StreamDemo_peek_App/StreamDemo/bin/StreamPeekDemo.class differ diff --git a/BasicJava/StreamDemo_peek_App/StreamDemo/src/StreamPeekDemo.java b/BasicJava/StreamDemo_peek_App/StreamDemo/src/StreamPeekDemo.java new file mode 100644 index 000000000..124f66be9 --- /dev/null +++ b/BasicJava/StreamDemo_peek_App/StreamDemo/src/StreamPeekDemo.java @@ -0,0 +1,22 @@ +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class StreamPeekDemo +{ + public static void main(String[] args) + { + + /* + * peek(): This method exists mainly to support debugging, + * where you want to see the elements as they flow past a + * certain point in a pipeline + */ + Stream.of("one", "two", "three", "four") + .filter(e -> e.length() > 3) + .peek(e -> System.out.println("Filtered value: " + e)) + .map(String::toUpperCase) + .peek(e -> System.out.println("Mapped value: " + e)) + .collect(Collectors.toList()); + + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_productList_Max_Min_App/Output.txt b/BasicJava/StreamDemo_productList_Max_Min_App/Output.txt new file mode 100644 index 000000000..b0fe2236c --- /dev/null +++ b/BasicJava/StreamDemo_productList_Max_Min_App/Output.txt @@ -0,0 +1,2 @@ +Max price product = Product [id=4, name=Samsung mobile, price=40000] +Min price product = Product [id=3, name=Nokia mobile, price=10000] diff --git a/BasicJava/StreamDemo_productList_Max_Min_App/StreamDemo/.classpath b/BasicJava/StreamDemo_productList_Max_Min_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_productList_Max_Min_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_productList_Max_Min_App/StreamDemo/.project b/BasicJava/StreamDemo_productList_Max_Min_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_productList_Max_Min_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_productList_Max_Min_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_productList_Max_Min_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_productList_Max_Min_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_productList_Max_Min_App/StreamDemo/bin/Product.class b/BasicJava/StreamDemo_productList_Max_Min_App/StreamDemo/bin/Product.class new file mode 100644 index 000000000..2a97ce097 Binary files /dev/null and b/BasicJava/StreamDemo_productList_Max_Min_App/StreamDemo/bin/Product.class differ diff --git a/BasicJava/StreamDemo_productList_Max_Min_App/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_productList_Max_Min_App/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..c0fe5f92a Binary files /dev/null and b/BasicJava/StreamDemo_productList_Max_Min_App/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_productList_Max_Min_App/StreamDemo/src/Product.java b/BasicJava/StreamDemo_productList_Max_Min_App/StreamDemo/src/Product.java new file mode 100644 index 000000000..9e53fdc45 --- /dev/null +++ b/BasicJava/StreamDemo_productList_Max_Min_App/StreamDemo/src/Product.java @@ -0,0 +1,52 @@ +class Product +{ + private int id; + private String name; + private int price; + + public Product(int id, String name, int price) + { + super(); + this.id = id; + this.name = name; + this.price = price; + } + + public int getId() + { + return id; + } + + public void setId(int id) + { + this.id = id; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getPrice() + { + return price; + } + + public void setPrice(int price) + { + this.price = price; + } + + @Override + public String toString() + { + return "Product [id=" + id + ", name=" + name + ", price=" + + price + "]"; + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_productList_Max_Min_App/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_productList_Max_Min_App/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..f36babdef --- /dev/null +++ b/BasicJava/StreamDemo_productList_Max_Min_App/StreamDemo/src/StreamDemo.java @@ -0,0 +1,37 @@ +import java.util.ArrayList; +import java.util.List; + +/** + * + * Find Max and Min Product Price. + * + */ +public class StreamDemo +{ + public static void main(String[] args) + { + List productList = new ArrayList(); + + // Adding Products + productList.add(new Product(1, "Sony mobile", 25000)); + productList.add(new Product(2, "Lenovo mobile", 15000)); + productList.add(new Product(3, "Nokia mobile", 10000)); + productList.add(new Product(4, "Samsung mobile", 40000)); + + + // max() method to get max Product price + Product maxPriceProduct = productList.stream() + .max((product1, product2)-> + product1.getPrice() > product2.getPrice() ? 1: -1).get(); + + System.out.println("Max price product = "+maxPriceProduct); + + // min() method to get min Product price + Product minPriceProduct = productList.stream() + .min((product1, product2)-> + product1.getPrice() > product2.getPrice() ? 1: -1).get(); + + System.out.println("Min price product = "+minPriceProduct); + + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_productList_sum_app/Output.txt b/BasicJava/StreamDemo_productList_sum_app/Output.txt new file mode 100644 index 000000000..5175565d2 --- /dev/null +++ b/BasicJava/StreamDemo_productList_sum_app/Output.txt @@ -0,0 +1,6 @@ +LongSummaryStatistics{count=4, sum=90000, min=10000, average=22500.000000, max=40000} +Count = 4 +Sum = 90000 +Max Price = 40000 +Min Price = 10000 +Average Price = 22500.0 diff --git a/BasicJava/StreamDemo_productList_sum_app/StreamDemo/.classpath b/BasicJava/StreamDemo_productList_sum_app/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_productList_sum_app/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_productList_sum_app/StreamDemo/.project b/BasicJava/StreamDemo_productList_sum_app/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_productList_sum_app/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_productList_sum_app/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_productList_sum_app/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_productList_sum_app/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_productList_sum_app/StreamDemo/bin/Product.class b/BasicJava/StreamDemo_productList_sum_app/StreamDemo/bin/Product.class new file mode 100644 index 000000000..2a97ce097 Binary files /dev/null and b/BasicJava/StreamDemo_productList_sum_app/StreamDemo/bin/Product.class differ diff --git a/BasicJava/StreamDemo_productList_sum_app/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_productList_sum_app/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..fc3528661 Binary files /dev/null and b/BasicJava/StreamDemo_productList_sum_app/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_productList_sum_app/StreamDemo/src/Product.java b/BasicJava/StreamDemo_productList_sum_app/StreamDemo/src/Product.java new file mode 100644 index 000000000..9e53fdc45 --- /dev/null +++ b/BasicJava/StreamDemo_productList_sum_app/StreamDemo/src/Product.java @@ -0,0 +1,52 @@ +class Product +{ + private int id; + private String name; + private int price; + + public Product(int id, String name, int price) + { + super(); + this.id = id; + this.name = name; + this.price = price; + } + + public int getId() + { + return id; + } + + public void setId(int id) + { + this.id = id; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getPrice() + { + return price; + } + + public void setPrice(int price) + { + this.price = price; + } + + @Override + public String toString() + { + return "Product [id=" + id + ", name=" + name + ", price=" + + price + "]"; + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_productList_sum_app/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_productList_sum_app/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..7fbd644ab --- /dev/null +++ b/BasicJava/StreamDemo_productList_sum_app/StreamDemo/src/StreamDemo.java @@ -0,0 +1,37 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.LongSummaryStatistics; +import java.util.stream.Collectors; +/** + * + * Sum by using Collectors Methods. + * + */ +public class StreamDemo +{ + public static void main(String[] args) + { + List productList = new ArrayList(); + + // Adding Products + productList.add(new Product(1, "Sony mobile", 25000)); + productList.add(new Product(2, "Lenovo mobile", 15000)); + productList.add(new Product(3, "Nokia mobile", 10000)); + productList.add(new Product(4, "Samsung mobile", 40000)); + + + /* + * Using Collectors's method to sum the prices. + */ + LongSummaryStatistics longSummaryStatistics = productList.stream() + .collect(Collectors.summarizingLong((product->product.getPrice()))); + + System.out.println(longSummaryStatistics); + System.out.println("Count = "+longSummaryStatistics.getCount()); + System.out.println("Sum = "+longSummaryStatistics.getSum()); + System.out.println("Max Price = "+longSummaryStatistics.getMax()); + System.out.println("Min Price = "+longSummaryStatistics.getMin()); + System.out.println("Average Price = "+longSummaryStatistics.getAverage()); + + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_product_list_reduce_App/Output.txt b/BasicJava/StreamDemo_product_list_reduce_App/Output.txt new file mode 100644 index 000000000..8cd6553d0 --- /dev/null +++ b/BasicJava/StreamDemo_product_list_reduce_App/Output.txt @@ -0,0 +1,2 @@ +90000 +90000 diff --git a/BasicJava/StreamDemo_product_list_reduce_App/StreamDemo/.classpath b/BasicJava/StreamDemo_product_list_reduce_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_product_list_reduce_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_product_list_reduce_App/StreamDemo/.project b/BasicJava/StreamDemo_product_list_reduce_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_product_list_reduce_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_product_list_reduce_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_product_list_reduce_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_product_list_reduce_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_product_list_reduce_App/StreamDemo/bin/Product.class b/BasicJava/StreamDemo_product_list_reduce_App/StreamDemo/bin/Product.class new file mode 100644 index 000000000..2a97ce097 Binary files /dev/null and b/BasicJava/StreamDemo_product_list_reduce_App/StreamDemo/bin/Product.class differ diff --git a/BasicJava/StreamDemo_product_list_reduce_App/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_product_list_reduce_App/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..f036914bc Binary files /dev/null and b/BasicJava/StreamDemo_product_list_reduce_App/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_product_list_reduce_App/StreamDemo/src/Product.java b/BasicJava/StreamDemo_product_list_reduce_App/StreamDemo/src/Product.java new file mode 100644 index 000000000..9e53fdc45 --- /dev/null +++ b/BasicJava/StreamDemo_product_list_reduce_App/StreamDemo/src/Product.java @@ -0,0 +1,52 @@ +class Product +{ + private int id; + private String name; + private int price; + + public Product(int id, String name, int price) + { + super(); + this.id = id; + this.name = name; + this.price = price; + } + + public int getId() + { + return id; + } + + public void setId(int id) + { + this.id = id; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getPrice() + { + return price; + } + + public void setPrice(int price) + { + this.price = price; + } + + @Override + public String toString() + { + return "Product [id=" + id + ", name=" + name + ", price=" + + price + "]"; + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_product_list_reduce_App/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_product_list_reduce_App/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..16d7f46b6 --- /dev/null +++ b/BasicJava/StreamDemo_product_list_reduce_App/StreamDemo/src/StreamDemo.java @@ -0,0 +1,41 @@ +import java.util.ArrayList; +import java.util.List; + +public class StreamDemo +{ + public static void main(String[] args) + { + List productList = new ArrayList(); + + // Adding Products + productList.add(new Product(1, "Sony mobile", 25000)); + productList.add(new Product(2, "Lenovo mobile", 15000)); + productList.add(new Product(3, "Nokia mobile", 10000)); + productList.add(new Product(4, "Samsung mobile", 40000)); + + + /* + * reduce method takes a sequence of input elements + * and combines them into a single summary result + * by repeated operation. + * + * Using reduce method we can perform Sum, min, max, average, + * and string concatenation. + * + * Here we are using reduce() method, which is used to sum of + * all the product prices. + */ + Integer totalPrice1 = productList.stream() + .map(product->product.getPrice()) + .reduce(0,(sum, price)->sum+price); // accumulating price + + System.out.println(totalPrice1); + + Integer totalPrice2 = productList.stream() + .map(product->product.getPrice()) + .reduce(0,Integer::sum); // accumulating price, by referring method of Integer class + + System.out.println(totalPrice2); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_range_reduce/Output.txt b/BasicJava/StreamDemo_range_reduce/Output.txt new file mode 100644 index 000000000..dc3ed24fd --- /dev/null +++ b/BasicJava/StreamDemo_range_reduce/Output.txt @@ -0,0 +1,2 @@ +6 +16 diff --git a/BasicJava/StreamDemo_range_reduce/StreamDemo/.classpath b/BasicJava/StreamDemo_range_reduce/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_range_reduce/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_range_reduce/StreamDemo/.project b/BasicJava/StreamDemo_range_reduce/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_range_reduce/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_range_reduce/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_range_reduce/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_range_reduce/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_range_reduce/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_range_reduce/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..e65d3f5a3 Binary files /dev/null and b/BasicJava/StreamDemo_range_reduce/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_range_reduce/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_range_reduce/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..5679f91e0 --- /dev/null +++ b/BasicJava/StreamDemo_range_reduce/StreamDemo/src/StreamDemo.java @@ -0,0 +1,23 @@ +import java.util.OptionalInt; +import java.util.stream.IntStream; + +public class StreamDemo +{ + public static void main(String[] args) + { + /* + * sum = 6 (1 + 2 + 3) + */ + OptionalInt optionalInt = IntStream.range(1, 4).reduce((a, b) -> a + b); + + System.out.println(optionalInt.getAsInt()); + + /* + * sum = 16 (10 + 1 + 2 + 3) + */ + int sum = IntStream.range(1, 4).reduce(10, (a, b) -> a + b); + + System.out.println(sum); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_reduce_accumulate/StreamDemo/.classpath b/BasicJava/StreamDemo_reduce_accumulate/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_reduce_accumulate/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_reduce_accumulate/StreamDemo/.project b/BasicJava/StreamDemo_reduce_accumulate/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_reduce_accumulate/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_reduce_accumulate/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_reduce_accumulate/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_reduce_accumulate/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_reduce_accumulate/StreamDemo/bin/Gender.class b/BasicJava/StreamDemo_reduce_accumulate/StreamDemo/bin/Gender.class new file mode 100644 index 000000000..c667336c7 Binary files /dev/null and b/BasicJava/StreamDemo_reduce_accumulate/StreamDemo/bin/Gender.class differ diff --git a/BasicJava/StreamDemo_reduce_accumulate/StreamDemo/bin/Person.class b/BasicJava/StreamDemo_reduce_accumulate/StreamDemo/bin/Person.class new file mode 100644 index 000000000..eda7e7dcb Binary files /dev/null and b/BasicJava/StreamDemo_reduce_accumulate/StreamDemo/bin/Person.class differ diff --git a/BasicJava/StreamDemo_reduce_accumulate/StreamDemo/bin/StreamReduceDemo1.class b/BasicJava/StreamDemo_reduce_accumulate/StreamDemo/bin/StreamReduceDemo1.class new file mode 100644 index 000000000..296b92cfd Binary files /dev/null and b/BasicJava/StreamDemo_reduce_accumulate/StreamDemo/bin/StreamReduceDemo1.class differ diff --git a/BasicJava/StreamDemo_reduce_accumulate/StreamDemo/bin/StreamReduceDemo2.class b/BasicJava/StreamDemo_reduce_accumulate/StreamDemo/bin/StreamReduceDemo2.class new file mode 100644 index 000000000..5b5a5b3f8 Binary files /dev/null and b/BasicJava/StreamDemo_reduce_accumulate/StreamDemo/bin/StreamReduceDemo2.class differ diff --git a/BasicJava/StreamDemo_reduce_accumulate/StreamDemo/src/Person.java b/BasicJava/StreamDemo_reduce_accumulate/StreamDemo/src/Person.java new file mode 100644 index 000000000..0e39eeb00 --- /dev/null +++ b/BasicJava/StreamDemo_reduce_accumulate/StreamDemo/src/Person.java @@ -0,0 +1,68 @@ +enum Gender +{ + MALE, FEMALE +} + +public class Person +{ + private String name; + private String email; + private Gender gender; + private int age; + + public Person(String name, String email, Gender gender, int age) + { + super(); + this.name = name; + this.email = email; + this.gender = gender; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getEmail() + { + return email; + } + + public void setEmail(String email) + { + this.email = email; + } + + public Gender getGender() + { + return gender; + } + + public void setGender(Gender gender) + { + this.gender = gender; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + @Override + public String toString() + { + return "Person [name=" + name + "]"; + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_reduce_accumulate/StreamDemo/src/StreamReduceDemo1.java b/BasicJava/StreamDemo_reduce_accumulate/StreamDemo/src/StreamReduceDemo1.java new file mode 100644 index 000000000..93a02791c --- /dev/null +++ b/BasicJava/StreamDemo_reduce_accumulate/StreamDemo/src/StreamReduceDemo1.java @@ -0,0 +1,38 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +public class StreamReduceDemo1 +{ + public static void main(String[] args) + { + List personList = new ArrayList<>(); + + personList.add(new Person("Alice","alice@gmail.com", Gender.FEMALE, 26)); + personList.add(new Person("Bob","bob@gmail.com", Gender.MALE, 32)); + personList.add(new Person("Carol","carol@gmail.com",Gender.FEMALE, 23)); + personList.add(new Person("David","david@gmail.com", Gender.MALE, 39)); + personList.add(new Person("Eric","eric@gmail.com", Gender.MALE, 26)); + + /* + * + * Version #1: Optional reduce(BinaryOperator accumulator) - This + * method performs a reduction on the elements of the stream, using an + * associative accumulation function, and returns an Optional object + * describing the reduced value. + * + * For example, the following code accumulates names of all persons into + * a String: + */ + Optional optional = personList.stream().map(p -> p.getName()) + .reduce((name1, name2) -> name1 + ", " + name2); + + if (optional.isPresent()) + { + String names = optional.get(); + System.out.println(names); + } + + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_reduce_accumulate/StreamDemo/src/StreamReduceDemo2.java b/BasicJava/StreamDemo_reduce_accumulate/StreamDemo/src/StreamReduceDemo2.java new file mode 100644 index 000000000..3ee706eb8 --- /dev/null +++ b/BasicJava/StreamDemo_reduce_accumulate/StreamDemo/src/StreamReduceDemo2.java @@ -0,0 +1,24 @@ +import java.util.Arrays; + +public class StreamReduceDemo2 +{ + public static void main(String[] args) + { + int[] numberArray = { 2, 3, 5}; + + /* + * Version #2: T reduce(T identity, BinaryOperator accumulator) - + * This method is similar to the version #1, but it returns the reduced + * value of the specified type T. The identity value must be an identity + * value for the accumulator function, which means it does not affect + * the result of accumulation. + * + * The following code calculates sum of numbers in a stream: + */ + int sum = Arrays.stream(numberArray).reduce(0, (x, y) -> (x + y)); + + System.out.println("sum = " + sum); + + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_reduce_accumulate/StreamReduceDemo1_Output.txt b/BasicJava/StreamDemo_reduce_accumulate/StreamReduceDemo1_Output.txt new file mode 100644 index 000000000..ea27981d6 --- /dev/null +++ b/BasicJava/StreamDemo_reduce_accumulate/StreamReduceDemo1_Output.txt @@ -0,0 +1 @@ +Alice, Bob, Carol, David, Eric diff --git a/BasicJava/StreamDemo_reduce_accumulate/StreamReduceDemo2_Output.txt b/BasicJava/StreamDemo_reduce_accumulate/StreamReduceDemo2_Output.txt new file mode 100644 index 000000000..e253056eb --- /dev/null +++ b/BasicJava/StreamDemo_reduce_accumulate/StreamReduceDemo2_Output.txt @@ -0,0 +1 @@ +sum = 10 diff --git a/BasicJava/StreamDemo_reduce_concatinate_App/Output.txt b/BasicJava/StreamDemo_reduce_concatinate_App/Output.txt new file mode 100644 index 000000000..afd4d4503 --- /dev/null +++ b/BasicJava/StreamDemo_reduce_concatinate_App/Output.txt @@ -0,0 +1 @@ +Welcome to India Peter diff --git a/BasicJava/StreamDemo_reduce_concatinate_App/StreamDemo/.classpath b/BasicJava/StreamDemo_reduce_concatinate_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_reduce_concatinate_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_reduce_concatinate_App/StreamDemo/.project b/BasicJava/StreamDemo_reduce_concatinate_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_reduce_concatinate_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_reduce_concatinate_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_reduce_concatinate_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_reduce_concatinate_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_reduce_concatinate_App/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_reduce_concatinate_App/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..ba611584d Binary files /dev/null and b/BasicJava/StreamDemo_reduce_concatinate_App/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_reduce_concatinate_App/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_reduce_concatinate_App/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..cf937c6ff --- /dev/null +++ b/BasicJava/StreamDemo_reduce_concatinate_App/StreamDemo/src/StreamDemo.java @@ -0,0 +1,25 @@ +import java.util.Arrays; + +/** + * If you want to perform more complex reduction operations, however, + * you must use the reduce method. + * + * The reduce method expects two arguments: an identity element, and a + * lambda expression. You can think of the identity element as an + * element which does not alter the result of the reduction operation. + * + */ +public class StreamDemo +{ + public static void main(String[] args) + { + String[] strArray ={ "Welcome ", "to ", "India ", "Peter" }; + + /* + * Reduce method to concatenate all the elements. + */ + String result = Arrays.stream(strArray).reduce("",(a, b) -> a + b); + + System.out.println(result); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_reduce_sum_1_App/Output.txt b/BasicJava/StreamDemo_reduce_sum_1_App/Output.txt new file mode 100644 index 000000000..c7652535a --- /dev/null +++ b/BasicJava/StreamDemo_reduce_sum_1_App/Output.txt @@ -0,0 +1 @@ +Sum:33 diff --git a/BasicJava/StreamDemo_reduce_sum_1_App/StreamDemo/.classpath b/BasicJava/StreamDemo_reduce_sum_1_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_reduce_sum_1_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_reduce_sum_1_App/StreamDemo/.project b/BasicJava/StreamDemo_reduce_sum_1_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_reduce_sum_1_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_reduce_sum_1_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_reduce_sum_1_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_reduce_sum_1_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_reduce_sum_1_App/StreamDemo/bin/StreamReduceDemo.class b/BasicJava/StreamDemo_reduce_sum_1_App/StreamDemo/bin/StreamReduceDemo.class new file mode 100644 index 000000000..ffc11a079 Binary files /dev/null and b/BasicJava/StreamDemo_reduce_sum_1_App/StreamDemo/bin/StreamReduceDemo.class differ diff --git a/BasicJava/StreamDemo_reduce_sum_1_App/StreamDemo/src/StreamReduceDemo.java b/BasicJava/StreamDemo_reduce_sum_1_App/StreamDemo/src/StreamReduceDemo.java new file mode 100644 index 000000000..6b355c8ff --- /dev/null +++ b/BasicJava/StreamDemo_reduce_sum_1_App/StreamDemo/src/StreamReduceDemo.java @@ -0,0 +1,16 @@ +import java.util.Arrays; + +public class StreamReduceDemo +{ + public static void main(String[] args) + { + + /* + * reduce(): It performs reduction on stream elements using a + * identity value and accumulation function. + */ + int[] intArray = { 3, 5, 10, 15 }; + int sum = Arrays.stream(intArray).reduce(0, (x, y) -> x + y); + System.out.println("Sum:" + sum); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_reduction_sca_App/Output.txt b/BasicJava/StreamDemo_reduction_sca_App/Output.txt new file mode 100644 index 000000000..b12757399 --- /dev/null +++ b/BasicJava/StreamDemo_reduction_sca_App/Output.txt @@ -0,0 +1,3 @@ +sum = 16 +count = 3 +average = 5.333333333333333 diff --git a/BasicJava/StreamDemo_reduction_sca_App/StreamDemo/.classpath b/BasicJava/StreamDemo_reduction_sca_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_reduction_sca_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_reduction_sca_App/StreamDemo/.project b/BasicJava/StreamDemo_reduction_sca_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_reduction_sca_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_reduction_sca_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_reduction_sca_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_reduction_sca_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_reduction_sca_App/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_reduction_sca_App/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..15efdb64b Binary files /dev/null and b/BasicJava/StreamDemo_reduction_sca_App/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_reduction_sca_App/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_reduction_sca_App/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..382268e80 --- /dev/null +++ b/BasicJava/StreamDemo_reduction_sca_App/StreamDemo/src/StreamDemo.java @@ -0,0 +1,30 @@ +import java.util.Arrays; +import java.util.OptionalDouble; + +/** + * + * A reduction operation is one which allows you to compute a result + * using all the elements present in a stream. + * + * Reduction operations are also called terminal operations because + * they are always present at the end of a chain of Stream methods + * + * Java 8 includes several reduction methods, such as sum, average and + * count, which allow to perform arithmetic operations on Stream + * objects and get numbers as results. + */ +public class StreamDemo +{ + public static void main(String[] args) + { + int[] numberArray = { 2, 6, 8 }; + int sum = Arrays.stream(numberArray).sum(); + System.out.println("sum = " + sum); + + long count = Arrays.stream(numberArray).count(); + System.out.println("count = " + count); + + OptionalDouble optionalDouble = Arrays.stream(numberArray).average(); + System.out.println("average = " + optionalDouble.getAsDouble()); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_reuse_stream_exe/Output.txt b/BasicJava/StreamDemo_reuse_stream_exe/Output.txt new file mode 100644 index 000000000..161d0f2c2 --- /dev/null +++ b/BasicJava/StreamDemo_reuse_stream_exe/Output.txt @@ -0,0 +1,6 @@ +anyElement = Optional[a] +Exception in thread "main" java.lang.IllegalStateException: +stream has already been operated upon or closed + at java.util.stream.AbstractPipeline.evaluate(Unknown Source) + at java.util.stream.ReferencePipeline.findFirst(Unknown Source) + at StreamDemo.main(StreamDemo.java:28) diff --git a/BasicJava/StreamDemo_reuse_stream_exe/StreamDemo/.classpath b/BasicJava/StreamDemo_reuse_stream_exe/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_reuse_stream_exe/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_reuse_stream_exe/StreamDemo/.project b/BasicJava/StreamDemo_reuse_stream_exe/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_reuse_stream_exe/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_reuse_stream_exe/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_reuse_stream_exe/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_reuse_stream_exe/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_reuse_stream_exe/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_reuse_stream_exe/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..f9655868f Binary files /dev/null and b/BasicJava/StreamDemo_reuse_stream_exe/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_reuse_stream_exe/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_reuse_stream_exe/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..a50f5c4d5 --- /dev/null +++ b/BasicJava/StreamDemo_reuse_stream_exe/StreamDemo/src/StreamDemo.java @@ -0,0 +1,32 @@ +import java.util.Optional; +import java.util.stream.Stream; + +public class StreamDemo +{ + public static void main(String[] args) + { + + Stream stream = Stream.of("a", "b", "c"); + + Optional anyElement = stream.findAny(); + + System.out.println("anyElement = " + anyElement); + + /* + * Attempt to reuse the same reference after calling the + * terminal operation will trigger the IllegalStateException. + * + * As the IllegalStateException is a RuntimeException, a + * compiler will not signalize about a problem. So, it is very + * important to remember that Java 8 streams can’t be reused. + * + * This kind of behavior is logical because streams were + * designed to provide an ability to apply a finite sequence + * of operations to the source of elements in a functional + * style, but not to store elements. + */ + Optional firstElement = stream.findFirst(); + System.out.println("firstElement = " + firstElement); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_shortcircuit_op_examples_App/StreamDemo/.classpath b/BasicJava/StreamDemo_shortcircuit_op_examples_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_shortcircuit_op_examples_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_shortcircuit_op_examples_App/StreamDemo/.project b/BasicJava/StreamDemo_shortcircuit_op_examples_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_shortcircuit_op_examples_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_shortcircuit_op_examples_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_shortcircuit_op_examples_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_shortcircuit_op_examples_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_shortcircuit_op_examples_App/StreamDemo/bin/StreamDemo1.class b/BasicJava/StreamDemo_shortcircuit_op_examples_App/StreamDemo/bin/StreamDemo1.class new file mode 100644 index 000000000..07562161a Binary files /dev/null and b/BasicJava/StreamDemo_shortcircuit_op_examples_App/StreamDemo/bin/StreamDemo1.class differ diff --git a/BasicJava/StreamDemo_shortcircuit_op_examples_App/StreamDemo/bin/StreamDemo2.class b/BasicJava/StreamDemo_shortcircuit_op_examples_App/StreamDemo/bin/StreamDemo2.class new file mode 100644 index 000000000..ecb197e72 Binary files /dev/null and b/BasicJava/StreamDemo_shortcircuit_op_examples_App/StreamDemo/bin/StreamDemo2.class differ diff --git a/BasicJava/StreamDemo_shortcircuit_op_examples_App/StreamDemo/src/StreamDemo1.java b/BasicJava/StreamDemo_shortcircuit_op_examples_App/StreamDemo/src/StreamDemo1.java new file mode 100644 index 000000000..3da8cad1b --- /dev/null +++ b/BasicJava/StreamDemo_shortcircuit_op_examples_App/StreamDemo/src/StreamDemo1.java @@ -0,0 +1,32 @@ +import java.util.ArrayList; +import java.util.List; + +/** + * + * Short-circuit operation - anyMatch(). + * + */ +public class StreamDemo1 +{ + public static void main(String[] args) + { + List nameList = new ArrayList<>(); + nameList.add("Amitabh"); + nameList.add("Shekhar"); + nameList.add("Aman"); + nameList.add("Rahul"); + nameList.add("Shahrukh"); + nameList.add("Salman"); + nameList.add("Yana"); + nameList.add("Lokesh"); + + /* + * This will return true once a condition passed as predicate + * satisfy. It will not process any more elements. + */ + boolean matched = nameList.stream() + .anyMatch((s) -> s.startsWith("S")); + + System.out.println(matched); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_shortcircuit_op_examples_App/StreamDemo/src/StreamDemo2.java b/BasicJava/StreamDemo_shortcircuit_op_examples_App/StreamDemo/src/StreamDemo2.java new file mode 100644 index 000000000..9809fa2d7 --- /dev/null +++ b/BasicJava/StreamDemo_shortcircuit_op_examples_App/StreamDemo/src/StreamDemo2.java @@ -0,0 +1,33 @@ +import java.util.ArrayList; +import java.util.List; + +/** + * + * Short-circuit operation - findFirst(). + * + */ +public class StreamDemo2 +{ + public static void main(String[] args) + { + List nameList = new ArrayList<>(); + nameList.add("Amitabh"); + nameList.add("Shekhar"); + nameList.add("Aman"); + nameList.add("Rahul"); + nameList.add("Shahrukh"); + nameList.add("Salman"); + nameList.add("Yana"); + nameList.add("Lokesh"); + + /* + * It will return first element from stream and then will not + * process any more element. + */ + + String firstMatchedName = nameList.stream() + .filter((s) -> s.startsWith("S")).findFirst().get(); + + System.out.println(firstMatchedName); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_shortcircuit_op_examples_App/StreamDemo1_Output.txt b/BasicJava/StreamDemo_shortcircuit_op_examples_App/StreamDemo1_Output.txt new file mode 100644 index 000000000..27ba77dda --- /dev/null +++ b/BasicJava/StreamDemo_shortcircuit_op_examples_App/StreamDemo1_Output.txt @@ -0,0 +1 @@ +true diff --git a/BasicJava/StreamDemo_shortcircuit_op_examples_App/StreamDemo2_Output.txt b/BasicJava/StreamDemo_shortcircuit_op_examples_App/StreamDemo2_Output.txt new file mode 100644 index 000000000..7518da6c2 --- /dev/null +++ b/BasicJava/StreamDemo_shortcircuit_op_examples_App/StreamDemo2_Output.txt @@ -0,0 +1 @@ +Shekhar diff --git a/BasicJava/StreamDemo_skip_App/Output.txt b/BasicJava/StreamDemo_skip_App/Output.txt new file mode 100644 index 000000000..d6770dbd3 --- /dev/null +++ b/BasicJava/StreamDemo_skip_App/Output.txt @@ -0,0 +1,2 @@ +15 +20 diff --git a/BasicJava/StreamDemo_skip_App/StreamDemo/.classpath b/BasicJava/StreamDemo_skip_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_skip_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_skip_App/StreamDemo/.project b/BasicJava/StreamDemo_skip_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_skip_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_skip_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_skip_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_skip_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_skip_App/StreamDemo/bin/StreamSkipDemo.class b/BasicJava/StreamDemo_skip_App/StreamDemo/bin/StreamSkipDemo.class new file mode 100644 index 000000000..74eb51ace Binary files /dev/null and b/BasicJava/StreamDemo_skip_App/StreamDemo/bin/StreamSkipDemo.class differ diff --git a/BasicJava/StreamDemo_skip_App/StreamDemo/src/StreamSkipDemo.java b/BasicJava/StreamDemo_skip_App/StreamDemo/src/StreamSkipDemo.java new file mode 100644 index 000000000..5e942e304 --- /dev/null +++ b/BasicJava/StreamDemo_skip_App/StreamDemo/src/StreamSkipDemo.java @@ -0,0 +1,15 @@ +import java.util.Arrays; + +public class StreamSkipDemo +{ + public static void main(String[] args) + { + + /* + * skip(): It returns a stream skipping the given number of + * elements. + */ + int[] intArray = { 5, 10, 15, 20 }; + Arrays.stream(intArray).skip(2).forEach(s -> System.out.println(s + " ")); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_skip_persons/Output.txt b/BasicJava/StreamDemo_skip_persons/Output.txt new file mode 100644 index 000000000..61a15e132 --- /dev/null +++ b/BasicJava/StreamDemo_skip_persons/Output.txt @@ -0,0 +1,3 @@ +Person [name=Carol, gender=FEMALE, age=23] +Person [name=David, gender=MALE, age=19] +Person [name=Eric, gender=MALE, age=17] diff --git a/BasicJava/StreamDemo_skip_persons/StreamDemo/.classpath b/BasicJava/StreamDemo_skip_persons/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_skip_persons/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_skip_persons/StreamDemo/.project b/BasicJava/StreamDemo_skip_persons/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_skip_persons/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_skip_persons/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_skip_persons/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_skip_persons/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_skip_persons/StreamDemo/bin/Gender.class b/BasicJava/StreamDemo_skip_persons/StreamDemo/bin/Gender.class new file mode 100644 index 000000000..c667336c7 Binary files /dev/null and b/BasicJava/StreamDemo_skip_persons/StreamDemo/bin/Gender.class differ diff --git a/BasicJava/StreamDemo_skip_persons/StreamDemo/bin/Person.class b/BasicJava/StreamDemo_skip_persons/StreamDemo/bin/Person.class new file mode 100644 index 000000000..3bea2dc8b Binary files /dev/null and b/BasicJava/StreamDemo_skip_persons/StreamDemo/bin/Person.class differ diff --git a/BasicJava/StreamDemo_skip_persons/StreamDemo/bin/StreamDistinctDemo.class b/BasicJava/StreamDemo_skip_persons/StreamDemo/bin/StreamDistinctDemo.class new file mode 100644 index 000000000..b323ddded Binary files /dev/null and b/BasicJava/StreamDemo_skip_persons/StreamDemo/bin/StreamDistinctDemo.class differ diff --git a/BasicJava/StreamDemo_skip_persons/StreamDemo/bin/StreamSkipDemo.class b/BasicJava/StreamDemo_skip_persons/StreamDemo/bin/StreamSkipDemo.class new file mode 100644 index 000000000..8619ec6af Binary files /dev/null and b/BasicJava/StreamDemo_skip_persons/StreamDemo/bin/StreamSkipDemo.class differ diff --git a/BasicJava/StreamDemo_skip_persons/StreamDemo/src/Person.java b/BasicJava/StreamDemo_skip_persons/StreamDemo/src/Person.java new file mode 100644 index 000000000..94051af71 --- /dev/null +++ b/BasicJava/StreamDemo_skip_persons/StreamDemo/src/Person.java @@ -0,0 +1,70 @@ +enum Gender +{ + MALE, FEMALE +} + +public class Person +{ + private String name; + private String email; + private Gender gender; + private int age; + + public Person(String name, String email, Gender gender, int age) + { + super(); + this.name = name; + this.email = email; + this.gender = gender; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getEmail() + { + return email; + } + + public void setEmail(String email) + { + this.email = email; + } + + public Gender getGender() + { + return gender; + } + + public void setGender(Gender gender) + { + this.gender = gender; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + + @Override + public String toString() + { + return "Person [name=" + name + ", gender=" + gender + ", age=" + age + + "]"; + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_skip_persons/StreamDemo/src/StreamSkipDemo.java b/BasicJava/StreamDemo_skip_persons/StreamDemo/src/StreamSkipDemo.java new file mode 100644 index 000000000..847669933 --- /dev/null +++ b/BasicJava/StreamDemo_skip_persons/StreamDemo/src/StreamSkipDemo.java @@ -0,0 +1,24 @@ +import java.util.ArrayList; +import java.util.List; + +public class StreamSkipDemo +{ + public static void main(String[] args) + { + List personList = new ArrayList<>(); + + personList.add(new Person("Alice", "alice@gmail.com", Gender.FEMALE, 15)); + personList.add(new Person("Bob", "bob@gmail.com", Gender.MALE, 16)); + personList.add(new Person("Carol", "carol@gmail.com", Gender.FEMALE, 23)); + personList.add(new Person("David", "david@gmail.com", Gender.MALE, 19)); + personList.add(new Person("Eric", "eric@gmail.com", Gender.MALE, 17)); + + /* + * The skip() operation returns a stream containing the remaining + * elements after discarding the first n elements of the stream. + * + */ + personList.stream().skip(2).forEach(System.out::println); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_sorted_name_age_comp/Output.txt b/BasicJava/StreamDemo_sorted_name_age_comp/Output.txt new file mode 100644 index 000000000..6a2e9b0e4 --- /dev/null +++ b/BasicJava/StreamDemo_sorted_name_age_comp/Output.txt @@ -0,0 +1,13 @@ +----------Sorted by Age------------------- +Person [name=Bob, gender=MALE, age=15] +Person [name=Alice, gender=FEMALE, age=16] +Person [name=David, gender=MALE, age=19] +Person [name=Carol, gender=FEMALE, age=23] +Person [name=Eric, gender=MALE, age=26] + +----------Sorted by Name------------------- +Person [name=Alice, gender=FEMALE, age=16] +Person [name=Bob, gender=MALE, age=15] +Person [name=Carol, gender=FEMALE, age=23] +Person [name=David, gender=MALE, age=19] +Person [name=Eric, gender=MALE, age=26] diff --git a/BasicJava/StreamDemo_sorted_name_age_comp/StreamDemo/.classpath b/BasicJava/StreamDemo_sorted_name_age_comp/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_sorted_name_age_comp/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_sorted_name_age_comp/StreamDemo/.project b/BasicJava/StreamDemo_sorted_name_age_comp/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_sorted_name_age_comp/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_sorted_name_age_comp/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_sorted_name_age_comp/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_sorted_name_age_comp/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_sorted_name_age_comp/StreamDemo/bin/Gender.class b/BasicJava/StreamDemo_sorted_name_age_comp/StreamDemo/bin/Gender.class new file mode 100644 index 000000000..c667336c7 Binary files /dev/null and b/BasicJava/StreamDemo_sorted_name_age_comp/StreamDemo/bin/Gender.class differ diff --git a/BasicJava/StreamDemo_sorted_name_age_comp/StreamDemo/bin/Person.class b/BasicJava/StreamDemo_sorted_name_age_comp/StreamDemo/bin/Person.class new file mode 100644 index 000000000..2c56c3967 Binary files /dev/null and b/BasicJava/StreamDemo_sorted_name_age_comp/StreamDemo/bin/Person.class differ diff --git a/BasicJava/StreamDemo_sorted_name_age_comp/StreamDemo/bin/StreamSortDemo.class b/BasicJava/StreamDemo_sorted_name_age_comp/StreamDemo/bin/StreamSortDemo.class new file mode 100644 index 000000000..64ed8959e Binary files /dev/null and b/BasicJava/StreamDemo_sorted_name_age_comp/StreamDemo/bin/StreamSortDemo.class differ diff --git a/BasicJava/StreamDemo_sorted_name_age_comp/StreamDemo/src/Person.java b/BasicJava/StreamDemo_sorted_name_age_comp/StreamDemo/src/Person.java new file mode 100644 index 000000000..21b811070 --- /dev/null +++ b/BasicJava/StreamDemo_sorted_name_age_comp/StreamDemo/src/Person.java @@ -0,0 +1,74 @@ +enum Gender +{ + MALE, FEMALE +} + +public class Person implements Comparable +{ + private String name; + private String email; + private Gender gender; + private int age; + + public Person(String name, String email, Gender gender, int age) + { + super(); + this.name = name; + this.email = email; + this.gender = gender; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getEmail() + { + return email; + } + + public void setEmail(String email) + { + this.email = email; + } + + public Gender getGender() + { + return gender; + } + + public void setGender(Gender gender) + { + this.gender = gender; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + public int compareTo(Person another) + { + return this.age - another.getAge(); + } + + @Override + public String toString() + { + return "Person [name=" + name + ", gender=" + gender + ", age=" + age + + "]"; + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_sorted_name_age_comp/StreamDemo/src/StreamSortDemo.java b/BasicJava/StreamDemo_sorted_name_age_comp/StreamDemo/src/StreamSortDemo.java new file mode 100644 index 000000000..6c2174ffc --- /dev/null +++ b/BasicJava/StreamDemo_sorted_name_age_comp/StreamDemo/src/StreamSortDemo.java @@ -0,0 +1,46 @@ +import java.util.ArrayList; +import java.util.List; + +public class StreamSortDemo +{ + public static void main(String[] args) + { + List personList = new ArrayList<>(); + + personList.add(new Person("Alice", "alice@gmail.com", Gender.FEMALE, 16)); + personList.add(new Person("Bob", "bob@gmail.com", Gender.MALE, 15)); + personList.add(new Person("Carol", "carol@gmail.com", Gender.FEMALE, 23)); + personList.add(new Person("David", "david@gmail.com", Gender.MALE, 19)); + personList.add(new Person("Eric", "eric@gmail.com", Gender.MALE, 26)); + + /* + * The Stream API provides two overloads of the sorted operation that + * returns a new stream consisting elements sorted according to natural + * order or by a specified comparator: + * + * 1.sorted(): sorts by natural order + * 2.sorted(comparator): sorts by a comparator + * + * The following code returns a stream of persons who are sorted by + * their age into ascending order: + * + */ + + System.out.println("----------Sorted by Age-------------------"); + + personList.stream().sorted() + .forEach(p -> System.out.println(p)); + + + System.out.println("\n----------Sorted by Name-------------------"); + + /* + * The following code shows how to use a specified comparator to return + * a stream of persons who are sorted by their name: + */ + personList.stream() + .sorted((p1, p2) -> p1.getName().compareTo(p2.getName())) + .forEach(System.out::println); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_stream_to_list_collect_App/Output.txt b/BasicJava/StreamDemo_stream_to_list_collect_App/Output.txt new file mode 100644 index 000000000..3f88069b2 --- /dev/null +++ b/BasicJava/StreamDemo_stream_to_list_collect_App/Output.txt @@ -0,0 +1 @@ +[2, 4, 6, 8, 10, 12, 14, 16, 18] \ No newline at end of file diff --git a/BasicJava/StreamDemo_stream_to_list_collect_App/StreamDemo/.classpath b/BasicJava/StreamDemo_stream_to_list_collect_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_stream_to_list_collect_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_stream_to_list_collect_App/StreamDemo/.project b/BasicJava/StreamDemo_stream_to_list_collect_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_stream_to_list_collect_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_stream_to_list_collect_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_stream_to_list_collect_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_stream_to_list_collect_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_stream_to_list_collect_App/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_stream_to_list_collect_App/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..6ca233130 Binary files /dev/null and b/BasicJava/StreamDemo_stream_to_list_collect_App/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_stream_to_list_collect_App/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_stream_to_list_collect_App/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..e0b27147b --- /dev/null +++ b/BasicJava/StreamDemo_stream_to_list_collect_App/StreamDemo/src/StreamDemo.java @@ -0,0 +1,27 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/** + * + * Convert Stream to List using stream.collect(Collectors.toList()) + * + */ +public class StreamDemo +{ + public static void main(String[] args) + { + List list = new ArrayList(); + for (int i = 1; i < 20; i++) + { + list.add(i); + } + Stream stream = list.stream(); + + List evenNumbersList = stream.filter(i -> i % 2 == 0) + .collect(Collectors.toList()); + + System.out.print(evenNumbersList); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_student_parallelstream/Output.txt b/BasicJava/StreamDemo_student_parallelstream/Output.txt new file mode 100644 index 000000000..24b33cdd0 --- /dev/null +++ b/BasicJava/StreamDemo_student_parallelstream/Output.txt @@ -0,0 +1,9 @@ +Bob - 90 +Henry - 98 +Gary - 88 +------------------------------ +Gary - 88 +David - 80 +Alice - 82 +Bob - 90 +Henry - 98 diff --git a/BasicJava/StreamDemo_student_parallelstream/StreamDemo/.classpath b/BasicJava/StreamDemo_student_parallelstream/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_student_parallelstream/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_student_parallelstream/StreamDemo/.project b/BasicJava/StreamDemo_student_parallelstream/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_student_parallelstream/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_student_parallelstream/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_student_parallelstream/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_student_parallelstream/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_student_parallelstream/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_student_parallelstream/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..f1e7a2317 Binary files /dev/null and b/BasicJava/StreamDemo_student_parallelstream/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_student_parallelstream/StreamDemo/bin/Student.class b/BasicJava/StreamDemo_student_parallelstream/StreamDemo/bin/Student.class new file mode 100644 index 000000000..964739973 Binary files /dev/null and b/BasicJava/StreamDemo_student_parallelstream/StreamDemo/bin/Student.class differ diff --git a/BasicJava/StreamDemo_student_parallelstream/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_student_parallelstream/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..96601f5df --- /dev/null +++ b/BasicJava/StreamDemo_student_parallelstream/StreamDemo/src/StreamDemo.java @@ -0,0 +1,46 @@ +import java.util.ArrayList; +import java.util.List; + +public class StreamDemo +{ + public static void main(String[] args) + { + List studentList = new ArrayList<>(); + + studentList.add(new Student("Alice", 82)); + studentList.add(new Student("Bob", 90)); + studentList.add(new Student("Carol", 67)); + studentList.add(new Student("David", 80)); + studentList.add(new Student("Eric", 55)); + studentList.add(new Student("Frank", 49)); + studentList.add(new Student("Gary", 88)); + studentList.add(new Student("Henry", 98)); + studentList.add(new Student("Ivan", 66)); + studentList.add(new Student("John", 52)); + + /* + * The following code may execute stream operations in + * parallel + */ + studentList.parallelStream().filter(s -> s.getScore() >= 80) + .sorted().limit(3).forEach(System.out::println); + + System.out.println("------------------------------"); + + /* + * The Collection’s stream() method returns a sequential + * stream. We can convert a sequential stream to a parallel + * stream by calling the parallel() method on the current + * stream. + * + * The following example shows a stream executes the sorted + * operation sequentially, and then execute the filter + * operation in parallel + */ + studentList.stream().sorted().parallel() + .filter(s -> s.getScore() >= 80) + .forEach(System.out::println); + + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_student_parallelstream/StreamDemo/src/Student.java b/BasicJava/StreamDemo_student_parallelstream/StreamDemo/src/Student.java new file mode 100644 index 000000000..6677c6358 --- /dev/null +++ b/BasicJava/StreamDemo_student_parallelstream/StreamDemo/src/Student.java @@ -0,0 +1,41 @@ +public class Student implements Comparable +{ + private String name; + private int score; + + public Student(String name, int score) + { + this.name = name; + this.score = score; + } + + public void setName(String name) + { + this.name = name; + } + + public String getName() + { + return this.name; + } + + public void setScore(int score) + { + this.score = score; + } + + public int getScore() + { + return this.score; + } + + public String toString() + { + return this.name + " - " + this.score; + } + + public int compareTo(Student another) + { + return another.getScore() - this.score; + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_summing_average_statistics/Output.txt b/BasicJava/StreamDemo_summing_average_statistics/Output.txt new file mode 100644 index 000000000..b895bbe33 --- /dev/null +++ b/BasicJava/StreamDemo_summing_average_statistics/Output.txt @@ -0,0 +1,8 @@ +averagePrice = 20.0 +summingPrice = 100 +statistics = IntSummaryStatistics{count=5, sum=100, min=15, average=20.000000, max=30} +Average = 20.0 +Count = 5 +Max = 30 +Min = 15 +Sum = 100 diff --git a/BasicJava/StreamDemo_summing_average_statistics/StreamDemo/.classpath b/BasicJava/StreamDemo_summing_average_statistics/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_summing_average_statistics/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_summing_average_statistics/StreamDemo/.project b/BasicJava/StreamDemo_summing_average_statistics/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_summing_average_statistics/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_summing_average_statistics/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_summing_average_statistics/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_summing_average_statistics/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_summing_average_statistics/StreamDemo/bin/Product.class b/BasicJava/StreamDemo_summing_average_statistics/StreamDemo/bin/Product.class new file mode 100644 index 000000000..a66bb2673 Binary files /dev/null and b/BasicJava/StreamDemo_summing_average_statistics/StreamDemo/bin/Product.class differ diff --git a/BasicJava/StreamDemo_summing_average_statistics/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_summing_average_statistics/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..e882e7ae5 Binary files /dev/null and b/BasicJava/StreamDemo_summing_average_statistics/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_summing_average_statistics/StreamDemo/src/Product.java b/BasicJava/StreamDemo_summing_average_statistics/StreamDemo/src/Product.java new file mode 100644 index 000000000..84d632c09 --- /dev/null +++ b/BasicJava/StreamDemo_summing_average_statistics/StreamDemo/src/Product.java @@ -0,0 +1,40 @@ + +public class Product +{ + private String name; + private int price; + + public Product(String name, int price) + { + super(); + this.name = name; + this.price = price; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getPrice() + { + return price; + } + + public void setPrice(int price) + { + this.price = price; + } + + @Override + public String toString() + { + return "Product [name=" + name + ", price=" + price + "]"; + } + +} diff --git a/BasicJava/StreamDemo_summing_average_statistics/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_summing_average_statistics/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..11143e4e0 --- /dev/null +++ b/BasicJava/StreamDemo_summing_average_statistics/StreamDemo/src/StreamDemo.java @@ -0,0 +1,55 @@ +import java.util.Arrays; +import java.util.IntSummaryStatistics; +import java.util.List; +import java.util.stream.Collectors; + +public class StreamDemo +{ + public static void main(String[] args) + { + List productList = Arrays.asList( + new Product("potatoes", 15), + new Product("orange", 15), new Product("lemon", 20), + new Product("bread", 20), new Product("sugar", 30)); + + /* + * Processing the average value of all numeric elements of the + * stream: + * + * Methods averagingXX(), summingXX() and summarizingXX() can + * work as with primitives (int, long, double) as with their + * wrapper classes (Integer, Long, Double). One more powerful + * feature of these methods is providing the mapping. So, + * developer doesn’t need to use an additional map() operation + * before the collect() method. + */ + double averagePrice = productList.stream() + .collect(Collectors.averagingInt(Product::getPrice)); + + System.out.println("averagePrice = " + averagePrice); + + /* + * Processing the sum of all numeric elements of the stream: + */ + + int summingPrice = productList.stream() + .collect(Collectors.summingInt(Product::getPrice)); + + System.out.println("summingPrice = " + summingPrice); + + /* + * Collecting statistical information about stream’s elements: + */ + IntSummaryStatistics statistics = productList.stream() + .collect( + Collectors.summarizingInt(Product::getPrice)); + + System.out.println("statistics = " + statistics); + System.out.println("Average = " + statistics.getAverage()); + System.out.println("Count = " + statistics.getCount()); + System.out.println("Max = " + statistics.getMax()); + System.out.println("Min = " + statistics.getMin()); + System.out.println("Sum = " + statistics.getSum()); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_swl_to_empl_App/NonStreamDemo_Output.txt b/BasicJava/StreamDemo_swl_to_empl_App/NonStreamDemo_Output.txt new file mode 100644 index 000000000..fd0770105 --- /dev/null +++ b/BasicJava/StreamDemo_swl_to_empl_App/NonStreamDemo_Output.txt @@ -0,0 +1 @@ +[Employee [name=Ram, age=30], Employee [name=Peter, age=27], Employee [name=Dave, age=33]] diff --git a/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/.classpath b/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/.project b/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/bin/Employee.class b/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/bin/Employee.class new file mode 100644 index 000000000..ed1fcb91d Binary files /dev/null and b/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/bin/Employee.class differ diff --git a/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/bin/NonStreamDemo.class b/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/bin/NonStreamDemo.class new file mode 100644 index 000000000..1d8776ea4 Binary files /dev/null and b/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/bin/NonStreamDemo.class differ diff --git a/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/bin/SoftwareEngineer.class b/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/bin/SoftwareEngineer.class new file mode 100644 index 000000000..4f95e1830 Binary files /dev/null and b/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/bin/SoftwareEngineer.class differ diff --git a/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..abf59e3d4 Binary files /dev/null and b/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/src/Employee.java b/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/src/Employee.java new file mode 100644 index 000000000..e4706d3dd --- /dev/null +++ b/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/src/Employee.java @@ -0,0 +1,44 @@ +public class Employee +{ + private String name; + private int age; + + public Employee() + { + + } + + public Employee(String name, int age) + { + super(); + this.name = name; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + @Override + public String toString() + { + return "Employee [name=" + name + ", age=" + age + "]"; + } + +} diff --git a/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/src/NonStreamDemo.java b/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/src/NonStreamDemo.java new file mode 100644 index 000000000..9e6cdb08e --- /dev/null +++ b/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/src/NonStreamDemo.java @@ -0,0 +1,44 @@ +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * + * List of objects -> List of other objects + * + * This example shows you how to convert a list of SoftwareEngineer + * objects into a list of Employee objects. + */ +public class NonStreamDemo +{ + public static void main(String[] args) + { + + List softwareEngineerList = Arrays.asList( + new SoftwareEngineer("Ram", 30), + new SoftwareEngineer("Peter", 27), + new SoftwareEngineer("Dave", 33)); + + // Before java 8 + List employeeList = convertToEmployee(softwareEngineerList); + System.out.println(employeeList); + } + + private static List convertToEmployee(List softwareEngineerList) + { + + List employeeList = new ArrayList<>(); + + for (SoftwareEngineer softwareEngineer : softwareEngineerList) + { + Employee employee = new Employee(); + employee.setName(softwareEngineer.getName()); + employee.setAge(softwareEngineer.getAge()); + employeeList.add(employee); + } + + return employeeList; + + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/src/SoftwareEngineer.java b/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/src/SoftwareEngineer.java new file mode 100644 index 000000000..13f251601 --- /dev/null +++ b/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/src/SoftwareEngineer.java @@ -0,0 +1,33 @@ +public class SoftwareEngineer +{ + private String name; + private int age; + + public SoftwareEngineer(String name, int age) + { + super(); + this.name = name; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + +} diff --git a/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..bbf21bc3f --- /dev/null +++ b/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo/src/StreamDemo.java @@ -0,0 +1,34 @@ +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + * + * List of objects -> List of other objects + * + * This example shows you how to convert a list of SoftwareEngineer + * objects into a list of Employee objects. + */ +public class StreamDemo +{ + public static void main(String[] args) + { + + List softwareEngineerList = Arrays.asList( + new SoftwareEngineer("Ram", 30), + new SoftwareEngineer("Peter", 27), + new SoftwareEngineer("Dave", 33)); + + // Java 8 + List employeeList = softwareEngineerList.stream() + .map(softwareEngineer -> { + Employee employee = new Employee(); + employee.setName(softwareEngineer.getName()); + employee.setAge(softwareEngineer.getAge()); + return employee; + }).collect(Collectors.toList()); + + System.out.println(employeeList); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo_Output.txt b/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo_Output.txt new file mode 100644 index 000000000..fd0770105 --- /dev/null +++ b/BasicJava/StreamDemo_swl_to_empl_App/StreamDemo_Output.txt @@ -0,0 +1 @@ +[Employee [name=Ram, age=30], Employee [name=Peter, age=27], Employee [name=Dave, age=33]] diff --git a/BasicJava/StreamDemo_terOp_fe_toArray_App/StreamDemo/.classpath b/BasicJava/StreamDemo_terOp_fe_toArray_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_terOp_fe_toArray_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_terOp_fe_toArray_App/StreamDemo/.project b/BasicJava/StreamDemo_terOp_fe_toArray_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_terOp_fe_toArray_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_terOp_fe_toArray_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_terOp_fe_toArray_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_terOp_fe_toArray_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_terOp_fe_toArray_App/StreamDemo/bin/StreamForEachDemo.class b/BasicJava/StreamDemo_terOp_fe_toArray_App/StreamDemo/bin/StreamForEachDemo.class new file mode 100644 index 000000000..ce6f7a6b7 Binary files /dev/null and b/BasicJava/StreamDemo_terOp_fe_toArray_App/StreamDemo/bin/StreamForEachDemo.class differ diff --git a/BasicJava/StreamDemo_terOp_fe_toArray_App/StreamDemo/bin/StreamToArrayDemo.class b/BasicJava/StreamDemo_terOp_fe_toArray_App/StreamDemo/bin/StreamToArrayDemo.class new file mode 100644 index 000000000..1cb69013f Binary files /dev/null and b/BasicJava/StreamDemo_terOp_fe_toArray_App/StreamDemo/bin/StreamToArrayDemo.class differ diff --git a/BasicJava/StreamDemo_terOp_fe_toArray_App/StreamDemo/src/StreamForEachDemo.java b/BasicJava/StreamDemo_terOp_fe_toArray_App/StreamDemo/src/StreamForEachDemo.java new file mode 100644 index 000000000..c864b16b3 --- /dev/null +++ b/BasicJava/StreamDemo_terOp_fe_toArray_App/StreamDemo/src/StreamForEachDemo.java @@ -0,0 +1,15 @@ +import java.util.stream.Stream; + +public class StreamForEachDemo +{ + public static void main(String[] args) + { + + Stream stream = Stream.of("peter", "Juli", "David"); + /* + * iterates over each element using forEach: + */ + stream.forEach(System.out::println); + + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_terOp_fe_toArray_App/StreamDemo/src/StreamToArrayDemo.java b/BasicJava/StreamDemo_terOp_fe_toArray_App/StreamDemo/src/StreamToArrayDemo.java new file mode 100644 index 000000000..9c9a7f11b --- /dev/null +++ b/BasicJava/StreamDemo_terOp_fe_toArray_App/StreamDemo/src/StreamToArrayDemo.java @@ -0,0 +1,27 @@ +import java.util.stream.Stream; + +public class StreamToArrayDemo +{ + public static void main(String[] args) + { + + Object[] objectArray = Stream.of(1, 2, 3, 4, 5).toArray(); + + for (Object object : objectArray) + { + System.out.println(object); + } + + System.out.println("-----------------------------------"); + + String[] upperCaseNameArray = (String[]) Stream.of("Peter", "Juli", "Ram") + .map(s -> s.toUpperCase()) + .toArray(String[]::new); + + for (String name : upperCaseNameArray) + { + System.out.println(name); + } + + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_terOp_fe_toArray_App/StreamForEachDemo_Output.txt b/BasicJava/StreamDemo_terOp_fe_toArray_App/StreamForEachDemo_Output.txt new file mode 100644 index 000000000..ccebdefdf --- /dev/null +++ b/BasicJava/StreamDemo_terOp_fe_toArray_App/StreamForEachDemo_Output.txt @@ -0,0 +1,3 @@ +peter +Juli +David diff --git a/BasicJava/StreamDemo_terOp_fe_toArray_App/StreamToArrayDemo_Output.txt b/BasicJava/StreamDemo_terOp_fe_toArray_App/StreamToArrayDemo_Output.txt new file mode 100644 index 000000000..3d2b9ef6a --- /dev/null +++ b/BasicJava/StreamDemo_terOp_fe_toArray_App/StreamToArrayDemo_Output.txt @@ -0,0 +1,9 @@ +1 +2 +3 +4 +5 +----------------------------------- +PETER +JULI +RAM diff --git a/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/.classpath b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/.project b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/bin/StreamDemo1.class b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/bin/StreamDemo1.class new file mode 100644 index 000000000..8c9b5955b Binary files /dev/null and b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/bin/StreamDemo1.class differ diff --git a/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/bin/StreamDemo2.class b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/bin/StreamDemo2.class new file mode 100644 index 000000000..aa98fc7e1 Binary files /dev/null and b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/bin/StreamDemo2.class differ diff --git a/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/bin/StreamDemo3.class b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/bin/StreamDemo3.class new file mode 100644 index 000000000..2c42946c2 Binary files /dev/null and b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/bin/StreamDemo3.class differ diff --git a/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/bin/StreamDemo4.class b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/bin/StreamDemo4.class new file mode 100644 index 000000000..3e2d18e6f Binary files /dev/null and b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/bin/StreamDemo4.class differ diff --git a/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/bin/StreamDemo5.class b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/bin/StreamDemo5.class new file mode 100644 index 000000000..db1074e75 Binary files /dev/null and b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/bin/StreamDemo5.class differ diff --git a/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/src/StreamDemo1.java b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/src/StreamDemo1.java new file mode 100644 index 000000000..bdf234ad6 --- /dev/null +++ b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/src/StreamDemo1.java @@ -0,0 +1,31 @@ +import java.util.ArrayList; +import java.util.List; + +/** + * + * Terminal operations return a result of a certain type instead of + * again a Stream. + * + */ +public class StreamDemo1 +{ + public static void main(String[] args) + { + List nameList = new ArrayList<>(); + nameList.add("Amitabh"); + nameList.add("Shekhar"); + nameList.add("Aman"); + nameList.add("Rahul"); + nameList.add("Shahrukh"); + nameList.add("Salman"); + nameList.add("Yana"); + nameList.add("Lokesh"); + + /* + * This method helps in iterating over all elements of a + * stream and perform some operation on each of them. The + * operation is passed as lambda expression parameter. + */ + nameList.forEach(System.out::println); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/src/StreamDemo2.java b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/src/StreamDemo2.java new file mode 100644 index 000000000..598dbc3ed --- /dev/null +++ b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/src/StreamDemo2.java @@ -0,0 +1,36 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * + * Terminal operations return a result of a certain type instead of + * again a Stream. + * + */ +public class StreamDemo2 +{ + public static void main(String[] args) + { + List nameList = new ArrayList<>(); + nameList.add("Amitabh"); + nameList.add("Shekhar"); + nameList.add("Aman"); + nameList.add("Rahul"); + nameList.add("Shahrukh"); + nameList.add("Salman"); + nameList.add("Yana"); + nameList.add("Lokesh"); + + /* + * collect() method used to receive elements from a stream and + * store them in a collection. + */ + List upperCaseNameList = nameList.stream() + .sorted() + .map(String::toUpperCase) + .collect(Collectors.toList()); + + System.out.print(upperCaseNameList); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/src/StreamDemo3.java b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/src/StreamDemo3.java new file mode 100644 index 000000000..db30eb54f --- /dev/null +++ b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/src/StreamDemo3.java @@ -0,0 +1,45 @@ +import java.util.ArrayList; +import java.util.List; + +/** + * + * Terminal operations return a result of a certain type instead of + * again a Stream. + * + */ +public class StreamDemo3 +{ + public static void main(String[] args) + { + List nameList = new ArrayList<>(); + nameList.add("Amitabh"); + nameList.add("Shekhar"); + nameList.add("Aman"); + nameList.add("Rahul"); + nameList.add("Shahrukh"); + nameList.add("Salman"); + nameList.add("Yana"); + nameList.add("Lokesh"); + + /* + * Various matching operations can be used to check whether a + * certain predicate matches the stream. All of those + * operations are terminal and return a boolean result. + */ + + boolean matchedResult = nameList.stream() + .anyMatch((s) -> s.startsWith("A")); + + System.out.println(matchedResult); + + matchedResult = nameList.stream() + .allMatch((s) -> s.startsWith("A")); + + System.out.println(matchedResult); + + matchedResult = nameList.stream() + .noneMatch((s) -> s.startsWith("A")); + + System.out.println(matchedResult); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/src/StreamDemo4.java b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/src/StreamDemo4.java new file mode 100644 index 000000000..a0049c64e --- /dev/null +++ b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/src/StreamDemo4.java @@ -0,0 +1,35 @@ +import java.util.ArrayList; +import java.util.List; + +/** + * + * Terminal operations return a result of a certain type instead of + * again a Stream. + * + */ +public class StreamDemo4 +{ + public static void main(String[] args) + { + List nameList = new ArrayList<>(); + nameList.add("Amitabh"); + nameList.add("Shekhar"); + nameList.add("Aman"); + nameList.add("Rahul"); + nameList.add("Shahrukh"); + nameList.add("Salman"); + nameList.add("Yana"); + nameList.add("Lokesh"); + + /* + * Count is a terminal operation returning the number of + * elements in the stream as a long. + */ + + long totalMatched = nameList.stream() + .filter((s) -> s.startsWith("A")) + .count(); + + System.out.println(totalMatched); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/src/StreamDemo5.java b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/src/StreamDemo5.java new file mode 100644 index 000000000..a8db94e2f --- /dev/null +++ b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo/src/StreamDemo5.java @@ -0,0 +1,36 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +/** + * + * Terminal operations return a result of a certain type instead of + * again a Stream. + * + */ +public class StreamDemo5 +{ + public static void main(String[] args) + { + List nameList = new ArrayList<>(); + nameList.add("Amitabh"); + nameList.add("Shekhar"); + nameList.add("Aman"); + nameList.add("Rahul"); + nameList.add("Shahrukh"); + nameList.add("Salman"); + nameList.add("Yana"); + nameList.add("Lokesh"); + + /* + * reduce() terminal operation performs a reduction on the + * elements of the stream with the given function. The result + * is an Optional holding the reduced value. + */ + + Optional optional = nameList.stream() + .reduce((s1, s2) -> s1 + "#" + s2); + + optional.ifPresent(System.out::println); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo1_Output.txt b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo1_Output.txt new file mode 100644 index 000000000..4a4eb401d --- /dev/null +++ b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo1_Output.txt @@ -0,0 +1,8 @@ +Amitabh +Shekhar +Aman +Rahul +Shahrukh +Salman +Yana +Lokesh diff --git a/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo2_Output.txt b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo2_Output.txt new file mode 100644 index 000000000..ed2e89f88 --- /dev/null +++ b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo2_Output.txt @@ -0,0 +1 @@ +[AMAN, AMITABH, LOKESH, RAHUL, SALMAN, SHAHRUKH, SHEKHAR, YANA] \ No newline at end of file diff --git a/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo3_Output.txt b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo3_Output.txt new file mode 100644 index 000000000..36bc6136b --- /dev/null +++ b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo3_Output.txt @@ -0,0 +1,3 @@ +true +false +false diff --git a/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo4_Output.txt b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo4_Output.txt new file mode 100644 index 000000000..0cfbf0888 --- /dev/null +++ b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo4_Output.txt @@ -0,0 +1 @@ +2 diff --git a/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo5_Output.txt b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo5_Output.txt new file mode 100644 index 000000000..621ffbe07 --- /dev/null +++ b/BasicJava/StreamDemo_terminal_op_examples_App/StreamDemo5_Output.txt @@ -0,0 +1 @@ +Amitabh#Shekhar#Aman#Rahul#Shahrukh#Salman#Yana#Lokesh diff --git a/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo/.classpath b/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo/.project b/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo/bin/StreamDemo1.class b/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo/bin/StreamDemo1.class new file mode 100644 index 000000000..6c5c49b22 Binary files /dev/null and b/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo/bin/StreamDemo1.class differ diff --git a/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo/bin/StreamDemo2.class b/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo/bin/StreamDemo2.class new file mode 100644 index 000000000..5c071ef4f Binary files /dev/null and b/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo/bin/StreamDemo2.class differ diff --git a/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo/bin/StreamDemo3.class b/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo/bin/StreamDemo3.class new file mode 100644 index 000000000..54f9ff7b2 Binary files /dev/null and b/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo/bin/StreamDemo3.class differ diff --git a/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo/src/StreamDemo1.java b/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo/src/StreamDemo1.java new file mode 100644 index 000000000..419b70989 --- /dev/null +++ b/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo/src/StreamDemo1.java @@ -0,0 +1,20 @@ +import java.util.Arrays; +import java.util.List; + +/** + * Terminal operation : foreach() + */ +public class StreamDemo1 +{ + public static void main(String[] args) + { + List list = Arrays.asList("Ball", "Cat", "Dog", "Apple"); + + /* + * foreach operations helps iterate the elements of the Stream. + */ + list.stream().sorted().filter((s) -> !s.startsWith("B")) + .map(String::toUpperCase).forEach(System.out::println); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo/src/StreamDemo2.java b/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo/src/StreamDemo2.java new file mode 100644 index 000000000..721ad671a --- /dev/null +++ b/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo/src/StreamDemo2.java @@ -0,0 +1,22 @@ +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/** + * Terminal operation : collect() + */ +public class StreamDemo2 +{ + public static void main(String[] args) + { + Stream stream = Stream.of("Apple", "Ball", "Cat"); + + /* + * collect() operation helps to collect the stream result in a + * collection like list. + */ + List list = stream.collect(Collectors.toList()); + System.out.println(list); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo/src/StreamDemo3.java b/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo/src/StreamDemo3.java new file mode 100644 index 000000000..1957f09ce --- /dev/null +++ b/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo/src/StreamDemo3.java @@ -0,0 +1,21 @@ +import java.util.Arrays; +import java.util.List; + +/** + * Terminal Operation : count() + */ +public class StreamDemo3 +{ + public static void main(String[] args) + { + List list = Arrays.asList("Ball", "Dog", "Apple"); + + /* + * count() operation return the aggregate count for stream data. + */ + long count = list.stream().filter((s) -> s.startsWith("B")).count(); + + System.out.println(count); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo1_Output.txt b/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo1_Output.txt new file mode 100644 index 000000000..b4721bc35 --- /dev/null +++ b/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo1_Output.txt @@ -0,0 +1,3 @@ +APPLE +CAT +DOG diff --git a/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo2_Output.txt b/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo2_Output.txt new file mode 100644 index 000000000..3cc4ead4b --- /dev/null +++ b/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo2_Output.txt @@ -0,0 +1 @@ +[Apple, Ball, Cat] diff --git a/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo3_Output.txt b/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo3_Output.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/BasicJava/StreamDemo_terminal_op_fcc/StreamDemo3_Output.txt @@ -0,0 +1 @@ +1 diff --git a/BasicJava/StreamDemo_terminal_op_mr/StreamDemo/.classpath b/BasicJava/StreamDemo_terminal_op_mr/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_terminal_op_mr/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_terminal_op_mr/StreamDemo/.project b/BasicJava/StreamDemo_terminal_op_mr/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_terminal_op_mr/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_terminal_op_mr/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_terminal_op_mr/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_terminal_op_mr/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_terminal_op_mr/StreamDemo/bin/StreamDemo1.class b/BasicJava/StreamDemo_terminal_op_mr/StreamDemo/bin/StreamDemo1.class new file mode 100644 index 000000000..753704442 Binary files /dev/null and b/BasicJava/StreamDemo_terminal_op_mr/StreamDemo/bin/StreamDemo1.class differ diff --git a/BasicJava/StreamDemo_terminal_op_mr/StreamDemo/bin/StreamDemo2.class b/BasicJava/StreamDemo_terminal_op_mr/StreamDemo/bin/StreamDemo2.class new file mode 100644 index 000000000..7566bd558 Binary files /dev/null and b/BasicJava/StreamDemo_terminal_op_mr/StreamDemo/bin/StreamDemo2.class differ diff --git a/BasicJava/StreamDemo_terminal_op_mr/StreamDemo/src/StreamDemo1.java b/BasicJava/StreamDemo_terminal_op_mr/StreamDemo/src/StreamDemo1.java new file mode 100644 index 000000000..868c85d6c --- /dev/null +++ b/BasicJava/StreamDemo_terminal_op_mr/StreamDemo/src/StreamDemo1.java @@ -0,0 +1,20 @@ +import java.util.Arrays; +import java.util.List; + +/** + * Terminal operation : match() + */ +public class StreamDemo1 +{ + public static void main(String[] args) + { + List list = Arrays.asList("Ball", "Cat", "Dog", "Apple"); + + /* + * match() operation returns a boolean depending upon the condition + * applied on stream data. + */ + boolean result = list.stream().anyMatch((s) -> s.startsWith("D")); + System.out.println(result); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_terminal_op_mr/StreamDemo/src/StreamDemo2.java b/BasicJava/StreamDemo_terminal_op_mr/StreamDemo/src/StreamDemo2.java new file mode 100644 index 000000000..9ab74b008 --- /dev/null +++ b/BasicJava/StreamDemo_terminal_op_mr/StreamDemo/src/StreamDemo2.java @@ -0,0 +1,20 @@ +import java.util.stream.IntStream; + +/** + * Terminal operation : reduce() + */ +public class StreamDemo2 +{ + public static void main(String[] args) + { + + /* + * reduce() operation combines the stream elements into one using a + * BinaryOperator. + * + */ + int result = IntStream.of(1, 2, 3, 4).reduce(0, (a, b) -> a + b); + System.out.println(result); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_terminal_op_mr/StreamDemo1_Output.txt b/BasicJava/StreamDemo_terminal_op_mr/StreamDemo1_Output.txt new file mode 100644 index 000000000..27ba77dda --- /dev/null +++ b/BasicJava/StreamDemo_terminal_op_mr/StreamDemo1_Output.txt @@ -0,0 +1 @@ +true diff --git a/BasicJava/StreamDemo_terminal_op_mr/StreamDemo2_Output.txt b/BasicJava/StreamDemo_terminal_op_mr/StreamDemo2_Output.txt new file mode 100644 index 000000000..f599e28b8 --- /dev/null +++ b/BasicJava/StreamDemo_terminal_op_mr/StreamDemo2_Output.txt @@ -0,0 +1 @@ +10 diff --git a/BasicJava/StreamDemo_toArray_ObjArray_App/Output.txt b/BasicJava/StreamDemo_toArray_ObjArray_App/Output.txt new file mode 100644 index 000000000..ee197e4e7 --- /dev/null +++ b/BasicJava/StreamDemo_toArray_ObjArray_App/Output.txt @@ -0,0 +1,5 @@ +Length of array: 4 +A +B +C +D diff --git a/BasicJava/StreamDemo_toArray_ObjArray_App/StreamDemo/.classpath b/BasicJava/StreamDemo_toArray_ObjArray_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_toArray_ObjArray_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_toArray_ObjArray_App/StreamDemo/.project b/BasicJava/StreamDemo_toArray_ObjArray_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_toArray_ObjArray_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_toArray_ObjArray_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_toArray_ObjArray_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_toArray_ObjArray_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_toArray_ObjArray_App/StreamDemo/bin/StreamToArrayDemo.class b/BasicJava/StreamDemo_toArray_ObjArray_App/StreamDemo/bin/StreamToArrayDemo.class new file mode 100644 index 000000000..a65840d13 Binary files /dev/null and b/BasicJava/StreamDemo_toArray_ObjArray_App/StreamDemo/bin/StreamToArrayDemo.class differ diff --git a/BasicJava/StreamDemo_toArray_ObjArray_App/StreamDemo/src/StreamToArrayDemo.java b/BasicJava/StreamDemo_toArray_ObjArray_App/StreamDemo/src/StreamToArrayDemo.java new file mode 100644 index 000000000..849bf2b19 --- /dev/null +++ b/BasicJava/StreamDemo_toArray_ObjArray_App/StreamDemo/src/StreamToArrayDemo.java @@ -0,0 +1,24 @@ +import java.util.Arrays; +import java.util.List; + +public class StreamToArrayDemo +{ + public static void main(String[] args) + { + + List list = Arrays.asList("A", "B", "C", "D"); + + /* + * toArray(): It returns an array containing the elements of + * stream. + */ + + Object[] objArray = list.stream().toArray(); + System.out.println("Length of array: " + objArray.length); + + for (Object object : objArray) + { + System.out.println(object); + } + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_top_3_youngest/Output.txt b/BasicJava/StreamDemo_top_3_youngest/Output.txt new file mode 100644 index 000000000..a9d1bbfa7 --- /dev/null +++ b/BasicJava/StreamDemo_top_3_youngest/Output.txt @@ -0,0 +1,3 @@ +Person [name=Alice, gender=FEMALE, age=15] +Person [name=Bob, gender=MALE, age=16] +Person [name=Eric, gender=MALE, age=17] diff --git a/BasicJava/StreamDemo_top_3_youngest/StreamDemo/.classpath b/BasicJava/StreamDemo_top_3_youngest/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_top_3_youngest/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_top_3_youngest/StreamDemo/.project b/BasicJava/StreamDemo_top_3_youngest/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_top_3_youngest/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_top_3_youngest/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_top_3_youngest/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_top_3_youngest/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_top_3_youngest/StreamDemo/bin/Gender.class b/BasicJava/StreamDemo_top_3_youngest/StreamDemo/bin/Gender.class new file mode 100644 index 000000000..c667336c7 Binary files /dev/null and b/BasicJava/StreamDemo_top_3_youngest/StreamDemo/bin/Gender.class differ diff --git a/BasicJava/StreamDemo_top_3_youngest/StreamDemo/bin/Person.class b/BasicJava/StreamDemo_top_3_youngest/StreamDemo/bin/Person.class new file mode 100644 index 000000000..2c56c3967 Binary files /dev/null and b/BasicJava/StreamDemo_top_3_youngest/StreamDemo/bin/Person.class differ diff --git a/BasicJava/StreamDemo_top_3_youngest/StreamDemo/bin/StreamLimitDemo.class b/BasicJava/StreamDemo_top_3_youngest/StreamDemo/bin/StreamLimitDemo.class new file mode 100644 index 000000000..abd1b81ab Binary files /dev/null and b/BasicJava/StreamDemo_top_3_youngest/StreamDemo/bin/StreamLimitDemo.class differ diff --git a/BasicJava/StreamDemo_top_3_youngest/StreamDemo/src/Person.java b/BasicJava/StreamDemo_top_3_youngest/StreamDemo/src/Person.java new file mode 100644 index 000000000..21b811070 --- /dev/null +++ b/BasicJava/StreamDemo_top_3_youngest/StreamDemo/src/Person.java @@ -0,0 +1,74 @@ +enum Gender +{ + MALE, FEMALE +} + +public class Person implements Comparable +{ + private String name; + private String email; + private Gender gender; + private int age; + + public Person(String name, String email, Gender gender, int age) + { + super(); + this.name = name; + this.email = email; + this.gender = gender; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getEmail() + { + return email; + } + + public void setEmail(String email) + { + this.email = email; + } + + public Gender getGender() + { + return gender; + } + + public void setGender(Gender gender) + { + this.gender = gender; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + public int compareTo(Person another) + { + return this.age - another.getAge(); + } + + @Override + public String toString() + { + return "Person [name=" + name + ", gender=" + gender + ", age=" + age + + "]"; + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_top_3_youngest/StreamDemo/src/StreamLimitDemo.java b/BasicJava/StreamDemo_top_3_youngest/StreamDemo/src/StreamLimitDemo.java new file mode 100644 index 000000000..c7ee351fa --- /dev/null +++ b/BasicJava/StreamDemo_top_3_youngest/StreamDemo/src/StreamLimitDemo.java @@ -0,0 +1,25 @@ +import java.util.ArrayList; +import java.util.List; + +public class StreamLimitDemo +{ + public static void main(String[] args) + { + List personList = new ArrayList<>(); + + personList.add(new Person("Alice", "alice@gmail.com", Gender.FEMALE, 15)); + personList.add(new Person("Bob", "bob@gmail.com", Gender.MALE, 16)); + personList.add(new Person("Carol", "carol@gmail.com", Gender.FEMALE, 23)); + personList.add(new Person("David", "david@gmail.com", Gender.MALE, 19)); + personList.add(new Person("Eric", "eric@gmail.com", Gender.MALE, 17)); + + /* + * The limit() operation returns a stream containing only a specified + * number of elements. Combining with the sorted() operation, the + * following example shows top 3 youngest persons: + * + */ + personList.stream().sorted().limit(3).forEach(System.out::println); + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_unmodifiable_set/Output.txt b/BasicJava/StreamDemo_unmodifiable_set/Output.txt new file mode 100644 index 000000000..7f6f9b577 --- /dev/null +++ b/BasicJava/StreamDemo_unmodifiable_set/Output.txt @@ -0,0 +1,3 @@ +unmodifiableSet = [Product [name=orange, price=15], Product [name=lemon, price=20], +Product [name=potatoes, price=15], Product [name=sugar, price=30], +Product [name=bread, price=20]] diff --git a/BasicJava/StreamDemo_unmodifiable_set/StreamDemo/.classpath b/BasicJava/StreamDemo_unmodifiable_set/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_unmodifiable_set/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_unmodifiable_set/StreamDemo/.project b/BasicJava/StreamDemo_unmodifiable_set/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_unmodifiable_set/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_unmodifiable_set/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_unmodifiable_set/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_unmodifiable_set/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_unmodifiable_set/StreamDemo/bin/Product.class b/BasicJava/StreamDemo_unmodifiable_set/StreamDemo/bin/Product.class new file mode 100644 index 000000000..a66bb2673 Binary files /dev/null and b/BasicJava/StreamDemo_unmodifiable_set/StreamDemo/bin/Product.class differ diff --git a/BasicJava/StreamDemo_unmodifiable_set/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_unmodifiable_set/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..c0d160b52 Binary files /dev/null and b/BasicJava/StreamDemo_unmodifiable_set/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_unmodifiable_set/StreamDemo/src/Product.java b/BasicJava/StreamDemo_unmodifiable_set/StreamDemo/src/Product.java new file mode 100644 index 000000000..84d632c09 --- /dev/null +++ b/BasicJava/StreamDemo_unmodifiable_set/StreamDemo/src/Product.java @@ -0,0 +1,40 @@ + +public class Product +{ + private String name; + private int price; + + public Product(String name, int price) + { + super(); + this.name = name; + this.price = price; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getPrice() + { + return price; + } + + public void setPrice(int price) + { + this.price = price; + } + + @Override + public String toString() + { + return "Product [name=" + name + ", price=" + price + "]"; + } + +} diff --git a/BasicJava/StreamDemo_unmodifiable_set/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_unmodifiable_set/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..bb2663a2f --- /dev/null +++ b/BasicJava/StreamDemo_unmodifiable_set/StreamDemo/src/StreamDemo.java @@ -0,0 +1,31 @@ +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +public class StreamDemo +{ + public static void main(String[] args) + { + List productList = Arrays.asList( + new Product("potatoes", 15), + new Product("orange", 15), new Product("lemon", 20), + new Product("bread", 20), new Product("sugar", 30)); + + /* + * Pushing the collector to perform additional transformation: + * + * The collector has converted a stream to a Set and then + * created the unmodifiable Set out of it. + */ + Set unmodifiableSet = productList.stream() + .collect(Collectors.collectingAndThen( + Collectors.toSet(), + Collections::unmodifiableSet)); + + System.out.println("unmodifiableSet = " + unmodifiableSet); + + } + +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_what_is_stream_App/Output.txt b/BasicJava/StreamDemo_what_is_stream_App/Output.txt new file mode 100644 index 000000000..bb72a4415 --- /dev/null +++ b/BasicJava/StreamDemo_what_is_stream_App/Output.txt @@ -0,0 +1 @@ +[[2], [4], [6]] diff --git a/BasicJava/StreamDemo_what_is_stream_App/StreamDemo/.classpath b/BasicJava/StreamDemo_what_is_stream_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_what_is_stream_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_what_is_stream_App/StreamDemo/.project b/BasicJava/StreamDemo_what_is_stream_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_what_is_stream_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_what_is_stream_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_what_is_stream_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_what_is_stream_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_what_is_stream_App/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_what_is_stream_App/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..a536c0000 Binary files /dev/null and b/BasicJava/StreamDemo_what_is_stream_App/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_what_is_stream_App/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_what_is_stream_App/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..0d339b535 --- /dev/null +++ b/BasicJava/StreamDemo_what_is_stream_App/StreamDemo/src/StreamDemo.java @@ -0,0 +1,19 @@ +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +public class StreamDemo +{ + public static void main(String[] args) + { + List numbers = Arrays.asList(1, 2, 3, 4, 5, 6, 7); + + // get List from Stream Operation + List result = numbers.stream() + .filter(i -> (i % 2) == 0) + .map(i -> "[" + i + "]") + .collect(Collectors.toList()); + + System.out.println(result); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_why_required_App/NonStreamDemo_Output.txt b/BasicJava/StreamDemo_why_required_App/NonStreamDemo_Output.txt new file mode 100644 index 000000000..6e0aff417 --- /dev/null +++ b/BasicJava/StreamDemo_why_required_App/NonStreamDemo_Output.txt @@ -0,0 +1 @@ +sum = 70 diff --git a/BasicJava/StreamDemo_why_required_App/StreamDemo/.classpath b/BasicJava/StreamDemo_why_required_App/StreamDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StreamDemo_why_required_App/StreamDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StreamDemo_why_required_App/StreamDemo/.project b/BasicJava/StreamDemo_why_required_App/StreamDemo/.project new file mode 100644 index 000000000..48d7cdf11 --- /dev/null +++ b/BasicJava/StreamDemo_why_required_App/StreamDemo/.project @@ -0,0 +1,17 @@ + + + StreamDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StreamDemo_why_required_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StreamDemo_why_required_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StreamDemo_why_required_App/StreamDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StreamDemo_why_required_App/StreamDemo/bin/NonStreamDemo.class b/BasicJava/StreamDemo_why_required_App/StreamDemo/bin/NonStreamDemo.class new file mode 100644 index 000000000..b9f8678bb Binary files /dev/null and b/BasicJava/StreamDemo_why_required_App/StreamDemo/bin/NonStreamDemo.class differ diff --git a/BasicJava/StreamDemo_why_required_App/StreamDemo/bin/StreamDemo.class b/BasicJava/StreamDemo_why_required_App/StreamDemo/bin/StreamDemo.class new file mode 100644 index 000000000..33be1e0e9 Binary files /dev/null and b/BasicJava/StreamDemo_why_required_App/StreamDemo/bin/StreamDemo.class differ diff --git a/BasicJava/StreamDemo_why_required_App/StreamDemo/src/NonStreamDemo.java b/BasicJava/StreamDemo_why_required_App/StreamDemo/src/NonStreamDemo.java new file mode 100644 index 000000000..510e0b340 --- /dev/null +++ b/BasicJava/StreamDemo_why_required_App/StreamDemo/src/NonStreamDemo.java @@ -0,0 +1,36 @@ +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; + +/** + * Before JDK8 + * + * We want to iterate over a list of integers and find out sum + * of all the integers greater than 10. + * + */ +public class NonStreamDemo +{ + public static void main(String[] args) + { + + List numberList = Arrays.asList(2, 5, 10, 20, 50); + int sum = calculateSum(numberList); + System.out.println("sum = " + sum); + } + + private static int calculateSum(List list) + { + Iterator it = list.iterator(); + int sum = 0; + while (it.hasNext()) + { + int num = it.next(); + if (num > 10) + { + sum += num; + } + } + return sum; + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_why_required_App/StreamDemo/src/StreamDemo.java b/BasicJava/StreamDemo_why_required_App/StreamDemo/src/StreamDemo.java new file mode 100644 index 000000000..aedc84eee --- /dev/null +++ b/BasicJava/StreamDemo_why_required_App/StreamDemo/src/StreamDemo.java @@ -0,0 +1,25 @@ +import java.util.Arrays; +import java.util.List; + +/** + * With JDK8 + * + * We want to iterate over a list of integers and find out sum + * of all the integers greater than 10. + * + */ +public class StreamDemo +{ + public static void main(String[] args) + { + + List numberList = Arrays.asList(2, 5, 10, 20, 50); + int sum = calculateSum(numberList); + System.out.println("sum = " + sum); + } + + private static int calculateSum(List list) + { + return list.stream().filter(i -> i > 10).mapToInt(i -> i).sum(); + } +} \ No newline at end of file diff --git a/BasicJava/StreamDemo_why_required_App/StreamDemo_Output.txt b/BasicJava/StreamDemo_why_required_App/StreamDemo_Output.txt new file mode 100644 index 000000000..6e0aff417 --- /dev/null +++ b/BasicJava/StreamDemo_why_required_App/StreamDemo_Output.txt @@ -0,0 +1 @@ +sum = 70 diff --git a/BasicJava/StringBufferDemo_HashCode_diff_App/Output.txt b/BasicJava/StringBufferDemo_HashCode_diff_App/Output.txt new file mode 100644 index 000000000..0fe9d4924 --- /dev/null +++ b/BasicJava/StringBufferDemo_HashCode_diff_App/Output.txt @@ -0,0 +1,7 @@ +Hashcode test of String: +Before Concat,HashCode = -1397214398 +After Concat,HashCode = 44468202 +--------------------------------- +Hashcode test of StringBuffer: +Before Concat,HashCode = 1704856573 +After Concat,HashCode = 1704856573 diff --git a/BasicJava/StringBufferDemo_HashCode_diff_App/StringBufferDemo/.classpath b/BasicJava/StringBufferDemo_HashCode_diff_App/StringBufferDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBufferDemo_HashCode_diff_App/StringBufferDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/StringBuffer/StringBuffer_1/StringBufferDemo/.project b/BasicJava/StringBufferDemo_HashCode_diff_App/StringBufferDemo/.project similarity index 100% rename from Later/StringBuffer/StringBuffer_1/StringBufferDemo/.project rename to BasicJava/StringBufferDemo_HashCode_diff_App/StringBufferDemo/.project diff --git a/BasicJava/StringBufferDemo_HashCode_diff_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBufferDemo_HashCode_diff_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBufferDemo_HashCode_diff_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBufferDemo_HashCode_diff_App/StringBufferDemo/bin/HashCodeTest.class b/BasicJava/StringBufferDemo_HashCode_diff_App/StringBufferDemo/bin/HashCodeTest.class new file mode 100644 index 000000000..b89bd342e Binary files /dev/null and b/BasicJava/StringBufferDemo_HashCode_diff_App/StringBufferDemo/bin/HashCodeTest.class differ diff --git a/BasicJava/StringBufferDemo_HashCode_diff_App/StringBufferDemo/src/HashCodeTest.java b/BasicJava/StringBufferDemo_HashCode_diff_App/StringBufferDemo/src/HashCodeTest.java new file mode 100644 index 000000000..4942d71c4 --- /dev/null +++ b/BasicJava/StringBufferDemo_HashCode_diff_App/StringBufferDemo/src/HashCodeTest.java @@ -0,0 +1,42 @@ +public class HashCodeTest +{ + + public static void main(String[] args) + { + + System.out.println("Hashcode test of String:"); + + /* + * String is immutable(once created, can not be + * modified). + */ + String str = "Welcome"; + + System.out.println("Before Concat,HashCode = " + + str.hashCode()); + + str = str + "Peter"; + + System.out.println("After Concat,HashCode = " + + str.hashCode()); + + System.out.println("---------------------------------"); + + System.out.println("Hashcode test of StringBuffer:"); + + /* + * StringBuffer is mutable (once created, can be + * modified. + */ + StringBuffer sb = new StringBuffer("Welcome"); + + System.out.println("Before Concat,HashCode = " + + sb.hashCode()); + + sb.append("Peter"); + + System.out.println("After Concat,HashCode = " + + sb.hashCode()); + + } +} \ No newline at end of file diff --git a/BasicJava/StringBufferDemo_Intro_App/Output.txt b/BasicJava/StringBufferDemo_Intro_App/Output.txt new file mode 100644 index 000000000..85a43d5d8 --- /dev/null +++ b/BasicJava/StringBufferDemo_Intro_App/Output.txt @@ -0,0 +1,11 @@ +sb1 = +sb1 capacity = 16 +----------------------- +sb2 = +sb2 capacity = 50 +----------------------- +sb3 = Hello +sb3 capacity = 21 +----------------------- +sb4 = Welcome +sb4 capacity = 23 diff --git a/BasicJava/StringBufferDemo_Intro_App/StringBufferDemo/.classpath b/BasicJava/StringBufferDemo_Intro_App/StringBufferDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBufferDemo_Intro_App/StringBufferDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/StringBuffer/StringBuffer_2/StringBufferDemo/.project b/BasicJava/StringBufferDemo_Intro_App/StringBufferDemo/.project similarity index 100% rename from Later/StringBuffer/StringBuffer_2/StringBufferDemo/.project rename to BasicJava/StringBufferDemo_Intro_App/StringBufferDemo/.project diff --git a/BasicJava/StringBufferDemo_Intro_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBufferDemo_Intro_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBufferDemo_Intro_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/StringBuffer/StringBuffer_1/StringBufferDemo/bin/StringBufferDemo.class b/BasicJava/StringBufferDemo_Intro_App/StringBufferDemo/bin/StringBufferDemo.class similarity index 100% rename from Later/StringBuffer/StringBuffer_1/StringBufferDemo/bin/StringBufferDemo.class rename to BasicJava/StringBufferDemo_Intro_App/StringBufferDemo/bin/StringBufferDemo.class diff --git a/Later/StringBuffer/StringBuffer_1/StringBufferDemo/src/StringBufferDemo.java b/BasicJava/StringBufferDemo_Intro_App/StringBufferDemo/src/StringBufferDemo.java similarity index 100% rename from Later/StringBuffer/StringBuffer_1/StringBufferDemo/src/StringBufferDemo.java rename to BasicJava/StringBufferDemo_Intro_App/StringBufferDemo/src/StringBufferDemo.java diff --git a/BasicJava/StringBufferDemo_Perf_App/Output.txt b/BasicJava/StringBufferDemo_Perf_App/Output.txt new file mode 100644 index 000000000..2ba6e4518 --- /dev/null +++ b/BasicJava/StringBufferDemo_Perf_App/Output.txt @@ -0,0 +1,2 @@ +Time taken by Concating with String : 15249ms +Time taken by Concating with StringBuffer: 10ms diff --git a/BasicJava/StringBufferDemo_Perf_App/StringBufferDemo/.classpath b/BasicJava/StringBufferDemo_Perf_App/StringBufferDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBufferDemo_Perf_App/StringBufferDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/StringBuffer/StringBuffer_3/StringBufferDemo/.project b/BasicJava/StringBufferDemo_Perf_App/StringBufferDemo/.project similarity index 100% rename from Later/StringBuffer/StringBuffer_3/StringBufferDemo/.project rename to BasicJava/StringBufferDemo_Perf_App/StringBufferDemo/.project diff --git a/BasicJava/StringBufferDemo_Perf_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBufferDemo_Perf_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBufferDemo_Perf_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBufferDemo_Perf_App/StringBufferDemo/bin/PerformanceTest.class b/BasicJava/StringBufferDemo_Perf_App/StringBufferDemo/bin/PerformanceTest.class new file mode 100644 index 000000000..37122a906 Binary files /dev/null and b/BasicJava/StringBufferDemo_Perf_App/StringBufferDemo/bin/PerformanceTest.class differ diff --git a/BasicJava/StringBufferDemo_Perf_App/StringBufferDemo/src/PerformanceTest.java b/BasicJava/StringBufferDemo_Perf_App/StringBufferDemo/src/PerformanceTest.java new file mode 100644 index 000000000..6c0f0dacc --- /dev/null +++ b/BasicJava/StringBufferDemo_Perf_App/StringBufferDemo/src/PerformanceTest.java @@ -0,0 +1,54 @@ +public class PerformanceTest +{ + + /* + * String is slow and consumes more memory when you + * concat too many strings because every time it creates + * new instance. + */ + public static String concatWithString() + { + String str = "Welcome"; + for (int i = 0; i < 70000; i++) + { + str = str + "Peter"; + } + return str; + } + + /* + * StringBuffer is fast and consumes less memory when + * you cancat strings. + */ + public static String concatWithStringBuffer() + { + StringBuffer sb = new StringBuffer("Welcome"); + for (int i = 0; i < 70000; i++) + { + sb.append("Peter"); + } + return sb.toString(); + } + + public static void main(String[] args) + { + long startTime = System.currentTimeMillis(); + + concatWithString(); + + long endTime = System.currentTimeMillis() - startTime; + + System.out.println("Time taken by Concating with String : " + + endTime + "ms"); + + startTime = System.currentTimeMillis(); + + concatWithStringBuffer(); + + endTime = System.currentTimeMillis() - startTime; + + System.out.println("Time taken by Concating with StringBuffer : " + + endTime + "ms"); + + } +} \ No newline at end of file diff --git a/BasicJava/StringBufferDemo_Replace_App/Output.txt b/BasicJava/StringBufferDemo_Replace_App/Output.txt new file mode 100644 index 000000000..0ff4efba2 --- /dev/null +++ b/BasicJava/StringBufferDemo_Replace_App/Output.txt @@ -0,0 +1,2 @@ +Hello Dave Welcome +Hello Peter Welcome diff --git a/BasicJava/StringBufferDemo_Replace_App/StringBufferDemo/.classpath b/BasicJava/StringBufferDemo_Replace_App/StringBufferDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBufferDemo_Replace_App/StringBufferDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/StringBuffer/StringBuffer_4/StringBufferDemo/.project b/BasicJava/StringBufferDemo_Replace_App/StringBufferDemo/.project similarity index 100% rename from Later/StringBuffer/StringBuffer_4/StringBufferDemo/.project rename to BasicJava/StringBufferDemo_Replace_App/StringBufferDemo/.project diff --git a/BasicJava/StringBufferDemo_Replace_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBufferDemo_Replace_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBufferDemo_Replace_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBufferDemo_Replace_App/StringBufferDemo/bin/StringBufferDemo.class b/BasicJava/StringBufferDemo_Replace_App/StringBufferDemo/bin/StringBufferDemo.class new file mode 100644 index 000000000..a93e7856d Binary files /dev/null and b/BasicJava/StringBufferDemo_Replace_App/StringBufferDemo/bin/StringBufferDemo.class differ diff --git a/BasicJava/StringBufferDemo_Replace_App/StringBufferDemo/src/StringBufferDemo.java b/BasicJava/StringBufferDemo_Replace_App/StringBufferDemo/src/StringBufferDemo.java new file mode 100644 index 000000000..b88ba98db --- /dev/null +++ b/BasicJava/StringBufferDemo_Replace_App/StringBufferDemo/src/StringBufferDemo.java @@ -0,0 +1,28 @@ +/* + * public StringBuffer replace(int start, int end, + * String str) + * + * Parameters: + * ----------- + * start - The beginning index, inclusive. + * + * end - The ending index, exclusive. + * + * str - String that will replace previous contents. + * + * Returns: + * -------- + * This object. + */ + +public class StringBufferDemo +{ + + public static void main(String[] args) + { + StringBuffer sb = new StringBuffer("Hello Dave Welcome"); + System.out.println(sb); + sb = sb.replace(6, 10, "Peter"); + System.out.println(sb); + } +} diff --git a/BasicJava/StringBufferDemo_Reverse_App/Output.txt b/BasicJava/StringBufferDemo_Reverse_App/Output.txt new file mode 100644 index 000000000..b22d9d89e --- /dev/null +++ b/BasicJava/StringBufferDemo_Reverse_App/Output.txt @@ -0,0 +1,2 @@ +Before Reverse = Hello +After Reverse = olleH diff --git a/BasicJava/StringBufferDemo_Reverse_App/StringBufferDemo/.classpath b/BasicJava/StringBufferDemo_Reverse_App/StringBufferDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBufferDemo_Reverse_App/StringBufferDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/StringBuffer/StringBuffer_5/StringBufferDemo/.project b/BasicJava/StringBufferDemo_Reverse_App/StringBufferDemo/.project similarity index 100% rename from Later/StringBuffer/StringBuffer_5/StringBufferDemo/.project rename to BasicJava/StringBufferDemo_Reverse_App/StringBufferDemo/.project diff --git a/BasicJava/StringBufferDemo_Reverse_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBufferDemo_Reverse_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBufferDemo_Reverse_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBufferDemo_Reverse_App/StringBufferDemo/bin/StringBufferDemo.class b/BasicJava/StringBufferDemo_Reverse_App/StringBufferDemo/bin/StringBufferDemo.class new file mode 100644 index 000000000..f096d26c8 Binary files /dev/null and b/BasicJava/StringBufferDemo_Reverse_App/StringBufferDemo/bin/StringBufferDemo.class differ diff --git a/BasicJava/StringBufferDemo_Reverse_App/StringBufferDemo/src/StringBufferDemo.java b/BasicJava/StringBufferDemo_Reverse_App/StringBufferDemo/src/StringBufferDemo.java new file mode 100644 index 000000000..62907e7e0 --- /dev/null +++ b/BasicJava/StringBufferDemo_Reverse_App/StringBufferDemo/src/StringBufferDemo.java @@ -0,0 +1,19 @@ +/* + * public StringBuffer reverse() + * + * Returns: + * -------- + * a reference to this object. + */ + +public class StringBufferDemo +{ + + public static void main(String[] args) + { + StringBuffer sb = new StringBuffer("Hello"); + System.out.println("Before Reverse = "+sb); + sb = sb.reverse(); + System.out.println("After Reverse = "+sb); + } +} diff --git a/BasicJava/StringBufferDemo_append_methods_app/Output.txt b/BasicJava/StringBufferDemo_append_methods_app/Output.txt new file mode 100644 index 000000000..97cfe5f2d --- /dev/null +++ b/BasicJava/StringBufferDemo_append_methods_app/Output.txt @@ -0,0 +1 @@ +Hello 20500.4 diff --git a/BasicJava/StringBufferDemo_append_methods_app/StringBufferDemo/.classpath b/BasicJava/StringBufferDemo_append_methods_app/StringBufferDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBufferDemo_append_methods_app/StringBufferDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/StringBuffer/StringBuffer_6/StringBufferDemo/.project b/BasicJava/StringBufferDemo_append_methods_app/StringBufferDemo/.project similarity index 100% rename from Later/StringBuffer/StringBuffer_6/StringBufferDemo/.project rename to BasicJava/StringBufferDemo_append_methods_app/StringBufferDemo/.project diff --git a/BasicJava/StringBufferDemo_append_methods_app/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBufferDemo_append_methods_app/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBufferDemo_append_methods_app/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBufferDemo_append_methods_app/StringBufferDemo/bin/StringBufferDemo.class b/BasicJava/StringBufferDemo_append_methods_app/StringBufferDemo/bin/StringBufferDemo.class new file mode 100644 index 000000000..c3d9bd161 Binary files /dev/null and b/BasicJava/StringBufferDemo_append_methods_app/StringBufferDemo/bin/StringBufferDemo.class differ diff --git a/BasicJava/StringBufferDemo_append_methods_app/StringBufferDemo/src/StringBufferDemo.java b/BasicJava/StringBufferDemo_append_methods_app/StringBufferDemo/src/StringBufferDemo.java new file mode 100644 index 000000000..88d89141a --- /dev/null +++ b/BasicJava/StringBufferDemo_append_methods_app/StringBufferDemo/src/StringBufferDemo.java @@ -0,0 +1,13 @@ +public class StringBufferDemo +{ + + public static void main(String[] args) + { + StringBuffer sb = new StringBuffer("Hello "); + int i = 20; + sb.append(i); + double d = 500.4; + sb.append(d); + System.out.println(sb); + } +} diff --git a/BasicJava/StringBufferDemo_append_sb_app/Output.txt b/BasicJava/StringBufferDemo_append_sb_app/Output.txt new file mode 100644 index 000000000..1535c4308 --- /dev/null +++ b/BasicJava/StringBufferDemo_append_sb_app/Output.txt @@ -0,0 +1 @@ +Hello Java diff --git a/BasicJava/StringBufferDemo_append_sb_app/StringBufferDemo/.classpath b/BasicJava/StringBufferDemo_append_sb_app/StringBufferDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBufferDemo_append_sb_app/StringBufferDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBufferDemo_append_sb_app/StringBufferDemo/.project b/BasicJava/StringBufferDemo_append_sb_app/StringBufferDemo/.project new file mode 100644 index 000000000..c01d103bd --- /dev/null +++ b/BasicJava/StringBufferDemo_append_sb_app/StringBufferDemo/.project @@ -0,0 +1,17 @@ + + + StringBufferDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBufferDemo_append_sb_app/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBufferDemo_append_sb_app/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBufferDemo_append_sb_app/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/StringBuffer/StringBuffer_3/StringBufferDemo/bin/StringBufferDemo.class b/BasicJava/StringBufferDemo_append_sb_app/StringBufferDemo/bin/StringBufferDemo.class similarity index 100% rename from Later/StringBuffer/StringBuffer_3/StringBufferDemo/bin/StringBufferDemo.class rename to BasicJava/StringBufferDemo_append_sb_app/StringBufferDemo/bin/StringBufferDemo.class diff --git a/Later/StringBuffer/StringBuffer_3/StringBufferDemo/src/StringBufferDemo.java b/BasicJava/StringBufferDemo_append_sb_app/StringBufferDemo/src/StringBufferDemo.java similarity index 100% rename from Later/StringBuffer/StringBuffer_3/StringBufferDemo/src/StringBufferDemo.java rename to BasicJava/StringBufferDemo_append_sb_app/StringBufferDemo/src/StringBufferDemo.java diff --git a/BasicJava/StringBufferDemo_append_str_app/Output.txt b/BasicJava/StringBufferDemo_append_str_app/Output.txt new file mode 100644 index 000000000..1535c4308 --- /dev/null +++ b/BasicJava/StringBufferDemo_append_str_app/Output.txt @@ -0,0 +1 @@ +Hello Java diff --git a/BasicJava/StringBufferDemo_append_str_app/StringBufferDemo/.classpath b/BasicJava/StringBufferDemo_append_str_app/StringBufferDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBufferDemo_append_str_app/StringBufferDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBufferDemo_append_str_app/StringBufferDemo/.project b/BasicJava/StringBufferDemo_append_str_app/StringBufferDemo/.project new file mode 100644 index 000000000..c01d103bd --- /dev/null +++ b/BasicJava/StringBufferDemo_append_str_app/StringBufferDemo/.project @@ -0,0 +1,17 @@ + + + StringBufferDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBufferDemo_append_str_app/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBufferDemo_append_str_app/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBufferDemo_append_str_app/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBufferDemo_append_str_app/StringBufferDemo/bin/StringBufferDemo.class b/BasicJava/StringBufferDemo_append_str_app/StringBufferDemo/bin/StringBufferDemo.class new file mode 100644 index 000000000..9c3e40ec3 Binary files /dev/null and b/BasicJava/StringBufferDemo_append_str_app/StringBufferDemo/bin/StringBufferDemo.class differ diff --git a/BasicJava/StringBufferDemo_append_str_app/StringBufferDemo/src/StringBufferDemo.java b/BasicJava/StringBufferDemo_append_str_app/StringBufferDemo/src/StringBufferDemo.java new file mode 100644 index 000000000..5a96f4c4e --- /dev/null +++ b/BasicJava/StringBufferDemo_append_str_app/StringBufferDemo/src/StringBufferDemo.java @@ -0,0 +1,24 @@ +/* + * public StringBuffer append(String str) + * + * Appends the specified string to this character sequence. + * + * Parameters: + * ----------- + * str - a string. + * + * Returns: + * -------- + * a reference to this object. + */ + +public class StringBufferDemo +{ + + public static void main(String[] args) + { + StringBuffer sb = new StringBuffer("Hello "); + sb.append("Java"); + System.out.println(sb); + } +} diff --git a/BasicJava/StringBufferDemo_capacity_App/Output.txt b/BasicJava/StringBufferDemo_capacity_App/Output.txt new file mode 100644 index 000000000..b89f8786a --- /dev/null +++ b/BasicJava/StringBufferDemo_capacity_App/Output.txt @@ -0,0 +1,3 @@ +16 +16 +34 diff --git a/BasicJava/StringBufferDemo_capacity_App/StringBufferDemo/.classpath b/BasicJava/StringBufferDemo_capacity_App/StringBufferDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBufferDemo_capacity_App/StringBufferDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBufferDemo_capacity_App/StringBufferDemo/.project b/BasicJava/StringBufferDemo_capacity_App/StringBufferDemo/.project new file mode 100644 index 000000000..c01d103bd --- /dev/null +++ b/BasicJava/StringBufferDemo_capacity_App/StringBufferDemo/.project @@ -0,0 +1,17 @@ + + + StringBufferDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBufferDemo_capacity_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBufferDemo_capacity_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBufferDemo_capacity_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBufferDemo_capacity_App/StringBufferDemo/bin/StringBufferDemo.class b/BasicJava/StringBufferDemo_capacity_App/StringBufferDemo/bin/StringBufferDemo.class new file mode 100644 index 000000000..5bbf68ff9 Binary files /dev/null and b/BasicJava/StringBufferDemo_capacity_App/StringBufferDemo/bin/StringBufferDemo.class differ diff --git a/BasicJava/StringBufferDemo_capacity_App/StringBufferDemo/src/StringBufferDemo.java b/BasicJava/StringBufferDemo_capacity_App/StringBufferDemo/src/StringBufferDemo.java new file mode 100644 index 000000000..5ee124d4a --- /dev/null +++ b/BasicJava/StringBufferDemo_capacity_App/StringBufferDemo/src/StringBufferDemo.java @@ -0,0 +1,25 @@ +/* + * public int capacity() + * + * Returns: + * -------- + * the current capacity + */ + +public class StringBufferDemo +{ + + public static void main(String[] args) + { + StringBuffer sb = new StringBuffer(); + // default 16 + System.out.println(sb.capacity()); + sb.append("Hello"); + // now 16 + System.out.println(sb.capacity()); + sb.append("Hello peter welcome to India"); + + // now (16*2)+2=34 i.e (oldcapacity*2)+2 + System.out.println(sb.capacity()); + } +} diff --git a/BasicJava/StringBufferDemo_charAt_App/Output.txt b/BasicJava/StringBufferDemo_charAt_App/Output.txt new file mode 100644 index 000000000..50cea3b04 --- /dev/null +++ b/BasicJava/StringBufferDemo_charAt_App/Output.txt @@ -0,0 +1,2 @@ +charAt(3) = c +charAt(5) = m diff --git a/BasicJava/StringBufferDemo_charAt_App/StringBufferDemo/.classpath b/BasicJava/StringBufferDemo_charAt_App/StringBufferDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBufferDemo_charAt_App/StringBufferDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBufferDemo_charAt_App/StringBufferDemo/.project b/BasicJava/StringBufferDemo_charAt_App/StringBufferDemo/.project new file mode 100644 index 000000000..c01d103bd --- /dev/null +++ b/BasicJava/StringBufferDemo_charAt_App/StringBufferDemo/.project @@ -0,0 +1,17 @@ + + + StringBufferDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBufferDemo_charAt_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBufferDemo_charAt_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBufferDemo_charAt_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBufferDemo_charAt_App/StringBufferDemo/bin/CharAtDemo.class b/BasicJava/StringBufferDemo_charAt_App/StringBufferDemo/bin/CharAtDemo.class new file mode 100644 index 000000000..ba296dd2d Binary files /dev/null and b/BasicJava/StringBufferDemo_charAt_App/StringBufferDemo/bin/CharAtDemo.class differ diff --git a/BasicJava/StringBufferDemo_charAt_App/StringBufferDemo/src/CharAtDemo.java b/BasicJava/StringBufferDemo_charAt_App/StringBufferDemo/src/CharAtDemo.java new file mode 100644 index 000000000..3f32d1832 --- /dev/null +++ b/BasicJava/StringBufferDemo_charAt_App/StringBufferDemo/src/CharAtDemo.java @@ -0,0 +1,32 @@ +/* + * public char charAt(int index) + * + * Parameters: + * ---------- + * index - the index of the desired char value. + * + * Returns: + * -------- + * the char value at the specified index. + * + * Throws: + * ------ + * IndexOutOfBoundsException - if index is negative + * or greater than or equal to length(). + */ + +public class CharAtDemo +{ + + public static void main(String[] args) + { + + StringBuffer sb = new StringBuffer("Welcome"); + + char ch = sb.charAt(3); + System.out.println("charAt(3) = " + ch); + + ch = sb.charAt(5); + System.out.println("charAt(5) = " + ch); + } +} diff --git a/BasicJava/StringBufferDemo_codePointAt_App/Output.txt b/BasicJava/StringBufferDemo_codePointAt_App/Output.txt new file mode 100644 index 000000000..c92fac0e6 --- /dev/null +++ b/BasicJava/StringBufferDemo_codePointAt_App/Output.txt @@ -0,0 +1,2 @@ +sb = JAVA +Character(unicode point) = 65 diff --git a/BasicJava/StringBufferDemo_codePointAt_App/StringBufferDemo/.classpath b/BasicJava/StringBufferDemo_codePointAt_App/StringBufferDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBufferDemo_codePointAt_App/StringBufferDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBufferDemo_codePointAt_App/StringBufferDemo/.project b/BasicJava/StringBufferDemo_codePointAt_App/StringBufferDemo/.project new file mode 100644 index 000000000..c01d103bd --- /dev/null +++ b/BasicJava/StringBufferDemo_codePointAt_App/StringBufferDemo/.project @@ -0,0 +1,17 @@ + + + StringBufferDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBufferDemo_codePointAt_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBufferDemo_codePointAt_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBufferDemo_codePointAt_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBufferDemo_codePointAt_App/StringBufferDemo/bin/CodePointAtDemo.class b/BasicJava/StringBufferDemo_codePointAt_App/StringBufferDemo/bin/CodePointAtDemo.class new file mode 100644 index 000000000..25bfabcf1 Binary files /dev/null and b/BasicJava/StringBufferDemo_codePointAt_App/StringBufferDemo/bin/CodePointAtDemo.class differ diff --git a/BasicJava/StringBufferDemo_codePointAt_App/StringBufferDemo/src/CodePointAtDemo.java b/BasicJava/StringBufferDemo_codePointAt_App/StringBufferDemo/src/CodePointAtDemo.java new file mode 100644 index 000000000..ed8523911 --- /dev/null +++ b/BasicJava/StringBufferDemo_codePointAt_App/StringBufferDemo/src/CodePointAtDemo.java @@ -0,0 +1,27 @@ +/* + * public int codePointAt(int index) + * + * Parameters: + * ---------- + * index - the index to the char values + * + * Returns: + * ------- + * the code point value of the character at the index. + */ + +public class CodePointAtDemo +{ + + public static void main(String[] args) + { + String str = "JAVA"; + StringBuffer sb = new StringBuffer(str); + System.out.println("sb = " + sb); + + int retval = sb.codePointAt(1);// returns 65 + System.out.println("Character(unicode point) = " + retval); + + } + +} \ No newline at end of file diff --git a/BasicJava/StringBufferDemo_codePointBefore_App/Output.txt b/BasicJava/StringBufferDemo_codePointBefore_App/Output.txt new file mode 100644 index 000000000..d724804bd --- /dev/null +++ b/BasicJava/StringBufferDemo_codePointBefore_App/Output.txt @@ -0,0 +1,2 @@ +sb = JAVA +Character(unicode point) = 74 diff --git a/BasicJava/StringBufferDemo_codePointBefore_App/StringBufferDemo/.classpath b/BasicJava/StringBufferDemo_codePointBefore_App/StringBufferDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBufferDemo_codePointBefore_App/StringBufferDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBufferDemo_codePointBefore_App/StringBufferDemo/.project b/BasicJava/StringBufferDemo_codePointBefore_App/StringBufferDemo/.project new file mode 100644 index 000000000..c01d103bd --- /dev/null +++ b/BasicJava/StringBufferDemo_codePointBefore_App/StringBufferDemo/.project @@ -0,0 +1,17 @@ + + + StringBufferDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBufferDemo_codePointBefore_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBufferDemo_codePointBefore_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBufferDemo_codePointBefore_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBufferDemo_codePointBefore_App/StringBufferDemo/bin/CodePointBeforeDemo.class b/BasicJava/StringBufferDemo_codePointBefore_App/StringBufferDemo/bin/CodePointBeforeDemo.class new file mode 100644 index 000000000..3a8a1b6ab Binary files /dev/null and b/BasicJava/StringBufferDemo_codePointBefore_App/StringBufferDemo/bin/CodePointBeforeDemo.class differ diff --git a/BasicJava/StringBufferDemo_codePointBefore_App/StringBufferDemo/src/CodePointBeforeDemo.java b/BasicJava/StringBufferDemo_codePointBefore_App/StringBufferDemo/src/CodePointBeforeDemo.java new file mode 100644 index 000000000..949fbf101 --- /dev/null +++ b/BasicJava/StringBufferDemo_codePointBefore_App/StringBufferDemo/src/CodePointBeforeDemo.java @@ -0,0 +1,30 @@ +/* + * public int codePointBefore(int index) + * + * Parameters: + * ---------- + * index - the index following the code point that + * should be returned + * + * Returns: + * ------- + * the Unicode code point value before the given index. + */ +public class CodePointBeforeDemo +{ + + public static void main(String[] args) + { + String str = "JAVA"; + StringBuffer sb = new StringBuffer(str); + System.out.println("sb = " + sb); + + // codepoint before index 1 i.e J + int retval = sb.codePointBefore(1); + + // prints character before index1 in string + System.out.println("Character(unicode point) = " + retval); + + } + +} \ No newline at end of file diff --git a/BasicJava/StringBufferDemo_codePointCount_App/Output.txt b/BasicJava/StringBufferDemo_codePointCount_App/Output.txt new file mode 100644 index 000000000..4273dedbb --- /dev/null +++ b/BasicJava/StringBufferDemo_codePointCount_App/Output.txt @@ -0,0 +1,2 @@ +sb = JAVA programming language +Codepoint count = 7 diff --git a/BasicJava/StringBufferDemo_codePointCount_App/StringBufferDemo/.classpath b/BasicJava/StringBufferDemo_codePointCount_App/StringBufferDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBufferDemo_codePointCount_App/StringBufferDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBufferDemo_codePointCount_App/StringBufferDemo/.project b/BasicJava/StringBufferDemo_codePointCount_App/StringBufferDemo/.project new file mode 100644 index 000000000..c01d103bd --- /dev/null +++ b/BasicJava/StringBufferDemo_codePointCount_App/StringBufferDemo/.project @@ -0,0 +1,17 @@ + + + StringBufferDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBufferDemo_codePointCount_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBufferDemo_codePointCount_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBufferDemo_codePointCount_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBufferDemo_codePointCount_App/StringBufferDemo/bin/CodePointCountDemo.class b/BasicJava/StringBufferDemo_codePointCount_App/StringBufferDemo/bin/CodePointCountDemo.class new file mode 100644 index 000000000..9ee8d8310 Binary files /dev/null and b/BasicJava/StringBufferDemo_codePointCount_App/StringBufferDemo/bin/CodePointCountDemo.class differ diff --git a/BasicJava/StringBufferDemo_codePointCount_App/StringBufferDemo/src/CodePointCountDemo.java b/BasicJava/StringBufferDemo_codePointCount_App/StringBufferDemo/src/CodePointCountDemo.java new file mode 100644 index 000000000..5373d2bb5 --- /dev/null +++ b/BasicJava/StringBufferDemo_codePointCount_App/StringBufferDemo/src/CodePointCountDemo.java @@ -0,0 +1,34 @@ +/* + * public int codePointCount(int beginIndex, int + * endIndex) + * + * Parameters: + * ---------- + * beginIndex - the index to the first char of the text + * range. + * + * endIndex - the index after the last char of + * the text range. + * + * Returns: + * ------- + * the number of Unicode code points in the specified + * text range + */ + +public class CodePointCountDemo +{ + + public static void main(String[] args) + { + String str = "JAVA programming language"; + StringBuffer sb = new StringBuffer(str); + System.out.println("sb = " + sb); + + int retval = sb.codePointCount(1, 8); + + System.out.println("Codepoint count = " + retval); + + } + +} \ No newline at end of file diff --git a/BasicJava/StringBufferDemo_deleteCharAt_App/Output.txt b/BasicJava/StringBufferDemo_deleteCharAt_App/Output.txt new file mode 100644 index 000000000..2e00e1246 --- /dev/null +++ b/BasicJava/StringBufferDemo_deleteCharAt_App/Output.txt @@ -0,0 +1,2 @@ +Welcome +Wecome diff --git a/BasicJava/StringBufferDemo_deleteCharAt_App/StringBufferDemo/.classpath b/BasicJava/StringBufferDemo_deleteCharAt_App/StringBufferDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBufferDemo_deleteCharAt_App/StringBufferDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBufferDemo_deleteCharAt_App/StringBufferDemo/.project b/BasicJava/StringBufferDemo_deleteCharAt_App/StringBufferDemo/.project new file mode 100644 index 000000000..c01d103bd --- /dev/null +++ b/BasicJava/StringBufferDemo_deleteCharAt_App/StringBufferDemo/.project @@ -0,0 +1,17 @@ + + + StringBufferDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBufferDemo_deleteCharAt_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBufferDemo_deleteCharAt_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBufferDemo_deleteCharAt_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBufferDemo_deleteCharAt_App/StringBufferDemo/bin/StringBufferDemo.class b/BasicJava/StringBufferDemo_deleteCharAt_App/StringBufferDemo/bin/StringBufferDemo.class new file mode 100644 index 000000000..0a63a1c65 Binary files /dev/null and b/BasicJava/StringBufferDemo_deleteCharAt_App/StringBufferDemo/bin/StringBufferDemo.class differ diff --git a/BasicJava/StringBufferDemo_deleteCharAt_App/StringBufferDemo/src/StringBufferDemo.java b/BasicJava/StringBufferDemo_deleteCharAt_App/StringBufferDemo/src/StringBufferDemo.java new file mode 100644 index 000000000..0e0df510f --- /dev/null +++ b/BasicJava/StringBufferDemo_deleteCharAt_App/StringBufferDemo/src/StringBufferDemo.java @@ -0,0 +1,23 @@ +/* + * public StringBuffer deleteCharAt(int index) + * + * Parameters: + * ----------- + * index - Index of char to remove + * + * Returns: + * -------- + * This object. + */ + +public class StringBufferDemo +{ + + public static void main(String[] args) + { + StringBuffer sb = new StringBuffer("Welcome"); + System.out.println(sb); + sb = sb.deleteCharAt(2); + System.out.println(sb); + } +} diff --git a/BasicJava/StringBufferDemo_delete_App/Output.txt b/BasicJava/StringBufferDemo_delete_App/Output.txt new file mode 100644 index 000000000..d05515d5c --- /dev/null +++ b/BasicJava/StringBufferDemo_delete_App/Output.txt @@ -0,0 +1,2 @@ +Welcome +Wele diff --git a/BasicJava/StringBufferDemo_delete_App/StringBufferDemo/.classpath b/BasicJava/StringBufferDemo_delete_App/StringBufferDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBufferDemo_delete_App/StringBufferDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBufferDemo_delete_App/StringBufferDemo/.project b/BasicJava/StringBufferDemo_delete_App/StringBufferDemo/.project new file mode 100644 index 000000000..c01d103bd --- /dev/null +++ b/BasicJava/StringBufferDemo_delete_App/StringBufferDemo/.project @@ -0,0 +1,17 @@ + + + StringBufferDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBufferDemo_delete_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBufferDemo_delete_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBufferDemo_delete_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBufferDemo_delete_App/StringBufferDemo/bin/StringBufferDemo.class b/BasicJava/StringBufferDemo_delete_App/StringBufferDemo/bin/StringBufferDemo.class new file mode 100644 index 000000000..59f4e3ccb Binary files /dev/null and b/BasicJava/StringBufferDemo_delete_App/StringBufferDemo/bin/StringBufferDemo.class differ diff --git a/BasicJava/StringBufferDemo_delete_App/StringBufferDemo/src/StringBufferDemo.java b/BasicJava/StringBufferDemo_delete_App/StringBufferDemo/src/StringBufferDemo.java new file mode 100644 index 000000000..ac4529527 --- /dev/null +++ b/BasicJava/StringBufferDemo_delete_App/StringBufferDemo/src/StringBufferDemo.java @@ -0,0 +1,25 @@ +/* + * public StringBuffer delete(int start, int end) + * + * Parameters: + * ----------- + * start - The beginning index, inclusive. + * + * end - The ending index, exclusive. + * + * Returns: + * -------- + * This object. + */ + +public class StringBufferDemo +{ + + public static void main(String[] args) + { + StringBuffer sb = new StringBuffer("Welcome"); + System.out.println(sb); + sb = sb.delete(3, 6); + System.out.println(sb); + } +} diff --git a/BasicJava/StringBufferDemo_ensureCapacity_App/Output.txt b/BasicJava/StringBufferDemo_ensureCapacity_App/Output.txt new file mode 100644 index 000000000..72fee754d --- /dev/null +++ b/BasicJava/StringBufferDemo_ensureCapacity_App/Output.txt @@ -0,0 +1,2 @@ +Old capacity = 16 +New Capacity = 40 diff --git a/BasicJava/StringBufferDemo_ensureCapacity_App/StringBufferDemo/.classpath b/BasicJava/StringBufferDemo_ensureCapacity_App/StringBufferDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBufferDemo_ensureCapacity_App/StringBufferDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBufferDemo_ensureCapacity_App/StringBufferDemo/.project b/BasicJava/StringBufferDemo_ensureCapacity_App/StringBufferDemo/.project new file mode 100644 index 000000000..c01d103bd --- /dev/null +++ b/BasicJava/StringBufferDemo_ensureCapacity_App/StringBufferDemo/.project @@ -0,0 +1,17 @@ + + + StringBufferDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBufferDemo_ensureCapacity_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBufferDemo_ensureCapacity_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBufferDemo_ensureCapacity_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBufferDemo_ensureCapacity_App/StringBufferDemo/bin/StringBufferDemo.class b/BasicJava/StringBufferDemo_ensureCapacity_App/StringBufferDemo/bin/StringBufferDemo.class new file mode 100644 index 000000000..bfbf786d6 Binary files /dev/null and b/BasicJava/StringBufferDemo_ensureCapacity_App/StringBufferDemo/bin/StringBufferDemo.class differ diff --git a/BasicJava/StringBufferDemo_ensureCapacity_App/StringBufferDemo/src/StringBufferDemo.java b/BasicJava/StringBufferDemo_ensureCapacity_App/StringBufferDemo/src/StringBufferDemo.java new file mode 100644 index 000000000..a3773d1ea --- /dev/null +++ b/BasicJava/StringBufferDemo_ensureCapacity_App/StringBufferDemo/src/StringBufferDemo.java @@ -0,0 +1,21 @@ +/* + * public void ensureCapacity(int minimumCapacity) + * + * Parameters: + * ---------- + * minimumCapacity - the minimum desired capacity + */ +public class StringBufferDemo +{ + + public static void main(String[] args) + { + StringBuffer sb = new StringBuffer(); + // default 16 + System.out.println("Old capacity = "+sb.capacity()); + + sb.ensureCapacity(40); + + System.out.println("New Capacity = "+sb.capacity()); + } +} diff --git a/BasicJava/StringBufferDemo_getChars_App/Output.txt b/BasicJava/StringBufferDemo_getChars_App/Output.txt new file mode 100644 index 000000000..fadd78432 --- /dev/null +++ b/BasicJava/StringBufferDemo_getChars_App/Output.txt @@ -0,0 +1,2 @@ +Welcome to india peter +india \ No newline at end of file diff --git a/BasicJava/StringBufferDemo_getChars_App/StringBufferDemo/.classpath b/BasicJava/StringBufferDemo_getChars_App/StringBufferDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBufferDemo_getChars_App/StringBufferDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBufferDemo_getChars_App/StringBufferDemo/.project b/BasicJava/StringBufferDemo_getChars_App/StringBufferDemo/.project new file mode 100644 index 000000000..c01d103bd --- /dev/null +++ b/BasicJava/StringBufferDemo_getChars_App/StringBufferDemo/.project @@ -0,0 +1,17 @@ + + + StringBufferDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBufferDemo_getChars_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBufferDemo_getChars_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBufferDemo_getChars_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBufferDemo_getChars_App/StringBufferDemo/bin/StringBufferDemo.class b/BasicJava/StringBufferDemo_getChars_App/StringBufferDemo/bin/StringBufferDemo.class new file mode 100644 index 000000000..346f1e03c Binary files /dev/null and b/BasicJava/StringBufferDemo_getChars_App/StringBufferDemo/bin/StringBufferDemo.class differ diff --git a/BasicJava/StringBufferDemo_getChars_App/StringBufferDemo/src/StringBufferDemo.java b/BasicJava/StringBufferDemo_getChars_App/StringBufferDemo/src/StringBufferDemo.java new file mode 100644 index 000000000..779e30fd3 --- /dev/null +++ b/BasicJava/StringBufferDemo_getChars_App/StringBufferDemo/src/StringBufferDemo.java @@ -0,0 +1,51 @@ +/* + * public void getChars(int srcBegin, int srcEnd, char[] + * dst, int dstBegin) + * + * Parameters: + * ---------- + * srcBegin - start copying at this offset. + * + * srcEnd - stop copying at this offset. + * + * dst - the array to copy the data into. + * + * dstBegin - offset into dst. + * + * Throws: + * ------- + * IndexOutOfBoundsException - if any of the following + * is true: + * + * srcBegin is negative. + * + * dstBegin is negative. + * + * the srcBegin argument is greater than the srcEnd + * argument. + * + * srcEnd is greater than this.length(). + * + * dstBegin+srcEnd-srcBegin is greater than dst.length. + */ +public class StringBufferDemo +{ + + public static void main(String[] args) + { + + String str = "Welcome to india peter"; + StringBuffer sb = new StringBuffer(str); + System.out.println(sb); + + char[] charArray = new char[30]; + + /* + * copies characters from starting and ending index + * into the destination character array + */ + sb.getChars(11, 16, charArray, 0); + + System.out.println(charArray); + } +} diff --git a/BasicJava/StringBufferDemo_indexOf_str_App/Output.txt b/BasicJava/StringBufferDemo_indexOf_str_App/Output.txt new file mode 100644 index 000000000..9779a926e --- /dev/null +++ b/BasicJava/StringBufferDemo_indexOf_str_App/Output.txt @@ -0,0 +1,2 @@ +indexOf("com") = 3 +indexOf("abc") = -1 diff --git a/BasicJava/StringBufferDemo_indexOf_str_App/StringBufferDemo/.classpath b/BasicJava/StringBufferDemo_indexOf_str_App/StringBufferDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBufferDemo_indexOf_str_App/StringBufferDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBufferDemo_indexOf_str_App/StringBufferDemo/.project b/BasicJava/StringBufferDemo_indexOf_str_App/StringBufferDemo/.project new file mode 100644 index 000000000..c01d103bd --- /dev/null +++ b/BasicJava/StringBufferDemo_indexOf_str_App/StringBufferDemo/.project @@ -0,0 +1,17 @@ + + + StringBufferDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBufferDemo_indexOf_str_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBufferDemo_indexOf_str_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBufferDemo_indexOf_str_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBufferDemo_indexOf_str_App/StringBufferDemo/bin/IndexOfDemo.class b/BasicJava/StringBufferDemo_indexOf_str_App/StringBufferDemo/bin/IndexOfDemo.class new file mode 100644 index 000000000..e2c295776 Binary files /dev/null and b/BasicJava/StringBufferDemo_indexOf_str_App/StringBufferDemo/bin/IndexOfDemo.class differ diff --git a/BasicJava/StringBufferDemo_indexOf_str_App/StringBufferDemo/src/IndexOfDemo.java b/BasicJava/StringBufferDemo_indexOf_str_App/StringBufferDemo/src/IndexOfDemo.java new file mode 100644 index 000000000..1166af034 --- /dev/null +++ b/BasicJava/StringBufferDemo_indexOf_str_App/StringBufferDemo/src/IndexOfDemo.java @@ -0,0 +1,31 @@ +/* + * public int indexOf(String str) + * + * Parameters: + * ---------- + * str - any string. + * + * Returns: + * ------- + * if the string argument occurs as a + * substring within this object, then the index of the + * first character of the first such substring is + * returned; if it does not occur as a substring, -1 is + * returned. + */ +public class IndexOfDemo +{ + + public static void main(String[] args) + { + String str = "Welcome.com"; + StringBuffer sb = new StringBuffer(str); + + int indexPosition = sb.indexOf("com"); // returns 3 + System.out.println("indexOf(\"com\") = " + indexPosition); + + indexPosition = sb.indexOf("abc");// returns -1 + System.out.println("indexOf(\"abc\") = " + indexPosition); + + } +} diff --git a/BasicJava/StringBufferDemo_indexOf_str_fromIndex_App/Output.txt b/BasicJava/StringBufferDemo_indexOf_str_fromIndex_App/Output.txt new file mode 100644 index 000000000..56c5dd241 --- /dev/null +++ b/BasicJava/StringBufferDemo_indexOf_str_fromIndex_App/Output.txt @@ -0,0 +1 @@ +indexOf("com",2) = 4 diff --git a/BasicJava/StringBufferDemo_indexOf_str_fromIndex_App/StringBufferDemo/.classpath b/BasicJava/StringBufferDemo_indexOf_str_fromIndex_App/StringBufferDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBufferDemo_indexOf_str_fromIndex_App/StringBufferDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBufferDemo_indexOf_str_fromIndex_App/StringBufferDemo/.project b/BasicJava/StringBufferDemo_indexOf_str_fromIndex_App/StringBufferDemo/.project new file mode 100644 index 000000000..c01d103bd --- /dev/null +++ b/BasicJava/StringBufferDemo_indexOf_str_fromIndex_App/StringBufferDemo/.project @@ -0,0 +1,17 @@ + + + StringBufferDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBufferDemo_indexOf_str_fromIndex_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBufferDemo_indexOf_str_fromIndex_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBufferDemo_indexOf_str_fromIndex_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBufferDemo_indexOf_str_fromIndex_App/StringBufferDemo/bin/IndexOfDemo.class b/BasicJava/StringBufferDemo_indexOf_str_fromIndex_App/StringBufferDemo/bin/IndexOfDemo.class new file mode 100644 index 000000000..1bf26285f Binary files /dev/null and b/BasicJava/StringBufferDemo_indexOf_str_fromIndex_App/StringBufferDemo/bin/IndexOfDemo.class differ diff --git a/BasicJava/StringBufferDemo_indexOf_str_fromIndex_App/StringBufferDemo/src/IndexOfDemo.java b/BasicJava/StringBufferDemo_indexOf_str_fromIndex_App/StringBufferDemo/src/IndexOfDemo.java new file mode 100644 index 000000000..bca4b80fa --- /dev/null +++ b/BasicJava/StringBufferDemo_indexOf_str_fromIndex_App/StringBufferDemo/src/IndexOfDemo.java @@ -0,0 +1,27 @@ +/* + * public int indexOf(String str, int fromIndex) + * + * Parameters: + * ---------- + * str - the substring for which to search. + * + * fromIndex - the index from which to start + * the search. + * + * Returns: + * ------- + * the index within this string of the + * first occurrence of the specified substring, starting + * at the specified index. + */ +public class IndexOfDemo +{ + public static void main(String[] args) + { + String str = "com.com.com"; + StringBuffer sb = new StringBuffer(str); + //Returns 4 + int indexPosition = sb.indexOf("com", 2); + System.out.println("indexOf(\"com\",2) = " + indexPosition); + } +} diff --git a/BasicJava/StringBufferDemo_insert_methods_App/Output.txt b/BasicJava/StringBufferDemo_insert_methods_App/Output.txt new file mode 100644 index 000000000..4bde1a9df --- /dev/null +++ b/BasicJava/StringBufferDemo_insert_methods_App/Output.txt @@ -0,0 +1,2 @@ +Hello World +Hello 100 World diff --git a/BasicJava/StringBufferDemo_insert_methods_App/StringBufferDemo/.classpath b/BasicJava/StringBufferDemo_insert_methods_App/StringBufferDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBufferDemo_insert_methods_App/StringBufferDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBufferDemo_insert_methods_App/StringBufferDemo/.project b/BasicJava/StringBufferDemo_insert_methods_App/StringBufferDemo/.project new file mode 100644 index 000000000..c01d103bd --- /dev/null +++ b/BasicJava/StringBufferDemo_insert_methods_App/StringBufferDemo/.project @@ -0,0 +1,17 @@ + + + StringBufferDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBufferDemo_insert_methods_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBufferDemo_insert_methods_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBufferDemo_insert_methods_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBufferDemo_insert_methods_App/StringBufferDemo/bin/StringBufferDemo.class b/BasicJava/StringBufferDemo_insert_methods_App/StringBufferDemo/bin/StringBufferDemo.class new file mode 100644 index 000000000..e1d5a6bf9 Binary files /dev/null and b/BasicJava/StringBufferDemo_insert_methods_App/StringBufferDemo/bin/StringBufferDemo.class differ diff --git a/BasicJava/StringBufferDemo_insert_methods_App/StringBufferDemo/src/StringBufferDemo.java b/BasicJava/StringBufferDemo_insert_methods_App/StringBufferDemo/src/StringBufferDemo.java new file mode 100644 index 000000000..f8539765d --- /dev/null +++ b/BasicJava/StringBufferDemo_insert_methods_App/StringBufferDemo/src/StringBufferDemo.java @@ -0,0 +1,12 @@ +public class StringBufferDemo +{ + + public static void main(String[] args) + { + StringBuffer sb = new StringBuffer("Hello World"); + System.out.println(sb); + int intValue = 100; + sb.insert(6, intValue); + System.out.println(sb); + } +} diff --git a/BasicJava/StringBufferDemo_insert_str_app/Output.txt b/BasicJava/StringBufferDemo_insert_str_app/Output.txt new file mode 100644 index 000000000..b5fb6a3da --- /dev/null +++ b/BasicJava/StringBufferDemo_insert_str_app/Output.txt @@ -0,0 +1,2 @@ +Hello World +Hello My World diff --git a/BasicJava/StringBufferDemo_insert_str_app/StringBufferDemo/.classpath b/BasicJava/StringBufferDemo_insert_str_app/StringBufferDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBufferDemo_insert_str_app/StringBufferDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBufferDemo_insert_str_app/StringBufferDemo/.project b/BasicJava/StringBufferDemo_insert_str_app/StringBufferDemo/.project new file mode 100644 index 000000000..c01d103bd --- /dev/null +++ b/BasicJava/StringBufferDemo_insert_str_app/StringBufferDemo/.project @@ -0,0 +1,17 @@ + + + StringBufferDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBufferDemo_insert_str_app/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBufferDemo_insert_str_app/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBufferDemo_insert_str_app/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBufferDemo_insert_str_app/StringBufferDemo/bin/StringBufferDemo.class b/BasicJava/StringBufferDemo_insert_str_app/StringBufferDemo/bin/StringBufferDemo.class new file mode 100644 index 000000000..559b5b8b5 Binary files /dev/null and b/BasicJava/StringBufferDemo_insert_str_app/StringBufferDemo/bin/StringBufferDemo.class differ diff --git a/BasicJava/StringBufferDemo_insert_str_app/StringBufferDemo/src/StringBufferDemo.java b/BasicJava/StringBufferDemo_insert_str_app/StringBufferDemo/src/StringBufferDemo.java new file mode 100644 index 000000000..1ad9442e8 --- /dev/null +++ b/BasicJava/StringBufferDemo_insert_str_app/StringBufferDemo/src/StringBufferDemo.java @@ -0,0 +1,27 @@ +/* + * public StringBuffer insert(int offset, String str) + * + * Inserts the string into this character sequence. + * + * Parameters: + * ---------- + * offset - the offset. + * str - a string. + * + * Returns: + * ------- + * a reference to this object. + */ +public class StringBufferDemo +{ + + public static void main(String[] args) + { + StringBuffer sb = new StringBuffer("Hello World"); + System.out.println(sb); + String str = "My "; + sb.insert(6, str); + System.out.println(sb); + + } +} diff --git a/BasicJava/StringBufferDemo_lastIndexOf_str_App/Output.txt b/BasicJava/StringBufferDemo_lastIndexOf_str_App/Output.txt new file mode 100644 index 000000000..decc0033c --- /dev/null +++ b/BasicJava/StringBufferDemo_lastIndexOf_str_App/Output.txt @@ -0,0 +1,2 @@ +lastIndexOf("com") = 8 +lastIndexOf("abc") = -1 diff --git a/BasicJava/StringBufferDemo_lastIndexOf_str_App/StringBufferDemo/.classpath b/BasicJava/StringBufferDemo_lastIndexOf_str_App/StringBufferDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBufferDemo_lastIndexOf_str_App/StringBufferDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBufferDemo_lastIndexOf_str_App/StringBufferDemo/.project b/BasicJava/StringBufferDemo_lastIndexOf_str_App/StringBufferDemo/.project new file mode 100644 index 000000000..c01d103bd --- /dev/null +++ b/BasicJava/StringBufferDemo_lastIndexOf_str_App/StringBufferDemo/.project @@ -0,0 +1,17 @@ + + + StringBufferDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBufferDemo_lastIndexOf_str_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBufferDemo_lastIndexOf_str_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBufferDemo_lastIndexOf_str_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBufferDemo_lastIndexOf_str_App/StringBufferDemo/bin/LastIndexOfDemo.class b/BasicJava/StringBufferDemo_lastIndexOf_str_App/StringBufferDemo/bin/LastIndexOfDemo.class new file mode 100644 index 000000000..8b09ff606 Binary files /dev/null and b/BasicJava/StringBufferDemo_lastIndexOf_str_App/StringBufferDemo/bin/LastIndexOfDemo.class differ diff --git a/BasicJava/StringBufferDemo_lastIndexOf_str_App/StringBufferDemo/src/LastIndexOfDemo.java b/BasicJava/StringBufferDemo_lastIndexOf_str_App/StringBufferDemo/src/LastIndexOfDemo.java new file mode 100644 index 000000000..fbe10ac46 --- /dev/null +++ b/BasicJava/StringBufferDemo_lastIndexOf_str_App/StringBufferDemo/src/LastIndexOfDemo.java @@ -0,0 +1,32 @@ +/* + * public int lastIndexOf(String str) + * + * Parameters: + * ---------- + * str - the substring to search for. + * + * Returns: + * ------- + * if the string argument occurs one or + * more times as a substring within this object, then + * the index of the first character of the last such + * substring is returned. If it does not occur as a + * substring, -1 is returned. + */ +public class LastIndexOfDemo +{ + + public static void main(String[] args) + { + String str = "Welcome.com"; + StringBuffer sb = new StringBuffer(str); + + //Returns 8 + int indexPosition = sb.lastIndexOf("com"); + System.out.println("lastIndexOf(\"com\") = " + indexPosition); + + indexPosition = sb.lastIndexOf("abc"); + System.out.println("lastIndexOf(\"abc\") = " + indexPosition); + + } +} diff --git a/BasicJava/StringBufferDemo_lastIndexOf_str_fromIndex_App/Output.txt b/BasicJava/StringBufferDemo_lastIndexOf_str_fromIndex_App/Output.txt new file mode 100644 index 000000000..339fda112 --- /dev/null +++ b/BasicJava/StringBufferDemo_lastIndexOf_str_fromIndex_App/Output.txt @@ -0,0 +1,2 @@ +sb = com.com.com +lastIndexOf("com",7) = 4 diff --git a/BasicJava/StringBufferDemo_lastIndexOf_str_fromIndex_App/StringBufferDemo/.classpath b/BasicJava/StringBufferDemo_lastIndexOf_str_fromIndex_App/StringBufferDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBufferDemo_lastIndexOf_str_fromIndex_App/StringBufferDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBufferDemo_lastIndexOf_str_fromIndex_App/StringBufferDemo/.project b/BasicJava/StringBufferDemo_lastIndexOf_str_fromIndex_App/StringBufferDemo/.project new file mode 100644 index 000000000..c01d103bd --- /dev/null +++ b/BasicJava/StringBufferDemo_lastIndexOf_str_fromIndex_App/StringBufferDemo/.project @@ -0,0 +1,17 @@ + + + StringBufferDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBufferDemo_lastIndexOf_str_fromIndex_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBufferDemo_lastIndexOf_str_fromIndex_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBufferDemo_lastIndexOf_str_fromIndex_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBufferDemo_lastIndexOf_str_fromIndex_App/StringBufferDemo/bin/LastIndexOfDemo.class b/BasicJava/StringBufferDemo_lastIndexOf_str_fromIndex_App/StringBufferDemo/bin/LastIndexOfDemo.class new file mode 100644 index 000000000..c56e21e01 Binary files /dev/null and b/BasicJava/StringBufferDemo_lastIndexOf_str_fromIndex_App/StringBufferDemo/bin/LastIndexOfDemo.class differ diff --git a/BasicJava/StringBufferDemo_lastIndexOf_str_fromIndex_App/StringBufferDemo/src/LastIndexOfDemo.java b/BasicJava/StringBufferDemo_lastIndexOf_str_fromIndex_App/StringBufferDemo/src/LastIndexOfDemo.java new file mode 100644 index 000000000..8026ba92e --- /dev/null +++ b/BasicJava/StringBufferDemo_lastIndexOf_str_fromIndex_App/StringBufferDemo/src/LastIndexOfDemo.java @@ -0,0 +1,30 @@ +/* + * public int lastIndexOf(String str, int fromIndex) + * + * Parameters: + * ---------- + * str - the substring to search for. + * + * fromIndex - the index to start the search from. + * + * Returns: + * ------- + * the index within this sequence of + * the last occurrence of the specified substring. + */ +public class LastIndexOfDemo +{ + + public static void main(String[] args) + { + String str = "com.com.com"; + StringBuffer sb = new StringBuffer(str); + System.out.println("sb = "+sb); + + //returns 4 + int indexPosition = sb.lastIndexOf("com", 7); + System.out.println("lastIndexOf(\"com\",7) = " + + indexPosition); + + } +} diff --git a/BasicJava/StringBufferDemo_length_App/Output.txt b/BasicJava/StringBufferDemo_length_App/Output.txt new file mode 100644 index 000000000..80532927d --- /dev/null +++ b/BasicJava/StringBufferDemo_length_App/Output.txt @@ -0,0 +1,2 @@ +length = 0 +length = 2 diff --git a/BasicJava/StringBufferDemo_length_App/StringBufferDemo/.classpath b/BasicJava/StringBufferDemo_length_App/StringBufferDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBufferDemo_length_App/StringBufferDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBufferDemo_length_App/StringBufferDemo/.project b/BasicJava/StringBufferDemo_length_App/StringBufferDemo/.project new file mode 100644 index 000000000..c01d103bd --- /dev/null +++ b/BasicJava/StringBufferDemo_length_App/StringBufferDemo/.project @@ -0,0 +1,17 @@ + + + StringBufferDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBufferDemo_length_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBufferDemo_length_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBufferDemo_length_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBufferDemo_length_App/StringBufferDemo/bin/StringBufferDemo.class b/BasicJava/StringBufferDemo_length_App/StringBufferDemo/bin/StringBufferDemo.class new file mode 100644 index 000000000..c25cf011e Binary files /dev/null and b/BasicJava/StringBufferDemo_length_App/StringBufferDemo/bin/StringBufferDemo.class differ diff --git a/BasicJava/StringBufferDemo_length_App/StringBufferDemo/src/StringBufferDemo.java b/BasicJava/StringBufferDemo_length_App/StringBufferDemo/src/StringBufferDemo.java new file mode 100644 index 000000000..68edf5d54 --- /dev/null +++ b/BasicJava/StringBufferDemo_length_App/StringBufferDemo/src/StringBufferDemo.java @@ -0,0 +1,21 @@ +/* + * public int length() + * + * Parameters: + * ---------- + * the length of the sequence of characters currently + * represented by this object + */ +public class StringBufferDemo +{ + + public static void main(String[] args) + { + StringBuffer sb = new StringBuffer(); + System.out.println("length = " + sb.length()); + + sb.append(40); + System.out.println("length = " + sb.length()); + + } +} diff --git a/BasicJava/StringBufferDemo_setLength_App/Output.txt b/BasicJava/StringBufferDemo_setLength_App/Output.txt new file mode 100644 index 000000000..ffe6de101 --- /dev/null +++ b/BasicJava/StringBufferDemo_setLength_App/Output.txt @@ -0,0 +1,4 @@ +Before setLength, sb = Welcome +Before setLength, sb = 7 +After setLength, sb = Wel +After setLength, sb = 3 diff --git a/BasicJava/StringBufferDemo_setLength_App/StringBufferDemo/.classpath b/BasicJava/StringBufferDemo_setLength_App/StringBufferDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBufferDemo_setLength_App/StringBufferDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBufferDemo_setLength_App/StringBufferDemo/.project b/BasicJava/StringBufferDemo_setLength_App/StringBufferDemo/.project new file mode 100644 index 000000000..c01d103bd --- /dev/null +++ b/BasicJava/StringBufferDemo_setLength_App/StringBufferDemo/.project @@ -0,0 +1,17 @@ + + + StringBufferDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBufferDemo_setLength_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBufferDemo_setLength_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBufferDemo_setLength_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBufferDemo_setLength_App/StringBufferDemo/bin/StringBufferDemo.class b/BasicJava/StringBufferDemo_setLength_App/StringBufferDemo/bin/StringBufferDemo.class new file mode 100644 index 000000000..bd2cbce8b Binary files /dev/null and b/BasicJava/StringBufferDemo_setLength_App/StringBufferDemo/bin/StringBufferDemo.class differ diff --git a/BasicJava/StringBufferDemo_setLength_App/StringBufferDemo/src/StringBufferDemo.java b/BasicJava/StringBufferDemo_setLength_App/StringBufferDemo/src/StringBufferDemo.java new file mode 100644 index 000000000..90db5fbab --- /dev/null +++ b/BasicJava/StringBufferDemo_setLength_App/StringBufferDemo/src/StringBufferDemo.java @@ -0,0 +1,29 @@ +/* + * public void setLength(int newLength) + * + * Parameters: + * ---------- + * newLength - the new length + * + * Throws: + * ------ + * IndexOutOfBoundsException - if the newLength + * argument is negative. + */ +public class StringBufferDemo +{ + + public static void main(String[] args) + { + String str = "Welcome"; + StringBuffer sb = new StringBuffer(str); + System.out.println("Before setLength, sb = " + sb); + System.out.println("Before setLength, sb = " + sb.length()); + + sb.setLength(3); + + System.out.println("After setLength, sb = " + sb); + System.out.println("After setLength, sb = " + sb.length()); + + } +} diff --git a/BasicJava/StringBufferDemo_setcharAt_App/Output.txt b/BasicJava/StringBufferDemo_setcharAt_App/Output.txt new file mode 100644 index 000000000..59bc930a6 --- /dev/null +++ b/BasicJava/StringBufferDemo_setcharAt_App/Output.txt @@ -0,0 +1,2 @@ +Before setCharAt, sb = Dig +After setCharAt, sb = Dog diff --git a/BasicJava/StringBufferDemo_setcharAt_App/StringBufferDemo/.classpath b/BasicJava/StringBufferDemo_setcharAt_App/StringBufferDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBufferDemo_setcharAt_App/StringBufferDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBufferDemo_setcharAt_App/StringBufferDemo/.project b/BasicJava/StringBufferDemo_setcharAt_App/StringBufferDemo/.project new file mode 100644 index 000000000..c01d103bd --- /dev/null +++ b/BasicJava/StringBufferDemo_setcharAt_App/StringBufferDemo/.project @@ -0,0 +1,17 @@ + + + StringBufferDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBufferDemo_setcharAt_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBufferDemo_setcharAt_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBufferDemo_setcharAt_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBufferDemo_setcharAt_App/StringBufferDemo/bin/StringBufferDemo.class b/BasicJava/StringBufferDemo_setcharAt_App/StringBufferDemo/bin/StringBufferDemo.class new file mode 100644 index 000000000..084441854 Binary files /dev/null and b/BasicJava/StringBufferDemo_setcharAt_App/StringBufferDemo/bin/StringBufferDemo.class differ diff --git a/BasicJava/StringBufferDemo_setcharAt_App/StringBufferDemo/src/StringBufferDemo.java b/BasicJava/StringBufferDemo_setcharAt_App/StringBufferDemo/src/StringBufferDemo.java new file mode 100644 index 000000000..c8cb5aee5 --- /dev/null +++ b/BasicJava/StringBufferDemo_setcharAt_App/StringBufferDemo/src/StringBufferDemo.java @@ -0,0 +1,29 @@ +/* + * public void setCharAt(int index, char ch) + * + * Parameters: + * ---------- + * index - the index of the character to modify. + * + * ch - the new character. + * + * Throws: + * ------ + * IndexOutOfBoundsException - if index is negative or + * greater than or equal to length(). + */ +public class StringBufferDemo +{ + + public static void main(String[] args) + { + String str = "Dig"; + StringBuffer sb = new StringBuffer(str); + System.out.println("Before setCharAt, sb = " + sb); + + sb.setCharAt(1, 'o'); + + System.out.println("After setCharAt, sb = " + sb); + + } +} diff --git a/BasicJava/StringBufferDemo_subSequence_App/Output.txt b/BasicJava/StringBufferDemo_subSequence_App/Output.txt new file mode 100644 index 000000000..5f4fdf6f5 --- /dev/null +++ b/BasicJava/StringBufferDemo_subSequence_App/Output.txt @@ -0,0 +1 @@ +strValue = com diff --git a/BasicJava/StringBufferDemo_subSequence_App/StringBufferDemo/.classpath b/BasicJava/StringBufferDemo_subSequence_App/StringBufferDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBufferDemo_subSequence_App/StringBufferDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBufferDemo_subSequence_App/StringBufferDemo/.project b/BasicJava/StringBufferDemo_subSequence_App/StringBufferDemo/.project new file mode 100644 index 000000000..c01d103bd --- /dev/null +++ b/BasicJava/StringBufferDemo_subSequence_App/StringBufferDemo/.project @@ -0,0 +1,17 @@ + + + StringBufferDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBufferDemo_subSequence_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBufferDemo_subSequence_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBufferDemo_subSequence_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBufferDemo_subSequence_App/StringBufferDemo/bin/SubSequenceDemo.class b/BasicJava/StringBufferDemo_subSequence_App/StringBufferDemo/bin/SubSequenceDemo.class new file mode 100644 index 000000000..aa2770a23 Binary files /dev/null and b/BasicJava/StringBufferDemo_subSequence_App/StringBufferDemo/bin/SubSequenceDemo.class differ diff --git a/BasicJava/StringBufferDemo_subSequence_App/StringBufferDemo/src/SubSequenceDemo.java b/BasicJava/StringBufferDemo_subSequence_App/StringBufferDemo/src/SubSequenceDemo.java new file mode 100644 index 000000000..901e4f089 --- /dev/null +++ b/BasicJava/StringBufferDemo_subSequence_App/StringBufferDemo/src/SubSequenceDemo.java @@ -0,0 +1,31 @@ +/* + * public CharSequence subSequence(int start, int end) + * + * Parameters: + * ---------- + * start - the start index,inclusive. + * + * end - the end index, exclusive. + * + * Returns: + * ------- + * the specified subsequence. + * + * Throws: + * ------ + * IndexOutOfBoundsException - if start or end + * are negative, if end is greater than length(), + * or if start is greater than end + */ +public class SubSequenceDemo +{ + + public static void main(String[] args) + { + StringBuffer sb = new StringBuffer("Welcome"); + CharSequence charSequence = sb.subSequence(3, 6); + String strValue = (String) charSequence; + System.out.println("strValue = " + strValue); + + } +} diff --git a/BasicJava/StringBufferDemo_substring_App/StringBufferDemo/.classpath b/BasicJava/StringBufferDemo_substring_App/StringBufferDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBufferDemo_substring_App/StringBufferDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBufferDemo_substring_App/StringBufferDemo/.project b/BasicJava/StringBufferDemo_substring_App/StringBufferDemo/.project new file mode 100644 index 000000000..c01d103bd --- /dev/null +++ b/BasicJava/StringBufferDemo_substring_App/StringBufferDemo/.project @@ -0,0 +1,17 @@ + + + StringBufferDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBufferDemo_substring_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBufferDemo_substring_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBufferDemo_substring_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBufferDemo_substring_App/StringBufferDemo/bin/SubStringDemo1.class b/BasicJava/StringBufferDemo_substring_App/StringBufferDemo/bin/SubStringDemo1.class new file mode 100644 index 000000000..3cf34bbf5 Binary files /dev/null and b/BasicJava/StringBufferDemo_substring_App/StringBufferDemo/bin/SubStringDemo1.class differ diff --git a/BasicJava/StringBufferDemo_substring_App/StringBufferDemo/bin/SubStringDemo2.class b/BasicJava/StringBufferDemo_substring_App/StringBufferDemo/bin/SubStringDemo2.class new file mode 100644 index 000000000..c86c5ecc6 Binary files /dev/null and b/BasicJava/StringBufferDemo_substring_App/StringBufferDemo/bin/SubStringDemo2.class differ diff --git a/BasicJava/StringBufferDemo_substring_App/StringBufferDemo/src/SubStringDemo1.java b/BasicJava/StringBufferDemo_substring_App/StringBufferDemo/src/SubStringDemo1.java new file mode 100644 index 000000000..6a45868ee --- /dev/null +++ b/BasicJava/StringBufferDemo_substring_App/StringBufferDemo/src/SubStringDemo1.java @@ -0,0 +1,29 @@ +/* + * public String substring(int start, int end) + * + * Parameters: + * ---------- + * start - The beginning index,inclusive. + * + * end - The ending index, exclusive. + * + * Returns: + * ------- + * The new string. + * + * Throws: + * ------ + * StringIndexOutOfBoundsException - if start or end are + * negative or greater than length(), or start is + * greater than end. + */ +public class SubStringDemo1 +{ + + public static void main(String[] args) + { + StringBuffer sb = new StringBuffer("Welcome"); + String subString = sb.substring(3, 6); + System.out.println("subString = " + subString); + } +} diff --git a/BasicJava/StringBufferDemo_substring_App/StringBufferDemo/src/SubStringDemo2.java b/BasicJava/StringBufferDemo_substring_App/StringBufferDemo/src/SubStringDemo2.java new file mode 100644 index 000000000..d02211bb0 --- /dev/null +++ b/BasicJava/StringBufferDemo_substring_App/StringBufferDemo/src/SubStringDemo2.java @@ -0,0 +1,28 @@ +/* + * public String substring(int start) + * + * Parameters: + * ---------- + * start - The beginning index, inclusive. + * + * Returns: + * ------- + * The new string. + * + * Throws: + * ------ + * StringIndexOutOfBoundsException - if start is less + * than zero, or greater than the length of this object. + */ + +public class SubStringDemo2 +{ + + public static void main(String[] args) + { + StringBuffer sb = new StringBuffer("Welcome"); + String subString = sb.substring(3); + System.out.println("subString = " + subString); + + } +} diff --git a/BasicJava/StringBufferDemo_substring_App/SubStringDemo1_Output.txt b/BasicJava/StringBufferDemo_substring_App/SubStringDemo1_Output.txt new file mode 100644 index 000000000..417c7ab78 --- /dev/null +++ b/BasicJava/StringBufferDemo_substring_App/SubStringDemo1_Output.txt @@ -0,0 +1 @@ +subString = com diff --git a/BasicJava/StringBufferDemo_substring_App/SubStringDemo2_Output.txt b/BasicJava/StringBufferDemo_substring_App/SubStringDemo2_Output.txt new file mode 100644 index 000000000..227fc1292 --- /dev/null +++ b/BasicJava/StringBufferDemo_substring_App/SubStringDemo2_Output.txt @@ -0,0 +1 @@ +subString = come diff --git a/BasicJava/StringBufferDemo_trimToSize_App/Output.txt b/BasicJava/StringBufferDemo_trimToSize_App/Output.txt new file mode 100644 index 000000000..7bc8159fe --- /dev/null +++ b/BasicJava/StringBufferDemo_trimToSize_App/Output.txt @@ -0,0 +1,4 @@ +Before timeToSize,Length = 7 +Before timeToSize,Capacity = 23 +After timeToSize,Length = 7 +After timeToSize,Capacity = 7 diff --git a/BasicJava/StringBufferDemo_trimToSize_App/StringBufferDemo/.classpath b/BasicJava/StringBufferDemo_trimToSize_App/StringBufferDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBufferDemo_trimToSize_App/StringBufferDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBufferDemo_trimToSize_App/StringBufferDemo/.project b/BasicJava/StringBufferDemo_trimToSize_App/StringBufferDemo/.project new file mode 100644 index 000000000..c01d103bd --- /dev/null +++ b/BasicJava/StringBufferDemo_trimToSize_App/StringBufferDemo/.project @@ -0,0 +1,17 @@ + + + StringBufferDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBufferDemo_trimToSize_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBufferDemo_trimToSize_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBufferDemo_trimToSize_App/StringBufferDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBufferDemo_trimToSize_App/StringBufferDemo/bin/StringBufferDemo.class b/BasicJava/StringBufferDemo_trimToSize_App/StringBufferDemo/bin/StringBufferDemo.class new file mode 100644 index 000000000..d38dfb967 Binary files /dev/null and b/BasicJava/StringBufferDemo_trimToSize_App/StringBufferDemo/bin/StringBufferDemo.class differ diff --git a/BasicJava/StringBufferDemo_trimToSize_App/StringBufferDemo/src/StringBufferDemo.java b/BasicJava/StringBufferDemo_trimToSize_App/StringBufferDemo/src/StringBufferDemo.java new file mode 100644 index 000000000..e9d696176 --- /dev/null +++ b/BasicJava/StringBufferDemo_trimToSize_App/StringBufferDemo/src/StringBufferDemo.java @@ -0,0 +1,34 @@ +/* + * public void trimToSize() + * + * Attempts to reduce storage used for the character + * sequence. If the buffer is larger than necessary to + * hold its current sequence of characters, then it may + * be resized to become more space efficient. Calling + * this method may, but is not required to, affect the + * value returned by a subsequent call to the capacity() + * method. + */ + +public class StringBufferDemo +{ + + public static void main(String[] args) + { + + StringBuffer sb = new StringBuffer("Welcome"); + System.out.println("Before timeToSize,Length = " + + sb.length()); + + System.out.println("Before timeToSize,Capacity = " + + sb.capacity()); + + sb.trimToSize(); + + System.out.println("After timeToSize,Length = " + + sb.length()); + + System.out.println("After timeToSize,Capacity = " + + sb.capacity()); + } +} diff --git a/BasicJava/StringBuilderDemo_Hashcode_diff_App/Output.txt b/BasicJava/StringBuilderDemo_Hashcode_diff_App/Output.txt new file mode 100644 index 000000000..dec1a9961 --- /dev/null +++ b/BasicJava/StringBuilderDemo_Hashcode_diff_App/Output.txt @@ -0,0 +1,7 @@ +Hashcode test of String: +Before Concat,HashCode = -1397214398 +After Concat,HashCode = 44468202 +--------------------------------- +Hashcode test of StringBuilder: +Before Concat,HashCode = 2114664380 +After Concat,HashCode = 2114664380 diff --git a/BasicJava/StringBuilderDemo_Hashcode_diff_App/StringBuilderDemo/.classpath b/BasicJava/StringBuilderDemo_Hashcode_diff_App/StringBuilderDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBuilderDemo_Hashcode_diff_App/StringBuilderDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBuilderDemo_Hashcode_diff_App/StringBuilderDemo/.project b/BasicJava/StringBuilderDemo_Hashcode_diff_App/StringBuilderDemo/.project new file mode 100644 index 000000000..e29d88a2a --- /dev/null +++ b/BasicJava/StringBuilderDemo_Hashcode_diff_App/StringBuilderDemo/.project @@ -0,0 +1,17 @@ + + + StringBuilderDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBuilderDemo_Hashcode_diff_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBuilderDemo_Hashcode_diff_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBuilderDemo_Hashcode_diff_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBuilderDemo_Hashcode_diff_App/StringBuilderDemo/bin/HashCodeTest.class b/BasicJava/StringBuilderDemo_Hashcode_diff_App/StringBuilderDemo/bin/HashCodeTest.class new file mode 100644 index 000000000..8011d94fc Binary files /dev/null and b/BasicJava/StringBuilderDemo_Hashcode_diff_App/StringBuilderDemo/bin/HashCodeTest.class differ diff --git a/BasicJava/StringBuilderDemo_Hashcode_diff_App/StringBuilderDemo/src/HashCodeTest.java b/BasicJava/StringBuilderDemo_Hashcode_diff_App/StringBuilderDemo/src/HashCodeTest.java new file mode 100644 index 000000000..cf1b756fa --- /dev/null +++ b/BasicJava/StringBuilderDemo_Hashcode_diff_App/StringBuilderDemo/src/HashCodeTest.java @@ -0,0 +1,36 @@ +public class HashCodeTest +{ + + public static void main(String[] args) + { + + System.out.println("Hashcode test of String:"); + + /* + * String is immutable(once created, can not be + * modified). + */ + String str = "Welcome"; + System.out.println("Before Concat,HashCode = " + + str.hashCode()); + str = str + "Peter"; + System.out.println("After Concat,HashCode = " + + str.hashCode()); + + System.out.println("---------------------------------"); + + System.out.println("Hashcode test of StringBuilder:"); + + /* + * StringBuilder is mutable (once created, can be + * modified. + */ + StringBuilder sb = new StringBuilder("Welcome"); + System.out.println("Before Concat,HashCode = " + + sb.hashCode()); + sb.append("Peter"); + System.out.println("After Concat,HashCode = " + + sb.hashCode()); + + } +} \ No newline at end of file diff --git a/BasicJava/StringBuilderDemo_Intro_App/Output.txt b/BasicJava/StringBuilderDemo_Intro_App/Output.txt new file mode 100644 index 000000000..85a43d5d8 --- /dev/null +++ b/BasicJava/StringBuilderDemo_Intro_App/Output.txt @@ -0,0 +1,11 @@ +sb1 = +sb1 capacity = 16 +----------------------- +sb2 = +sb2 capacity = 50 +----------------------- +sb3 = Hello +sb3 capacity = 21 +----------------------- +sb4 = Welcome +sb4 capacity = 23 diff --git a/BasicJava/StringBuilderDemo_Intro_App/StringBuilderDemo/.classpath b/BasicJava/StringBuilderDemo_Intro_App/StringBuilderDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBuilderDemo_Intro_App/StringBuilderDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBuilderDemo_Intro_App/StringBuilderDemo/.project b/BasicJava/StringBuilderDemo_Intro_App/StringBuilderDemo/.project new file mode 100644 index 000000000..e29d88a2a --- /dev/null +++ b/BasicJava/StringBuilderDemo_Intro_App/StringBuilderDemo/.project @@ -0,0 +1,17 @@ + + + StringBuilderDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBuilderDemo_Intro_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBuilderDemo_Intro_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBuilderDemo_Intro_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBuilderDemo_Intro_App/StringBuilderDemo/bin/StringBuilderDemo.class b/BasicJava/StringBuilderDemo_Intro_App/StringBuilderDemo/bin/StringBuilderDemo.class new file mode 100644 index 000000000..03fd75dde Binary files /dev/null and b/BasicJava/StringBuilderDemo_Intro_App/StringBuilderDemo/bin/StringBuilderDemo.class differ diff --git a/BasicJava/StringBuilderDemo_Intro_App/StringBuilderDemo/src/StringBuilderDemo.java b/BasicJava/StringBuilderDemo_Intro_App/StringBuilderDemo/src/StringBuilderDemo.java new file mode 100644 index 000000000..9bbe3dcbc --- /dev/null +++ b/BasicJava/StringBuilderDemo_Intro_App/StringBuilderDemo/src/StringBuilderDemo.java @@ -0,0 +1,51 @@ +public class StringBuilderDemo +{ + + public static void main(String[] args) + { + /* + * Constructs a string Builder with no characters in + * it and an initial capacity of 16 characters. + */ + StringBuilder sb1 = new StringBuilder(); + System.out.println("sb1 = " + sb1); + System.out.println("sb1 capacity = " + sb1.capacity()); + + System.out.println("-----------------------"); + + /* + * Constructs a string Builder with no characters in + * it and the specified initial capacity. + */ + StringBuilder sb2 = new StringBuilder(50); + System.out.println("sb2 = " + sb2); + System.out.println("sb2 capacity = " + sb2.capacity()); + + System.out.println("-----------------------"); + + /* + * Constructs a string Builder initialized to the + * contents of the specified string. The initial + * capacity of the string Builder is 16 plus the + * length of the string argument. + */ + String str = "Hello"; + StringBuilder sb3 = new StringBuilder(str); + System.out.println("sb3 = " + sb3); + System.out.println("sb3 capacity = " + sb3.capacity()); + + System.out.println("-----------------------"); + + /* + * Constructs a string Builder that contains the same + * characters as the specified CharSequence. The + * initial capacity of the string Builder is 16 plus + * the length of the CharSequence argument. + */ + CharSequence charSequence = new StringBuilder("Welcome"); + StringBuilder sb4 = new StringBuilder(charSequence); + System.out.println("sb4 = " + sb4); + System.out.println("sb4 capacity = " + sb4.capacity()); + + } +} diff --git a/BasicJava/StringBuilderDemo_MemoryTest_App/Output.txt b/BasicJava/StringBuilderDemo_MemoryTest_App/Output.txt new file mode 100644 index 000000000..6d70a8fed --- /dev/null +++ b/BasicJava/StringBuilderDemo_MemoryTest_App/Output.txt @@ -0,0 +1,25 @@ +Initial Max memory in Java virtual machine in KBs=919552 +........................................................... +String memory test + +Initial Total memory in Java virtual machine in KBs=62976 +Initial Free memory in Java virtual machine in KBs=61992 +Time taken to complete the process in MilliSeconds:7729 +Memory used by String in KBs=130666 +Free Memory after GC in KBs=349431 +........................................................... +StringBuffer memory test + +Initial Total memory in Java virtual machine in KBs=355840 +Initial Free memory in Java virtual machine in KBs=349431 +Time taken to complete the process in MilliSeconds:11 +Memory used by StringBuffer in KBs=0 +Free Memory after GC in KBs=348918 +............................................................ +StringBuilder memory test + +Initial Total memory in Java virtual machine in KBs=355328 +Initial Free memory in Java virtual machine in KBs=348918 +Time taken to complete the process in MilliSeconds:5 +Memory used by StringBuilder in KBs=0 +Free Memory after GC in KBs=348406 diff --git a/BasicJava/StringBuilderDemo_MemoryTest_App/StringBuilderDemo/.classpath b/BasicJava/StringBuilderDemo_MemoryTest_App/StringBuilderDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBuilderDemo_MemoryTest_App/StringBuilderDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBuilderDemo_MemoryTest_App/StringBuilderDemo/.project b/BasicJava/StringBuilderDemo_MemoryTest_App/StringBuilderDemo/.project new file mode 100644 index 000000000..e29d88a2a --- /dev/null +++ b/BasicJava/StringBuilderDemo_MemoryTest_App/StringBuilderDemo/.project @@ -0,0 +1,17 @@ + + + StringBuilderDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBuilderDemo_MemoryTest_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBuilderDemo_MemoryTest_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBuilderDemo_MemoryTest_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBuilderDemo_MemoryTest_App/StringBuilderDemo/bin/StringMemoryTest.class b/BasicJava/StringBuilderDemo_MemoryTest_App/StringBuilderDemo/bin/StringMemoryTest.class new file mode 100644 index 000000000..334b7b121 Binary files /dev/null and b/BasicJava/StringBuilderDemo_MemoryTest_App/StringBuilderDemo/bin/StringMemoryTest.class differ diff --git a/BasicJava/StringBuilderDemo_MemoryTest_App/StringBuilderDemo/src/StringMemoryTest.java b/BasicJava/StringBuilderDemo_MemoryTest_App/StringBuilderDemo/src/StringMemoryTest.java new file mode 100644 index 000000000..95774858d --- /dev/null +++ b/BasicJava/StringBuilderDemo_MemoryTest_App/StringBuilderDemo/src/StringMemoryTest.java @@ -0,0 +1,162 @@ +public class StringMemoryTest +{ + + private static final int KBinBytes = 1024; + + /** + * Perform GC + */ + private void performGC() + { + for (int i = 0; i < 10; i++) + { + System.gc(); + try + { + Thread.sleep(100); + } + catch (InterruptedException e) + { + Thread.currentThread().interrupt(); + } + } + } + + /** + * Get the memory used value. + * + * @return long + */ + private long memoryUsed() + { + return ((Runtime.getRuntime().totalMemory() / KBinBytes) - (Runtime + .getRuntime().freeMemory() / KBinBytes)); + } + + /** + * Method to test String object memory consumption in a + * BIG loop + */ + public void testStringMemory() + { + System.out + .println("Initial Total memory in Java virtual machine in KBs=" + + Runtime.getRuntime().totalMemory() + / KBinBytes); + System.out + .println("Initial Free memory in Java virtual machine in KBs=" + + Runtime.getRuntime().freeMemory() + / KBinBytes); + long initialmemory = memoryUsed(); + long startTime = System.currentTimeMillis(); + String str = ""; + for (int i = 1; i < 50000; i++) + { + str = str + "Hello"; + } + long stopTime = System.currentTimeMillis(); + long elapsedTime = stopTime - startTime; + System.out.println("Time taken to complete the process in MilliSeconds:" + + elapsedTime); + + System.out.println("Memory used by String in KBs=" + + (memoryUsed() - initialmemory)); + str = null; + performGC(); + System.out.println("Free Memory after GC in KBs=" + + Runtime.getRuntime().freeMemory() / KBinBytes); + + } + + /** + * Method to test StringBuilder object memory + * consumption in a BIG loop + */ + public void testStringBuilderMemory() + { + System.out + .println("Initial Total memory in Java virtual machine in KBs=" + + Runtime.getRuntime().totalMemory() + / KBinBytes); + System.out + .println("Initial Free memory in Java virtual machine in KBs=" + + Runtime.getRuntime().freeMemory() + / KBinBytes); + long initialmemory = memoryUsed(); + long startTime = System.currentTimeMillis(); + StringBuilder sb = new StringBuilder(); + for (int i = 1; i < 50000; i++) + { + sb.append("Hello"); + } + long stopTime = System.currentTimeMillis(); + long elapsedTime = stopTime - startTime; + System.out + .println("Time taken to complete the process in MilliSeconds:" + + elapsedTime); + System.out.println("Memory used by StringBuilder in KBs=" + + (memoryUsed() - initialmemory)); + sb = null; + performGC(); + System.out.println("Free Memory after GC in KBs=" + + Runtime.getRuntime().freeMemory() / KBinBytes); + + } + + /** + * Method to test StringBuffer object memory consumption + * in a BIG loop + */ + public void testStringBufferMemory() + { + System.out + .println("Initial Total memory in Java virtual machine in KBs=" + + Runtime.getRuntime().totalMemory() + / KBinBytes); + System.out + .println("Initial Free memory in Java virtual machine in KBs=" + + Runtime.getRuntime().freeMemory() + / KBinBytes); + long initialmemory = memoryUsed(); + long startTime = System.currentTimeMillis(); + StringBuffer sb = new StringBuffer(); + + for (int i = 1; i < 50000; i++) + { + sb.append("Hello"); + } + long stopTime = System.currentTimeMillis(); + long elapsedTime = stopTime - startTime; + System.out.println("Time taken to complete the process in MilliSeconds:" + + elapsedTime); + System.out.println("Memory used by StringBuffer in KBs=" + + (memoryUsed() - initialmemory)); + sb = null; + performGC(); + System.out.println("Free Memory after GC in KBs=" + + Runtime.getRuntime().freeMemory() / KBinBytes); + + } + + /** + * Main class + * + * @param args + */ + public static void main(String[] args) + { + System.out + .println("Initial Max memory in Java virtual machine in KBs=" + + Runtime.getRuntime().maxMemory() + / KBinBytes); + StringMemoryTest memoryTest = new StringMemoryTest(); + System.out.println("...........................................................\nString memory test\n"); + memoryTest.testStringMemory(); + System.out.println("...........................................................\nStringBuffer memory test\n"); + memoryTest.testStringBufferMemory(); + System.out.println("............................................................\nStringBuilder memory test\n"); + memoryTest.testStringBuilderMemory(); + + } + +} \ No newline at end of file diff --git a/BasicJava/StringBuilderDemo_Perf_App/Output.txt b/BasicJava/StringBuilderDemo_Perf_App/Output.txt new file mode 100644 index 000000000..e737eb93f --- /dev/null +++ b/BasicJava/StringBuilderDemo_Perf_App/Output.txt @@ -0,0 +1,3 @@ +Time taken by Concatenating with String : 17394ms +Time taken by Concatenating with StringBuffer : 20ms +Time taken by Concatenating with StringBuilder: 10ms diff --git a/BasicJava/StringBuilderDemo_Perf_App/StringBuilderDemo/.classpath b/BasicJava/StringBuilderDemo_Perf_App/StringBuilderDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBuilderDemo_Perf_App/StringBuilderDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBuilderDemo_Perf_App/StringBuilderDemo/.project b/BasicJava/StringBuilderDemo_Perf_App/StringBuilderDemo/.project new file mode 100644 index 000000000..e29d88a2a --- /dev/null +++ b/BasicJava/StringBuilderDemo_Perf_App/StringBuilderDemo/.project @@ -0,0 +1,17 @@ + + + StringBuilderDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBuilderDemo_Perf_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBuilderDemo_Perf_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBuilderDemo_Perf_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBuilderDemo_Perf_App/StringBuilderDemo/bin/PerformanceTest.class b/BasicJava/StringBuilderDemo_Perf_App/StringBuilderDemo/bin/PerformanceTest.class new file mode 100644 index 000000000..10e5b8209 Binary files /dev/null and b/BasicJava/StringBuilderDemo_Perf_App/StringBuilderDemo/bin/PerformanceTest.class differ diff --git a/BasicJava/StringBuilderDemo_Perf_App/StringBuilderDemo/src/PerformanceTest.java b/BasicJava/StringBuilderDemo_Perf_App/StringBuilderDemo/src/PerformanceTest.java new file mode 100644 index 000000000..4dc2c120b --- /dev/null +++ b/BasicJava/StringBuilderDemo_Perf_App/StringBuilderDemo/src/PerformanceTest.java @@ -0,0 +1,80 @@ +public class PerformanceTest +{ + + /* + * String is slow and consumes more memory when you + * concat too many strings because every time it creates + * new instance. + */ + public static String concatenatingWithString() + { + String str = "Welcome"; + for (int i = 0; i < 70000; i++) + { + str = str + "Peter"; + } + return str; + } + + /* + * StringBuffer is fast and consumes less memory when + * you cancat strings. + * + * StringBuffer is faster than String. + */ + public static String concatenatingWithStringBuffer() + { + StringBuffer sb = new StringBuffer("Welcome"); + for (int i = 0; i < 70000; i++) + { + sb.append("Peter"); + } + return sb.toString(); + } + + /* + * StringBuilder is fast and consumes less memory when + * you cancat strings. + * + * StringBuilder is faster than StringBuffer. + */ + public static String concatenatingWithStringBuilder() + { + StringBuilder sb = new StringBuilder("Welcome"); + for (int i = 0; i < 70000; i++) + { + sb.append("Peter"); + } + return sb.toString(); + } + + public static void main(String[] args) + { + long startTime = System.currentTimeMillis(); + + concatenatingWithString(); + + System.out + .println("Time taken by Concatenating with String : " + + (System.currentTimeMillis() - startTime) + + "ms"); + + startTime = System.currentTimeMillis(); + + concatenatingWithStringBuffer(); + + System.out + .println("Time taken by Concatenating with StringBuffer : " + + (System.currentTimeMillis() - startTime) + + "ms"); + + startTime = System.currentTimeMillis(); + + concatenatingWithStringBuilder(); + + System.out + .println("Time taken by Concatenating with StringBuilder: " + + (System.currentTimeMillis() - startTime) + + "ms"); + } +} \ No newline at end of file diff --git a/BasicJava/StringBuilderDemo_append_methods_App/Output.txt b/BasicJava/StringBuilderDemo_append_methods_App/Output.txt new file mode 100644 index 000000000..97cfe5f2d --- /dev/null +++ b/BasicJava/StringBuilderDemo_append_methods_App/Output.txt @@ -0,0 +1 @@ +Hello 20500.4 diff --git a/BasicJava/StringBuilderDemo_append_methods_App/StringBuilderDemo/.classpath b/BasicJava/StringBuilderDemo_append_methods_App/StringBuilderDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBuilderDemo_append_methods_App/StringBuilderDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBuilderDemo_append_methods_App/StringBuilderDemo/.project b/BasicJava/StringBuilderDemo_append_methods_App/StringBuilderDemo/.project new file mode 100644 index 000000000..e29d88a2a --- /dev/null +++ b/BasicJava/StringBuilderDemo_append_methods_App/StringBuilderDemo/.project @@ -0,0 +1,17 @@ + + + StringBuilderDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBuilderDemo_append_methods_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBuilderDemo_append_methods_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBuilderDemo_append_methods_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBuilderDemo_append_methods_App/StringBuilderDemo/bin/StringBuilderDemo.class b/BasicJava/StringBuilderDemo_append_methods_App/StringBuilderDemo/bin/StringBuilderDemo.class new file mode 100644 index 000000000..1982710af Binary files /dev/null and b/BasicJava/StringBuilderDemo_append_methods_App/StringBuilderDemo/bin/StringBuilderDemo.class differ diff --git a/BasicJava/StringBuilderDemo_append_methods_App/StringBuilderDemo/src/StringBuilderDemo.java b/BasicJava/StringBuilderDemo_append_methods_App/StringBuilderDemo/src/StringBuilderDemo.java new file mode 100644 index 000000000..b856099fa --- /dev/null +++ b/BasicJava/StringBuilderDemo_append_methods_App/StringBuilderDemo/src/StringBuilderDemo.java @@ -0,0 +1,13 @@ +public class StringBuilderDemo +{ + + public static void main(String[] args) + { + StringBuilder sb = new StringBuilder("Hello "); + int intValue = 20; + sb.append(intValue); + double doubleValue = 500.4; + sb.append(doubleValue); + System.out.println(sb); + } +} diff --git a/BasicJava/StringBuilderDemo_append_sb_App/Output.txt b/BasicJava/StringBuilderDemo_append_sb_App/Output.txt new file mode 100644 index 000000000..1535c4308 --- /dev/null +++ b/BasicJava/StringBuilderDemo_append_sb_App/Output.txt @@ -0,0 +1 @@ +Hello Java diff --git a/BasicJava/StringBuilderDemo_append_sb_App/StringBuilderDemo/.classpath b/BasicJava/StringBuilderDemo_append_sb_App/StringBuilderDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBuilderDemo_append_sb_App/StringBuilderDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBuilderDemo_append_sb_App/StringBuilderDemo/.project b/BasicJava/StringBuilderDemo_append_sb_App/StringBuilderDemo/.project new file mode 100644 index 000000000..e29d88a2a --- /dev/null +++ b/BasicJava/StringBuilderDemo_append_sb_App/StringBuilderDemo/.project @@ -0,0 +1,17 @@ + + + StringBuilderDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBuilderDemo_append_sb_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBuilderDemo_append_sb_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBuilderDemo_append_sb_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBuilderDemo_append_sb_App/StringBuilderDemo/bin/StringBuilderDemo.class b/BasicJava/StringBuilderDemo_append_sb_App/StringBuilderDemo/bin/StringBuilderDemo.class new file mode 100644 index 000000000..44ead49c4 Binary files /dev/null and b/BasicJava/StringBuilderDemo_append_sb_App/StringBuilderDemo/bin/StringBuilderDemo.class differ diff --git a/BasicJava/StringBuilderDemo_append_sb_App/StringBuilderDemo/src/StringBuilderDemo.java b/BasicJava/StringBuilderDemo_append_sb_App/StringBuilderDemo/src/StringBuilderDemo.java new file mode 100644 index 000000000..09b775c19 --- /dev/null +++ b/BasicJava/StringBuilderDemo_append_sb_App/StringBuilderDemo/src/StringBuilderDemo.java @@ -0,0 +1,26 @@ +/* + * public StringBuilder append(StringBuffer sb) + * + * Appends the specified StringBuffer to this sequence. + * + * Parameters: + * ---------- + * sb - the StringBuffer to append. + * + * Returns: + * ------- + * a reference to this object. + */ + + +public class StringBuilderDemo +{ + + public static void main(String[] args) + { + StringBuilder stringbuilder = new StringBuilder("Hello "); + StringBuffer stringBuffer = new StringBuffer("Java"); + stringbuilder.append(stringBuffer); + System.out.println(stringbuilder); + } +} diff --git a/BasicJava/StringBuilderDemo_append_str_App/Output.txt b/BasicJava/StringBuilderDemo_append_str_App/Output.txt new file mode 100644 index 000000000..f822666c2 --- /dev/null +++ b/BasicJava/StringBuilderDemo_append_str_App/Output.txt @@ -0,0 +1,2 @@ +Hello +Hello Java diff --git a/BasicJava/StringBuilderDemo_append_str_App/StringBuilderDemo/.classpath b/BasicJava/StringBuilderDemo_append_str_App/StringBuilderDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBuilderDemo_append_str_App/StringBuilderDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBuilderDemo_append_str_App/StringBuilderDemo/.project b/BasicJava/StringBuilderDemo_append_str_App/StringBuilderDemo/.project new file mode 100644 index 000000000..e29d88a2a --- /dev/null +++ b/BasicJava/StringBuilderDemo_append_str_App/StringBuilderDemo/.project @@ -0,0 +1,17 @@ + + + StringBuilderDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBuilderDemo_append_str_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBuilderDemo_append_str_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBuilderDemo_append_str_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBuilderDemo_append_str_App/StringBuilderDemo/bin/StringBuilderDemo.class b/BasicJava/StringBuilderDemo_append_str_App/StringBuilderDemo/bin/StringBuilderDemo.class new file mode 100644 index 000000000..9b6a84dc9 Binary files /dev/null and b/BasicJava/StringBuilderDemo_append_str_App/StringBuilderDemo/bin/StringBuilderDemo.class differ diff --git a/BasicJava/StringBuilderDemo_append_str_App/StringBuilderDemo/src/StringBuilderDemo.java b/BasicJava/StringBuilderDemo_append_str_App/StringBuilderDemo/src/StringBuilderDemo.java new file mode 100644 index 000000000..91ce5789f --- /dev/null +++ b/BasicJava/StringBuilderDemo_append_str_App/StringBuilderDemo/src/StringBuilderDemo.java @@ -0,0 +1,23 @@ +/* + * public StringBuilder append(String str) + * + * Parameters: + * ---------- + * str - a string. + * + * Returns: + * ------- + * a reference to this object. + */ + +public class StringBuilderDemo +{ + + public static void main(String[] args) + { + StringBuilder sb = new StringBuilder("Hello "); + System.out.println(sb); + sb.append("Java"); + System.out.println(sb); + } +} diff --git a/BasicJava/StringBuilderDemo_capacity_App/Output.txt b/BasicJava/StringBuilderDemo_capacity_App/Output.txt new file mode 100644 index 000000000..b89f8786a --- /dev/null +++ b/BasicJava/StringBuilderDemo_capacity_App/Output.txt @@ -0,0 +1,3 @@ +16 +16 +34 diff --git a/BasicJava/StringBuilderDemo_capacity_App/StringBuilderDemo/.classpath b/BasicJava/StringBuilderDemo_capacity_App/StringBuilderDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBuilderDemo_capacity_App/StringBuilderDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBuilderDemo_capacity_App/StringBuilderDemo/.project b/BasicJava/StringBuilderDemo_capacity_App/StringBuilderDemo/.project new file mode 100644 index 000000000..e29d88a2a --- /dev/null +++ b/BasicJava/StringBuilderDemo_capacity_App/StringBuilderDemo/.project @@ -0,0 +1,17 @@ + + + StringBuilderDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBuilderDemo_capacity_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBuilderDemo_capacity_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBuilderDemo_capacity_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBuilderDemo_capacity_App/StringBuilderDemo/bin/StringBuilderDemo.class b/BasicJava/StringBuilderDemo_capacity_App/StringBuilderDemo/bin/StringBuilderDemo.class new file mode 100644 index 000000000..2cf9e7604 Binary files /dev/null and b/BasicJava/StringBuilderDemo_capacity_App/StringBuilderDemo/bin/StringBuilderDemo.class differ diff --git a/BasicJava/StringBuilderDemo_capacity_App/StringBuilderDemo/src/StringBuilderDemo.java b/BasicJava/StringBuilderDemo_capacity_App/StringBuilderDemo/src/StringBuilderDemo.java new file mode 100644 index 000000000..e6fd2a396 --- /dev/null +++ b/BasicJava/StringBuilderDemo_capacity_App/StringBuilderDemo/src/StringBuilderDemo.java @@ -0,0 +1,25 @@ +/* + * public int capacity() + * + * Returns: + * -------- + * the current capacity + */ + +public class StringBuilderDemo +{ + + public static void main(String[] args) + { + StringBuilder sb = new StringBuilder(); + // default 16 + System.out.println(sb.capacity()); + sb.append("Hello"); + // now 16 + System.out.println(sb.capacity()); + sb.append("Hello peter welcome to India"); + + // now (16*2)+2=34 i.e (oldcapacity*2)+2 + System.out.println(sb.capacity()); + } +} diff --git a/BasicJava/StringBuilderDemo_charAt_App/Output.txt b/BasicJava/StringBuilderDemo_charAt_App/Output.txt new file mode 100644 index 000000000..50cea3b04 --- /dev/null +++ b/BasicJava/StringBuilderDemo_charAt_App/Output.txt @@ -0,0 +1,2 @@ +charAt(3) = c +charAt(5) = m diff --git a/BasicJava/StringBuilderDemo_charAt_App/StringBuilderDemo/.classpath b/BasicJava/StringBuilderDemo_charAt_App/StringBuilderDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBuilderDemo_charAt_App/StringBuilderDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBuilderDemo_charAt_App/StringBuilderDemo/.project b/BasicJava/StringBuilderDemo_charAt_App/StringBuilderDemo/.project new file mode 100644 index 000000000..e29d88a2a --- /dev/null +++ b/BasicJava/StringBuilderDemo_charAt_App/StringBuilderDemo/.project @@ -0,0 +1,17 @@ + + + StringBuilderDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBuilderDemo_charAt_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBuilderDemo_charAt_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBuilderDemo_charAt_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBuilderDemo_charAt_App/StringBuilderDemo/bin/CharAtDemo.class b/BasicJava/StringBuilderDemo_charAt_App/StringBuilderDemo/bin/CharAtDemo.class new file mode 100644 index 000000000..9e2cf3ebe Binary files /dev/null and b/BasicJava/StringBuilderDemo_charAt_App/StringBuilderDemo/bin/CharAtDemo.class differ diff --git a/BasicJava/StringBuilderDemo_charAt_App/StringBuilderDemo/src/CharAtDemo.java b/BasicJava/StringBuilderDemo_charAt_App/StringBuilderDemo/src/CharAtDemo.java new file mode 100644 index 000000000..1fee14dbe --- /dev/null +++ b/BasicJava/StringBuilderDemo_charAt_App/StringBuilderDemo/src/CharAtDemo.java @@ -0,0 +1,32 @@ +/* + * public char charAt(int index) + * + * Parameters: + * ---------- + * index - the index of the desired char value. + * + * Returns: + * -------- + * the char value at the specified index. + * + * Throws: + * ------ + * IndexOutOfBoundsException - if index is negative + * or greater than or equal to length(). + */ + +public class CharAtDemo +{ + + public static void main(String[] args) + { + + StringBuilder sb = new StringBuilder("Welcome"); + + char ch = sb.charAt(3); + System.out.println("charAt(3) = " + ch); + + ch = sb.charAt(5); + System.out.println("charAt(5) = " + ch); + } +} diff --git a/BasicJava/StringBuilderDemo_codePointAt_App/Output.txt b/BasicJava/StringBuilderDemo_codePointAt_App/Output.txt new file mode 100644 index 000000000..c92fac0e6 --- /dev/null +++ b/BasicJava/StringBuilderDemo_codePointAt_App/Output.txt @@ -0,0 +1,2 @@ +sb = JAVA +Character(unicode point) = 65 diff --git a/BasicJava/StringBuilderDemo_codePointAt_App/StringBuilderDemo/.classpath b/BasicJava/StringBuilderDemo_codePointAt_App/StringBuilderDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBuilderDemo_codePointAt_App/StringBuilderDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBuilderDemo_codePointAt_App/StringBuilderDemo/.project b/BasicJava/StringBuilderDemo_codePointAt_App/StringBuilderDemo/.project new file mode 100644 index 000000000..e29d88a2a --- /dev/null +++ b/BasicJava/StringBuilderDemo_codePointAt_App/StringBuilderDemo/.project @@ -0,0 +1,17 @@ + + + StringBuilderDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBuilderDemo_codePointAt_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBuilderDemo_codePointAt_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBuilderDemo_codePointAt_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBuilderDemo_codePointAt_App/StringBuilderDemo/bin/StringBuilderDemo.class b/BasicJava/StringBuilderDemo_codePointAt_App/StringBuilderDemo/bin/StringBuilderDemo.class new file mode 100644 index 000000000..e68e83bf6 Binary files /dev/null and b/BasicJava/StringBuilderDemo_codePointAt_App/StringBuilderDemo/bin/StringBuilderDemo.class differ diff --git a/BasicJava/StringBuilderDemo_codePointAt_App/StringBuilderDemo/src/StringBuilderDemo.java b/BasicJava/StringBuilderDemo_codePointAt_App/StringBuilderDemo/src/StringBuilderDemo.java new file mode 100644 index 000000000..e73479564 --- /dev/null +++ b/BasicJava/StringBuilderDemo_codePointAt_App/StringBuilderDemo/src/StringBuilderDemo.java @@ -0,0 +1,26 @@ +/* + * public int codePointAt(int index) + * + * Parameters: + * ---------- + * index - the index to the char values + * + * Returns: + * ------- + * the code point value of the character at the index. + */ + +public class StringBuilderDemo +{ + + public static void main(String[] args) + { + String str = "JAVA"; + StringBuilder sb = new StringBuilder(str); + System.out.println("sb = " + sb); + + int retval = sb.codePointAt(1);// returns 65 + System.out.println("Character(unicode point) = " + retval); + + } +} diff --git a/BasicJava/StringBuilderDemo_codePointBefore_App/Output.txt b/BasicJava/StringBuilderDemo_codePointBefore_App/Output.txt new file mode 100644 index 000000000..d724804bd --- /dev/null +++ b/BasicJava/StringBuilderDemo_codePointBefore_App/Output.txt @@ -0,0 +1,2 @@ +sb = JAVA +Character(unicode point) = 74 diff --git a/BasicJava/StringBuilderDemo_codePointBefore_App/StringBuilderDemo/.classpath b/BasicJava/StringBuilderDemo_codePointBefore_App/StringBuilderDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBuilderDemo_codePointBefore_App/StringBuilderDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBuilderDemo_codePointBefore_App/StringBuilderDemo/.project b/BasicJava/StringBuilderDemo_codePointBefore_App/StringBuilderDemo/.project new file mode 100644 index 000000000..e29d88a2a --- /dev/null +++ b/BasicJava/StringBuilderDemo_codePointBefore_App/StringBuilderDemo/.project @@ -0,0 +1,17 @@ + + + StringBuilderDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBuilderDemo_codePointBefore_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBuilderDemo_codePointBefore_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBuilderDemo_codePointBefore_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBuilderDemo_codePointBefore_App/StringBuilderDemo/bin/StringBuilderDemo.class b/BasicJava/StringBuilderDemo_codePointBefore_App/StringBuilderDemo/bin/StringBuilderDemo.class new file mode 100644 index 000000000..2ce7f83ad Binary files /dev/null and b/BasicJava/StringBuilderDemo_codePointBefore_App/StringBuilderDemo/bin/StringBuilderDemo.class differ diff --git a/BasicJava/StringBuilderDemo_codePointBefore_App/StringBuilderDemo/src/StringBuilderDemo.java b/BasicJava/StringBuilderDemo_codePointBefore_App/StringBuilderDemo/src/StringBuilderDemo.java new file mode 100644 index 000000000..0363e6eda --- /dev/null +++ b/BasicJava/StringBuilderDemo_codePointBefore_App/StringBuilderDemo/src/StringBuilderDemo.java @@ -0,0 +1,30 @@ +/* + * public int codePointBefore(int index) + * + * Parameters: + * ---------- + * index - the index following the code point that + * should be returned + * + * Returns: + * ------- + * the Unicode code point value before the given index. + */ + +public class StringBuilderDemo +{ + + public static void main(String[] args) + { + String str = "JAVA"; + StringBuilder sb = new StringBuilder(str); + System.out.println("sb = " + sb); + + // codepoint before index 1 i.e J + int retval = sb.codePointBefore(1); + + // prints character before index1 in string + System.out.println("Character(unicode point) = " + retval); + + } +} diff --git a/BasicJava/StringBuilderDemo_codePointCount_App/Output.txt b/BasicJava/StringBuilderDemo_codePointCount_App/Output.txt new file mode 100644 index 000000000..4273dedbb --- /dev/null +++ b/BasicJava/StringBuilderDemo_codePointCount_App/Output.txt @@ -0,0 +1,2 @@ +sb = JAVA programming language +Codepoint count = 7 diff --git a/BasicJava/StringBuilderDemo_codePointCount_App/StringBuilderDemo/.classpath b/BasicJava/StringBuilderDemo_codePointCount_App/StringBuilderDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBuilderDemo_codePointCount_App/StringBuilderDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBuilderDemo_codePointCount_App/StringBuilderDemo/.project b/BasicJava/StringBuilderDemo_codePointCount_App/StringBuilderDemo/.project new file mode 100644 index 000000000..e29d88a2a --- /dev/null +++ b/BasicJava/StringBuilderDemo_codePointCount_App/StringBuilderDemo/.project @@ -0,0 +1,17 @@ + + + StringBuilderDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBuilderDemo_codePointCount_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBuilderDemo_codePointCount_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBuilderDemo_codePointCount_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBuilderDemo_codePointCount_App/StringBuilderDemo/bin/StringBuilderDemo.class b/BasicJava/StringBuilderDemo_codePointCount_App/StringBuilderDemo/bin/StringBuilderDemo.class new file mode 100644 index 000000000..cc76b7990 Binary files /dev/null and b/BasicJava/StringBuilderDemo_codePointCount_App/StringBuilderDemo/bin/StringBuilderDemo.class differ diff --git a/BasicJava/StringBuilderDemo_codePointCount_App/StringBuilderDemo/src/StringBuilderDemo.java b/BasicJava/StringBuilderDemo_codePointCount_App/StringBuilderDemo/src/StringBuilderDemo.java new file mode 100644 index 000000000..257a78c64 --- /dev/null +++ b/BasicJava/StringBuilderDemo_codePointCount_App/StringBuilderDemo/src/StringBuilderDemo.java @@ -0,0 +1,32 @@ +/* + * public int codePointCount(int beginIndex, int + * endIndex) + * + * Parameters: + * ---------- + * beginIndex - the index to the first char of the text + * range. + * + * endIndex - the index after the last char of + * the text range. + * + * Returns: + * ------- + * the number of Unicode code points in the specified + * text range + */ +public class StringBuilderDemo +{ + + public static void main(String[] args) + { + String str = "JAVA programming language"; + StringBuilder sb = new StringBuilder(str); + System.out.println("sb = " + sb); + + int retval = sb.codePointCount(1, 8); + + System.out.println("Codepoint count = " + retval); + + } +} diff --git a/BasicJava/StringBuilderDemo_deleteCharAt_App/Output.txt b/BasicJava/StringBuilderDemo_deleteCharAt_App/Output.txt new file mode 100644 index 000000000..2e00e1246 --- /dev/null +++ b/BasicJava/StringBuilderDemo_deleteCharAt_App/Output.txt @@ -0,0 +1,2 @@ +Welcome +Wecome diff --git a/BasicJava/StringBuilderDemo_deleteCharAt_App/StringBuilderDemo/.classpath b/BasicJava/StringBuilderDemo_deleteCharAt_App/StringBuilderDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBuilderDemo_deleteCharAt_App/StringBuilderDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBuilderDemo_deleteCharAt_App/StringBuilderDemo/.project b/BasicJava/StringBuilderDemo_deleteCharAt_App/StringBuilderDemo/.project new file mode 100644 index 000000000..e29d88a2a --- /dev/null +++ b/BasicJava/StringBuilderDemo_deleteCharAt_App/StringBuilderDemo/.project @@ -0,0 +1,17 @@ + + + StringBuilderDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBuilderDemo_deleteCharAt_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBuilderDemo_deleteCharAt_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBuilderDemo_deleteCharAt_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBuilderDemo_deleteCharAt_App/StringBuilderDemo/bin/StringBuilderDemo.class b/BasicJava/StringBuilderDemo_deleteCharAt_App/StringBuilderDemo/bin/StringBuilderDemo.class new file mode 100644 index 000000000..ab4102c29 Binary files /dev/null and b/BasicJava/StringBuilderDemo_deleteCharAt_App/StringBuilderDemo/bin/StringBuilderDemo.class differ diff --git a/BasicJava/StringBuilderDemo_deleteCharAt_App/StringBuilderDemo/src/StringBuilderDemo.java b/BasicJava/StringBuilderDemo_deleteCharAt_App/StringBuilderDemo/src/StringBuilderDemo.java new file mode 100644 index 000000000..0987b24f0 --- /dev/null +++ b/BasicJava/StringBuilderDemo_deleteCharAt_App/StringBuilderDemo/src/StringBuilderDemo.java @@ -0,0 +1,29 @@ +/* + * public StringBuilder deleteCharAt(int index) + * + * Parameters: + * ----------- + * index - Index of char to remove + * + * Returns: + * -------- + * This object. + * + * Throws: + * ------- + * StringIndexOutOfBoundsException - if the index is negative + * or greater than or equal to length(). + * + */ + +public class StringBuilderDemo +{ + + public static void main(String[] args) + { + StringBuilder sb = new StringBuilder("Welcome"); + System.out.println(sb); + sb = sb.deleteCharAt(2); + System.out.println(sb); + } +} diff --git a/BasicJava/StringBuilderDemo_delete_str_App/Output.txt b/BasicJava/StringBuilderDemo_delete_str_App/Output.txt new file mode 100644 index 000000000..d05515d5c --- /dev/null +++ b/BasicJava/StringBuilderDemo_delete_str_App/Output.txt @@ -0,0 +1,2 @@ +Welcome +Wele diff --git a/BasicJava/StringBuilderDemo_delete_str_App/StringBuilderDemo/.classpath b/BasicJava/StringBuilderDemo_delete_str_App/StringBuilderDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBuilderDemo_delete_str_App/StringBuilderDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBuilderDemo_delete_str_App/StringBuilderDemo/.project b/BasicJava/StringBuilderDemo_delete_str_App/StringBuilderDemo/.project new file mode 100644 index 000000000..e29d88a2a --- /dev/null +++ b/BasicJava/StringBuilderDemo_delete_str_App/StringBuilderDemo/.project @@ -0,0 +1,17 @@ + + + StringBuilderDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBuilderDemo_delete_str_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBuilderDemo_delete_str_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBuilderDemo_delete_str_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBuilderDemo_delete_str_App/StringBuilderDemo/bin/StringBuilderDemo.class b/BasicJava/StringBuilderDemo_delete_str_App/StringBuilderDemo/bin/StringBuilderDemo.class new file mode 100644 index 000000000..f1222aecc Binary files /dev/null and b/BasicJava/StringBuilderDemo_delete_str_App/StringBuilderDemo/bin/StringBuilderDemo.class differ diff --git a/BasicJava/StringBuilderDemo_delete_str_App/StringBuilderDemo/src/StringBuilderDemo.java b/BasicJava/StringBuilderDemo_delete_str_App/StringBuilderDemo/src/StringBuilderDemo.java new file mode 100644 index 000000000..f0f1dfd9e --- /dev/null +++ b/BasicJava/StringBuilderDemo_delete_str_App/StringBuilderDemo/src/StringBuilderDemo.java @@ -0,0 +1,24 @@ +/* + * public StringBuilder delete(int start, int end) + * + * Parameters: + * ----------- + * start - The beginning index, inclusive. + * + * end - The ending index, exclusive. + * + * Returns: + * -------- + * This object. + */ +public class StringBuilderDemo +{ + + public static void main(String[] args) + { + StringBuilder sb = new StringBuilder("Welcome"); + System.out.println(sb); + sb = sb.delete(3, 6); + System.out.println(sb); + } +} \ No newline at end of file diff --git a/BasicJava/StringBuilderDemo_ensureCapacity_App/Output.txt b/BasicJava/StringBuilderDemo_ensureCapacity_App/Output.txt new file mode 100644 index 000000000..72fee754d --- /dev/null +++ b/BasicJava/StringBuilderDemo_ensureCapacity_App/Output.txt @@ -0,0 +1,2 @@ +Old capacity = 16 +New Capacity = 40 diff --git a/BasicJava/StringBuilderDemo_ensureCapacity_App/StringBuilderDemo/.classpath b/BasicJava/StringBuilderDemo_ensureCapacity_App/StringBuilderDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBuilderDemo_ensureCapacity_App/StringBuilderDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBuilderDemo_ensureCapacity_App/StringBuilderDemo/.project b/BasicJava/StringBuilderDemo_ensureCapacity_App/StringBuilderDemo/.project new file mode 100644 index 000000000..e29d88a2a --- /dev/null +++ b/BasicJava/StringBuilderDemo_ensureCapacity_App/StringBuilderDemo/.project @@ -0,0 +1,17 @@ + + + StringBuilderDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBuilderDemo_ensureCapacity_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBuilderDemo_ensureCapacity_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBuilderDemo_ensureCapacity_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBuilderDemo_ensureCapacity_App/StringBuilderDemo/bin/StringBuilderDemo.class b/BasicJava/StringBuilderDemo_ensureCapacity_App/StringBuilderDemo/bin/StringBuilderDemo.class new file mode 100644 index 000000000..45e09506f Binary files /dev/null and b/BasicJava/StringBuilderDemo_ensureCapacity_App/StringBuilderDemo/bin/StringBuilderDemo.class differ diff --git a/BasicJava/StringBuilderDemo_ensureCapacity_App/StringBuilderDemo/src/StringBuilderDemo.java b/BasicJava/StringBuilderDemo_ensureCapacity_App/StringBuilderDemo/src/StringBuilderDemo.java new file mode 100644 index 000000000..629e31032 --- /dev/null +++ b/BasicJava/StringBuilderDemo_ensureCapacity_App/StringBuilderDemo/src/StringBuilderDemo.java @@ -0,0 +1,21 @@ +/* + * public void ensureCapacity(int minimumCapacity) + * + * Parameters: + * ---------- + * minimumCapacity - the minimum desired capacity + */ +public class StringBuilderDemo +{ + + public static void main(String[] args) + { + StringBuilder sb = new StringBuilder(); + // default 16 + System.out.println("Old capacity = "+sb.capacity()); + + sb.ensureCapacity(40); + + System.out.println("New Capacity = "+sb.capacity()); + } +} diff --git a/BasicJava/StringBuilderDemo_getChars_App/Output.txt b/BasicJava/StringBuilderDemo_getChars_App/Output.txt new file mode 100644 index 000000000..fadd78432 --- /dev/null +++ b/BasicJava/StringBuilderDemo_getChars_App/Output.txt @@ -0,0 +1,2 @@ +Welcome to india peter +india \ No newline at end of file diff --git a/BasicJava/StringBuilderDemo_getChars_App/StringBuilderDemo/.classpath b/BasicJava/StringBuilderDemo_getChars_App/StringBuilderDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBuilderDemo_getChars_App/StringBuilderDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBuilderDemo_getChars_App/StringBuilderDemo/.project b/BasicJava/StringBuilderDemo_getChars_App/StringBuilderDemo/.project new file mode 100644 index 000000000..e29d88a2a --- /dev/null +++ b/BasicJava/StringBuilderDemo_getChars_App/StringBuilderDemo/.project @@ -0,0 +1,17 @@ + + + StringBuilderDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBuilderDemo_getChars_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBuilderDemo_getChars_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBuilderDemo_getChars_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBuilderDemo_getChars_App/StringBuilderDemo/bin/StringBuilderDemo.class b/BasicJava/StringBuilderDemo_getChars_App/StringBuilderDemo/bin/StringBuilderDemo.class new file mode 100644 index 000000000..2498a014f Binary files /dev/null and b/BasicJava/StringBuilderDemo_getChars_App/StringBuilderDemo/bin/StringBuilderDemo.class differ diff --git a/BasicJava/StringBuilderDemo_getChars_App/StringBuilderDemo/src/StringBuilderDemo.java b/BasicJava/StringBuilderDemo_getChars_App/StringBuilderDemo/src/StringBuilderDemo.java new file mode 100644 index 000000000..7be6b7f69 --- /dev/null +++ b/BasicJava/StringBuilderDemo_getChars_App/StringBuilderDemo/src/StringBuilderDemo.java @@ -0,0 +1,47 @@ +/* + * public void getChars(int srcBegin, int srcEnd, char[] + * dst, int dstBegin) + * + * Parameters: + * ---------- + * srcBegin - start copying at this offset. + * + * srcEnd - stop copying at this offset. + * + * dst - the array to copy the data into. + * + * dstBegin - offset into dst. + * + * Throws: + * ------- + * IndexOutOfBoundsException - if any of the following + * is true: + * + * srcBegin is negative. + * dstBegin is negative. + * the srcBegin argument is greater than the srcEnd + * argument. + * srcEnd is greater than this.length(). + * dstBegin+srcEnd-srcBegin is greater than dst.length. + */ +public class StringBuilderDemo +{ + + public static void main(String[] args) + { + + String str = "Welcome to india peter"; + StringBuilder sb = new StringBuilder(str); + System.out.println(sb); + + char[] charArray = new char[30]; + + /* + * copies characters from starting and ending index + * into the destination character array + */ + sb.getChars(11, 16, charArray, 0); + + System.out.println(charArray); + } +} diff --git a/BasicJava/StringBuilderDemo_indexOf_fromIndex_App/Output.txt b/BasicJava/StringBuilderDemo_indexOf_fromIndex_App/Output.txt new file mode 100644 index 000000000..285f36757 --- /dev/null +++ b/BasicJava/StringBuilderDemo_indexOf_fromIndex_App/Output.txt @@ -0,0 +1,2 @@ +sb = com.com.com +indexOf("com",2) = 4 diff --git a/BasicJava/StringBuilderDemo_indexOf_fromIndex_App/StringBuilderDemo/.classpath b/BasicJava/StringBuilderDemo_indexOf_fromIndex_App/StringBuilderDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBuilderDemo_indexOf_fromIndex_App/StringBuilderDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBuilderDemo_indexOf_fromIndex_App/StringBuilderDemo/.project b/BasicJava/StringBuilderDemo_indexOf_fromIndex_App/StringBuilderDemo/.project new file mode 100644 index 000000000..e29d88a2a --- /dev/null +++ b/BasicJava/StringBuilderDemo_indexOf_fromIndex_App/StringBuilderDemo/.project @@ -0,0 +1,17 @@ + + + StringBuilderDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBuilderDemo_indexOf_fromIndex_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBuilderDemo_indexOf_fromIndex_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBuilderDemo_indexOf_fromIndex_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBuilderDemo_indexOf_fromIndex_App/StringBuilderDemo/bin/StringBuilderDemo.class b/BasicJava/StringBuilderDemo_indexOf_fromIndex_App/StringBuilderDemo/bin/StringBuilderDemo.class new file mode 100644 index 000000000..42dda2fd6 Binary files /dev/null and b/BasicJava/StringBuilderDemo_indexOf_fromIndex_App/StringBuilderDemo/bin/StringBuilderDemo.class differ diff --git a/BasicJava/StringBuilderDemo_indexOf_fromIndex_App/StringBuilderDemo/src/StringBuilderDemo.java b/BasicJava/StringBuilderDemo_indexOf_fromIndex_App/StringBuilderDemo/src/StringBuilderDemo.java new file mode 100644 index 000000000..a31298e78 --- /dev/null +++ b/BasicJava/StringBuilderDemo_indexOf_fromIndex_App/StringBuilderDemo/src/StringBuilderDemo.java @@ -0,0 +1,29 @@ +/* + * public int indexOf(String str, int fromIndex) + * + * Parameters: + * ---------- + * str - the substring for which to search. + * + * fromIndex - the index from which to start + * the search. + * + * Returns: + * ------- + * the index within this string of the + * first occurrence of the specified substring, starting + * at the specified index. + */ +public class StringBuilderDemo +{ + + public static void main(String[] args) + { + String str = "com.com.com"; + StringBuilder sb = new StringBuilder(str); + System.out.println("sb = "+sb); + // Returns 4 + int indexPosition = sb.indexOf("com", 2); + System.out.println("indexOf(\"com\",2) = " + indexPosition); + } +} diff --git a/BasicJava/StringBuilderDemo_indexOf_str_App/Output.txt b/BasicJava/StringBuilderDemo_indexOf_str_App/Output.txt new file mode 100644 index 000000000..9779a926e --- /dev/null +++ b/BasicJava/StringBuilderDemo_indexOf_str_App/Output.txt @@ -0,0 +1,2 @@ +indexOf("com") = 3 +indexOf("abc") = -1 diff --git a/BasicJava/StringBuilderDemo_indexOf_str_App/StringBuilderDemo/.classpath b/BasicJava/StringBuilderDemo_indexOf_str_App/StringBuilderDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBuilderDemo_indexOf_str_App/StringBuilderDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBuilderDemo_indexOf_str_App/StringBuilderDemo/.project b/BasicJava/StringBuilderDemo_indexOf_str_App/StringBuilderDemo/.project new file mode 100644 index 000000000..e29d88a2a --- /dev/null +++ b/BasicJava/StringBuilderDemo_indexOf_str_App/StringBuilderDemo/.project @@ -0,0 +1,17 @@ + + + StringBuilderDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBuilderDemo_indexOf_str_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBuilderDemo_indexOf_str_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBuilderDemo_indexOf_str_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBuilderDemo_indexOf_str_App/StringBuilderDemo/bin/StringBuilderDemo.class b/BasicJava/StringBuilderDemo_indexOf_str_App/StringBuilderDemo/bin/StringBuilderDemo.class new file mode 100644 index 000000000..56807bde3 Binary files /dev/null and b/BasicJava/StringBuilderDemo_indexOf_str_App/StringBuilderDemo/bin/StringBuilderDemo.class differ diff --git a/BasicJava/StringBuilderDemo_indexOf_str_App/StringBuilderDemo/src/StringBuilderDemo.java b/BasicJava/StringBuilderDemo_indexOf_str_App/StringBuilderDemo/src/StringBuilderDemo.java new file mode 100644 index 000000000..f8aff756b --- /dev/null +++ b/BasicJava/StringBuilderDemo_indexOf_str_App/StringBuilderDemo/src/StringBuilderDemo.java @@ -0,0 +1,32 @@ +/* + * public int indexOf(String str) + * + * Parameters: + * ---------- + * str - any string. + * + * Returns: + * ------- + * if the string argument occurs as a + * substring within this object, then the index of the + * first character of the first such substring is + * returned; if it does not occur as a substring, -1 is + * returned. + */ +public class StringBuilderDemo +{ + + public static void main(String[] args) + { + + String str = "Welcome.com"; + StringBuilder sb = new StringBuilder(str); + + int indexPosition = sb.indexOf("com"); // returns 3 + System.out.println("indexOf(\"com\") = " + indexPosition); + + indexPosition = sb.indexOf("abc");// returns -1 + System.out.println("indexOf(\"abc\") = " + indexPosition); + + } +} diff --git a/BasicJava/StringBuilderDemo_insert_App/Output.txt b/BasicJava/StringBuilderDemo_insert_App/Output.txt new file mode 100644 index 000000000..b5fb6a3da --- /dev/null +++ b/BasicJava/StringBuilderDemo_insert_App/Output.txt @@ -0,0 +1,2 @@ +Hello World +Hello My World diff --git a/BasicJava/StringBuilderDemo_insert_App/StringBuilderDemo/.classpath b/BasicJava/StringBuilderDemo_insert_App/StringBuilderDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBuilderDemo_insert_App/StringBuilderDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBuilderDemo_insert_App/StringBuilderDemo/.project b/BasicJava/StringBuilderDemo_insert_App/StringBuilderDemo/.project new file mode 100644 index 000000000..e29d88a2a --- /dev/null +++ b/BasicJava/StringBuilderDemo_insert_App/StringBuilderDemo/.project @@ -0,0 +1,17 @@ + + + StringBuilderDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBuilderDemo_insert_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBuilderDemo_insert_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBuilderDemo_insert_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBuilderDemo_insert_App/StringBuilderDemo/bin/StringBuilderDemo.class b/BasicJava/StringBuilderDemo_insert_App/StringBuilderDemo/bin/StringBuilderDemo.class new file mode 100644 index 000000000..cd7f37257 Binary files /dev/null and b/BasicJava/StringBuilderDemo_insert_App/StringBuilderDemo/bin/StringBuilderDemo.class differ diff --git a/BasicJava/StringBuilderDemo_insert_App/StringBuilderDemo/src/StringBuilderDemo.java b/BasicJava/StringBuilderDemo_insert_App/StringBuilderDemo/src/StringBuilderDemo.java new file mode 100644 index 000000000..a7a1474f4 --- /dev/null +++ b/BasicJava/StringBuilderDemo_insert_App/StringBuilderDemo/src/StringBuilderDemo.java @@ -0,0 +1,25 @@ +/* + * public StringBuilder insert(int offset, String str) + * + * Parameters: + * ---------- + * offset - the offset. + * + * str - a string. + * + * Returns: + * ------- + * a reference to this object. + */ +public class StringBuilderDemo +{ + + public static void main(String[] args) + { + StringBuilder sb = new StringBuilder("Hello World"); + System.out.println(sb); + String str = "My "; + sb.insert(6, str); + System.out.println(sb); + } +} \ No newline at end of file diff --git a/BasicJava/StringBuilderDemo_insert_methods_App/Output.txt b/BasicJava/StringBuilderDemo_insert_methods_App/Output.txt new file mode 100644 index 000000000..4bde1a9df --- /dev/null +++ b/BasicJava/StringBuilderDemo_insert_methods_App/Output.txt @@ -0,0 +1,2 @@ +Hello World +Hello 100 World diff --git a/BasicJava/StringBuilderDemo_insert_methods_App/StringBuilderDemo/.classpath b/BasicJava/StringBuilderDemo_insert_methods_App/StringBuilderDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBuilderDemo_insert_methods_App/StringBuilderDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBuilderDemo_insert_methods_App/StringBuilderDemo/.project b/BasicJava/StringBuilderDemo_insert_methods_App/StringBuilderDemo/.project new file mode 100644 index 000000000..e29d88a2a --- /dev/null +++ b/BasicJava/StringBuilderDemo_insert_methods_App/StringBuilderDemo/.project @@ -0,0 +1,17 @@ + + + StringBuilderDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBuilderDemo_insert_methods_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBuilderDemo_insert_methods_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBuilderDemo_insert_methods_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBuilderDemo_insert_methods_App/StringBuilderDemo/bin/StringBuilderDemo.class b/BasicJava/StringBuilderDemo_insert_methods_App/StringBuilderDemo/bin/StringBuilderDemo.class new file mode 100644 index 000000000..af9b44e98 Binary files /dev/null and b/BasicJava/StringBuilderDemo_insert_methods_App/StringBuilderDemo/bin/StringBuilderDemo.class differ diff --git a/BasicJava/StringBuilderDemo_insert_methods_App/StringBuilderDemo/src/StringBuilderDemo.java b/BasicJava/StringBuilderDemo_insert_methods_App/StringBuilderDemo/src/StringBuilderDemo.java new file mode 100644 index 000000000..4dfe3f914 --- /dev/null +++ b/BasicJava/StringBuilderDemo_insert_methods_App/StringBuilderDemo/src/StringBuilderDemo.java @@ -0,0 +1,12 @@ +public class StringBuilderDemo +{ + + public static void main(String[] args) + { + StringBuilder sb = new StringBuilder("Hello World"); + System.out.println(sb); + int intValue = 100; + sb.insert(6, intValue); + System.out.println(sb); + } +} \ No newline at end of file diff --git a/BasicJava/StringBuilderDemo_lastIndexOf_fromIndex_App/Output.txt b/BasicJava/StringBuilderDemo_lastIndexOf_fromIndex_App/Output.txt new file mode 100644 index 000000000..339fda112 --- /dev/null +++ b/BasicJava/StringBuilderDemo_lastIndexOf_fromIndex_App/Output.txt @@ -0,0 +1,2 @@ +sb = com.com.com +lastIndexOf("com",7) = 4 diff --git a/BasicJava/StringBuilderDemo_lastIndexOf_fromIndex_App/StringBuilderDemo/.classpath b/BasicJava/StringBuilderDemo_lastIndexOf_fromIndex_App/StringBuilderDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBuilderDemo_lastIndexOf_fromIndex_App/StringBuilderDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBuilderDemo_lastIndexOf_fromIndex_App/StringBuilderDemo/.project b/BasicJava/StringBuilderDemo_lastIndexOf_fromIndex_App/StringBuilderDemo/.project new file mode 100644 index 000000000..e29d88a2a --- /dev/null +++ b/BasicJava/StringBuilderDemo_lastIndexOf_fromIndex_App/StringBuilderDemo/.project @@ -0,0 +1,17 @@ + + + StringBuilderDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBuilderDemo_lastIndexOf_fromIndex_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBuilderDemo_lastIndexOf_fromIndex_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBuilderDemo_lastIndexOf_fromIndex_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBuilderDemo_lastIndexOf_fromIndex_App/StringBuilderDemo/bin/StringBuilderDemo.class b/BasicJava/StringBuilderDemo_lastIndexOf_fromIndex_App/StringBuilderDemo/bin/StringBuilderDemo.class new file mode 100644 index 000000000..b225b9b74 Binary files /dev/null and b/BasicJava/StringBuilderDemo_lastIndexOf_fromIndex_App/StringBuilderDemo/bin/StringBuilderDemo.class differ diff --git a/BasicJava/StringBuilderDemo_lastIndexOf_fromIndex_App/StringBuilderDemo/src/StringBuilderDemo.java b/BasicJava/StringBuilderDemo_lastIndexOf_fromIndex_App/StringBuilderDemo/src/StringBuilderDemo.java new file mode 100644 index 000000000..a8678218b --- /dev/null +++ b/BasicJava/StringBuilderDemo_lastIndexOf_fromIndex_App/StringBuilderDemo/src/StringBuilderDemo.java @@ -0,0 +1,30 @@ +/* + * public int lastIndexOf(String str, int fromIndex) + * + * Parameters: + * ---------- + * str - the substring to search for. + * + * fromIndex - the index to start the search from. + * + * Returns: + * ------- + * the index within this sequence of + * the last occurrence of the specified substring. + */ +public class StringBuilderDemo +{ + + public static void main(String[] args) + { + String str = "com.com.com"; + StringBuilder sb = new StringBuilder(str); + System.out.println("sb = "+sb); + + //returns 4 + int indexPosition = sb.lastIndexOf("com", 7); + System.out.println("lastIndexOf(\"com\",7) = " + + indexPosition); + + } +} diff --git a/BasicJava/StringBuilderDemo_lastIndexOf_str_App/Output.txt b/BasicJava/StringBuilderDemo_lastIndexOf_str_App/Output.txt new file mode 100644 index 000000000..e48527c27 --- /dev/null +++ b/BasicJava/StringBuilderDemo_lastIndexOf_str_App/Output.txt @@ -0,0 +1,3 @@ +sb = Welcome.com +lastIndexOf("com") = 8 +lastIndexOf("abc") = -1 diff --git a/BasicJava/StringBuilderDemo_lastIndexOf_str_App/StringBuilderDemo/.classpath b/BasicJava/StringBuilderDemo_lastIndexOf_str_App/StringBuilderDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBuilderDemo_lastIndexOf_str_App/StringBuilderDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBuilderDemo_lastIndexOf_str_App/StringBuilderDemo/.project b/BasicJava/StringBuilderDemo_lastIndexOf_str_App/StringBuilderDemo/.project new file mode 100644 index 000000000..e29d88a2a --- /dev/null +++ b/BasicJava/StringBuilderDemo_lastIndexOf_str_App/StringBuilderDemo/.project @@ -0,0 +1,17 @@ + + + StringBuilderDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBuilderDemo_lastIndexOf_str_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBuilderDemo_lastIndexOf_str_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBuilderDemo_lastIndexOf_str_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBuilderDemo_lastIndexOf_str_App/StringBuilderDemo/bin/StringBuilderDemo.class b/BasicJava/StringBuilderDemo_lastIndexOf_str_App/StringBuilderDemo/bin/StringBuilderDemo.class new file mode 100644 index 000000000..d00773780 Binary files /dev/null and b/BasicJava/StringBuilderDemo_lastIndexOf_str_App/StringBuilderDemo/bin/StringBuilderDemo.class differ diff --git a/BasicJava/StringBuilderDemo_lastIndexOf_str_App/StringBuilderDemo/src/StringBuilderDemo.java b/BasicJava/StringBuilderDemo_lastIndexOf_str_App/StringBuilderDemo/src/StringBuilderDemo.java new file mode 100644 index 000000000..395ac1dd8 --- /dev/null +++ b/BasicJava/StringBuilderDemo_lastIndexOf_str_App/StringBuilderDemo/src/StringBuilderDemo.java @@ -0,0 +1,32 @@ +/* + * public int lastIndexOf(String str) + * + * Parameters: + * ---------- + * str - the substring to search for. + * + * Returns: + * ------- + * if the string argument occurs one or + * more times as a substring within this object, then + * the index of the first character of the last such + * substring is returned. If it does not occur as a + * substring, -1 is returned. + */ +public class StringBuilderDemo +{ + + public static void main(String[] args) + { + String str = "Welcome.com"; + StringBuilder sb = new StringBuilder(str); + System.out.println("sb = "+sb); + + //Returns 8 + int indexPosition = sb.lastIndexOf("com"); + System.out.println("lastIndexOf(\"com\") = " + indexPosition); + + indexPosition = sb.lastIndexOf("abc"); + System.out.println("lastIndexOf(\"abc\") = " + indexPosition); + } +} diff --git a/BasicJava/StringBuilderDemo_length_App/Output.txt b/BasicJava/StringBuilderDemo_length_App/Output.txt new file mode 100644 index 000000000..d959f04e0 --- /dev/null +++ b/BasicJava/StringBuilderDemo_length_App/Output.txt @@ -0,0 +1,4 @@ +sb = +length = 0 +sb = Welcome +length = 7 diff --git a/BasicJava/StringBuilderDemo_length_App/StringBuilderDemo/.classpath b/BasicJava/StringBuilderDemo_length_App/StringBuilderDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBuilderDemo_length_App/StringBuilderDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBuilderDemo_length_App/StringBuilderDemo/.project b/BasicJava/StringBuilderDemo_length_App/StringBuilderDemo/.project new file mode 100644 index 000000000..e29d88a2a --- /dev/null +++ b/BasicJava/StringBuilderDemo_length_App/StringBuilderDemo/.project @@ -0,0 +1,17 @@ + + + StringBuilderDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBuilderDemo_length_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBuilderDemo_length_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBuilderDemo_length_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBuilderDemo_length_App/StringBuilderDemo/bin/StringBuilderDemo.class b/BasicJava/StringBuilderDemo_length_App/StringBuilderDemo/bin/StringBuilderDemo.class new file mode 100644 index 000000000..4efdd7af8 Binary files /dev/null and b/BasicJava/StringBuilderDemo_length_App/StringBuilderDemo/bin/StringBuilderDemo.class differ diff --git a/BasicJava/StringBuilderDemo_length_App/StringBuilderDemo/src/StringBuilderDemo.java b/BasicJava/StringBuilderDemo_length_App/StringBuilderDemo/src/StringBuilderDemo.java new file mode 100644 index 000000000..45fa16980 --- /dev/null +++ b/BasicJava/StringBuilderDemo_length_App/StringBuilderDemo/src/StringBuilderDemo.java @@ -0,0 +1,23 @@ +/* + * public int length() + * + * Parameters: + * ---------- + * the length of the sequence of characters currently + * represented by this object + */ +public class StringBuilderDemo +{ + + public static void main(String[] args) + { + StringBuilder sb = new StringBuilder(); + System.out.println("sb = " + sb); + System.out.println("length = " + sb.length()); + + sb.append("Welcome"); + System.out.println("sb = " + sb); + System.out.println("length = " + sb.length()); + + } +} diff --git a/BasicJava/StringBuilderDemo_replace_App/Output.txt b/BasicJava/StringBuilderDemo_replace_App/Output.txt new file mode 100644 index 000000000..0ff4efba2 --- /dev/null +++ b/BasicJava/StringBuilderDemo_replace_App/Output.txt @@ -0,0 +1,2 @@ +Hello Dave Welcome +Hello Peter Welcome diff --git a/BasicJava/StringBuilderDemo_replace_App/StringBuilderDemo/.classpath b/BasicJava/StringBuilderDemo_replace_App/StringBuilderDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBuilderDemo_replace_App/StringBuilderDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBuilderDemo_replace_App/StringBuilderDemo/.project b/BasicJava/StringBuilderDemo_replace_App/StringBuilderDemo/.project new file mode 100644 index 000000000..e29d88a2a --- /dev/null +++ b/BasicJava/StringBuilderDemo_replace_App/StringBuilderDemo/.project @@ -0,0 +1,17 @@ + + + StringBuilderDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBuilderDemo_replace_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBuilderDemo_replace_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBuilderDemo_replace_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBuilderDemo_replace_App/StringBuilderDemo/bin/StringBuilderDemo.class b/BasicJava/StringBuilderDemo_replace_App/StringBuilderDemo/bin/StringBuilderDemo.class new file mode 100644 index 000000000..28956cf90 Binary files /dev/null and b/BasicJava/StringBuilderDemo_replace_App/StringBuilderDemo/bin/StringBuilderDemo.class differ diff --git a/BasicJava/StringBuilderDemo_replace_App/StringBuilderDemo/src/StringBuilderDemo.java b/BasicJava/StringBuilderDemo_replace_App/StringBuilderDemo/src/StringBuilderDemo.java new file mode 100644 index 000000000..b926a67d9 --- /dev/null +++ b/BasicJava/StringBuilderDemo_replace_App/StringBuilderDemo/src/StringBuilderDemo.java @@ -0,0 +1,32 @@ +/* + * public StringBuilder replace(int start, int end, + * String str) + * + * Parameters: + * ----------- + * start - The beginning index, inclusive. + * + * end - The ending index, exclusive. + * + * str - String that will replace previous contents. + * + * Returns: + * -------- + * This object. + * + * Throws: + * ------- + * StringIndexOutOfBoundsException - if start is negative, + * greater than length(), or greater than end. + */ +public class StringBuilderDemo +{ + + public static void main(String[] args) + { + StringBuilder sb = new StringBuilder("Hello Dave Welcome"); + System.out.println(sb); + sb = sb.replace(6, 10, "Peter"); + System.out.println(sb); + } +} \ No newline at end of file diff --git a/BasicJava/StringBuilderDemo_reverse_App/Output.txt b/BasicJava/StringBuilderDemo_reverse_App/Output.txt new file mode 100644 index 000000000..0359b5f3b --- /dev/null +++ b/BasicJava/StringBuilderDemo_reverse_App/Output.txt @@ -0,0 +1,2 @@ +Hello +olleH diff --git a/BasicJava/StringBuilderDemo_reverse_App/StringBuilderDemo/.classpath b/BasicJava/StringBuilderDemo_reverse_App/StringBuilderDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBuilderDemo_reverse_App/StringBuilderDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBuilderDemo_reverse_App/StringBuilderDemo/.project b/BasicJava/StringBuilderDemo_reverse_App/StringBuilderDemo/.project new file mode 100644 index 000000000..e29d88a2a --- /dev/null +++ b/BasicJava/StringBuilderDemo_reverse_App/StringBuilderDemo/.project @@ -0,0 +1,17 @@ + + + StringBuilderDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBuilderDemo_reverse_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBuilderDemo_reverse_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBuilderDemo_reverse_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBuilderDemo_reverse_App/StringBuilderDemo/bin/StringBuilderDemo.class b/BasicJava/StringBuilderDemo_reverse_App/StringBuilderDemo/bin/StringBuilderDemo.class new file mode 100644 index 000000000..6755406c6 Binary files /dev/null and b/BasicJava/StringBuilderDemo_reverse_App/StringBuilderDemo/bin/StringBuilderDemo.class differ diff --git a/BasicJava/StringBuilderDemo_reverse_App/StringBuilderDemo/src/StringBuilderDemo.java b/BasicJava/StringBuilderDemo_reverse_App/StringBuilderDemo/src/StringBuilderDemo.java new file mode 100644 index 000000000..b403f11d6 --- /dev/null +++ b/BasicJava/StringBuilderDemo_reverse_App/StringBuilderDemo/src/StringBuilderDemo.java @@ -0,0 +1,18 @@ +/* + * public StringBuilder reverse() + * + * Returns: + * -------- + * a reference to this object. + */ +public class StringBuilderDemo +{ + + public static void main(String[] args) + { + StringBuilder sb = new StringBuilder("Hello"); + System.out.println(sb); + sb = sb.reverse(); + System.out.println(sb); + } +} \ No newline at end of file diff --git a/BasicJava/StringBuilderDemo_setCharAt_App/Output.txt b/BasicJava/StringBuilderDemo_setCharAt_App/Output.txt new file mode 100644 index 000000000..59bc930a6 --- /dev/null +++ b/BasicJava/StringBuilderDemo_setCharAt_App/Output.txt @@ -0,0 +1,2 @@ +Before setCharAt, sb = Dig +After setCharAt, sb = Dog diff --git a/BasicJava/StringBuilderDemo_setCharAt_App/StringBuilderDemo/.classpath b/BasicJava/StringBuilderDemo_setCharAt_App/StringBuilderDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBuilderDemo_setCharAt_App/StringBuilderDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBuilderDemo_setCharAt_App/StringBuilderDemo/.project b/BasicJava/StringBuilderDemo_setCharAt_App/StringBuilderDemo/.project new file mode 100644 index 000000000..e29d88a2a --- /dev/null +++ b/BasicJava/StringBuilderDemo_setCharAt_App/StringBuilderDemo/.project @@ -0,0 +1,17 @@ + + + StringBuilderDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBuilderDemo_setCharAt_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBuilderDemo_setCharAt_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBuilderDemo_setCharAt_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBuilderDemo_setCharAt_App/StringBuilderDemo/bin/StringBuilderDemo.class b/BasicJava/StringBuilderDemo_setCharAt_App/StringBuilderDemo/bin/StringBuilderDemo.class new file mode 100644 index 000000000..ec9f326f8 Binary files /dev/null and b/BasicJava/StringBuilderDemo_setCharAt_App/StringBuilderDemo/bin/StringBuilderDemo.class differ diff --git a/BasicJava/StringBuilderDemo_setCharAt_App/StringBuilderDemo/src/StringBuilderDemo.java b/BasicJava/StringBuilderDemo_setCharAt_App/StringBuilderDemo/src/StringBuilderDemo.java new file mode 100644 index 000000000..794fd96b1 --- /dev/null +++ b/BasicJava/StringBuilderDemo_setCharAt_App/StringBuilderDemo/src/StringBuilderDemo.java @@ -0,0 +1,28 @@ +/* + * public void setCharAt(int index, char ch) + * + * Parameters: + * ---------- + * index - the index of the character to modify. + * ch - the new character. + * + * Throws: + * ------ + * IndexOutOfBoundsException - if index is negative or + * greater than or equal to length(). + */ +public class StringBuilderDemo +{ + + public static void main(String[] args) + { + String str = "Dig"; + StringBuilder sb = new StringBuilder(str); + System.out.println("Before setCharAt, sb = " + sb); + + sb.setCharAt(1, 'o'); + + System.out.println("After setCharAt, sb = " + sb); + + } +} diff --git a/BasicJava/StringBuilderDemo_setLength_App/Output.txt b/BasicJava/StringBuilderDemo_setLength_App/Output.txt new file mode 100644 index 000000000..ffe6de101 --- /dev/null +++ b/BasicJava/StringBuilderDemo_setLength_App/Output.txt @@ -0,0 +1,4 @@ +Before setLength, sb = Welcome +Before setLength, sb = 7 +After setLength, sb = Wel +After setLength, sb = 3 diff --git a/BasicJava/StringBuilderDemo_setLength_App/StringBuilderDemo/.classpath b/BasicJava/StringBuilderDemo_setLength_App/StringBuilderDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBuilderDemo_setLength_App/StringBuilderDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBuilderDemo_setLength_App/StringBuilderDemo/.project b/BasicJava/StringBuilderDemo_setLength_App/StringBuilderDemo/.project new file mode 100644 index 000000000..e29d88a2a --- /dev/null +++ b/BasicJava/StringBuilderDemo_setLength_App/StringBuilderDemo/.project @@ -0,0 +1,17 @@ + + + StringBuilderDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBuilderDemo_setLength_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBuilderDemo_setLength_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBuilderDemo_setLength_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBuilderDemo_setLength_App/StringBuilderDemo/bin/StringBuilderDemo.class b/BasicJava/StringBuilderDemo_setLength_App/StringBuilderDemo/bin/StringBuilderDemo.class new file mode 100644 index 000000000..7c536c675 Binary files /dev/null and b/BasicJava/StringBuilderDemo_setLength_App/StringBuilderDemo/bin/StringBuilderDemo.class differ diff --git a/BasicJava/StringBuilderDemo_setLength_App/StringBuilderDemo/src/StringBuilderDemo.java b/BasicJava/StringBuilderDemo_setLength_App/StringBuilderDemo/src/StringBuilderDemo.java new file mode 100644 index 000000000..608035597 --- /dev/null +++ b/BasicJava/StringBuilderDemo_setLength_App/StringBuilderDemo/src/StringBuilderDemo.java @@ -0,0 +1,29 @@ +/* + * public void setLength(int newLength) + * + * Parameters: + * ---------- + * newLength - the new length + * + * Throws: + * ------ + * IndexOutOfBoundsException - if the newLength + * argument is negative. + */ +public class StringBuilderDemo +{ + + public static void main(String[] args) + { + String str = "Welcome"; + StringBuilder sb = new StringBuilder(str); + System.out.println("Before setLength, sb = " + sb); + System.out.println("Before setLength, sb = " + sb.length()); + + sb.setLength(3); + + System.out.println("After setLength, sb = " + sb); + System.out.println("After setLength, sb = " + sb.length()); + + } +} diff --git a/BasicJava/StringBuilderDemo_subSequence_App/Output.txt b/BasicJava/StringBuilderDemo_subSequence_App/Output.txt new file mode 100644 index 000000000..5f4fdf6f5 --- /dev/null +++ b/BasicJava/StringBuilderDemo_subSequence_App/Output.txt @@ -0,0 +1 @@ +strValue = com diff --git a/BasicJava/StringBuilderDemo_subSequence_App/StringBuilderDemo/.classpath b/BasicJava/StringBuilderDemo_subSequence_App/StringBuilderDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBuilderDemo_subSequence_App/StringBuilderDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBuilderDemo_subSequence_App/StringBuilderDemo/.project b/BasicJava/StringBuilderDemo_subSequence_App/StringBuilderDemo/.project new file mode 100644 index 000000000..e29d88a2a --- /dev/null +++ b/BasicJava/StringBuilderDemo_subSequence_App/StringBuilderDemo/.project @@ -0,0 +1,17 @@ + + + StringBuilderDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBuilderDemo_subSequence_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBuilderDemo_subSequence_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBuilderDemo_subSequence_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBuilderDemo_subSequence_App/StringBuilderDemo/bin/SubSequenceDemo.class b/BasicJava/StringBuilderDemo_subSequence_App/StringBuilderDemo/bin/SubSequenceDemo.class new file mode 100644 index 000000000..a2cd5377b Binary files /dev/null and b/BasicJava/StringBuilderDemo_subSequence_App/StringBuilderDemo/bin/SubSequenceDemo.class differ diff --git a/BasicJava/StringBuilderDemo_subSequence_App/StringBuilderDemo/src/SubSequenceDemo.java b/BasicJava/StringBuilderDemo_subSequence_App/StringBuilderDemo/src/SubSequenceDemo.java new file mode 100644 index 000000000..ceba6a0f5 --- /dev/null +++ b/BasicJava/StringBuilderDemo_subSequence_App/StringBuilderDemo/src/SubSequenceDemo.java @@ -0,0 +1,31 @@ +/* + * public CharSequence subSequence(int start, int end) + * + * Parameters: + * ---------- + * start - the start index,inclusive. + * + * end - the end index, exclusive. + * + * Returns: + * ------- + * the specified subsequence. + * + * Throws: + * ------ + * IndexOutOfBoundsException - if start or end + * are negative, if end is greater than length(), + * or if start is greater than end. + */ +public class SubSequenceDemo +{ + + public static void main(String[] args) + { + StringBuilder sb = new StringBuilder("Welcome"); + CharSequence charSequence = sb.subSequence(3, 6); + String strValue = (String) charSequence; + System.out.println("strValue = " + strValue); + + } +} diff --git a/BasicJava/StringBuilderDemo_substring_App/StringBuilderDemo/.classpath b/BasicJava/StringBuilderDemo_substring_App/StringBuilderDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBuilderDemo_substring_App/StringBuilderDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBuilderDemo_substring_App/StringBuilderDemo/.project b/BasicJava/StringBuilderDemo_substring_App/StringBuilderDemo/.project new file mode 100644 index 000000000..e29d88a2a --- /dev/null +++ b/BasicJava/StringBuilderDemo_substring_App/StringBuilderDemo/.project @@ -0,0 +1,17 @@ + + + StringBuilderDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBuilderDemo_substring_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBuilderDemo_substring_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBuilderDemo_substring_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBuilderDemo_substring_App/StringBuilderDemo/bin/SubStringDemo1.class b/BasicJava/StringBuilderDemo_substring_App/StringBuilderDemo/bin/SubStringDemo1.class new file mode 100644 index 000000000..d681a6240 Binary files /dev/null and b/BasicJava/StringBuilderDemo_substring_App/StringBuilderDemo/bin/SubStringDemo1.class differ diff --git a/BasicJava/StringBuilderDemo_substring_App/StringBuilderDemo/bin/SubStringDemo2.class b/BasicJava/StringBuilderDemo_substring_App/StringBuilderDemo/bin/SubStringDemo2.class new file mode 100644 index 000000000..6a3cdac8f Binary files /dev/null and b/BasicJava/StringBuilderDemo_substring_App/StringBuilderDemo/bin/SubStringDemo2.class differ diff --git a/BasicJava/StringBuilderDemo_substring_App/StringBuilderDemo/src/SubStringDemo1.java b/BasicJava/StringBuilderDemo_substring_App/StringBuilderDemo/src/SubStringDemo1.java new file mode 100644 index 000000000..49bf42c7c --- /dev/null +++ b/BasicJava/StringBuilderDemo_substring_App/StringBuilderDemo/src/SubStringDemo1.java @@ -0,0 +1,29 @@ +/* + * public String substring(int start, int end) + * + * Parameters: + * ---------- + * start - The beginning index,inclusive. + * + * end - The ending index, exclusive. + * + * Returns: + * ------- + * The new string. + * + * Throws: + * ------ + * StringIndexOutOfBoundsException - if start or end are + * negative or greater than length(), or start is + * greater than end. + */ +public class SubStringDemo1 +{ + + public static void main(String[] args) + { + StringBuilder sb = new StringBuilder("Welcome"); + String subString = sb.substring(3, 6); + System.out.println("subString = " + subString); + } +} diff --git a/BasicJava/StringBuilderDemo_substring_App/StringBuilderDemo/src/SubStringDemo2.java b/BasicJava/StringBuilderDemo_substring_App/StringBuilderDemo/src/SubStringDemo2.java new file mode 100644 index 000000000..a5fbf12e1 --- /dev/null +++ b/BasicJava/StringBuilderDemo_substring_App/StringBuilderDemo/src/SubStringDemo2.java @@ -0,0 +1,28 @@ +/* + * public String substring(int start) + * + * Parameters: + * ---------- + * start - The beginning index, inclusive. + * + * Returns: + * ------- + * The new string. + * + * Throws: + * ------ + * StringIndexOutOfBoundsException - if start is less + * than zero, or greater than the length of this object. + */ + +public class SubStringDemo2 +{ + + public static void main(String[] args) + { + StringBuilder sb = new StringBuilder("Welcome"); + String subString = sb.substring(3); + System.out.println("subString = " + subString); + + } +} diff --git a/BasicJava/StringBuilderDemo_substring_App/SubStringDemo1_Output.txt b/BasicJava/StringBuilderDemo_substring_App/SubStringDemo1_Output.txt new file mode 100644 index 000000000..417c7ab78 --- /dev/null +++ b/BasicJava/StringBuilderDemo_substring_App/SubStringDemo1_Output.txt @@ -0,0 +1 @@ +subString = com diff --git a/BasicJava/StringBuilderDemo_substring_App/SubStringDemo2_Output.txt b/BasicJava/StringBuilderDemo_substring_App/SubStringDemo2_Output.txt new file mode 100644 index 000000000..227fc1292 --- /dev/null +++ b/BasicJava/StringBuilderDemo_substring_App/SubStringDemo2_Output.txt @@ -0,0 +1 @@ +subString = come diff --git a/BasicJava/StringBuilderDemo_trimToSize_App/Output.txt b/BasicJava/StringBuilderDemo_trimToSize_App/Output.txt new file mode 100644 index 000000000..60ca96f47 --- /dev/null +++ b/BasicJava/StringBuilderDemo_trimToSize_App/Output.txt @@ -0,0 +1,2 @@ +Before timeToSize,Capacity = 23 +After timeToSize,Capacity = 7 diff --git a/BasicJava/StringBuilderDemo_trimToSize_App/StringBuilderDemo/.classpath b/BasicJava/StringBuilderDemo_trimToSize_App/StringBuilderDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringBuilderDemo_trimToSize_App/StringBuilderDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringBuilderDemo_trimToSize_App/StringBuilderDemo/.project b/BasicJava/StringBuilderDemo_trimToSize_App/StringBuilderDemo/.project new file mode 100644 index 000000000..e29d88a2a --- /dev/null +++ b/BasicJava/StringBuilderDemo_trimToSize_App/StringBuilderDemo/.project @@ -0,0 +1,17 @@ + + + StringBuilderDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringBuilderDemo_trimToSize_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringBuilderDemo_trimToSize_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringBuilderDemo_trimToSize_App/StringBuilderDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringBuilderDemo_trimToSize_App/StringBuilderDemo/bin/StringBuilderDemo.class b/BasicJava/StringBuilderDemo_trimToSize_App/StringBuilderDemo/bin/StringBuilderDemo.class new file mode 100644 index 000000000..29083aba8 Binary files /dev/null and b/BasicJava/StringBuilderDemo_trimToSize_App/StringBuilderDemo/bin/StringBuilderDemo.class differ diff --git a/BasicJava/StringBuilderDemo_trimToSize_App/StringBuilderDemo/src/StringBuilderDemo.java b/BasicJava/StringBuilderDemo_trimToSize_App/StringBuilderDemo/src/StringBuilderDemo.java new file mode 100644 index 000000000..06e89dfba --- /dev/null +++ b/BasicJava/StringBuilderDemo_trimToSize_App/StringBuilderDemo/src/StringBuilderDemo.java @@ -0,0 +1,29 @@ +/* + * public void trimToSize() + * + * Attempts to reduce storage used for the character + * sequence. If the buffer is larger than necessary to + * hold its current sequence of characters, then it may + * be resized to become more space efficient. Calling + * this method may, but is not required to, affect the + * value returned by a subsequent call to the capacity() + * method. + */ + +public class StringBuilderDemo +{ + + public static void main(String[] args) + { + + StringBuilder sb = new StringBuilder("Welcome"); + + System.out.println("Before timeToSize,Capacity = " + + sb.capacity()); + + sb.trimToSize(); + + System.out.println("After timeToSize,Capacity = " + + sb.capacity()); + } +} diff --git a/BasicJava/StringDemo_Comparison_App/CompareByCompareToDemo_Output.txt b/BasicJava/StringDemo_Comparison_App/CompareByCompareToDemo_Output.txt new file mode 100644 index 000000000..d7e52d192 --- /dev/null +++ b/BasicJava/StringDemo_Comparison_App/CompareByCompareToDemo_Output.txt @@ -0,0 +1,3 @@ +0 +1 +-1 diff --git a/BasicJava/StringDemo_Comparison_App/CompareByDemo_Output.txt b/BasicJava/StringDemo_Comparison_App/CompareByDemo_Output.txt new file mode 100644 index 000000000..da29283aa --- /dev/null +++ b/BasicJava/StringDemo_Comparison_App/CompareByDemo_Output.txt @@ -0,0 +1,2 @@ +true +false diff --git a/BasicJava/StringDemo_Comparison_App/CompareByEqualsDemo_Output.txt b/BasicJava/StringDemo_Comparison_App/CompareByEqualsDemo_Output.txt new file mode 100644 index 000000000..9e8a46acf --- /dev/null +++ b/BasicJava/StringDemo_Comparison_App/CompareByEqualsDemo_Output.txt @@ -0,0 +1,3 @@ +true +true +false diff --git a/BasicJava/StringDemo_Comparison_App/CompareByEqualsIgnoreCaseDemo_Output.txt b/BasicJava/StringDemo_Comparison_App/CompareByEqualsIgnoreCaseDemo_Output.txt new file mode 100644 index 000000000..1d474d525 --- /dev/null +++ b/BasicJava/StringDemo_Comparison_App/CompareByEqualsIgnoreCaseDemo_Output.txt @@ -0,0 +1,2 @@ +false +true diff --git a/BasicJava/StringDemo_Comparison_App/StringDemo/.classpath b/BasicJava/StringDemo_Comparison_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_Comparison_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_34/StringDemo/.project b/BasicJava/StringDemo_Comparison_App/StringDemo/.project similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_34/StringDemo/.project rename to BasicJava/StringDemo_Comparison_App/StringDemo/.project diff --git a/BasicJava/StringDemo_Comparison_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_Comparison_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_Comparison_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/String/misc/String-Comparison_61/String_61/StringDemo/bin/CompareByCompareToDemo.class b/BasicJava/StringDemo_Comparison_App/StringDemo/bin/CompareByCompareToDemo.class similarity index 100% rename from Later/String/misc/String-Comparison_61/String_61/StringDemo/bin/CompareByCompareToDemo.class rename to BasicJava/StringDemo_Comparison_App/StringDemo/bin/CompareByCompareToDemo.class diff --git a/Later/String/misc/String-Comparison_61/String_61/StringDemo/bin/CompareByDemo.class b/BasicJava/StringDemo_Comparison_App/StringDemo/bin/CompareByDemo.class similarity index 100% rename from Later/String/misc/String-Comparison_61/String_61/StringDemo/bin/CompareByDemo.class rename to BasicJava/StringDemo_Comparison_App/StringDemo/bin/CompareByDemo.class diff --git a/Later/String/misc/String-Comparison_61/String_61/StringDemo/bin/CompareByEqualsDemo.class b/BasicJava/StringDemo_Comparison_App/StringDemo/bin/CompareByEqualsDemo.class similarity index 100% rename from Later/String/misc/String-Comparison_61/String_61/StringDemo/bin/CompareByEqualsDemo.class rename to BasicJava/StringDemo_Comparison_App/StringDemo/bin/CompareByEqualsDemo.class diff --git a/Later/String/misc/String-Comparison_61/String_61/StringDemo/bin/CompareByEqualsIgnoreCaseDemo.class b/BasicJava/StringDemo_Comparison_App/StringDemo/bin/CompareByEqualsIgnoreCaseDemo.class similarity index 91% rename from Later/String/misc/String-Comparison_61/String_61/StringDemo/bin/CompareByEqualsIgnoreCaseDemo.class rename to BasicJava/StringDemo_Comparison_App/StringDemo/bin/CompareByEqualsIgnoreCaseDemo.class index 2add199cb..3f5abb878 100644 Binary files a/Later/String/misc/String-Comparison_61/String_61/StringDemo/bin/CompareByEqualsIgnoreCaseDemo.class and b/BasicJava/StringDemo_Comparison_App/StringDemo/bin/CompareByEqualsIgnoreCaseDemo.class differ diff --git a/Later/String/misc/String-Comparison_61/String_61/StringDemo/src/CompareByCompareToDemo.java b/BasicJava/StringDemo_Comparison_App/StringDemo/src/CompareByCompareToDemo.java similarity index 100% rename from Later/String/misc/String-Comparison_61/String_61/StringDemo/src/CompareByCompareToDemo.java rename to BasicJava/StringDemo_Comparison_App/StringDemo/src/CompareByCompareToDemo.java diff --git a/Later/String/misc/String-Comparison_61/String_61/StringDemo/src/CompareByDemo.java b/BasicJava/StringDemo_Comparison_App/StringDemo/src/CompareByDemo.java similarity index 100% rename from Later/String/misc/String-Comparison_61/String_61/StringDemo/src/CompareByDemo.java rename to BasicJava/StringDemo_Comparison_App/StringDemo/src/CompareByDemo.java diff --git a/Later/String/misc/String-Comparison_61/String_61/StringDemo/src/CompareByEqualsDemo.java b/BasicJava/StringDemo_Comparison_App/StringDemo/src/CompareByEqualsDemo.java similarity index 100% rename from Later/String/misc/String-Comparison_61/String_61/StringDemo/src/CompareByEqualsDemo.java rename to BasicJava/StringDemo_Comparison_App/StringDemo/src/CompareByEqualsDemo.java diff --git a/Later/String/misc/String-Comparison_61/String_61/StringDemo/src/CompareByEqualsIgnoreCaseDemo.java b/BasicJava/StringDemo_Comparison_App/StringDemo/src/CompareByEqualsIgnoreCaseDemo.java similarity index 90% rename from Later/String/misc/String-Comparison_61/String_61/StringDemo/src/CompareByEqualsIgnoreCaseDemo.java rename to BasicJava/StringDemo_Comparison_App/StringDemo/src/CompareByEqualsIgnoreCaseDemo.java index 72668bf62..3f54f14f7 100644 --- a/Later/String/misc/String-Comparison_61/String_61/StringDemo/src/CompareByEqualsIgnoreCaseDemo.java +++ b/BasicJava/StringDemo_Comparison_App/StringDemo/src/CompareByEqualsIgnoreCaseDemo.java @@ -3,7 +3,7 @@ public class CompareByEqualsIgnoreCaseDemo public static void main(String[] args) { - String s1 = "Peter"; + String s1 = "peter"; String s2 = "PETER"; System.out.println(s1.equals(s2));// false diff --git a/BasicJava/StringDemo_Concatination_App/ConcatenationDemo1_Output.txt b/BasicJava/StringDemo_Concatination_App/ConcatenationDemo1_Output.txt new file mode 100644 index 000000000..f23ede230 --- /dev/null +++ b/BasicJava/StringDemo_Concatination_App/ConcatenationDemo1_Output.txt @@ -0,0 +1,2 @@ +Hello World +80Hello4040 diff --git a/BasicJava/StringDemo_Concatination_App/ConcatenationDemo2_Output.txt b/BasicJava/StringDemo_Concatination_App/ConcatenationDemo2_Output.txt new file mode 100644 index 000000000..a8ad19b8d --- /dev/null +++ b/BasicJava/StringDemo_Concatination_App/ConcatenationDemo2_Output.txt @@ -0,0 +1 @@ +Sachin Tendulkar diff --git a/BasicJava/StringDemo_Concatination_App/StringDemo/.classpath b/BasicJava/StringDemo_Concatination_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_Concatination_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_35/StringDemo/.project b/BasicJava/StringDemo_Concatination_App/StringDemo/.project similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_35/StringDemo/.project rename to BasicJava/StringDemo_Concatination_App/StringDemo/.project diff --git a/BasicJava/StringDemo_Concatination_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_Concatination_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_Concatination_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/String/misc/String Concatenation in Java_62/StringDemo/bin/ConcatenationDemo1.class b/BasicJava/StringDemo_Concatination_App/StringDemo/bin/ConcatenationDemo1.class similarity index 100% rename from Later/String/misc/String Concatenation in Java_62/StringDemo/bin/ConcatenationDemo1.class rename to BasicJava/StringDemo_Concatination_App/StringDemo/bin/ConcatenationDemo1.class diff --git a/Later/String/misc/String Concatenation in Java_62/StringDemo/bin/ConcatenationDemo2.class b/BasicJava/StringDemo_Concatination_App/StringDemo/bin/ConcatenationDemo2.class similarity index 100% rename from Later/String/misc/String Concatenation in Java_62/StringDemo/bin/ConcatenationDemo2.class rename to BasicJava/StringDemo_Concatination_App/StringDemo/bin/ConcatenationDemo2.class diff --git a/Later/String/misc/String Concatenation in Java_62/StringDemo/src/ConcatenationDemo1.java b/BasicJava/StringDemo_Concatination_App/StringDemo/src/ConcatenationDemo1.java similarity index 100% rename from Later/String/misc/String Concatenation in Java_62/StringDemo/src/ConcatenationDemo1.java rename to BasicJava/StringDemo_Concatination_App/StringDemo/src/ConcatenationDemo1.java diff --git a/Later/String/misc/String Concatenation in Java_62/StringDemo/src/ConcatenationDemo2.java b/BasicJava/StringDemo_Concatination_App/StringDemo/src/ConcatenationDemo2.java similarity index 100% rename from Later/String/misc/String Concatenation in Java_62/StringDemo/src/ConcatenationDemo2.java rename to BasicJava/StringDemo_Concatination_App/StringDemo/src/ConcatenationDemo2.java diff --git a/BasicJava/StringDemo_Contains_App/Output.txt b/BasicJava/StringDemo_Contains_App/Output.txt new file mode 100644 index 000000000..e8cc5ff87 --- /dev/null +++ b/BasicJava/StringDemo_Contains_App/Output.txt @@ -0,0 +1,2 @@ +contains("are") = true +contains("do") = false diff --git a/BasicJava/StringDemo_Contains_App/StringDemo/.classpath b/BasicJava/StringDemo_Contains_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_Contains_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_36/StringDemo/.project b/BasicJava/StringDemo_Contains_App/StringDemo/.project similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_36/StringDemo/.project rename to BasicJava/StringDemo_Contains_App/StringDemo/.project diff --git a/BasicJava/StringDemo_Contains_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_Contains_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_Contains_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_Contains_App/StringDemo/bin/ContainsDemo.class b/BasicJava/StringDemo_Contains_App/StringDemo/bin/ContainsDemo.class new file mode 100644 index 000000000..b17d48096 Binary files /dev/null and b/BasicJava/StringDemo_Contains_App/StringDemo/bin/ContainsDemo.class differ diff --git a/BasicJava/StringDemo_Contains_App/StringDemo/src/ContainsDemo.java b/BasicJava/StringDemo_Contains_App/StringDemo/src/ContainsDemo.java new file mode 100644 index 000000000..52817622d --- /dev/null +++ b/BasicJava/StringDemo_Contains_App/StringDemo/src/ContainsDemo.java @@ -0,0 +1,34 @@ +/* + * public boolean contains(CharSequence s) + * + * Parameters: + * ---------- + * s - the sequence to search for. + * + * Returns: + * ------- + * Returns true if and only if this string contains + * the specified sequence of char values. + */ + +public class ContainsDemo +{ + + public static void main(String[] args) + { + String str = "How are you peter?"; + + boolean isExist = str.contains("are"); + System.out.println("contains(\"are\") = " + isExist); + + /* + * CharSequence is an interface that is implemented + * by the String class. Therefore, you can use a + * string as an argument for the contains() method. + */ + + isExist = str.contains("do"); + System.out.println("contains(\"do\") = " + isExist); + + } +} diff --git a/BasicJava/StringDemo_Join_Iterable_App/Output.txt b/BasicJava/StringDemo_Join_Iterable_App/Output.txt new file mode 100644 index 000000000..aa58a6ff3 --- /dev/null +++ b/BasicJava/StringDemo_Join_Iterable_App/Output.txt @@ -0,0 +1,2 @@ +Java|is|cool +Java-is-very-cool diff --git a/BasicJava/StringDemo_Join_Iterable_App/StringDemo/.classpath b/BasicJava/StringDemo_Join_Iterable_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_Join_Iterable_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_37/StringDemo/.project b/BasicJava/StringDemo_Join_Iterable_App/StringDemo/.project similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_37/StringDemo/.project rename to BasicJava/StringDemo_Join_Iterable_App/StringDemo/.project diff --git a/BasicJava/StringDemo_Join_Iterable_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_Join_Iterable_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_Join_Iterable_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_Join_Iterable_App/StringDemo/bin/JoinDemo.class b/BasicJava/StringDemo_Join_Iterable_App/StringDemo/bin/JoinDemo.class new file mode 100644 index 000000000..d5683effa Binary files /dev/null and b/BasicJava/StringDemo_Join_Iterable_App/StringDemo/bin/JoinDemo.class differ diff --git a/BasicJava/StringDemo_Join_Iterable_App/StringDemo/src/JoinDemo.java b/BasicJava/StringDemo_Join_Iterable_App/StringDemo/src/JoinDemo.java new file mode 100644 index 000000000..dc77f8224 --- /dev/null +++ b/BasicJava/StringDemo_Join_Iterable_App/StringDemo/src/JoinDemo.java @@ -0,0 +1,54 @@ +import java.util.LinkedHashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; + +/* + * public static String join(CharSequence delimiter, + * Iterable elements) + * + * Parameters: + * ----------- + * delimiter - a sequence of characters that is used + * to separate each of the elements in the resulting + * String + * + * elements - an Iterable that will have its + * elements joined together. + * + * Returns: + * -------- + * a new String that is composed from the elements + * argument + * + * Throws: + * ------- + * NullPointerException - If delimiter or elements + * is null + */ + +public class JoinDemo +{ + public static void main(String[] args) + { + List listOfStrings = new LinkedList<>(); + listOfStrings.add("Java"); + listOfStrings.add("is"); + listOfStrings.add("cool"); + + // message returned is: "Java|is|cool" + String message = String.join("|", listOfStrings); + System.out.println(message); + + Set setOfStrings = new LinkedHashSet<>(); + setOfStrings.add("Java"); + setOfStrings.add("is"); + setOfStrings.add("very"); + setOfStrings.add("cool"); + + // message returned is: "Java-is-very-cool" + message = String.join("-", setOfStrings); + System.out.println(message); + } + +} \ No newline at end of file diff --git a/BasicJava/StringDemo_LastIndexOf_Int_App/Output.txt b/BasicJava/StringDemo_LastIndexOf_Int_App/Output.txt new file mode 100644 index 000000000..e368df14e --- /dev/null +++ b/BasicJava/StringDemo_LastIndexOf_Int_App/Output.txt @@ -0,0 +1,3 @@ +lastIndexOf('e') = 6 +lastIndexOf('m') = 5 +lastIndexOf('a') = -1 diff --git a/BasicJava/StringDemo_LastIndexOf_Int_App/StringDemo/.classpath b/BasicJava/StringDemo_LastIndexOf_Int_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_LastIndexOf_Int_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_38/StringDemo/.project b/BasicJava/StringDemo_LastIndexOf_Int_App/StringDemo/.project similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_38/StringDemo/.project rename to BasicJava/StringDemo_LastIndexOf_Int_App/StringDemo/.project diff --git a/BasicJava/StringDemo_LastIndexOf_Int_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_LastIndexOf_Int_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_LastIndexOf_Int_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/String/Manipulating Characters in a String/String_21/StringDemo/bin/LastIndexDemo.class b/BasicJava/StringDemo_LastIndexOf_Int_App/StringDemo/bin/LastIndexDemo.class similarity index 100% rename from Later/String/Manipulating Characters in a String/String_21/StringDemo/bin/LastIndexDemo.class rename to BasicJava/StringDemo_LastIndexOf_Int_App/StringDemo/bin/LastIndexDemo.class diff --git a/BasicJava/StringDemo_LastIndexOf_Int_App/StringDemo/bin/LastIndexOfDemo.class b/BasicJava/StringDemo_LastIndexOf_Int_App/StringDemo/bin/LastIndexOfDemo.class new file mode 100644 index 000000000..b66feb38c Binary files /dev/null and b/BasicJava/StringDemo_LastIndexOf_Int_App/StringDemo/bin/LastIndexOfDemo.class differ diff --git a/BasicJava/StringDemo_LastIndexOf_Int_App/StringDemo/src/LastIndexOfDemo.java b/BasicJava/StringDemo_LastIndexOf_Int_App/StringDemo/src/LastIndexOfDemo.java new file mode 100644 index 000000000..267db0bf1 --- /dev/null +++ b/BasicJava/StringDemo_LastIndexOf_Int_App/StringDemo/src/LastIndexOfDemo.java @@ -0,0 +1,33 @@ +/* + * public int lastIndexOf(int ch) + * + * Parameters: + * ---------- + * ch - a character (Unicode code point). + * + * Returns: + * ------- + * Returns the index within this string of the last + * occurrence of the specified character. , or -1 if + * the character does not occur. + */ + +public class LastIndexOfDemo +{ + + public static void main(String[] args) + { + String str = "Welcome"; + + int indexPosition = str.lastIndexOf('e'); + System.out.println("lastIndexOf(\'e\') = " + indexPosition); + + // Unicode value of m is 109. + indexPosition = str.lastIndexOf(109); + System.out.println("lastIndexOf(\'m\') = " + indexPosition); + + indexPosition = str.lastIndexOf('a'); + System.out.println("lastIndexOf(\'a\') = " + indexPosition); + + } +} diff --git a/BasicJava/StringDemo_ReplaceAll_App/Output.txt b/BasicJava/StringDemo_ReplaceAll_App/Output.txt new file mode 100644 index 000000000..ce6508cbb --- /dev/null +++ b/BasicJava/StringDemo_ReplaceAll_App/Output.txt @@ -0,0 +1,2 @@ +str = My name is Peter,her name is Juli +replacedStr = My_name_is_Peter,her_name_is_Juli diff --git a/BasicJava/StringDemo_ReplaceAll_App/StringDemo/.classpath b/BasicJava/StringDemo_ReplaceAll_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_ReplaceAll_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_39/StringDemo/.project b/BasicJava/StringDemo_ReplaceAll_App/StringDemo/.project similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_39/StringDemo/.project rename to BasicJava/StringDemo_ReplaceAll_App/StringDemo/.project diff --git a/BasicJava/StringDemo_ReplaceAll_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_ReplaceAll_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_ReplaceAll_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_ReplaceAll_App/StringDemo/bin/ReplaceAllDemo.class b/BasicJava/StringDemo_ReplaceAll_App/StringDemo/bin/ReplaceAllDemo.class new file mode 100644 index 000000000..049b508d7 Binary files /dev/null and b/BasicJava/StringDemo_ReplaceAll_App/StringDemo/bin/ReplaceAllDemo.class differ diff --git a/BasicJava/StringDemo_ReplaceAll_App/StringDemo/src/ReplaceAllDemo.java b/BasicJava/StringDemo_ReplaceAll_App/StringDemo/src/ReplaceAllDemo.java new file mode 100644 index 000000000..e8a76884b --- /dev/null +++ b/BasicJava/StringDemo_ReplaceAll_App/StringDemo/src/ReplaceAllDemo.java @@ -0,0 +1,37 @@ +/* + * public String replaceAll(String regex, String + * replacement) + * + * Parameters: + * ---------- + * regex - the regular expression to which this + * string is to be matched. + * + * replacement - the string to be substituted for + * each match. + * + * Returns: + * ------- + * Replaces each substring of this string that + * matches the given regular expression with the + * given replacement. + * + * Throws: + * ------ + * PatternSyntaxException - if the + * regular expression's syntax is invalid. + */ + +public class ReplaceAllDemo +{ + + public static void main(String[] args) + { + String str = "My name is Peter,her name is Juli"; + System.out.println("str = " + str); + + String replacedStr = str.replaceAll("\\s", "_"); + System.out.println("replacedStr = " + replacedStr); + + } +} diff --git a/BasicJava/StringDemo_ReplaceFirst_App/Output.txt b/BasicJava/StringDemo_ReplaceFirst_App/Output.txt new file mode 100644 index 000000000..4438204be --- /dev/null +++ b/BasicJava/StringDemo_ReplaceFirst_App/Output.txt @@ -0,0 +1,2 @@ +str = My name is Peter,her name is Juli +replacedStr = My name was Peter,her name is Juli diff --git a/BasicJava/StringDemo_ReplaceFirst_App/StringDemo/.classpath b/BasicJava/StringDemo_ReplaceFirst_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_ReplaceFirst_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_40/StringDemo/.project b/BasicJava/StringDemo_ReplaceFirst_App/StringDemo/.project similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_40/StringDemo/.project rename to BasicJava/StringDemo_ReplaceFirst_App/StringDemo/.project diff --git a/BasicJava/StringDemo_ReplaceFirst_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_ReplaceFirst_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_ReplaceFirst_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/String/Manipulating Characters in a String/String_32/StringDemo/bin/ReplaceFirstDemo.class b/BasicJava/StringDemo_ReplaceFirst_App/StringDemo/bin/ReplaceFirstDemo.class similarity index 87% rename from Later/String/Manipulating Characters in a String/String_32/StringDemo/bin/ReplaceFirstDemo.class rename to BasicJava/StringDemo_ReplaceFirst_App/StringDemo/bin/ReplaceFirstDemo.class index 497eef101..f9b56003e 100644 Binary files a/Later/String/Manipulating Characters in a String/String_32/StringDemo/bin/ReplaceFirstDemo.class and b/BasicJava/StringDemo_ReplaceFirst_App/StringDemo/bin/ReplaceFirstDemo.class differ diff --git a/BasicJava/StringDemo_ReplaceFirst_App/StringDemo/src/ReplaceFirstDemo.java b/BasicJava/StringDemo_ReplaceFirst_App/StringDemo/src/ReplaceFirstDemo.java new file mode 100644 index 000000000..8d8728600 --- /dev/null +++ b/BasicJava/StringDemo_ReplaceFirst_App/StringDemo/src/ReplaceFirstDemo.java @@ -0,0 +1,37 @@ +/* + * public String replaceFirst(String regex, String + * replacement) + * + * Parameters: + * ---------- + * regex - the regular expression to which this + * string is to be matched. + * + * replacement - the string to be substituted + * for the first match. + * + * Returns: + * ------- + * Replaces the first substring of this string that + * matches the given regular expression with the + * given replacement. + * + * Throws: + * ------ + * PatternSyntaxException - if the regular + * expression's syntax is invalid. + */ + +public class ReplaceFirstDemo +{ + + public static void main(String[] args) + { + String str = "My name is Peter,her name is Juli"; + System.out.println("str = " + str); + + String replacedStr = str.replaceFirst("is", "was"); + System.out.println("replacedStr = " + replacedStr); + + } +} diff --git a/BasicJava/StringDemo_Replace_CharSeq_App/Output.txt b/BasicJava/StringDemo_Replace_CharSeq_App/Output.txt new file mode 100644 index 000000000..e97cbe726 --- /dev/null +++ b/BasicJava/StringDemo_Replace_CharSeq_App/Output.txt @@ -0,0 +1,2 @@ +str = My name is Peter,her name is Juli +replacedStr = My name was Peter,her name was Juli diff --git a/BasicJava/StringDemo_Replace_CharSeq_App/StringDemo/.classpath b/BasicJava/StringDemo_Replace_CharSeq_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_Replace_CharSeq_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_41/StringDemo/.project b/BasicJava/StringDemo_Replace_CharSeq_App/StringDemo/.project similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_41/StringDemo/.project rename to BasicJava/StringDemo_Replace_CharSeq_App/StringDemo/.project diff --git a/BasicJava/StringDemo_Replace_CharSeq_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_Replace_CharSeq_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_Replace_CharSeq_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_Replace_CharSeq_App/StringDemo/bin/ReplaceDemo.class b/BasicJava/StringDemo_Replace_CharSeq_App/StringDemo/bin/ReplaceDemo.class new file mode 100644 index 000000000..f4b42556e Binary files /dev/null and b/BasicJava/StringDemo_Replace_CharSeq_App/StringDemo/bin/ReplaceDemo.class differ diff --git a/BasicJava/StringDemo_Replace_CharSeq_App/StringDemo/src/ReplaceDemo.java b/BasicJava/StringDemo_Replace_CharSeq_App/StringDemo/src/ReplaceDemo.java new file mode 100644 index 000000000..1df4ce0b4 --- /dev/null +++ b/BasicJava/StringDemo_Replace_CharSeq_App/StringDemo/src/ReplaceDemo.java @@ -0,0 +1,33 @@ +/* + * public String replace(CharSequence target, + * CharSequence replacement) + * + * Parameters: + * ---------- + * target - The sequence of char values to be + * replaced. + * + * replacement - The replacement sequence + * of char values. + * + * Returns: + * ------- + * Replaces each substring of this string that + * matches the literal target sequence with the + * specified literal replacement sequence. The + * replacement proceeds from the beginning of the + * string to the end. + */ + +public class ReplaceDemo +{ + + public static void main(String[] args) + { + String str = "My name is Peter,her name is Juli"; + System.out.println("str = " + str); + String replacedStr = str.replace("is", "was"); + System.out.println("replacedStr = " + replacedStr); + + } +} diff --git a/BasicJava/StringDemo_Replace_OldC_NewC_App/Output.txt b/BasicJava/StringDemo_Replace_OldC_NewC_App/Output.txt new file mode 100644 index 000000000..e483bca06 --- /dev/null +++ b/BasicJava/StringDemo_Replace_OldC_NewC_App/Output.txt @@ -0,0 +1,2 @@ +str = aaabbb +replacedStr = zzzbbb diff --git a/BasicJava/StringDemo_Replace_OldC_NewC_App/StringDemo/.classpath b/BasicJava/StringDemo_Replace_OldC_NewC_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_Replace_OldC_NewC_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_42/StringDemo/.project b/BasicJava/StringDemo_Replace_OldC_NewC_App/StringDemo/.project similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_42/StringDemo/.project rename to BasicJava/StringDemo_Replace_OldC_NewC_App/StringDemo/.project diff --git a/BasicJava/StringDemo_Replace_OldC_NewC_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_Replace_OldC_NewC_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_Replace_OldC_NewC_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_Replace_OldC_NewC_App/StringDemo/bin/ReplaceDemo.class b/BasicJava/StringDemo_Replace_OldC_NewC_App/StringDemo/bin/ReplaceDemo.class new file mode 100644 index 000000000..b973bc2f8 Binary files /dev/null and b/BasicJava/StringDemo_Replace_OldC_NewC_App/StringDemo/bin/ReplaceDemo.class differ diff --git a/BasicJava/StringDemo_Replace_OldC_NewC_App/StringDemo/src/ReplaceDemo.java b/BasicJava/StringDemo_Replace_OldC_NewC_App/StringDemo/src/ReplaceDemo.java new file mode 100644 index 000000000..fd6aa0ea6 --- /dev/null +++ b/BasicJava/StringDemo_Replace_OldC_NewC_App/StringDemo/src/ReplaceDemo.java @@ -0,0 +1,26 @@ +/* + * public String replace(char oldChar, char newChar) + * + * Parameters: + * ---------- + * oldChar - the old character. + * newChar - the new character. + * + * Returns: + * ------- + * Returns a string resulting from replacing all + * occurrences of oldChar in this string with + * newChar. + */ + +public class ReplaceDemo +{ + + public static void main(String[] args) + { + String str = "aaabbb"; + System.out.println("str = " + str); + String replacedStr = str.replace('a', 'z'); + System.out.println("replacedStr = " + replacedStr); + } +} diff --git a/BasicJava/StringDemo_Split_App/Output.txt b/BasicJava/StringDemo_Split_App/Output.txt new file mode 100644 index 000000000..b1b2a7456 --- /dev/null +++ b/BasicJava/StringDemo_Split_App/Output.txt @@ -0,0 +1,4 @@ +Peter +Welcome +to +India diff --git a/BasicJava/StringDemo_Split_App/StringDemo/.classpath b/BasicJava/StringDemo_Split_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_Split_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_43/StringDemo/.project b/BasicJava/StringDemo_Split_App/StringDemo/.project similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_43/StringDemo/.project rename to BasicJava/StringDemo_Split_App/StringDemo/.project diff --git a/BasicJava/StringDemo_Split_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_Split_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_Split_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_Split_App/StringDemo/bin/SplitDemo.class b/BasicJava/StringDemo_Split_App/StringDemo/bin/SplitDemo.class new file mode 100644 index 000000000..1338eb945 Binary files /dev/null and b/BasicJava/StringDemo_Split_App/StringDemo/bin/SplitDemo.class differ diff --git a/BasicJava/StringDemo_Split_App/StringDemo/src/SplitDemo.java b/BasicJava/StringDemo_Split_App/StringDemo/src/SplitDemo.java new file mode 100644 index 000000000..3a87588cd --- /dev/null +++ b/BasicJava/StringDemo_Split_App/StringDemo/src/SplitDemo.java @@ -0,0 +1,28 @@ +/* + * public String[] split(String regex) + * + * Parameters: + * ---------- + * regex - the delimiting regular expression + * + * Returns: + * ------- + * the array of strings computed by splitting this + * string around matches of the given regular + * expression + */ + +public class SplitDemo +{ + + public static void main(String[] args) + { + String str = "Peter,Welcome,to,India"; + String strArray[] = str.split(","); + for (String string : strArray) + { + System.out.println(string); + } + + } +} diff --git a/BasicJava/StringDemo_Split_limit_App/Output.txt b/BasicJava/StringDemo_Split_limit_App/Output.txt new file mode 100644 index 000000000..c3d88088d --- /dev/null +++ b/BasicJava/StringDemo_Split_limit_App/Output.txt @@ -0,0 +1,3 @@ +Peter +Welcome +to,India diff --git a/BasicJava/StringDemo_Split_limit_App/StringDemo/.classpath b/BasicJava/StringDemo_Split_limit_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_Split_limit_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_44/StringDemo/.project b/BasicJava/StringDemo_Split_limit_App/StringDemo/.project similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_44/StringDemo/.project rename to BasicJava/StringDemo_Split_limit_App/StringDemo/.project diff --git a/BasicJava/StringDemo_Split_limit_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_Split_limit_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_Split_limit_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_Split_limit_App/StringDemo/bin/SplitDemo.class b/BasicJava/StringDemo_Split_limit_App/StringDemo/bin/SplitDemo.class new file mode 100644 index 000000000..4d3ddc263 Binary files /dev/null and b/BasicJava/StringDemo_Split_limit_App/StringDemo/bin/SplitDemo.class differ diff --git a/BasicJava/StringDemo_Split_limit_App/StringDemo/src/SplitDemo.java b/BasicJava/StringDemo_Split_limit_App/StringDemo/src/SplitDemo.java new file mode 100644 index 000000000..296174ac0 --- /dev/null +++ b/BasicJava/StringDemo_Split_limit_App/StringDemo/src/SplitDemo.java @@ -0,0 +1,32 @@ +/* + * public String[] split(String regex, int limit) + * + * Parameters: + * ---------- + * regex - the delimiting regular expression + * + * limit - limit for the number of strings in array. + * If it is zero, it will returns all the strings + * matching regex. + * + * Returns: + * ------- + * the array of strings computed by splitting this + * string around matches of the given regular + * expression + */ + +public class SplitDemo +{ + + public static void main(String[] args) + { + String str = "Peter,Welcome,to,India"; + String strArray[] = str.split(",", 3); + for (String string : strArray) + { + System.out.println(string); + } + + } +} diff --git a/BasicJava/StringDemo_SubString_App/StringDemo/.classpath b/BasicJava/StringDemo_SubString_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_SubString_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/Manipulating Characters in a String/String_18/StringDemo/.project b/BasicJava/StringDemo_SubString_App/StringDemo/.project similarity index 100% rename from Later/String/Manipulating Characters in a String/String_18/StringDemo/.project rename to BasicJava/StringDemo_SubString_App/StringDemo/.project diff --git a/BasicJava/StringDemo_SubString_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_SubString_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_SubString_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_SubString_App/StringDemo/bin/SubStringDemo1.class b/BasicJava/StringDemo_SubString_App/StringDemo/bin/SubStringDemo1.class new file mode 100644 index 000000000..5692a0cae Binary files /dev/null and b/BasicJava/StringDemo_SubString_App/StringDemo/bin/SubStringDemo1.class differ diff --git a/BasicJava/StringDemo_SubString_App/StringDemo/bin/SubStringDemo2.class b/BasicJava/StringDemo_SubString_App/StringDemo/bin/SubStringDemo2.class new file mode 100644 index 000000000..caba42919 Binary files /dev/null and b/BasicJava/StringDemo_SubString_App/StringDemo/bin/SubStringDemo2.class differ diff --git a/BasicJava/StringDemo_SubString_App/StringDemo/src/SubStringDemo1.java b/BasicJava/StringDemo_SubString_App/StringDemo/src/SubStringDemo1.java new file mode 100644 index 000000000..38906e875 --- /dev/null +++ b/BasicJava/StringDemo_SubString_App/StringDemo/src/SubStringDemo1.java @@ -0,0 +1,29 @@ +/* + * public String substring(int beginIndex, int + * endIndex) + * + * Parameters: + * ---------- + * beginIndex - the beginning index, inclusive. + * endIndex - the ending index, exclusive. + * + * Returns: + * ------- + * Returns a string that is a substring of this + * string. The substring begins at the specified + * beginIndex and extends to the character at index + * endIndex - 1. Thus the length of the substring is + * endIndex-beginIndex. + */ + +public class SubStringDemo1 +{ + + public static void main(String[] args) + { + String str = "Welcome"; + + String subString = str.substring(3, 6); + System.out.println("subString = " + subString); + } +} diff --git a/BasicJava/StringDemo_SubString_App/StringDemo/src/SubStringDemo2.java b/BasicJava/StringDemo_SubString_App/StringDemo/src/SubStringDemo2.java new file mode 100644 index 000000000..f24508802 --- /dev/null +++ b/BasicJava/StringDemo_SubString_App/StringDemo/src/SubStringDemo2.java @@ -0,0 +1,27 @@ +/* + * public String substring(int beginIndex) + * + * Parameters: + * ---------- + * beginIndex - the beginning index,inclusive. + * + * Returns: + * ------- + * Returns a string that is a substring of this + * string. The substring begins with the character + * at the specified index and extends to the end of + * this string. + */ + +public class SubStringDemo2 +{ + + public static void main(String[] args) + { + String str = "Welcome"; + + String subString = str.substring(3); + System.out.println("subString = " + subString); + + } +} diff --git a/BasicJava/StringDemo_SubString_App/SubStringDemo1_Output.txt b/BasicJava/StringDemo_SubString_App/SubStringDemo1_Output.txt new file mode 100644 index 000000000..417c7ab78 --- /dev/null +++ b/BasicJava/StringDemo_SubString_App/SubStringDemo1_Output.txt @@ -0,0 +1 @@ +subString = com diff --git a/BasicJava/StringDemo_SubString_App/SubStringDemo2_Output.txt b/BasicJava/StringDemo_SubString_App/SubStringDemo2_Output.txt new file mode 100644 index 000000000..227fc1292 --- /dev/null +++ b/BasicJava/StringDemo_SubString_App/SubStringDemo2_Output.txt @@ -0,0 +1 @@ +subString = come diff --git a/BasicJava/StringDemo_codePointAt_App/Output.txt b/BasicJava/StringDemo_codePointAt_App/Output.txt new file mode 100644 index 000000000..05ba0bcec --- /dev/null +++ b/BasicJava/StringDemo_codePointAt_App/Output.txt @@ -0,0 +1,2 @@ +String = JAVA +Character(unicode point) = 65 diff --git a/BasicJava/StringDemo_codePointAt_App/StringDemo/.classpath b/BasicJava/StringDemo_codePointAt_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_codePointAt_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/Manipulating Characters in a String/String_19/StringDemo/.project b/BasicJava/StringDemo_codePointAt_App/StringDemo/.project similarity index 100% rename from Later/String/Manipulating Characters in a String/String_19/StringDemo/.project rename to BasicJava/StringDemo_codePointAt_App/StringDemo/.project diff --git a/BasicJava/StringDemo_codePointAt_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_codePointAt_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_codePointAt_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_codePointAt_App/StringDemo/bin/CodePointAtDemo.class b/BasicJava/StringDemo_codePointAt_App/StringDemo/bin/CodePointAtDemo.class new file mode 100644 index 000000000..5f225284f Binary files /dev/null and b/BasicJava/StringDemo_codePointAt_App/StringDemo/bin/CodePointAtDemo.class differ diff --git a/BasicJava/StringDemo_codePointAt_App/StringDemo/src/CodePointAtDemo.java b/BasicJava/StringDemo_codePointAt_App/StringDemo/src/CodePointAtDemo.java new file mode 100644 index 000000000..b93c2a098 --- /dev/null +++ b/BasicJava/StringDemo_codePointAt_App/StringDemo/src/CodePointAtDemo.java @@ -0,0 +1,31 @@ +/* + * public int codePointAt(int index) + * + * Parameters: + * ---------- + * index - the index to the char values + * + * Returns: + * ------- + * the code point value of the character at the index + * + * Throws: + * ------ + * IndexOutOfBoundsException - if the index argument is + * negative or not less than the length of this string. + */ + +public class CodePointAtDemo +{ + + public static void main(String[] args) + { + String str = "JAVA"; + System.out.println("String = " + str); + + int retval = str.codePointAt(1); + System.out.println("Character(unicode point) = " + retval); + + } + +} \ No newline at end of file diff --git a/BasicJava/StringDemo_codePointBefore_App/Output.txt b/BasicJava/StringDemo_codePointBefore_App/Output.txt new file mode 100644 index 000000000..421a85060 --- /dev/null +++ b/BasicJava/StringDemo_codePointBefore_App/Output.txt @@ -0,0 +1,2 @@ +String = JAVA +Character(unicode point) = 74 diff --git a/BasicJava/StringDemo_codePointBefore_App/StringDemo/.classpath b/BasicJava/StringDemo_codePointBefore_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_codePointBefore_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/Manipulating Characters in a String/String_20/StringDemo/.project b/BasicJava/StringDemo_codePointBefore_App/StringDemo/.project similarity index 100% rename from Later/String/Manipulating Characters in a String/String_20/StringDemo/.project rename to BasicJava/StringDemo_codePointBefore_App/StringDemo/.project diff --git a/BasicJava/StringDemo_codePointBefore_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_codePointBefore_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_codePointBefore_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_codePointBefore_App/StringDemo/bin/CodePointBeforeDemo.class b/BasicJava/StringDemo_codePointBefore_App/StringDemo/bin/CodePointBeforeDemo.class new file mode 100644 index 000000000..5c7288814 Binary files /dev/null and b/BasicJava/StringDemo_codePointBefore_App/StringDemo/bin/CodePointBeforeDemo.class differ diff --git a/BasicJava/StringDemo_codePointBefore_App/StringDemo/src/CodePointBeforeDemo.java b/BasicJava/StringDemo_codePointBefore_App/StringDemo/src/CodePointBeforeDemo.java new file mode 100644 index 000000000..41e98735a --- /dev/null +++ b/BasicJava/StringDemo_codePointBefore_App/StringDemo/src/CodePointBeforeDemo.java @@ -0,0 +1,35 @@ +/* + * public int codePointBefore(int index) + * + * Parameters: + * ---------- + * index - the index following the code point that + * should be returned + * + * Returns: + * ------- + * the Unicode code point value before the given index. + * + * Throws: + * ------ + * IndexOutOfBoundsException - if the index argument is + * less than 1 or greater than the length of this + * string. + */ +public class CodePointBeforeDemo +{ + + public static void main(String[] args) + { + String str = "JAVA"; + System.out.println("String = " + str); + + // codepoint before index 1 i.e J + int retval = str.codePointBefore(1); + + // prints character before index1 in string + System.out.println("Character(unicode point) = " + retval); + + } + +} \ No newline at end of file diff --git a/BasicJava/StringDemo_codePointCount_App/Output.txt b/BasicJava/StringDemo_codePointCount_App/Output.txt new file mode 100644 index 000000000..43793234b --- /dev/null +++ b/BasicJava/StringDemo_codePointCount_App/Output.txt @@ -0,0 +1,2 @@ +String = JAVA programming language +Codepoint count = 7 diff --git a/BasicJava/StringDemo_codePointCount_App/StringDemo/.classpath b/BasicJava/StringDemo_codePointCount_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_codePointCount_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/Manipulating Characters in a String/String_21/StringDemo/.project b/BasicJava/StringDemo_codePointCount_App/StringDemo/.project similarity index 100% rename from Later/String/Manipulating Characters in a String/String_21/StringDemo/.project rename to BasicJava/StringDemo_codePointCount_App/StringDemo/.project diff --git a/BasicJava/StringDemo_codePointCount_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_codePointCount_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_codePointCount_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_codePointCount_App/StringDemo/bin/CodePointCountDemo.class b/BasicJava/StringDemo_codePointCount_App/StringDemo/bin/CodePointCountDemo.class new file mode 100644 index 000000000..e87ca8961 Binary files /dev/null and b/BasicJava/StringDemo_codePointCount_App/StringDemo/bin/CodePointCountDemo.class differ diff --git a/BasicJava/StringDemo_codePointCount_App/StringDemo/src/CodePointCountDemo.java b/BasicJava/StringDemo_codePointCount_App/StringDemo/src/CodePointCountDemo.java new file mode 100644 index 000000000..040410e3b --- /dev/null +++ b/BasicJava/StringDemo_codePointCount_App/StringDemo/src/CodePointCountDemo.java @@ -0,0 +1,39 @@ +/* + * public int codePointCount(int beginIndex, int + * endIndex) + * + * Parameters: + * ---------- + * beginIndex - the index to the first char of the text + * range. + * + * endIndex - the index after the last char of + * the text range. + * + * Returns: + * ------- + * the number of Unicode code points in the specified + * text range + * + * Throws: + * ------ + * IndexOutOfBoundsException - if the beginIndex is + * negative, or endIndex is larger than the length of + * this String, or beginIndex is larger than endIndex. + */ + +public class CodePointCountDemo +{ + + public static void main(String[] args) + { + String str = "JAVA programming language"; + System.out.println("String = " + str); + + int retval = str.codePointCount(1, 8); + + System.out.println("Codepoint count = " + retval); + + } + +} \ No newline at end of file diff --git a/BasicJava/StringDemo_compareToIgnoreCase_App/Output.txt b/BasicJava/StringDemo_compareToIgnoreCase_App/Output.txt new file mode 100644 index 000000000..65fc3cbc5 --- /dev/null +++ b/BasicJava/StringDemo_compareToIgnoreCase_App/Output.txt @@ -0,0 +1,2 @@ +"welcome".compareTo("WELCOME") = 32 +"welcome".compareToIgnoreCase("WELCOME") = 0 diff --git a/BasicJava/StringDemo_compareToIgnoreCase_App/StringDemo/.classpath b/BasicJava/StringDemo_compareToIgnoreCase_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_compareToIgnoreCase_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/Manipulating Characters in a String/String_22/StringDemo/.project b/BasicJava/StringDemo_compareToIgnoreCase_App/StringDemo/.project similarity index 100% rename from Later/String/Manipulating Characters in a String/String_22/StringDemo/.project rename to BasicJava/StringDemo_compareToIgnoreCase_App/StringDemo/.project diff --git a/BasicJava/StringDemo_compareToIgnoreCase_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_compareToIgnoreCase_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_compareToIgnoreCase_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_compareToIgnoreCase_App/StringDemo/bin/CompareToIgnoreCaseDemo.class b/BasicJava/StringDemo_compareToIgnoreCase_App/StringDemo/bin/CompareToIgnoreCaseDemo.class new file mode 100644 index 000000000..89eab5bdc Binary files /dev/null and b/BasicJava/StringDemo_compareToIgnoreCase_App/StringDemo/bin/CompareToIgnoreCaseDemo.class differ diff --git a/BasicJava/StringDemo_compareToIgnoreCase_App/StringDemo/src/CompareToIgnoreCaseDemo.java b/BasicJava/StringDemo_compareToIgnoreCase_App/StringDemo/src/CompareToIgnoreCaseDemo.java new file mode 100644 index 000000000..8e76a7520 --- /dev/null +++ b/BasicJava/StringDemo_compareToIgnoreCase_App/StringDemo/src/CompareToIgnoreCaseDemo.java @@ -0,0 +1,30 @@ +/* + * public int compareToIgnoreCase(String str) + * + * Parameters: + * ---------- + * str - the String to be compared. + * + * Returns: + * ------- + * Returns an integer indicating whether this string + * is greater than (result is > 0), equal to (result + * is = 0), or less than (result is < 0) the + * argument. + */ + +public class CompareToIgnoreCaseDemo +{ + public static void main(String[] args) + { + + int result = "welcome".compareTo("WELCOME"); + System.out.println("\"welcome\".compareTo(\"WELCOME\") = " + + result); + + result = "welcome".compareToIgnoreCase("WELCOME"); + System.out + .println("\"welcome\".compareToIgnoreCase(\"WELCOME\") = " + + result); + } +} \ No newline at end of file diff --git a/BasicJava/StringDemo_compareTo_App/Output.txt b/BasicJava/StringDemo_compareTo_App/Output.txt new file mode 100644 index 000000000..1d6611656 --- /dev/null +++ b/BasicJava/StringDemo_compareTo_App/Output.txt @@ -0,0 +1,3 @@ +"Welcome".compareTo("Welcome") = 0 +"Hello".compareTo("Welcome") = -15 +"Welcome".compareTo("Apple") = 22 diff --git a/BasicJava/StringDemo_compareTo_App/StringDemo/.classpath b/BasicJava/StringDemo_compareTo_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_compareTo_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/Manipulating Characters in a String/String_23/StringDemo/.project b/BasicJava/StringDemo_compareTo_App/StringDemo/.project similarity index 100% rename from Later/String/Manipulating Characters in a String/String_23/StringDemo/.project rename to BasicJava/StringDemo_compareTo_App/StringDemo/.project diff --git a/BasicJava/StringDemo_compareTo_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_compareTo_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_compareTo_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_compareTo_App/StringDemo/bin/CompareToDemo.class b/BasicJava/StringDemo_compareTo_App/StringDemo/bin/CompareToDemo.class new file mode 100644 index 000000000..cadf28810 Binary files /dev/null and b/BasicJava/StringDemo_compareTo_App/StringDemo/bin/CompareToDemo.class differ diff --git a/BasicJava/StringDemo_compareTo_App/StringDemo/src/CompareToDemo.java b/BasicJava/StringDemo_compareTo_App/StringDemo/src/CompareToDemo.java new file mode 100644 index 000000000..348f5864d --- /dev/null +++ b/BasicJava/StringDemo_compareTo_App/StringDemo/src/CompareToDemo.java @@ -0,0 +1,40 @@ +/* + * public int compareTo(String anotherString) + * + * Parameters: + * ---------- + * anotherString - the String to be compared. + * + * Returns: + * ------- + * the value 0 if the argument string is equal to + * this string; + * + * a value less than 0 if this string + * is lexicographically less than the string + * argument; + * + * a value greater than 0 if this + * string is lexicographically greater than the + * string argument. + */ + +public class CompareToDemo +{ + public static void main(String[] args) + { + + int result = "Welcome".compareTo("Welcome"); + System.out.println("\"Welcome\".compareTo(\"Welcome\") = " + + result); + + result = "Hello".compareTo("Welcome"); + System.out.println("\"Hello\".compareTo(\"Welcome\") = " + + result); + + result = "Welcome".compareTo("Apple"); + System.out.println("\"Welcome\".compareTo(\"Apple\") = " + + result); + + } +} \ No newline at end of file diff --git a/BasicJava/StringDemo_contentEquals_App/Output.txt b/BasicJava/StringDemo_contentEquals_App/Output.txt new file mode 100644 index 000000000..f1151046d --- /dev/null +++ b/BasicJava/StringDemo_contentEquals_App/Output.txt @@ -0,0 +1,2 @@ +"Welcome Peter".contentEquals("Hi") = false +"Welcome Peter".contentEquals("Welcome Peter") = true diff --git a/BasicJava/StringDemo_contentEquals_App/StringDemo/.classpath b/BasicJava/StringDemo_contentEquals_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_contentEquals_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/Manipulating Characters in a String/String_24/StringDemo/.project b/BasicJava/StringDemo_contentEquals_App/StringDemo/.project similarity index 100% rename from Later/String/Manipulating Characters in a String/String_24/StringDemo/.project rename to BasicJava/StringDemo_contentEquals_App/StringDemo/.project diff --git a/BasicJava/StringDemo_contentEquals_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_contentEquals_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_contentEquals_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_contentEquals_App/StringDemo/bin/ContentEqualsDemo.class b/BasicJava/StringDemo_contentEquals_App/StringDemo/bin/ContentEqualsDemo.class new file mode 100644 index 000000000..37c7522d6 Binary files /dev/null and b/BasicJava/StringDemo_contentEquals_App/StringDemo/bin/ContentEqualsDemo.class differ diff --git a/BasicJava/StringDemo_contentEquals_App/StringDemo/src/ContentEqualsDemo.java b/BasicJava/StringDemo_contentEquals_App/StringDemo/src/ContentEqualsDemo.java new file mode 100644 index 000000000..ddda1f468 --- /dev/null +++ b/BasicJava/StringDemo_contentEquals_App/StringDemo/src/ContentEqualsDemo.java @@ -0,0 +1,31 @@ +/* + * public boolean contentEquals(CharSequence cs) + * + * Parameters: + * ---------- + * cs - The sequence to compare this String against + * + * Returns: + * ------- + * true if this String represents the same sequence of + * char values as the specified sequence, false + * otherwise + */ + +public class ContentEqualsDemo +{ + + public static void main(String[] args) + { + String str1 = "Welcome Peter"; + String str2 = "Hi"; + String str3 = "Welcome Peter"; + + boolean result = str1.contentEquals(str2); + System.out.println("\"Welcome Peter\".contentEquals(\"Hi\") = " + result); + result = str1.contentEquals(str3); + System.out.println("\"Welcome Peter\".contentEquals(\"Welcome Peter\") = " + result); + + } + +} \ No newline at end of file diff --git a/BasicJava/StringDemo_contentEquals_sb_App/Output.txt b/BasicJava/StringDemo_contentEquals_sb_App/Output.txt new file mode 100644 index 000000000..0b815d514 --- /dev/null +++ b/BasicJava/StringDemo_contentEquals_sb_App/Output.txt @@ -0,0 +1,2 @@ +str.contentEquals(sb1) = true +str.contentEquals(sb2) = false diff --git a/BasicJava/StringDemo_contentEquals_sb_App/StringDemo/.classpath b/BasicJava/StringDemo_contentEquals_sb_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_contentEquals_sb_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/Manipulating Characters in a String/String_25/StringDemo/.project b/BasicJava/StringDemo_contentEquals_sb_App/StringDemo/.project similarity index 100% rename from Later/String/Manipulating Characters in a String/String_25/StringDemo/.project rename to BasicJava/StringDemo_contentEquals_sb_App/StringDemo/.project diff --git a/BasicJava/StringDemo_contentEquals_sb_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_contentEquals_sb_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_contentEquals_sb_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_contentEquals_sb_App/StringDemo/bin/ContentEqualsDemo.class b/BasicJava/StringDemo_contentEquals_sb_App/StringDemo/bin/ContentEqualsDemo.class new file mode 100644 index 000000000..cbcc5ff59 Binary files /dev/null and b/BasicJava/StringDemo_contentEquals_sb_App/StringDemo/bin/ContentEqualsDemo.class differ diff --git a/BasicJava/StringDemo_contentEquals_sb_App/StringDemo/src/ContentEqualsDemo.java b/BasicJava/StringDemo_contentEquals_sb_App/StringDemo/src/ContentEqualsDemo.java new file mode 100644 index 000000000..09ea0a921 --- /dev/null +++ b/BasicJava/StringDemo_contentEquals_sb_App/StringDemo/src/ContentEqualsDemo.java @@ -0,0 +1,30 @@ +/* + * public boolean contentEquals(StringBuffer sb) + * + * Parameters: + * ---------- + * sb - The StringBuffer to compare this String against + * + * Returns: + * ------- + * true if this String represents the same sequence of + * characters as the specified StringBuffer, false + * otherwise + */ +public class ContentEqualsDemo +{ + + public static void main(String[] args) + { + String str = "Welcome Peter"; + StringBuffer sb1 = new StringBuffer("Welcome Peter"); + StringBuffer sb2 = new StringBuffer("Hello"); + + boolean result = str.contentEquals(sb1); + System.out.println("str.contentEquals(sb1) = " + result); + result = str.contentEquals(sb2); + System.out.println("str.contentEquals(sb2) = " + result); + + } + +} \ No newline at end of file diff --git a/BasicJava/StringDemo_copyValueOf_App/Output.txt b/BasicJava/StringDemo_copyValueOf_App/Output.txt new file mode 100644 index 000000000..b14df6442 --- /dev/null +++ b/BasicJava/StringDemo_copyValueOf_App/Output.txt @@ -0,0 +1 @@ +Hi diff --git a/BasicJava/StringDemo_copyValueOf_App/StringDemo/.classpath b/BasicJava/StringDemo_copyValueOf_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_copyValueOf_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/Manipulating Characters in a String/String_26/StringDemo/.project b/BasicJava/StringDemo_copyValueOf_App/StringDemo/.project similarity index 100% rename from Later/String/Manipulating Characters in a String/String_26/StringDemo/.project rename to BasicJava/StringDemo_copyValueOf_App/StringDemo/.project diff --git a/BasicJava/StringDemo_copyValueOf_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_copyValueOf_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_copyValueOf_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_copyValueOf_App/StringDemo/bin/CopyValueOfDemo.class b/BasicJava/StringDemo_copyValueOf_App/StringDemo/bin/CopyValueOfDemo.class new file mode 100644 index 000000000..401034443 Binary files /dev/null and b/BasicJava/StringDemo_copyValueOf_App/StringDemo/bin/CopyValueOfDemo.class differ diff --git a/BasicJava/StringDemo_copyValueOf_App/StringDemo/src/CopyValueOfDemo.java b/BasicJava/StringDemo_copyValueOf_App/StringDemo/src/CopyValueOfDemo.java new file mode 100644 index 000000000..b7c13da75 --- /dev/null +++ b/BasicJava/StringDemo_copyValueOf_App/StringDemo/src/CopyValueOfDemo.java @@ -0,0 +1,28 @@ +/* + * public static String copyValueOf(char[] data) + * + * Equivalent to valueOf(char[]). + * + * Parameters: + * ---------- + * data - the character array. + * + * Returns: + * ------- + * a String that contains the + * characters of the character array. + */ +public class CopyValueOfDemo +{ + + public static void main(String[] args) + { + char[] charArray = + { 'H', 'i' }; + + String str = String.copyValueOf(charArray); + System.out.println(str); + + } + +} \ No newline at end of file diff --git a/BasicJava/StringDemo_copyValueOf_Offset_App/Output.txt b/BasicJava/StringDemo_copyValueOf_Offset_App/Output.txt new file mode 100644 index 000000000..6de13f060 --- /dev/null +++ b/BasicJava/StringDemo_copyValueOf_Offset_App/Output.txt @@ -0,0 +1 @@ +com diff --git a/BasicJava/StringDemo_copyValueOf_Offset_App/StringDemo/.classpath b/BasicJava/StringDemo_copyValueOf_Offset_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_copyValueOf_Offset_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/Manipulating Characters in a String/String_27/StringDemo/.project b/BasicJava/StringDemo_copyValueOf_Offset_App/StringDemo/.project similarity index 100% rename from Later/String/Manipulating Characters in a String/String_27/StringDemo/.project rename to BasicJava/StringDemo_copyValueOf_Offset_App/StringDemo/.project diff --git a/BasicJava/StringDemo_copyValueOf_Offset_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_copyValueOf_Offset_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_copyValueOf_Offset_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_copyValueOf_Offset_App/StringDemo/bin/CopyValueOfDemo.class b/BasicJava/StringDemo_copyValueOf_Offset_App/StringDemo/bin/CopyValueOfDemo.class new file mode 100644 index 000000000..024f50dbc Binary files /dev/null and b/BasicJava/StringDemo_copyValueOf_Offset_App/StringDemo/bin/CopyValueOfDemo.class differ diff --git a/BasicJava/StringDemo_copyValueOf_Offset_App/StringDemo/src/CopyValueOfDemo.java b/BasicJava/StringDemo_copyValueOf_Offset_App/StringDemo/src/CopyValueOfDemo.java new file mode 100644 index 000000000..92fc2629e --- /dev/null +++ b/BasicJava/StringDemo_copyValueOf_Offset_App/StringDemo/src/CopyValueOfDemo.java @@ -0,0 +1,40 @@ +/* + * public static String copyValueOf(char[] data, + * int offset, int count) + * + * Equivalent to valueOf(char[], int, int). + * + * Parameters: + * ---------- + * data - the character array. + * + * offset - initial offset of the subarray. + * + * count - length of the subarray. + * + * Returns: + * ------- + * a String that contains the characters of the + * specified subarray of the character array. + * + * Throws: + * ------ + * IndexOutOfBoundsException - if offset is negative, or + * count is negative, or offset+count is larger than + * data.length. + */ + +public class CopyValueOfDemo +{ + + public static void main(String[] args) + { + char[] charArray = + { 'H', 'i', ' ', 'W', 'e', 'l', 'c', 'o', 'm', 'e' }; + + String str = String.copyValueOf(charArray, 6, 3); + System.out.println(str); + + } + +} \ No newline at end of file diff --git a/BasicJava/StringDemo_endWith_App/Output.txt b/BasicJava/StringDemo_endWith_App/Output.txt new file mode 100644 index 000000000..dfa39cd81 --- /dev/null +++ b/BasicJava/StringDemo_endWith_App/Output.txt @@ -0,0 +1 @@ +result = true diff --git a/BasicJava/StringDemo_endWith_App/StringDemo/.classpath b/BasicJava/StringDemo_endWith_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_endWith_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/Manipulating Characters in a String/String_28/StringDemo/.project b/BasicJava/StringDemo_endWith_App/StringDemo/.project similarity index 100% rename from Later/String/Manipulating Characters in a String/String_28/StringDemo/.project rename to BasicJava/StringDemo_endWith_App/StringDemo/.project diff --git a/BasicJava/StringDemo_endWith_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_endWith_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_endWith_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_endWith_App/StringDemo/bin/EndsWithDemo.class b/BasicJava/StringDemo_endWith_App/StringDemo/bin/EndsWithDemo.class new file mode 100644 index 000000000..2c84d392e Binary files /dev/null and b/BasicJava/StringDemo_endWith_App/StringDemo/bin/EndsWithDemo.class differ diff --git a/BasicJava/StringDemo_endWith_App/StringDemo/src/EndsWithDemo.java b/BasicJava/StringDemo_endWith_App/StringDemo/src/EndsWithDemo.java new file mode 100644 index 000000000..093f70eac --- /dev/null +++ b/BasicJava/StringDemo_endWith_App/StringDemo/src/EndsWithDemo.java @@ -0,0 +1,23 @@ +/* + * public boolean endsWith(String suffix) + * + * Parameters: + * ---------- + * suffix - the suffix. + * + * Returns: + * ------- + * true if the character sequence represented by the + * argument is a suffix of the character sequence + * represented by this object; false otherwise. + */ + +public class EndsWithDemo +{ + public static void main(String[] args) + { + String str = "Welcome Peter"; + boolean result = str.endsWith("Peter"); + System.out.println("result = " + result); + } +} \ No newline at end of file diff --git a/BasicJava/StringDemo_equalsIgnoreCaseDemo_App/Output.txt b/BasicJava/StringDemo_equalsIgnoreCaseDemo_App/Output.txt new file mode 100644 index 000000000..9318d442e --- /dev/null +++ b/BasicJava/StringDemo_equalsIgnoreCaseDemo_App/Output.txt @@ -0,0 +1 @@ +"welcome".equalsIgnoreCase("WELCOME") = true diff --git a/BasicJava/StringDemo_equalsIgnoreCaseDemo_App/StringDemo/.classpath b/BasicJava/StringDemo_equalsIgnoreCaseDemo_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_equalsIgnoreCaseDemo_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/Manipulating Characters in a String/String_29/StringDemo/.project b/BasicJava/StringDemo_equalsIgnoreCaseDemo_App/StringDemo/.project similarity index 100% rename from Later/String/Manipulating Characters in a String/String_29/StringDemo/.project rename to BasicJava/StringDemo_equalsIgnoreCaseDemo_App/StringDemo/.project diff --git a/BasicJava/StringDemo_equalsIgnoreCaseDemo_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_equalsIgnoreCaseDemo_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_equalsIgnoreCaseDemo_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_40/StringDemo/bin/EqualsIgnoreCaseDemo.class b/BasicJava/StringDemo_equalsIgnoreCaseDemo_App/StringDemo/bin/EqualsIgnoreCaseDemo.class similarity index 85% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_40/StringDemo/bin/EqualsIgnoreCaseDemo.class rename to BasicJava/StringDemo_equalsIgnoreCaseDemo_App/StringDemo/bin/EqualsIgnoreCaseDemo.class index 5a3a51cec..5bd403375 100644 Binary files a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_40/StringDemo/bin/EqualsIgnoreCaseDemo.class and b/BasicJava/StringDemo_equalsIgnoreCaseDemo_App/StringDemo/bin/EqualsIgnoreCaseDemo.class differ diff --git a/BasicJava/StringDemo_equalsIgnoreCaseDemo_App/StringDemo/src/EqualsIgnoreCaseDemo.java b/BasicJava/StringDemo_equalsIgnoreCaseDemo_App/StringDemo/src/EqualsIgnoreCaseDemo.java new file mode 100644 index 000000000..44abdfa75 --- /dev/null +++ b/BasicJava/StringDemo_equalsIgnoreCaseDemo_App/StringDemo/src/EqualsIgnoreCaseDemo.java @@ -0,0 +1,28 @@ +/* + * public boolean equalsIgnoreCase(String + * anotherString) + * + * Parameters: + * ---------- + * anotherString - The String to compare this String + * against. + * + * Returns: + * ------- + * true if the argument is not null and it + * represents an equivalent String ignoring case; + * false otherwise. + */ + +public class EqualsIgnoreCaseDemo +{ + public static void main(String[] args) + { + + boolean result = "welcome".equalsIgnoreCase("WELCOME"); + System.out + .println("\"welcome\".equalsIgnoreCase(\"WELCOME\") = " + + result); + + } +} \ No newline at end of file diff --git a/BasicJava/StringDemo_equals_App/Output.txt b/BasicJava/StringDemo_equals_App/Output.txt new file mode 100644 index 000000000..14cfb5cae --- /dev/null +++ b/BasicJava/StringDemo_equals_App/Output.txt @@ -0,0 +1,3 @@ +"welcome".equals("welcome") = true +"welcome".equals("WELCOME") = false +"welcome".equals("hello") = false diff --git a/BasicJava/StringDemo_equals_App/StringDemo/.classpath b/BasicJava/StringDemo_equals_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_equals_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/Manipulating Characters in a String/String_30/StringDemo/.project b/BasicJava/StringDemo_equals_App/StringDemo/.project similarity index 100% rename from Later/String/Manipulating Characters in a String/String_30/StringDemo/.project rename to BasicJava/StringDemo_equals_App/StringDemo/.project diff --git a/BasicJava/StringDemo_equals_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_equals_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_equals_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_39/StringDemo/bin/EqualsDemo.class b/BasicJava/StringDemo_equals_App/StringDemo/bin/EqualsDemo.class similarity index 87% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_39/StringDemo/bin/EqualsDemo.class rename to BasicJava/StringDemo_equals_App/StringDemo/bin/EqualsDemo.class index 12b7208f5..ec6dc8da7 100644 Binary files a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_39/StringDemo/bin/EqualsDemo.class and b/BasicJava/StringDemo_equals_App/StringDemo/bin/EqualsDemo.class differ diff --git a/BasicJava/StringDemo_equals_App/StringDemo/src/EqualsDemo.java b/BasicJava/StringDemo_equals_App/StringDemo/src/EqualsDemo.java new file mode 100644 index 000000000..c813adda1 --- /dev/null +++ b/BasicJava/StringDemo_equals_App/StringDemo/src/EqualsDemo.java @@ -0,0 +1,41 @@ +/* + * public boolean equals(Object anObject) + * ------------------------------------- + * Compares this string to the specified object. The + * result is true if and only if the argument is not + * null and is a String object that represents the + * same sequence of characters as this object. + * + * Overrides: + * --------- + * equals in class Object + * + * Parameters: + * ---------- + * anObject - The object to compare this String + * against + * + * Returns: + * ------- + * true if the given object represents a String + * equivalent to this string, false otherwise + */ + +public class EqualsDemo +{ + public static void main(String[] args) + { + + boolean result = "welcome".equals("welcome"); + System.out.println("\"welcome\".equals(\"welcome\") = " + + result); + + result = "welcome".equals("WELCOME"); + System.out.println("\"welcome\".equals(\"WELCOME\") = " + + result); + + result = "welcome".equals("hello"); + System.out.println("\"welcome\".equals(\"hello\") = " + + result); + } +} \ No newline at end of file diff --git a/BasicJava/StringDemo_filename_split_App/Output.txt b/BasicJava/StringDemo_filename_split_App/Output.txt new file mode 100644 index 000000000..bb7e71d53 --- /dev/null +++ b/BasicJava/StringDemo_filename_split_App/Output.txt @@ -0,0 +1,3 @@ +Extension = html +Filename = Account +Path = /home/yahoo diff --git a/BasicJava/StringDemo_filename_split_App/StringDemo/.classpath b/BasicJava/StringDemo_filename_split_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_filename_split_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/Manipulating Characters in a String/String_31/StringDemo/.project b/BasicJava/StringDemo_filename_split_App/StringDemo/.project similarity index 100% rename from Later/String/Manipulating Characters in a String/String_31/StringDemo/.project rename to BasicJava/StringDemo_filename_split_App/StringDemo/.project diff --git a/BasicJava/StringDemo_filename_split_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_filename_split_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_filename_split_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/String/Manipulating Characters in a String/String_33/StringDemo/bin/Filename.class b/BasicJava/StringDemo_filename_split_App/StringDemo/bin/Filename.class similarity index 83% rename from Later/String/Manipulating Characters in a String/String_33/StringDemo/bin/Filename.class rename to BasicJava/StringDemo_filename_split_App/StringDemo/bin/Filename.class index ed31fa5a9..296f2b01c 100644 Binary files a/Later/String/Manipulating Characters in a String/String_33/StringDemo/bin/Filename.class and b/BasicJava/StringDemo_filename_split_App/StringDemo/bin/Filename.class differ diff --git a/Later/String/Manipulating Characters in a String/String_33/StringDemo/bin/FilenameDemo.class b/BasicJava/StringDemo_filename_split_App/StringDemo/bin/FilenameDemo.class similarity index 100% rename from Later/String/Manipulating Characters in a String/String_33/StringDemo/bin/FilenameDemo.class rename to BasicJava/StringDemo_filename_split_App/StringDemo/bin/FilenameDemo.class diff --git a/Later/String/Manipulating Characters in a String/String_33/StringDemo/src/Filename.java b/BasicJava/StringDemo_filename_split_App/StringDemo/src/Filename.java similarity index 100% rename from Later/String/Manipulating Characters in a String/String_33/StringDemo/src/Filename.java rename to BasicJava/StringDemo_filename_split_App/StringDemo/src/Filename.java diff --git a/Later/String/Manipulating Characters in a String/String_33/StringDemo/src/FilenameDemo.java b/BasicJava/StringDemo_filename_split_App/StringDemo/src/FilenameDemo.java similarity index 100% rename from Later/String/Manipulating Characters in a String/String_33/StringDemo/src/FilenameDemo.java rename to BasicJava/StringDemo_filename_split_App/StringDemo/src/FilenameDemo.java diff --git a/BasicJava/StringDemo_getBytes_App/Output.txt b/BasicJava/StringDemo_getBytes_App/Output.txt new file mode 100644 index 000000000..cfac5d073 --- /dev/null +++ b/BasicJava/StringDemo_getBytes_App/Output.txt @@ -0,0 +1,3 @@ +byteArray of "Hi" = [B@659e0bfd +72 +105 diff --git a/BasicJava/StringDemo_getBytes_App/StringDemo/.classpath b/BasicJava/StringDemo_getBytes_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_getBytes_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/Manipulating Characters in a String/String_32/StringDemo/.project b/BasicJava/StringDemo_getBytes_App/StringDemo/.project similarity index 100% rename from Later/String/Manipulating Characters in a String/String_32/StringDemo/.project rename to BasicJava/StringDemo_getBytes_App/StringDemo/.project diff --git a/BasicJava/StringDemo_getBytes_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_getBytes_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_getBytes_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_getBytes_App/StringDemo/bin/GetBytesDemo.class b/BasicJava/StringDemo_getBytes_App/StringDemo/bin/GetBytesDemo.class new file mode 100644 index 000000000..75a6e1a47 Binary files /dev/null and b/BasicJava/StringDemo_getBytes_App/StringDemo/bin/GetBytesDemo.class differ diff --git a/BasicJava/StringDemo_getBytes_App/StringDemo/src/GetBytesDemo.java b/BasicJava/StringDemo_getBytes_App/StringDemo/src/GetBytesDemo.java new file mode 100644 index 000000000..16aace5d8 --- /dev/null +++ b/BasicJava/StringDemo_getBytes_App/StringDemo/src/GetBytesDemo.java @@ -0,0 +1,27 @@ +/* + * public byte[] getBytes() + * + * Encodes this String into a sequence of bytes + * using the platform's default charset, storing the + * result into a new byte array. + * + * Returns: + * ------- + * The resultant byte array + */ + +public class GetBytesDemo +{ + public static void main(String[] args) + { + String str = "Hi"; + + byte[] byteArray = str.getBytes(); + System.out.println("byteArray of \"Hi\" = " + byteArray); + + for (byte b : byteArray) + { + System.out.println(b); + } + } +} \ No newline at end of file diff --git a/BasicJava/StringDemo_getBytes_charsetName_App/Output.txt b/BasicJava/StringDemo_getBytes_charsetName_App/Output.txt new file mode 100644 index 000000000..730176b1b --- /dev/null +++ b/BasicJava/StringDemo_getBytes_charsetName_App/Output.txt @@ -0,0 +1,7 @@ +byteArray of "Hi" with charsetName "UTF-8" = [B@1a93a7ca +72 +105 +-------------------- +byteArray of "Hi" with charsetName "ISO-8859-1" = [B@66cd51c3 +72 +105 diff --git a/BasicJava/StringDemo_getBytes_charsetName_App/StringDemo/.classpath b/BasicJava/StringDemo_getBytes_charsetName_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_getBytes_charsetName_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/Manipulating Characters in a String/String_33/StringDemo/.project b/BasicJava/StringDemo_getBytes_charsetName_App/StringDemo/.project similarity index 100% rename from Later/String/Manipulating Characters in a String/String_33/StringDemo/.project rename to BasicJava/StringDemo_getBytes_charsetName_App/StringDemo/.project diff --git a/BasicJava/StringDemo_getBytes_charsetName_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_getBytes_charsetName_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_getBytes_charsetName_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_getBytes_charsetName_App/StringDemo/bin/GetBytesDemo.class b/BasicJava/StringDemo_getBytes_charsetName_App/StringDemo/bin/GetBytesDemo.class new file mode 100644 index 000000000..1f8b4d5c6 Binary files /dev/null and b/BasicJava/StringDemo_getBytes_charsetName_App/StringDemo/bin/GetBytesDemo.class differ diff --git a/BasicJava/StringDemo_getBytes_charsetName_App/StringDemo/src/GetBytesDemo.java b/BasicJava/StringDemo_getBytes_charsetName_App/StringDemo/src/GetBytesDemo.java new file mode 100644 index 000000000..15c95eb92 --- /dev/null +++ b/BasicJava/StringDemo_getBytes_charsetName_App/StringDemo/src/GetBytesDemo.java @@ -0,0 +1,52 @@ +import java.io.UnsupportedEncodingException; + +/* + * public byte[] getBytes(String charsetName) throws + * UnsupportedEncodingException + * + * Parameters: + * ---------- + * charsetName - The name of a supported charset. + * + * Returns: + * ------- + * The resultant byte array + * + * Throws: + * ------ + * UnsupportedEncodingException - If the named + * charset is not supported + */ +public class GetBytesDemo +{ + public static void main(String[] args) + { + String str = "Hi"; + + try + { + byte[] byteArray = str.getBytes("UTF-8"); + System.out + .println("byteArray of \"Hi\" with charsetName \"UTF-8\" = " + + byteArray); + for (byte b : byteArray) + { + System.out.println(b); + } + System.out.println("--------------------"); + byteArray = str.getBytes("ISO-8859-1"); + System.out + .println("byteArray of \"Hi\" with charsetName \"ISO-8859-1\" = " + + byteArray); + for (byte b : byteArray) + { + System.out.println(b); + } + } + catch (UnsupportedEncodingException e) + { + e.printStackTrace(); + } + + } +} \ No newline at end of file diff --git a/BasicJava/StringDemo_getBytes_charset_App/Output.txt b/BasicJava/StringDemo_getBytes_charset_App/Output.txt new file mode 100644 index 000000000..ebb8506c1 --- /dev/null +++ b/BasicJava/StringDemo_getBytes_charset_App/Output.txt @@ -0,0 +1,3 @@ +byteArray of "Hi" with charsetName "ASCII" = [B@6ae40994 +72 +105 diff --git a/BasicJava/StringDemo_getBytes_charset_App/StringDemo/.classpath b/BasicJava/StringDemo_getBytes_charset_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_getBytes_charset_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/misc/String Concatenation in Java_62/StringDemo/.project b/BasicJava/StringDemo_getBytes_charset_App/StringDemo/.project similarity index 100% rename from Later/String/misc/String Concatenation in Java_62/StringDemo/.project rename to BasicJava/StringDemo_getBytes_charset_App/StringDemo/.project diff --git a/BasicJava/StringDemo_getBytes_charset_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_getBytes_charset_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_getBytes_charset_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_getBytes_charset_App/StringDemo/bin/GetBytesDemo.class b/BasicJava/StringDemo_getBytes_charset_App/StringDemo/bin/GetBytesDemo.class new file mode 100644 index 000000000..cc0d93312 Binary files /dev/null and b/BasicJava/StringDemo_getBytes_charset_App/StringDemo/bin/GetBytesDemo.class differ diff --git a/BasicJava/StringDemo_getBytes_charset_App/StringDemo/src/GetBytesDemo.java b/BasicJava/StringDemo_getBytes_charset_App/StringDemo/src/GetBytesDemo.java new file mode 100644 index 000000000..aee762d48 --- /dev/null +++ b/BasicJava/StringDemo_getBytes_charset_App/StringDemo/src/GetBytesDemo.java @@ -0,0 +1,32 @@ +/* + * public byte[] getBytes(Charset charset) + * + * Parameters: + * ---------- + * charset - The Charset to be used to encode the + * String + * + * Returns: + * ------- + * The resultant byte array + */ +public class GetBytesDemo +{ + public static void main(String[] args) + { + String str = "Hi"; + + java.nio.charset.Charset charSet = java.nio.charset.Charset + .forName("ASCII"); + + byte[] byteArray = str.getBytes(charSet); + System.out + .println("byteArray of \"Hi\" with charsetName \"ASCII\" = " + + byteArray); + for (byte b : byteArray) + { + System.out.println(b); + } + + } +} \ No newline at end of file diff --git a/BasicJava/StringDemo_indexOf_int_App/Output.txt b/BasicJava/StringDemo_indexOf_int_App/Output.txt new file mode 100644 index 000000000..c0944f535 --- /dev/null +++ b/BasicJava/StringDemo_indexOf_int_App/Output.txt @@ -0,0 +1,3 @@ +indexOf('e') = 1 +indexOf('m') = 5 +indexOf('a') = -1 diff --git a/BasicJava/StringDemo_indexOf_int_App/StringDemo/.classpath b/BasicJava/StringDemo_indexOf_int_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_indexOf_int_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/misc/String-Comparison_61/String_61/StringDemo/.project b/BasicJava/StringDemo_indexOf_int_App/StringDemo/.project similarity index 100% rename from Later/String/misc/String-Comparison_61/String_61/StringDemo/.project rename to BasicJava/StringDemo_indexOf_int_App/StringDemo/.project diff --git a/BasicJava/StringDemo_indexOf_int_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_indexOf_int_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_indexOf_int_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_indexOf_int_App/StringDemo/bin/IndexOfDemo.class b/BasicJava/StringDemo_indexOf_int_App/StringDemo/bin/IndexOfDemo.class new file mode 100644 index 000000000..fecffa7d4 Binary files /dev/null and b/BasicJava/StringDemo_indexOf_int_App/StringDemo/bin/IndexOfDemo.class differ diff --git a/BasicJava/StringDemo_indexOf_int_App/StringDemo/src/IndexOfDemo.java b/BasicJava/StringDemo_indexOf_int_App/StringDemo/src/IndexOfDemo.java new file mode 100644 index 000000000..738801135 --- /dev/null +++ b/BasicJava/StringDemo_indexOf_int_App/StringDemo/src/IndexOfDemo.java @@ -0,0 +1,32 @@ +/* + * public int indexOf(int ch) + * + * Parameters: + * ---------- + * ch - a character (Unicode code point). + * + * Returns: + * -------- + * Returns the index within this string of the first + * occurrence of the specified character. , or -1 if + * the character does not occur. + */ + +public class IndexOfDemo +{ + + public static void main(String[] args) + { + String str = "Welcome"; + + int indexPosition = str.indexOf('e'); + System.out.println("indexOf(\'e\') = " + indexPosition); + + indexPosition = str.indexOf(109); //Unicode value of m is 109 + System.out.println("indexOf(\'m\') = " + indexPosition); + + indexPosition = str.indexOf('a'); + System.out.println("indexOf(\'a\') = " + indexPosition); + + } +} diff --git a/BasicJava/StringDemo_indexOf_int_fromIndex_App/Output.txt b/BasicJava/StringDemo_indexOf_int_fromIndex_App/Output.txt new file mode 100644 index 000000000..b9f542391 --- /dev/null +++ b/BasicJava/StringDemo_indexOf_int_fromIndex_App/Output.txt @@ -0,0 +1 @@ +indexOf('e',2) = 4 diff --git a/BasicJava/StringDemo_indexOf_int_fromIndex_App/StringDemo/.classpath b/BasicJava/StringDemo_indexOf_int_fromIndex_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_indexOf_int_fromIndex_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/misc/String_45/StringDemo/.project b/BasicJava/StringDemo_indexOf_int_fromIndex_App/StringDemo/.project similarity index 100% rename from Later/String/misc/String_45/StringDemo/.project rename to BasicJava/StringDemo_indexOf_int_fromIndex_App/StringDemo/.project diff --git a/BasicJava/StringDemo_indexOf_int_fromIndex_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_indexOf_int_fromIndex_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_indexOf_int_fromIndex_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_indexOf_int_fromIndex_App/StringDemo/bin/IndexOfDemo.class b/BasicJava/StringDemo_indexOf_int_fromIndex_App/StringDemo/bin/IndexOfDemo.class new file mode 100644 index 000000000..7d9245bb0 Binary files /dev/null and b/BasicJava/StringDemo_indexOf_int_fromIndex_App/StringDemo/bin/IndexOfDemo.class differ diff --git a/BasicJava/StringDemo_indexOf_int_fromIndex_App/StringDemo/src/IndexOfDemo.java b/BasicJava/StringDemo_indexOf_int_fromIndex_App/StringDemo/src/IndexOfDemo.java new file mode 100644 index 000000000..d3368c31e --- /dev/null +++ b/BasicJava/StringDemo_indexOf_int_fromIndex_App/StringDemo/src/IndexOfDemo.java @@ -0,0 +1,27 @@ +/* + * public int indexOf(int ch, int fromIndex) + * + * Parameters: + * ---------- + * ch - a character (Unicode code point). + * fromIndex - the index to start the search from. + * + * Returns: + * ------- + * Returns the index within this string of the first + * occurrence of the specified character, starting + * the search at the specified index. , or -1 if the + * character does not occur. + */ + +public class IndexOfDemo +{ + + public static void main(String[] args) + { + String str = "Welceee"; + int indexPosition = str.indexOf('e', 2); + System.out.println("indexOf(\'e\',2) = " + indexPosition); + + } +} diff --git a/BasicJava/StringDemo_indexOf_str_App/Output.txt b/BasicJava/StringDemo_indexOf_str_App/Output.txt new file mode 100644 index 000000000..9779a926e --- /dev/null +++ b/BasicJava/StringDemo_indexOf_str_App/Output.txt @@ -0,0 +1,2 @@ +indexOf("com") = 3 +indexOf("abc") = -1 diff --git a/BasicJava/StringDemo_indexOf_str_App/StringDemo/.classpath b/BasicJava/StringDemo_indexOf_str_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_indexOf_str_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/misc/String_46/StringDemo/.project b/BasicJava/StringDemo_indexOf_str_App/StringDemo/.project similarity index 100% rename from Later/String/misc/String_46/StringDemo/.project rename to BasicJava/StringDemo_indexOf_str_App/StringDemo/.project diff --git a/BasicJava/StringDemo_indexOf_str_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_indexOf_str_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_indexOf_str_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_indexOf_str_App/StringDemo/bin/IndexOfDemo.class b/BasicJava/StringDemo_indexOf_str_App/StringDemo/bin/IndexOfDemo.class new file mode 100644 index 000000000..d8a4bd481 Binary files /dev/null and b/BasicJava/StringDemo_indexOf_str_App/StringDemo/bin/IndexOfDemo.class differ diff --git a/BasicJava/StringDemo_indexOf_str_App/StringDemo/src/IndexOfDemo.java b/BasicJava/StringDemo_indexOf_str_App/StringDemo/src/IndexOfDemo.java new file mode 100644 index 000000000..37eb6d78d --- /dev/null +++ b/BasicJava/StringDemo_indexOf_str_App/StringDemo/src/IndexOfDemo.java @@ -0,0 +1,29 @@ +/* + * public int indexOf(String str) + * + * Parameters: + * ---------- + * str - the substring to search for. + * + * Returns: + * ------- + * the index of the first occurrence of the + * specified substring, or -1 if there is no such + * occurrence. + */ + +public class IndexOfDemo +{ + + public static void main(String[] args) + { + String str = "Welcome.com"; + + int indexPosition = str.indexOf("com"); + System.out.println("indexOf(\"com\") = " + indexPosition); + + indexPosition = str.indexOf("abc"); + System.out.println("indexOf(\"abc\") = " + indexPosition); + + } +} diff --git a/BasicJava/StringDemo_indexOf_str_fromIndex_App/Output.txt b/BasicJava/StringDemo_indexOf_str_fromIndex_App/Output.txt new file mode 100644 index 000000000..56c5dd241 --- /dev/null +++ b/BasicJava/StringDemo_indexOf_str_fromIndex_App/Output.txt @@ -0,0 +1 @@ +indexOf("com",2) = 4 diff --git a/BasicJava/StringDemo_indexOf_str_fromIndex_App/StringDemo/.classpath b/BasicJava/StringDemo_indexOf_str_fromIndex_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_indexOf_str_fromIndex_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/misc/String_47/StringDemo/.project b/BasicJava/StringDemo_indexOf_str_fromIndex_App/StringDemo/.project similarity index 100% rename from Later/String/misc/String_47/StringDemo/.project rename to BasicJava/StringDemo_indexOf_str_fromIndex_App/StringDemo/.project diff --git a/BasicJava/StringDemo_indexOf_str_fromIndex_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_indexOf_str_fromIndex_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_indexOf_str_fromIndex_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_indexOf_str_fromIndex_App/StringDemo/bin/IndexOfDemo.class b/BasicJava/StringDemo_indexOf_str_fromIndex_App/StringDemo/bin/IndexOfDemo.class new file mode 100644 index 000000000..e6889cf54 Binary files /dev/null and b/BasicJava/StringDemo_indexOf_str_fromIndex_App/StringDemo/bin/IndexOfDemo.class differ diff --git a/BasicJava/StringDemo_indexOf_str_fromIndex_App/StringDemo/src/IndexOfDemo.java b/BasicJava/StringDemo_indexOf_str_fromIndex_App/StringDemo/src/IndexOfDemo.java new file mode 100644 index 000000000..7d107415f --- /dev/null +++ b/BasicJava/StringDemo_indexOf_str_fromIndex_App/StringDemo/src/IndexOfDemo.java @@ -0,0 +1,26 @@ +/* + * public int indexOf(String str, int fromIndex) + * + * Parameters: + * ---------- + * str - the substring to search for. + * fromIndex - the index from which to start the + * search. + * + * Returns: + * ------- + * the index of the first occurrence of the + * specified substring, starting at the specified + * index, or -1 if there is no such occurrence. + */ + +public class IndexOfDemo +{ + + public static void main(String[] args) + { + String str = "com.com.com"; + int indexPosition = str.indexOf("com", 2); + System.out.println("indexOf(\"com\",2) = " + indexPosition); + } +} diff --git a/BasicJava/StringDemo_intern_App/Output.txt b/BasicJava/StringDemo_intern_App/Output.txt new file mode 100644 index 000000000..807b973d7 --- /dev/null +++ b/BasicJava/StringDemo_intern_App/Output.txt @@ -0,0 +1,3 @@ +hello +false +true diff --git a/BasicJava/StringDemo_intern_App/StringDemo/.classpath b/BasicJava/StringDemo_intern_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_intern_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/misc/String_48/StringDemo/.project b/BasicJava/StringDemo_intern_App/StringDemo/.project similarity index 100% rename from Later/String/misc/String_48/StringDemo/.project rename to BasicJava/StringDemo_intern_App/StringDemo/.project diff --git a/BasicJava/StringDemo_intern_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_intern_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_intern_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_intern_App/StringDemo/bin/InternDemo.class b/BasicJava/StringDemo_intern_App/StringDemo/bin/InternDemo.class new file mode 100644 index 000000000..48c37f329 Binary files /dev/null and b/BasicJava/StringDemo_intern_App/StringDemo/bin/InternDemo.class differ diff --git a/Later/String/misc/String_49/StringDemo/src/InternDemo.java b/BasicJava/StringDemo_intern_App/StringDemo/src/InternDemo.java similarity index 95% rename from Later/String/misc/String_49/StringDemo/src/InternDemo.java rename to BasicJava/StringDemo_intern_App/StringDemo/src/InternDemo.java index b6807a839..9a93cd271 100644 --- a/Later/String/misc/String_49/StringDemo/src/InternDemo.java +++ b/BasicJava/StringDemo_intern_App/StringDemo/src/InternDemo.java @@ -20,6 +20,7 @@ public static void main(String[] args) */ String s3 = s1.intern(); + System.out.println(s3); /* * false because reference is different diff --git a/BasicJava/StringDemo_isEmpty_App/Output.txt b/BasicJava/StringDemo_isEmpty_App/Output.txt new file mode 100644 index 000000000..da29283aa --- /dev/null +++ b/BasicJava/StringDemo_isEmpty_App/Output.txt @@ -0,0 +1,2 @@ +true +false diff --git a/BasicJava/StringDemo_isEmpty_App/StringDemo/.classpath b/BasicJava/StringDemo_isEmpty_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_isEmpty_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/misc/String_49/StringDemo/.project b/BasicJava/StringDemo_isEmpty_App/StringDemo/.project similarity index 100% rename from Later/String/misc/String_49/StringDemo/.project rename to BasicJava/StringDemo_isEmpty_App/StringDemo/.project diff --git a/BasicJava/StringDemo_isEmpty_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_isEmpty_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_isEmpty_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/String/misc/String_48/StringDemo/bin/IsEmptyDemo.class b/BasicJava/StringDemo_isEmpty_App/StringDemo/bin/IsEmptyDemo.class similarity index 100% rename from Later/String/misc/String_48/StringDemo/bin/IsEmptyDemo.class rename to BasicJava/StringDemo_isEmpty_App/StringDemo/bin/IsEmptyDemo.class diff --git a/Later/String/misc/String_48/StringDemo/src/IsEmptyDemo.java b/BasicJava/StringDemo_isEmpty_App/StringDemo/src/IsEmptyDemo.java similarity index 100% rename from Later/String/misc/String_48/StringDemo/src/IsEmptyDemo.java rename to BasicJava/StringDemo_isEmpty_App/StringDemo/src/IsEmptyDemo.java diff --git a/BasicJava/StringDemo_join_App/Output.txt b/BasicJava/StringDemo_join_App/Output.txt new file mode 100644 index 000000000..469cd1c32 --- /dev/null +++ b/BasicJava/StringDemo_join_App/Output.txt @@ -0,0 +1 @@ +JoinString = welcome_to_India diff --git a/BasicJava/StringDemo_join_App/StringDemo/.classpath b/BasicJava/StringDemo_join_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_join_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/misc/String_50/StringDemo/.project b/BasicJava/StringDemo_join_App/StringDemo/.project similarity index 100% rename from Later/String/misc/String_50/StringDemo/.project rename to BasicJava/StringDemo_join_App/StringDemo/.project diff --git a/BasicJava/StringDemo_join_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_join_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_join_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_join_App/StringDemo/bin/JoinDemo.class b/BasicJava/StringDemo_join_App/StringDemo/bin/JoinDemo.class new file mode 100644 index 000000000..6c385135d Binary files /dev/null and b/BasicJava/StringDemo_join_App/StringDemo/bin/JoinDemo.class differ diff --git a/BasicJava/StringDemo_join_App/StringDemo/src/JoinDemo.java b/BasicJava/StringDemo_join_App/StringDemo/src/JoinDemo.java new file mode 100644 index 000000000..552820b39 --- /dev/null +++ b/BasicJava/StringDemo_join_App/StringDemo/src/JoinDemo.java @@ -0,0 +1,35 @@ +/* + * public static String join(CharSequence delimiter, + * CharSequence... elements) + * + * Parameters: + * ----------- + * delimiter - the delimiter that separates each element + * + * elements - the elements to join together. + * + * Returns: + * -------- + * a new String that is composed of the elements + * separated by the delimiter. + * + * Throws: + * ------- + * NullPointerException - If delimiter or elements is + * null + */ + +public class JoinDemo +{ + public static void main(String[] args) + { + String str1 = "welcome"; + String str2 = "to"; + String str3 = "India"; + + String joinString = String.join("_", str1, str2, str3); + System.out.println("JoinString = " + joinString); + + } + +} \ No newline at end of file diff --git a/BasicJava/StringDemo_lastIndexOf_int_fromIndex_App/Output.txt b/BasicJava/StringDemo_lastIndexOf_int_fromIndex_App/Output.txt new file mode 100644 index 000000000..4e1fd581b --- /dev/null +++ b/BasicJava/StringDemo_lastIndexOf_int_fromIndex_App/Output.txt @@ -0,0 +1 @@ +lastIndexOf('e',5) = 4 diff --git a/BasicJava/StringDemo_lastIndexOf_int_fromIndex_App/StringDemo/.classpath b/BasicJava/StringDemo_lastIndexOf_int_fromIndex_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_lastIndexOf_int_fromIndex_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/misc/String_51/StringDemo/.project b/BasicJava/StringDemo_lastIndexOf_int_fromIndex_App/StringDemo/.project similarity index 100% rename from Later/String/misc/String_51/StringDemo/.project rename to BasicJava/StringDemo_lastIndexOf_int_fromIndex_App/StringDemo/.project diff --git a/BasicJava/StringDemo_lastIndexOf_int_fromIndex_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_lastIndexOf_int_fromIndex_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_lastIndexOf_int_fromIndex_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_lastIndexOf_int_fromIndex_App/StringDemo/bin/LastIndexOfDemo.class b/BasicJava/StringDemo_lastIndexOf_int_fromIndex_App/StringDemo/bin/LastIndexOfDemo.class new file mode 100644 index 000000000..5b6317d01 Binary files /dev/null and b/BasicJava/StringDemo_lastIndexOf_int_fromIndex_App/StringDemo/bin/LastIndexOfDemo.class differ diff --git a/BasicJava/StringDemo_lastIndexOf_int_fromIndex_App/StringDemo/src/LastIndexOfDemo.java b/BasicJava/StringDemo_lastIndexOf_int_fromIndex_App/StringDemo/src/LastIndexOfDemo.java new file mode 100644 index 000000000..820a53ffb --- /dev/null +++ b/BasicJava/StringDemo_lastIndexOf_int_fromIndex_App/StringDemo/src/LastIndexOfDemo.java @@ -0,0 +1,27 @@ +/* + * public int lastIndexOf(int ch, int fromIndex) + * + * Parameters: + * ---------- * + * ch - a character (Unicode code point). + * fromIndex - the index to start the search from. + * + * Returns: + * ------- + * Returns the index within this string of the last + * occurrence of the specified character, starting + * the search at the specified index. , or -1 if the + * character does not occur. + */ + +public class LastIndexOfDemo +{ + + public static void main(String[] args) + { + String str = "Welcece"; + int indexPosition = str.lastIndexOf('e',5); + System.out.println("lastIndexOf(\'e\',5) = " + indexPosition); + + } +} diff --git a/BasicJava/StringDemo_lastIndexOf_str_App/Output.txt b/BasicJava/StringDemo_lastIndexOf_str_App/Output.txt new file mode 100644 index 000000000..decc0033c --- /dev/null +++ b/BasicJava/StringDemo_lastIndexOf_str_App/Output.txt @@ -0,0 +1,2 @@ +lastIndexOf("com") = 8 +lastIndexOf("abc") = -1 diff --git a/BasicJava/StringDemo_lastIndexOf_str_App/StringDemo/.classpath b/BasicJava/StringDemo_lastIndexOf_str_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_lastIndexOf_str_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/misc/String_52/StringDemo/.project b/BasicJava/StringDemo_lastIndexOf_str_App/StringDemo/.project similarity index 100% rename from Later/String/misc/String_52/StringDemo/.project rename to BasicJava/StringDemo_lastIndexOf_str_App/StringDemo/.project diff --git a/BasicJava/StringDemo_lastIndexOf_str_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_lastIndexOf_str_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_lastIndexOf_str_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_lastIndexOf_str_App/StringDemo/bin/LastIndexOfDemo.class b/BasicJava/StringDemo_lastIndexOf_str_App/StringDemo/bin/LastIndexOfDemo.class new file mode 100644 index 000000000..2b09317bd Binary files /dev/null and b/BasicJava/StringDemo_lastIndexOf_str_App/StringDemo/bin/LastIndexOfDemo.class differ diff --git a/BasicJava/StringDemo_lastIndexOf_str_App/StringDemo/src/LastIndexOfDemo.java b/BasicJava/StringDemo_lastIndexOf_str_App/StringDemo/src/LastIndexOfDemo.java new file mode 100644 index 000000000..085149e33 --- /dev/null +++ b/BasicJava/StringDemo_lastIndexOf_str_App/StringDemo/src/LastIndexOfDemo.java @@ -0,0 +1,28 @@ +/* + * public int lastIndexOf(String str) + * + * Parameters: + * ---------- + * str - the substring to search for. + * + * Returns: + * ------- + * the index of the last occurrence of the specified + * substring, or -1 if there is no such occurrence. + */ + +public class LastIndexOfDemo +{ + + public static void main(String[] args) + { + String str = "Welcome.com"; + + int indexPosition = str.lastIndexOf("com"); + System.out.println("lastIndexOf(\"com\") = " + indexPosition); + + indexPosition = str.lastIndexOf("abc"); + System.out.println("lastIndexOf(\"abc\") = " + indexPosition); + + } +} diff --git a/BasicJava/StringDemo_lastIndexOf_str_fromIndex_App/Output.txt b/BasicJava/StringDemo_lastIndexOf_str_fromIndex_App/Output.txt new file mode 100644 index 000000000..b9ee3dd9a --- /dev/null +++ b/BasicJava/StringDemo_lastIndexOf_str_fromIndex_App/Output.txt @@ -0,0 +1 @@ +lastIndexOf("com",7) = 4 diff --git a/BasicJava/StringDemo_lastIndexOf_str_fromIndex_App/StringDemo/.classpath b/BasicJava/StringDemo_lastIndexOf_str_fromIndex_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_lastIndexOf_str_fromIndex_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/misc/String_53/StringDemo/.project b/BasicJava/StringDemo_lastIndexOf_str_fromIndex_App/StringDemo/.project similarity index 100% rename from Later/String/misc/String_53/StringDemo/.project rename to BasicJava/StringDemo_lastIndexOf_str_fromIndex_App/StringDemo/.project diff --git a/BasicJava/StringDemo_lastIndexOf_str_fromIndex_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_lastIndexOf_str_fromIndex_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_lastIndexOf_str_fromIndex_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_lastIndexOf_str_fromIndex_App/StringDemo/bin/LastIndexOfDemo.class b/BasicJava/StringDemo_lastIndexOf_str_fromIndex_App/StringDemo/bin/LastIndexOfDemo.class new file mode 100644 index 000000000..d53d43aa4 Binary files /dev/null and b/BasicJava/StringDemo_lastIndexOf_str_fromIndex_App/StringDemo/bin/LastIndexOfDemo.class differ diff --git a/BasicJava/StringDemo_lastIndexOf_str_fromIndex_App/StringDemo/src/LastIndexOfDemo.java b/BasicJava/StringDemo_lastIndexOf_str_fromIndex_App/StringDemo/src/LastIndexOfDemo.java new file mode 100644 index 000000000..ca256fce2 --- /dev/null +++ b/BasicJava/StringDemo_lastIndexOf_str_fromIndex_App/StringDemo/src/LastIndexOfDemo.java @@ -0,0 +1,28 @@ +/* + * public int lastIndexOf(String str, int fromIndex) + * + * Parameters: + * ---------- + * str - the substring to search for. + * fromIndex - the index to start the search from. + * + * Returns: + * ------- + * the index of the last occurrence of the specified + * substring, searching backward from the specified + * index, or -1 if there is no such occurrence. + */ + +public class LastIndexOfDemo +{ + + public static void main(String[] args) + { + String str = "com.com.com"; + + int indexPosition = str.lastIndexOf("com", 7); + System.out.println("lastIndexOf(\"com\",7) = " + + indexPosition); + + } +} diff --git a/BasicJava/StringDemo_matches_App/Output.txt b/BasicJava/StringDemo_matches_App/Output.txt new file mode 100644 index 000000000..6794c27f2 --- /dev/null +++ b/BasicJava/StringDemo_matches_App/Output.txt @@ -0,0 +1,2 @@ +"Welcome to ramj2ee.com".matches("Welcome(.*)") = true +"Welcome to ramj2ee.com".matches("(.*)ramj2ee(.*)") = true diff --git a/BasicJava/StringDemo_matches_App/StringDemo/.classpath b/BasicJava/StringDemo_matches_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_matches_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/misc/String_54/StringDemo/.project b/BasicJava/StringDemo_matches_App/StringDemo/.project similarity index 100% rename from Later/String/misc/String_54/StringDemo/.project rename to BasicJava/StringDemo_matches_App/StringDemo/.project diff --git a/BasicJava/StringDemo_matches_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_matches_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_matches_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_43/StringDemo/bin/MatchesDemo.class b/BasicJava/StringDemo_matches_App/StringDemo/bin/MatchesDemo.class similarity index 86% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_43/StringDemo/bin/MatchesDemo.class rename to BasicJava/StringDemo_matches_App/StringDemo/bin/MatchesDemo.class index 1312811db..6260d9643 100644 Binary files a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_43/StringDemo/bin/MatchesDemo.class and b/BasicJava/StringDemo_matches_App/StringDemo/bin/MatchesDemo.class differ diff --git a/BasicJava/StringDemo_matches_App/StringDemo/src/MatchesDemo.java b/BasicJava/StringDemo_matches_App/StringDemo/src/MatchesDemo.java new file mode 100644 index 000000000..3ccdc48c7 --- /dev/null +++ b/BasicJava/StringDemo_matches_App/StringDemo/src/MatchesDemo.java @@ -0,0 +1,36 @@ +/* + * public boolean matches(String regex) + * + * Parameters: + * ---------- + * regex - the regular expression to which this + * string is to be matched + * + * Returns: + * ------- + * true if, and only if, this string matches the + * given regular expression + * + * Throws: + * ------ + * PatternSyntaxException - if the regular + * expression's syntax is invalid + */ + +public class MatchesDemo +{ + public static void main(String[] args) + { + + String str = new String("Welcome to ramj2ee.com"); + + System.out + .print("\"Welcome to ramj2ee.com\".matches(\"Welcome(.*)\") = "); + System.out.println(str.matches("Welcome(.*)")); + + System.out + .print("\"Welcome to ramj2ee.com\".matches(\"(.*)ramj2ee(.*)\") = "); + System.out.println(str.matches("(.*)ramj2ee(.*)")); + + } +} \ No newline at end of file diff --git a/BasicJava/StringDemo_regionMatches_App/Output.txt b/BasicJava/StringDemo_regionMatches_App/Output.txt new file mode 100644 index 000000000..ecf8365bf --- /dev/null +++ b/BasicJava/StringDemo_regionMatches_App/Output.txt @@ -0,0 +1,3 @@ +"Welcome to ramj2ee.com".regionMatches(11,"ramj2ee",0,7) = true +"Welcome to ramj2ee.com".regionMatches(11,"RAMJ2EE",0,7) = false +"Welcome to ramj2ee.com".regionMatches(11,"hello",0,7) = false diff --git a/BasicJava/StringDemo_regionMatches_App/StringDemo/.classpath b/BasicJava/StringDemo_regionMatches_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_regionMatches_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/misc/String_55/StringDemo/.project b/BasicJava/StringDemo_regionMatches_App/StringDemo/.project similarity index 100% rename from Later/String/misc/String_55/StringDemo/.project rename to BasicJava/StringDemo_regionMatches_App/StringDemo/.project diff --git a/BasicJava/StringDemo_regionMatches_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_regionMatches_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_regionMatches_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_regionMatches_App/StringDemo/bin/RegionMatchesDemo.class b/BasicJava/StringDemo_regionMatches_App/StringDemo/bin/RegionMatchesDemo.class new file mode 100644 index 000000000..a14aae311 Binary files /dev/null and b/BasicJava/StringDemo_regionMatches_App/StringDemo/bin/RegionMatchesDemo.class differ diff --git a/BasicJava/StringDemo_regionMatches_App/StringDemo/src/RegionMatchesDemo.java b/BasicJava/StringDemo_regionMatches_App/StringDemo/src/RegionMatchesDemo.java new file mode 100644 index 000000000..5b2edbc0d --- /dev/null +++ b/BasicJava/StringDemo_regionMatches_App/StringDemo/src/RegionMatchesDemo.java @@ -0,0 +1,48 @@ +/* + * public boolean regionMatches(int toffset, + * String other, + * int ooffset, + * int len) + * + * Parameters: + * ---------- + * toffset - the starting offset of the subregion in + * this string. + * + * other - the string argument. + * + * ooffset - the starting offset of the subregion in + * the string argument. + * + * len - the number of characters to compare. + * + * Returns: + * ------- + * true if the specified subregion of this string + * exactly matches the specified subregion of the + * string argument; false otherwise. + */ + +public class RegionMatchesDemo +{ + public static void main(String[] args) + { + + String str1 = new String("Welcome to ramj2ee.com"); + String str2 = new String("ramj2ee"); + String str3 = new String("RAMJ2EE"); + String str4 = new String("hello"); + + System.out + .print("\"Welcome to ramj2ee.com\".regionMatches(11,\"ramj2ee\",0,7) = "); + System.out.println(str1.regionMatches(11, str2, 0, 7)); + + System.out + .print("\"Welcome to ramj2ee.com\".regionMatches(11,\"RAMJ2EE\",0,7) = "); + System.out.println(str1.regionMatches(11, str3, 0, 7)); + + System.out + .print("\"Welcome to ramj2ee.com\".regionMatches(11,\"hello\",0,7) = "); + System.out.println(str1.regionMatches(11, str4, 0, 7)); + } +} \ No newline at end of file diff --git a/BasicJava/StringDemo_regionMatches_IgnoreCase_App/Output.txt b/BasicJava/StringDemo_regionMatches_IgnoreCase_App/Output.txt new file mode 100644 index 000000000..beda40bce --- /dev/null +++ b/BasicJava/StringDemo_regionMatches_IgnoreCase_App/Output.txt @@ -0,0 +1,2 @@ +"Welcome to ramj2ee.com".regionMatches(false,11,"RAMJ2EE",0,7) = false +"Welcome to ramj2ee.com".regionMatches(true,11,"RAMJ2EE",0,7) = true diff --git a/BasicJava/StringDemo_regionMatches_IgnoreCase_App/StringDemo/.classpath b/BasicJava/StringDemo_regionMatches_IgnoreCase_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_regionMatches_IgnoreCase_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/misc/String_56/StringDemo/.project b/BasicJava/StringDemo_regionMatches_IgnoreCase_App/StringDemo/.project similarity index 100% rename from Later/String/misc/String_56/StringDemo/.project rename to BasicJava/StringDemo_regionMatches_IgnoreCase_App/StringDemo/.project diff --git a/BasicJava/StringDemo_regionMatches_IgnoreCase_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_regionMatches_IgnoreCase_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_regionMatches_IgnoreCase_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_regionMatches_IgnoreCase_App/StringDemo/bin/RegionMatchesDemo.class b/BasicJava/StringDemo_regionMatches_IgnoreCase_App/StringDemo/bin/RegionMatchesDemo.class new file mode 100644 index 000000000..f3677025f Binary files /dev/null and b/BasicJava/StringDemo_regionMatches_IgnoreCase_App/StringDemo/bin/RegionMatchesDemo.class differ diff --git a/BasicJava/StringDemo_regionMatches_IgnoreCase_App/StringDemo/src/RegionMatchesDemo.java b/BasicJava/StringDemo_regionMatches_IgnoreCase_App/StringDemo/src/RegionMatchesDemo.java new file mode 100644 index 000000000..8f31d25de --- /dev/null +++ b/BasicJava/StringDemo_regionMatches_IgnoreCase_App/StringDemo/src/RegionMatchesDemo.java @@ -0,0 +1,49 @@ +/* + * public boolean regionMatches(boolean ignoreCase, + * int toffset, + * String other, + * int ooffset, + * int len) + * + * Parameters: + * ---------- + * ignoreCase - if true, ignore case when comparing + * characters. + * + * toffset - the starting offset of the subregion in + * this string. + * + * other - the string argument. + * + * ooffset - the starting offset of the subregion in + * the string argument. + * + * len - the number of characters to compare. + * + * Returns: + * ------- + * true if the specified subregion of this string + * matches the specified subregion of the string + * argument; false otherwise. Whether the matching + * is exact or case insensitive depends on the + * ignoreCase argument. + */ + +public class RegionMatchesDemo +{ + public static void main(String[] args) + { + + String str1 = new String("Welcome to ramj2ee.com"); + String str2 = new String("RAMJ2EE"); + + System.out + .print("\"Welcome to ramj2ee.com\".regionMatches(false,11,\"RAMJ2EE\",0,7) = "); + System.out.println(str1.regionMatches(false, 11, str2, 0, 7)); + + System.out + .print("\"Welcome to ramj2ee.com\".regionMatches(true,11,\"RAMJ2EE\",0,7) = "); + System.out.println(str1.regionMatches(true, 11, str2, 0, 7)); + + } +} \ No newline at end of file diff --git a/BasicJava/StringDemo_regionMatches_example_App/Output.txt b/BasicJava/StringDemo_regionMatches_example_App/Output.txt new file mode 100644 index 000000000..195b333ac --- /dev/null +++ b/BasicJava/StringDemo_regionMatches_example_App/Output.txt @@ -0,0 +1,2 @@ +foundIt = true +Eggs diff --git a/BasicJava/StringDemo_regionMatches_example_App/StringDemo/.classpath b/BasicJava/StringDemo_regionMatches_example_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_regionMatches_example_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/misc/String_57/StringDemo/.project b/BasicJava/StringDemo_regionMatches_example_App/StringDemo/.project similarity index 100% rename from Later/String/misc/String_57/StringDemo/.project rename to BasicJava/StringDemo_regionMatches_example_App/StringDemo/.project diff --git a/BasicJava/StringDemo_regionMatches_example_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_regionMatches_example_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_regionMatches_example_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_44/StringDemo/bin/RegionMatchesDemo.class b/BasicJava/StringDemo_regionMatches_example_App/StringDemo/bin/RegionMatchesDemo.class similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_44/StringDemo/bin/RegionMatchesDemo.class rename to BasicJava/StringDemo_regionMatches_example_App/StringDemo/bin/RegionMatchesDemo.class diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_44/StringDemo/src/RegionMatchesDemo.java b/BasicJava/StringDemo_regionMatches_example_App/StringDemo/src/RegionMatchesDemo.java similarity index 100% rename from Later/String/Comparing_Strings_and_Portions_of_Strings/String_44/StringDemo/src/RegionMatchesDemo.java rename to BasicJava/StringDemo_regionMatches_example_App/StringDemo/src/RegionMatchesDemo.java diff --git a/BasicJava/StringDemo_startsWith_App/Output.txt b/BasicJava/StringDemo_startsWith_App/Output.txt new file mode 100644 index 000000000..dfa39cd81 --- /dev/null +++ b/BasicJava/StringDemo_startsWith_App/Output.txt @@ -0,0 +1 @@ +result = true diff --git a/BasicJava/StringDemo_startsWith_App/StringDemo/.classpath b/BasicJava/StringDemo_startsWith_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_startsWith_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/misc/String_58/StringDemo/.project b/BasicJava/StringDemo_startsWith_App/StringDemo/.project similarity index 100% rename from Later/String/misc/String_58/StringDemo/.project rename to BasicJava/StringDemo_startsWith_App/StringDemo/.project diff --git a/BasicJava/StringDemo_startsWith_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_startsWith_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_startsWith_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_startsWith_App/StringDemo/bin/StartsWithDemo.class b/BasicJava/StringDemo_startsWith_App/StringDemo/bin/StartsWithDemo.class new file mode 100644 index 000000000..afb3d736e Binary files /dev/null and b/BasicJava/StringDemo_startsWith_App/StringDemo/bin/StartsWithDemo.class differ diff --git a/BasicJava/StringDemo_startsWith_App/StringDemo/src/StartsWithDemo.java b/BasicJava/StringDemo_startsWith_App/StringDemo/src/StartsWithDemo.java new file mode 100644 index 000000000..a25091ca3 --- /dev/null +++ b/BasicJava/StringDemo_startsWith_App/StringDemo/src/StartsWithDemo.java @@ -0,0 +1,23 @@ +/* + * public boolean startsWith(String prefix) + * + * Parameters: + * ---------- + * prefix - the prefix. + * + * Returns: + * ------- + * true if the character sequence represented + * by the argument is a prefix of the + * character sequence represented by this string; false + * otherwise. + */ +public class StartsWithDemo +{ + public static void main(String[] args) + { + String str = "Hi Peter"; + boolean result = str.startsWith("Hi"); + System.out.println("result = " + result); + } +} \ No newline at end of file diff --git a/BasicJava/StringDemo_startsWith_Offset_App/Output.txt b/BasicJava/StringDemo_startsWith_Offset_App/Output.txt new file mode 100644 index 000000000..ce5c2e06b --- /dev/null +++ b/BasicJava/StringDemo_startsWith_Offset_App/Output.txt @@ -0,0 +1,2 @@ +startsWith("come", 3) = true +startsWith("come", 0) = false diff --git a/BasicJava/StringDemo_startsWith_Offset_App/StringDemo/.classpath b/BasicJava/StringDemo_startsWith_Offset_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_startsWith_Offset_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/misc/String_59/StringDemo/.project b/BasicJava/StringDemo_startsWith_Offset_App/StringDemo/.project similarity index 100% rename from Later/String/misc/String_59/StringDemo/.project rename to BasicJava/StringDemo_startsWith_Offset_App/StringDemo/.project diff --git a/BasicJava/StringDemo_startsWith_Offset_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_startsWith_Offset_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_startsWith_Offset_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_startsWith_Offset_App/StringDemo/bin/StartsWithDemo.class b/BasicJava/StringDemo_startsWith_Offset_App/StringDemo/bin/StartsWithDemo.class new file mode 100644 index 000000000..c01410997 Binary files /dev/null and b/BasicJava/StringDemo_startsWith_Offset_App/StringDemo/bin/StartsWithDemo.class differ diff --git a/BasicJava/StringDemo_startsWith_Offset_App/StringDemo/src/StartsWithDemo.java b/BasicJava/StringDemo_startsWith_Offset_App/StringDemo/src/StartsWithDemo.java new file mode 100644 index 000000000..8c4a89aa6 --- /dev/null +++ b/BasicJava/StringDemo_startsWith_Offset_App/StringDemo/src/StartsWithDemo.java @@ -0,0 +1,31 @@ +/* + * public boolean startsWith(String prefix, int + * offset) + * + * Parameters: + * ---------- + * prefix - the prefix. + * offset - where to begin looking in this string. + * + * Returns: + * ------- + * true if the character sequence represented by the + * argument is a prefix of the substring of this + * object starting at index offset; false + * otherwise. + */ + +public class StartsWithDemo +{ + public static void main(String[] args) + { + String str = "Welcome Peter"; + + boolean result = str.startsWith("come", 3); + System.out.println("startsWith(\"come\", 3) = " + result); + + result = str.startsWith("come", 0); + System.out.println("startsWith(\"come\", 0) = " + result); + + } +} \ No newline at end of file diff --git a/BasicJava/StringDemo_subSequence_App/Output.txt b/BasicJava/StringDemo_subSequence_App/Output.txt new file mode 100644 index 000000000..5f4fdf6f5 --- /dev/null +++ b/BasicJava/StringDemo_subSequence_App/Output.txt @@ -0,0 +1 @@ +strValue = com diff --git a/BasicJava/StringDemo_subSequence_App/StringDemo/.classpath b/BasicJava/StringDemo_subSequence_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_subSequence_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/String/misc/String_60/StringDemo/.project b/BasicJava/StringDemo_subSequence_App/StringDemo/.project similarity index 100% rename from Later/String/misc/String_60/StringDemo/.project rename to BasicJava/StringDemo_subSequence_App/StringDemo/.project diff --git a/BasicJava/StringDemo_subSequence_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_subSequence_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_subSequence_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_subSequence_App/StringDemo/bin/SubSequenceDemo.class b/BasicJava/StringDemo_subSequence_App/StringDemo/bin/SubSequenceDemo.class new file mode 100644 index 000000000..cd5b736ba Binary files /dev/null and b/BasicJava/StringDemo_subSequence_App/StringDemo/bin/SubSequenceDemo.class differ diff --git a/BasicJava/StringDemo_subSequence_App/StringDemo/src/SubSequenceDemo.java b/BasicJava/StringDemo_subSequence_App/StringDemo/src/SubSequenceDemo.java new file mode 100644 index 000000000..685edcf8c --- /dev/null +++ b/BasicJava/StringDemo_subSequence_App/StringDemo/src/SubSequenceDemo.java @@ -0,0 +1,36 @@ +/* + * public CharSequence subSequence(int beginIndex, + * int endIndex) + * + * Parameters: + * ---------- + * beginIndex - the begin index, + * inclusive. endIndex - the end index, exclusive. + * + * Returns: + * ------- + * Returns a character sequence that is a + * subsequence of this sequence. + * + * An invocation of this method of the form + * + * str.subSequence(begin, end) + * + * behaves in exactly the same way as the + * invocation + * + * str.substring(begin, end) + */ + +public class SubSequenceDemo +{ + + public static void main(String[] args) + { + String str = "Welcome"; + CharSequence charSequence = str.subSequence(3, 6); + String strValue = (String) charSequence; + System.out.println("strValue = " + strValue); + + } +} diff --git a/BasicJava/StringDemo_toCharArray_App/Output.txt b/BasicJava/StringDemo_toCharArray_App/Output.txt new file mode 100644 index 000000000..01e8fd145 --- /dev/null +++ b/BasicJava/StringDemo_toCharArray_App/Output.txt @@ -0,0 +1,7 @@ +W +e +l +c +o +m +e diff --git a/BasicJava/StringDemo_toCharArray_App/StringDemo/.classpath b/BasicJava/StringDemo_toCharArray_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_toCharArray_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringDemo_toCharArray_App/StringDemo/.project b/BasicJava/StringDemo_toCharArray_App/StringDemo/.project new file mode 100644 index 000000000..f0fd51247 --- /dev/null +++ b/BasicJava/StringDemo_toCharArray_App/StringDemo/.project @@ -0,0 +1,17 @@ + + + StringDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringDemo_toCharArray_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_toCharArray_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_toCharArray_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_toCharArray_App/StringDemo/bin/ToCharArrayDemo.class b/BasicJava/StringDemo_toCharArray_App/StringDemo/bin/ToCharArrayDemo.class new file mode 100644 index 000000000..3d852712a Binary files /dev/null and b/BasicJava/StringDemo_toCharArray_App/StringDemo/bin/ToCharArrayDemo.class differ diff --git a/BasicJava/StringDemo_toCharArray_App/StringDemo/src/ToCharArrayDemo.java b/BasicJava/StringDemo_toCharArray_App/StringDemo/src/ToCharArrayDemo.java new file mode 100644 index 000000000..8e817e55b --- /dev/null +++ b/BasicJava/StringDemo_toCharArray_App/StringDemo/src/ToCharArrayDemo.java @@ -0,0 +1,26 @@ +/* + * public char[] toCharArray() + * + * + * Returns: + * -------- + * + * a newly allocated character array whose length is the + * length of this string and whose contents are + * initialized to contain the character sequence + * represented by this string. + */ +public class ToCharArrayDemo +{ + + public static void main(String[] args) + { + String str = "Welcome"; + char[] charArray = str.toCharArray(); + for (char c : charArray) + { + System.out.println(c); + } + } + +} \ No newline at end of file diff --git a/BasicJava/StringDemo_toLower_Upper_App/StringDemo/.classpath b/BasicJava/StringDemo_toLower_Upper_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_toLower_Upper_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringDemo_toLower_Upper_App/StringDemo/.project b/BasicJava/StringDemo_toLower_Upper_App/StringDemo/.project new file mode 100644 index 000000000..f0fd51247 --- /dev/null +++ b/BasicJava/StringDemo_toLower_Upper_App/StringDemo/.project @@ -0,0 +1,17 @@ + + + StringDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringDemo_toLower_Upper_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_toLower_Upper_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_toLower_Upper_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_toLower_Upper_App/StringDemo/bin/ToLowerCaseDemo.class b/BasicJava/StringDemo_toLower_Upper_App/StringDemo/bin/ToLowerCaseDemo.class new file mode 100644 index 000000000..e28e7b265 Binary files /dev/null and b/BasicJava/StringDemo_toLower_Upper_App/StringDemo/bin/ToLowerCaseDemo.class differ diff --git a/BasicJava/StringDemo_toLower_Upper_App/StringDemo/bin/ToUpperCaseDemo.class b/BasicJava/StringDemo_toLower_Upper_App/StringDemo/bin/ToUpperCaseDemo.class new file mode 100644 index 000000000..1b49c42de Binary files /dev/null and b/BasicJava/StringDemo_toLower_Upper_App/StringDemo/bin/ToUpperCaseDemo.class differ diff --git a/BasicJava/StringDemo_toLower_Upper_App/StringDemo/src/ToLowerCaseDemo.java b/BasicJava/StringDemo_toLower_Upper_App/StringDemo/src/ToLowerCaseDemo.java new file mode 100644 index 000000000..0ce5ee5ad --- /dev/null +++ b/BasicJava/StringDemo_toLower_Upper_App/StringDemo/src/ToLowerCaseDemo.java @@ -0,0 +1,39 @@ +/* + * public String toLowerCase() + * + * Returns: + * ------- + * the String, converted to lowercase. + * + * ============================================ + * + * public String toLowerCase(Locale locale) + * + * Parameters: + * ---------- + * locale - use the case transformation rules for + * this locale. + * + * Returns: + * ------- + * the String, converted to lowercase. + */ + +import java.util.Locale; + +public class ToLowerCaseDemo +{ + + public static void main(String[] args) + { + String str1 = "WELCOME"; + String strLower1 = str1.toLowerCase(); + System.out.println("strLower1 = " + strLower1); + + String str2 = "HELLO"; + String strLower2 = str2.toLowerCase(Locale.CANADA); + System.out.println("strLower2 = " + strLower2); + + } + +} diff --git a/BasicJava/StringDemo_toLower_Upper_App/StringDemo/src/ToUpperCaseDemo.java b/BasicJava/StringDemo_toLower_Upper_App/StringDemo/src/ToUpperCaseDemo.java new file mode 100644 index 000000000..8791eb584 --- /dev/null +++ b/BasicJava/StringDemo_toLower_Upper_App/StringDemo/src/ToUpperCaseDemo.java @@ -0,0 +1,36 @@ +/* + * public String toUpperCase() + * * + * Returns: + * ------- * + * the String, converted to uppercase. + * + * =========================================== + * + * public String toUpperCase(Locale locale) + * + * Parameters: + * ---------- + * locale - use the case transformation rules for + * this locale. + * + * Returns: + * ------- + * the String, converted to uppercase. + */ +import java.util.Locale; + +public class ToUpperCaseDemo +{ + + public static void main(String[] args) + { + String str1 = "welcome"; + String strUpper1 = str1.toUpperCase(); + System.out.println("strUpper1 = " + strUpper1); + + String str2 = "hello"; + String strUpper2 = str2.toUpperCase(Locale.ITALIAN); + System.out.println("strUpper2 = " + strUpper2); + } +} diff --git a/BasicJava/StringDemo_toLower_Upper_App/ToLowerCaseDemo_Output.txt b/BasicJava/StringDemo_toLower_Upper_App/ToLowerCaseDemo_Output.txt new file mode 100644 index 000000000..16f7f950e --- /dev/null +++ b/BasicJava/StringDemo_toLower_Upper_App/ToLowerCaseDemo_Output.txt @@ -0,0 +1,2 @@ +strLower1 = welcome +strLower2 = hello diff --git a/BasicJava/StringDemo_toLower_Upper_App/ToUpperCaseDemo_Output.txt b/BasicJava/StringDemo_toLower_Upper_App/ToUpperCaseDemo_Output.txt new file mode 100644 index 000000000..6107836e3 --- /dev/null +++ b/BasicJava/StringDemo_toLower_Upper_App/ToUpperCaseDemo_Output.txt @@ -0,0 +1,2 @@ +strUpper1 = WELCOME +strUpper2 = HELLO diff --git a/BasicJava/StringDemo_trim_App/Output.txt b/BasicJava/StringDemo_trim_App/Output.txt new file mode 100644 index 000000000..59bbeebe1 --- /dev/null +++ b/BasicJava/StringDemo_trim_App/Output.txt @@ -0,0 +1,4 @@ +str = Welcome +str length = 15 +trimedValue = Welcome +trimedValue length = 7 diff --git a/BasicJava/StringDemo_trim_App/StringDemo/.classpath b/BasicJava/StringDemo_trim_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_trim_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringDemo_trim_App/StringDemo/.project b/BasicJava/StringDemo_trim_App/StringDemo/.project new file mode 100644 index 000000000..f0fd51247 --- /dev/null +++ b/BasicJava/StringDemo_trim_App/StringDemo/.project @@ -0,0 +1,17 @@ + + + StringDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringDemo_trim_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_trim_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_trim_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_trim_App/StringDemo/bin/TrimDemo.class b/BasicJava/StringDemo_trim_App/StringDemo/bin/TrimDemo.class new file mode 100644 index 000000000..e62773194 Binary files /dev/null and b/BasicJava/StringDemo_trim_App/StringDemo/bin/TrimDemo.class differ diff --git a/BasicJava/StringDemo_trim_App/StringDemo/src/TrimDemo.java b/BasicJava/StringDemo_trim_App/StringDemo/src/TrimDemo.java new file mode 100644 index 000000000..4cc6ea01b --- /dev/null +++ b/BasicJava/StringDemo_trim_App/StringDemo/src/TrimDemo.java @@ -0,0 +1,26 @@ +/* + * public String trim() + * + * Returns: + * -------- + * A string whose value is this string, with any + * leading and trailing white space removed, or this + * string if it has no leading or trailing white + * space. + */ + +public class TrimDemo +{ + + public static void main(String[] args) + { + String str = " Welcome "; + System.out.println("str = " + str); + System.out.println("str length = " + str.length()); + + String trimedValue = str.trim(); + System.out.println("trimedValue = " + trimedValue); + System.out.println("trimedValue length = " + trimedValue.length()); + + } +} diff --git a/BasicJava/StringDemo_valueOf_methods_App/Output.txt b/BasicJava/StringDemo_valueOf_methods_App/Output.txt new file mode 100644 index 000000000..dc2f35202 --- /dev/null +++ b/BasicJava/StringDemo_valueOf_methods_App/Output.txt @@ -0,0 +1,4 @@ +30 +30.0 +Hi +true diff --git a/BasicJava/StringDemo_valueOf_methods_App/StringDemo/.classpath b/BasicJava/StringDemo_valueOf_methods_App/StringDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/StringDemo_valueOf_methods_App/StringDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/StringDemo_valueOf_methods_App/StringDemo/.project b/BasicJava/StringDemo_valueOf_methods_App/StringDemo/.project new file mode 100644 index 000000000..f0fd51247 --- /dev/null +++ b/BasicJava/StringDemo_valueOf_methods_App/StringDemo/.project @@ -0,0 +1,17 @@ + + + StringDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/StringDemo_valueOf_methods_App/StringDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/StringDemo_valueOf_methods_App/StringDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/StringDemo_valueOf_methods_App/StringDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/StringDemo_valueOf_methods_App/StringDemo/bin/ValueOfDemo.class b/BasicJava/StringDemo_valueOf_methods_App/StringDemo/bin/ValueOfDemo.class new file mode 100644 index 000000000..440dd866a Binary files /dev/null and b/BasicJava/StringDemo_valueOf_methods_App/StringDemo/bin/ValueOfDemo.class differ diff --git a/Later/String/misc/String_53/StringDemo/bin/toCharArrayDemo.class b/BasicJava/StringDemo_valueOf_methods_App/StringDemo/bin/toCharArrayDemo.class similarity index 100% rename from Later/String/misc/String_53/StringDemo/bin/toCharArrayDemo.class rename to BasicJava/StringDemo_valueOf_methods_App/StringDemo/bin/toCharArrayDemo.class diff --git a/BasicJava/StringDemo_valueOf_methods_App/StringDemo/src/ValueOfDemo.java b/BasicJava/StringDemo_valueOf_methods_App/StringDemo/src/ValueOfDemo.java new file mode 100644 index 000000000..3de5b1193 --- /dev/null +++ b/BasicJava/StringDemo_valueOf_methods_App/StringDemo/src/ValueOfDemo.java @@ -0,0 +1,23 @@ +public class ValueOfDemo +{ + + public static void main(String[] args) + { + int intValue=30; + String str=String.valueOf(intValue); + System.out.println(str); + + double doubleValue=30; + str=String.valueOf(doubleValue); + System.out.println(str); + + char[] charArray ={'H','i'};; + str=String.valueOf(charArray); + System.out.println(str); + + boolean value = true; + str=String.valueOf(value); + System.out.println(str); + } + +} \ No newline at end of file diff --git a/BasicJava/SynchronizationDemo_Bank_App/SynchronizationDemo/.classpath b/BasicJava/SynchronizationDemo_Bank_App/SynchronizationDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/SynchronizationDemo_Bank_App/SynchronizationDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/SynchronizationDemo_Bank_App/SynchronizationDemo/.project b/BasicJava/SynchronizationDemo_Bank_App/SynchronizationDemo/.project new file mode 100644 index 000000000..aaa873735 --- /dev/null +++ b/BasicJava/SynchronizationDemo_Bank_App/SynchronizationDemo/.project @@ -0,0 +1,17 @@ + + + SynchronizationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/SynchronizationDemo_Bank_App/SynchronizationDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/SynchronizationDemo_Bank_App/SynchronizationDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/SynchronizationDemo_Bank_App/SynchronizationDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/SynchronizationDemo_Bank_App/SynchronizationDemo/bin/AccountDAO.class b/BasicJava/SynchronizationDemo_Bank_App/SynchronizationDemo/bin/AccountDAO.class new file mode 100644 index 000000000..beaa5b853 Binary files /dev/null and b/BasicJava/SynchronizationDemo_Bank_App/SynchronizationDemo/bin/AccountDAO.class differ diff --git a/BasicJava/SynchronizationDemo_Bank_App/SynchronizationDemo/bin/BankAccount.class b/BasicJava/SynchronizationDemo_Bank_App/SynchronizationDemo/bin/BankAccount.class new file mode 100644 index 000000000..ad2a2a8cf Binary files /dev/null and b/BasicJava/SynchronizationDemo_Bank_App/SynchronizationDemo/bin/BankAccount.class differ diff --git a/BasicJava/SynchronizationDemo_Bank_App/SynchronizationDemo/src/AccountDAO.java b/BasicJava/SynchronizationDemo_Bank_App/SynchronizationDemo/src/AccountDAO.java new file mode 100644 index 000000000..ecb5326b9 --- /dev/null +++ b/BasicJava/SynchronizationDemo_Bank_App/SynchronizationDemo/src/AccountDAO.java @@ -0,0 +1,21 @@ + +public class AccountDAO +{ + + public double getCurrentAccountBalance(int accountNumber) + { + /* + * Code to get the current balance from DB table. + */ + return 0; + } + + public void updateAccountBalance(double newAccountBalance) + { + /* + * Code to update the new balance in the DB table. + */ + + } + +} diff --git a/BasicJava/SynchronizationDemo_Bank_App/SynchronizationDemo/src/BankAccount.java b/BasicJava/SynchronizationDemo_Bank_App/SynchronizationDemo/src/BankAccount.java new file mode 100644 index 000000000..1f75324b0 --- /dev/null +++ b/BasicJava/SynchronizationDemo_Bank_App/SynchronizationDemo/src/BankAccount.java @@ -0,0 +1,36 @@ +public class BankAccount +{ + + private int accountNumber; + private double accountBalance; + + private AccountDAO dao; + + public synchronized boolean deposit(double amount) + { + double newAccountBalance; + /* + * Get the current balance from DB table. + */ + accountBalance = dao.getCurrentAccountBalance(accountNumber); + + if (amount < 0.0) + { + /* + * Can not deposit a negative amount. + */ + return false; + } + + else + { + newAccountBalance = accountBalance + amount; + /* + * Update the new balance in the DB table. + */ + dao.updateAccountBalance(newAccountBalance); + return true; + } + + } +} \ No newline at end of file diff --git a/BasicJava/Synchronization_Block_Demo_App/Output.txt b/BasicJava/Synchronization_Block_Demo_App/Output.txt new file mode 100644 index 000000000..04a6db1a0 --- /dev/null +++ b/BasicJava/Synchronization_Block_Demo_App/Output.txt @@ -0,0 +1,36 @@ +------------------------------------- +If printTable method has synchronized block, +then below will be the output: +------------------------------------- + +Thread Name = Thread 1 +5 +10 +15 +20 +25 +Thread Name = Thread 2 +50 +100 +150 +200 +250 + +----------------------------------------- +If printTable method does not have synchronized block, +then below will be the output: +----------------------------------------- +Thread Name = Thread 2 +50 +Thread Name = Thread 1 +5 +100 +10 +150 +15 +200 +20 +25 +250 + + diff --git a/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/.classpath b/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/.project b/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/.project new file mode 100644 index 000000000..aaa873735 --- /dev/null +++ b/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/.project @@ -0,0 +1,17 @@ + + + SynchronizationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/bin/SynchronizationDemo.class b/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/bin/SynchronizationDemo.class new file mode 100644 index 000000000..85a4779d8 Binary files /dev/null and b/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/bin/SynchronizationDemo.class differ diff --git a/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/bin/Table.class b/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/bin/Table.class new file mode 100644 index 000000000..1b4cb8079 Binary files /dev/null and b/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/bin/Table.class differ diff --git a/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/bin/Thread1.class b/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/bin/Thread1.class new file mode 100644 index 000000000..307fc8405 Binary files /dev/null and b/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/bin/Thread1.class differ diff --git a/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/bin/Thread2.class b/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/bin/Thread2.class new file mode 100644 index 000000000..690d2038d Binary files /dev/null and b/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/bin/Thread2.class differ diff --git a/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/src/SynchronizationDemo.java b/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/src/SynchronizationDemo.java new file mode 100644 index 000000000..b46b16016 --- /dev/null +++ b/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/src/SynchronizationDemo.java @@ -0,0 +1,15 @@ +import java.io.IOException; + +public class SynchronizationDemo +{ + + public static void main(String[] args) throws IOException + { + Table tableObj = new Table(); + Thread1 t1 = new Thread1(tableObj,"Thread 1"); + Thread2 t2 = new Thread2(tableObj,"Thread 2"); + t1.start(); + t2.start(); + } + +} diff --git a/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/src/Table.java b/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/src/Table.java new file mode 100644 index 000000000..8ab3e302c --- /dev/null +++ b/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/src/Table.java @@ -0,0 +1,27 @@ +public class Table +{ + public void printTable(int n) + { + + /* + * Synchronized block + */ + synchronized (this) + { + System.out.println("Thread Name = " + + Thread.currentThread().getName()); + for (int i = 1; i <= 5; i++) + { + System.out.println(n * i); + try + { + Thread.sleep(1000); + } + catch (Exception e) + { + System.out.println(e); + } + } + } + } +} diff --git a/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/src/Thread1.java b/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/src/Thread1.java new file mode 100644 index 000000000..2d0b40ac5 --- /dev/null +++ b/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/src/Thread1.java @@ -0,0 +1,16 @@ +public class Thread1 extends Thread +{ + private Table t; + + public Thread1(Table t,String threadName) + { + super(threadName); + this.t = t; + } + + public void run() + { + t.printTable(5); + } + +} diff --git a/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/src/Thread2.java b/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/src/Thread2.java new file mode 100644 index 000000000..daed704db --- /dev/null +++ b/BasicJava/Synchronization_Block_Demo_App/SynchronizationDemo/src/Thread2.java @@ -0,0 +1,16 @@ +public class Thread2 extends Thread +{ + private Table t; + + public Thread2(Table t,String threadName) + { + super(threadName); + this.t = t; + } + + public void run() + { + t.printTable(50); + } + +} diff --git a/BasicJava/Synchronization_Block_Demo_V3_App/Output.txt b/BasicJava/Synchronization_Block_Demo_V3_App/Output.txt new file mode 100644 index 000000000..354977fc2 --- /dev/null +++ b/BasicJava/Synchronization_Block_Demo_V3_App/Output.txt @@ -0,0 +1,25 @@ +------------------------------------- +If showMessage method has synchronized block, +then below will be the output: +------------------------------------- + +Thread Name = Thread-0 +[welcome] +Thread Name = Thread-1 +[Hello] +Thread Name = Thread-2 +[Peter] + +----------------------------------------- +If showMessage method does not have synchronized block, +then below will be the output: +----------------------------------------- +Thread Name = Thread-0 +Thread Name = Thread-1 +Thread Name = Thread-2 +[Hello[welcome[Peter] +] +] + + + diff --git a/BasicJava/Synchronization_Block_Demo_V3_App/SynchronizationDemo/.classpath b/BasicJava/Synchronization_Block_Demo_V3_App/SynchronizationDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/Synchronization_Block_Demo_V3_App/SynchronizationDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/Synchronization_Block_Demo_V3_App/SynchronizationDemo/.project b/BasicJava/Synchronization_Block_Demo_V3_App/SynchronizationDemo/.project new file mode 100644 index 000000000..aaa873735 --- /dev/null +++ b/BasicJava/Synchronization_Block_Demo_V3_App/SynchronizationDemo/.project @@ -0,0 +1,17 @@ + + + SynchronizationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/Synchronization_Block_Demo_V3_App/SynchronizationDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/Synchronization_Block_Demo_V3_App/SynchronizationDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/Synchronization_Block_Demo_V3_App/SynchronizationDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/Synchronization_Block_Demo_V3_App/SynchronizationDemo/bin/DisplayMessage.class b/BasicJava/Synchronization_Block_Demo_V3_App/SynchronizationDemo/bin/DisplayMessage.class new file mode 100644 index 000000000..ea8046608 Binary files /dev/null and b/BasicJava/Synchronization_Block_Demo_V3_App/SynchronizationDemo/bin/DisplayMessage.class differ diff --git a/BasicJava/Synchronization_Block_Demo_V3_App/SynchronizationDemo/bin/DisplayThread.class b/BasicJava/Synchronization_Block_Demo_V3_App/SynchronizationDemo/bin/DisplayThread.class new file mode 100644 index 000000000..87a0b96bd Binary files /dev/null and b/BasicJava/Synchronization_Block_Demo_V3_App/SynchronizationDemo/bin/DisplayThread.class differ diff --git a/BasicJava/Synchronization_Block_Demo_V3_App/SynchronizationDemo/bin/SynchronizationDemo.class b/BasicJava/Synchronization_Block_Demo_V3_App/SynchronizationDemo/bin/SynchronizationDemo.class new file mode 100644 index 000000000..a85f06a09 Binary files /dev/null and b/BasicJava/Synchronization_Block_Demo_V3_App/SynchronizationDemo/bin/SynchronizationDemo.class differ diff --git a/BasicJava/Synchronization_Block_Demo_V3_App/SynchronizationDemo/src/DisplayMessage.java b/BasicJava/Synchronization_Block_Demo_V3_App/SynchronizationDemo/src/DisplayMessage.java new file mode 100644 index 000000000..27e35c49b --- /dev/null +++ b/BasicJava/Synchronization_Block_Demo_V3_App/SynchronizationDemo/src/DisplayMessage.java @@ -0,0 +1,27 @@ +public class DisplayMessage +{ + + public void showMessage(String msg) + { + + /* + * synchronized block. + */ + synchronized (this) + { + System.out.println("Thread Name = " + + Thread.currentThread().getName()); + System.out.print("[" + msg); + try + { + Thread.sleep(1000); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + System.out.println("]"); + } + } + +} diff --git a/BasicJava/Synchronization_Block_Demo_V3_App/SynchronizationDemo/src/DisplayThread.java b/BasicJava/Synchronization_Block_Demo_V3_App/SynchronizationDemo/src/DisplayThread.java new file mode 100644 index 000000000..005206d13 --- /dev/null +++ b/BasicJava/Synchronization_Block_Demo_V3_App/SynchronizationDemo/src/DisplayThread.java @@ -0,0 +1,16 @@ +public class DisplayThread extends Thread +{ + private String msg; + private DisplayMessage displayMessage; + + public DisplayThread(DisplayMessage displayMessage, String msg) + { + this.displayMessage = displayMessage; + this.msg = msg; + } + + public void run() + { + displayMessage.showMessage(msg); + } +} diff --git a/BasicJava/Synchronization_Block_Demo_V3_App/SynchronizationDemo/src/SynchronizationDemo.java b/BasicJava/Synchronization_Block_Demo_V3_App/SynchronizationDemo/src/SynchronizationDemo.java new file mode 100644 index 000000000..5a95d8941 --- /dev/null +++ b/BasicJava/Synchronization_Block_Demo_V3_App/SynchronizationDemo/src/SynchronizationDemo.java @@ -0,0 +1,13 @@ +public class SynchronizationDemo +{ + public static void main(String[] args) + { + DisplayMessage displayMessage = new DisplayMessage(); + DisplayThread thread1 = new DisplayThread(displayMessage, "welcome"); + DisplayThread thread2 = new DisplayThread(displayMessage, "Hello"); + DisplayThread thread3 = new DisplayThread(displayMessage, "Peter"); + thread1.start(); + thread2.start(); + thread3.start(); + } +} \ No newline at end of file diff --git a/BasicJava/Synchronization_Block_Demo_V4_File_App/Output.txt b/BasicJava/Synchronization_Block_Demo_V4_File_App/Output.txt new file mode 100644 index 000000000..1bea7a0d3 --- /dev/null +++ b/BasicJava/Synchronization_Block_Demo_V4_File_App/Output.txt @@ -0,0 +1,39 @@ +------------------------------------- +If printCount method has synchronized block, +then below will be the output: +------------------------------------- + +Thread Name = Thread1 +Counter --- 5 +Counter --- 4 +Counter --- 3 +Counter --- 2 +Counter --- 1 + +Thread Name = Thread2 +Counter --- 5 +Counter --- 4 +Counter --- 3 +Counter --- 2 +Counter --- 1 + +----------------------------------------- +If printCount method does not have synchronized block, +then below will be the output: +----------------------------------------- +Thread Name = Thread1 +Thread Name = Thread2 +Counter --- 5 +Counter --- 5 +Counter --- 4 +Counter --- 4 +Counter --- 3 +Counter --- 3 +Counter --- 2 +Counter --- 2 +Counter --- 1 +Counter --- 1 + + + + diff --git a/BasicJava/Synchronization_Block_Demo_V4_File_App/SynchronizationDemo/.classpath b/BasicJava/Synchronization_Block_Demo_V4_File_App/SynchronizationDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/Synchronization_Block_Demo_V4_File_App/SynchronizationDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/Synchronization_Block_Demo_V4_File_App/SynchronizationDemo/.project b/BasicJava/Synchronization_Block_Demo_V4_File_App/SynchronizationDemo/.project new file mode 100644 index 000000000..aaa873735 --- /dev/null +++ b/BasicJava/Synchronization_Block_Demo_V4_File_App/SynchronizationDemo/.project @@ -0,0 +1,17 @@ + + + SynchronizationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/Synchronization_Block_Demo_V4_File_App/SynchronizationDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/Synchronization_Block_Demo_V4_File_App/SynchronizationDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/Synchronization_Block_Demo_V4_File_App/SynchronizationDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/Synchronization_Block_Demo_V4_File_App/SynchronizationDemo/bin/DisplayCounter.class b/BasicJava/Synchronization_Block_Demo_V4_File_App/SynchronizationDemo/bin/DisplayCounter.class new file mode 100644 index 000000000..aa2eb2fcb Binary files /dev/null and b/BasicJava/Synchronization_Block_Demo_V4_File_App/SynchronizationDemo/bin/DisplayCounter.class differ diff --git a/BasicJava/Synchronization_Block_Demo_V4_File_App/SynchronizationDemo/bin/DisplayThread.class b/BasicJava/Synchronization_Block_Demo_V4_File_App/SynchronizationDemo/bin/DisplayThread.class new file mode 100644 index 000000000..c518b695b Binary files /dev/null and b/BasicJava/Synchronization_Block_Demo_V4_File_App/SynchronizationDemo/bin/DisplayThread.class differ diff --git a/BasicJava/Synchronization_Block_Demo_V4_File_App/SynchronizationDemo/bin/SynchronizationDemo.class b/BasicJava/Synchronization_Block_Demo_V4_File_App/SynchronizationDemo/bin/SynchronizationDemo.class new file mode 100644 index 000000000..f0e39d24c Binary files /dev/null and b/BasicJava/Synchronization_Block_Demo_V4_File_App/SynchronizationDemo/bin/SynchronizationDemo.class differ diff --git a/BasicJava/Synchronization_Block_Demo_V4_File_App/SynchronizationDemo/src/DisplayCounter.java b/BasicJava/Synchronization_Block_Demo_V4_File_App/SynchronizationDemo/src/DisplayCounter.java new file mode 100644 index 000000000..f30db9684 --- /dev/null +++ b/BasicJava/Synchronization_Block_Demo_V4_File_App/SynchronizationDemo/src/DisplayCounter.java @@ -0,0 +1,28 @@ +public class DisplayCounter +{ + + public void printCount() + { + /* + * synchronized block. + */ + //synchronized (this) + //{ + try + { + System.out.println("Thread Name = " + Thread.currentThread().getName()); + for (int i = 5; i > 0; i--) + { + System.out.println("Counter --- " + i); + Thread.sleep(200); + } + System.out.println(); + } + catch (Exception e) + { + e.printStackTrace(); + } + //} + + } +} diff --git a/BasicJava/Synchronization_Block_Demo_V4_File_App/SynchronizationDemo/src/DisplayThread.java b/BasicJava/Synchronization_Block_Demo_V4_File_App/SynchronizationDemo/src/DisplayThread.java new file mode 100644 index 000000000..c34ca5a2e --- /dev/null +++ b/BasicJava/Synchronization_Block_Demo_V4_File_App/SynchronizationDemo/src/DisplayThread.java @@ -0,0 +1,16 @@ +public class DisplayThread extends Thread +{ + private DisplayCounter dc; + + public DisplayThread(String name, DisplayCounter dc) + { + super.setName(name); + this.dc = dc; + } + + public void run() + { + dc.printCount(); + } + +} diff --git a/BasicJava/Synchronization_Block_Demo_V4_File_App/SynchronizationDemo/src/SynchronizationDemo.java b/BasicJava/Synchronization_Block_Demo_V4_File_App/SynchronizationDemo/src/SynchronizationDemo.java new file mode 100644 index 000000000..3ac5c15af --- /dev/null +++ b/BasicJava/Synchronization_Block_Demo_V4_File_App/SynchronizationDemo/src/SynchronizationDemo.java @@ -0,0 +1,13 @@ +public class SynchronizationDemo +{ + public static void main(String[] args) + { + DisplayCounter displayCounter = new DisplayCounter(); + + DisplayThread thread1 = new DisplayThread("Thread1", displayCounter); + DisplayThread thread2 = new DisplayThread("Thread2", displayCounter); + + thread1.start(); + thread2.start(); + } +} \ No newline at end of file diff --git a/BasicJava/Synchronization_Block_annonymous_App/Output.txt b/BasicJava/Synchronization_Block_annonymous_App/Output.txt new file mode 100644 index 000000000..b039d7a15 --- /dev/null +++ b/BasicJava/Synchronization_Block_annonymous_App/Output.txt @@ -0,0 +1,37 @@ +------------------------------------- +If printTable method has synchronized block, +then below will be the output: +------------------------------------- + +Thread Name = Thread-0 +5 +10 +15 +20 +25 +Thread Name = Thread-1 +100 +200 +300 +400 +500 + +----------------------------------------- +If printTable method does not have synchronized block, +then below will be the output: +----------------------------------------- +Thread Name = Thread-1 +100 +Thread Name = Thread-0 +5 +200 +10 +15 +300 +20 +400 +25 +500 + + + diff --git a/BasicJava/Synchronization_Block_annonymous_App/SynchronizationDemo/.classpath b/BasicJava/Synchronization_Block_annonymous_App/SynchronizationDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/Synchronization_Block_annonymous_App/SynchronizationDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/Synchronization_Block_annonymous_App/SynchronizationDemo/.project b/BasicJava/Synchronization_Block_annonymous_App/SynchronizationDemo/.project new file mode 100644 index 000000000..aaa873735 --- /dev/null +++ b/BasicJava/Synchronization_Block_annonymous_App/SynchronizationDemo/.project @@ -0,0 +1,17 @@ + + + SynchronizationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/Synchronization_Block_annonymous_App/SynchronizationDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/Synchronization_Block_annonymous_App/SynchronizationDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/Synchronization_Block_annonymous_App/SynchronizationDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/Synchronization_Block_annonymous_App/SynchronizationDemo/bin/SynchronizationDemo$1.class b/BasicJava/Synchronization_Block_annonymous_App/SynchronizationDemo/bin/SynchronizationDemo$1.class new file mode 100644 index 000000000..ef90a3b17 Binary files /dev/null and b/BasicJava/Synchronization_Block_annonymous_App/SynchronizationDemo/bin/SynchronizationDemo$1.class differ diff --git a/BasicJava/Synchronization_Block_annonymous_App/SynchronizationDemo/bin/SynchronizationDemo$2.class b/BasicJava/Synchronization_Block_annonymous_App/SynchronizationDemo/bin/SynchronizationDemo$2.class new file mode 100644 index 000000000..37961d590 Binary files /dev/null and b/BasicJava/Synchronization_Block_annonymous_App/SynchronizationDemo/bin/SynchronizationDemo$2.class differ diff --git a/BasicJava/Synchronization_Block_annonymous_App/SynchronizationDemo/bin/SynchronizationDemo.class b/BasicJava/Synchronization_Block_annonymous_App/SynchronizationDemo/bin/SynchronizationDemo.class new file mode 100644 index 000000000..e0ef24444 Binary files /dev/null and b/BasicJava/Synchronization_Block_annonymous_App/SynchronizationDemo/bin/SynchronizationDemo.class differ diff --git a/BasicJava/Synchronization_Block_annonymous_App/SynchronizationDemo/bin/Table.class b/BasicJava/Synchronization_Block_annonymous_App/SynchronizationDemo/bin/Table.class new file mode 100644 index 000000000..1b4cb8079 Binary files /dev/null and b/BasicJava/Synchronization_Block_annonymous_App/SynchronizationDemo/bin/Table.class differ diff --git a/BasicJava/Synchronization_Block_annonymous_App/SynchronizationDemo/src/SynchronizationDemo.java b/BasicJava/Synchronization_Block_annonymous_App/SynchronizationDemo/src/SynchronizationDemo.java new file mode 100644 index 000000000..a44e7a409 --- /dev/null +++ b/BasicJava/Synchronization_Block_annonymous_App/SynchronizationDemo/src/SynchronizationDemo.java @@ -0,0 +1,32 @@ +import java.io.IOException; + +public class SynchronizationDemo +{ + + public static void main(String[] args) throws IOException + { + Table tableObj = new Table(); + + /* + * Created the two threads by annonymous class. + */ + Thread t1 = new Thread() + { + public void run() + { + tableObj.printTable(5); + } + }; + Thread t2 = new Thread() + { + public void run() + { + tableObj.printTable(100); + } + }; + + t1.start(); + t2.start(); + } + +} diff --git a/BasicJava/Synchronization_Block_annonymous_App/SynchronizationDemo/src/Table.java b/BasicJava/Synchronization_Block_annonymous_App/SynchronizationDemo/src/Table.java new file mode 100644 index 000000000..8ab3e302c --- /dev/null +++ b/BasicJava/Synchronization_Block_annonymous_App/SynchronizationDemo/src/Table.java @@ -0,0 +1,27 @@ +public class Table +{ + public void printTable(int n) + { + + /* + * Synchronized block + */ + synchronized (this) + { + System.out.println("Thread Name = " + + Thread.currentThread().getName()); + for (int i = 1; i <= 5; i++) + { + System.out.println(n * i); + try + { + Thread.sleep(1000); + } + catch (Exception e) + { + System.out.println(e); + } + } + } + } +} diff --git a/BasicJava/Synchronization_Method_V1_Demo_App/Output.txt b/BasicJava/Synchronization_Method_V1_Demo_App/Output.txt new file mode 100644 index 000000000..5026e10d4 --- /dev/null +++ b/BasicJava/Synchronization_Method_V1_Demo_App/Output.txt @@ -0,0 +1,35 @@ +------------------------------------- +If printTable method is synchronized, +then below will be the output: +------------------------------------- + +Thread Name = Thread 1 +5 +10 +15 +20 +25 +Thread Name = Thread 2 +50 +100 +150 +200 +250 + +----------------------------------------- +If printTable method is not synchronized, +then below will be the output: +----------------------------------------- + +Thread Name = Thread 2 +Thread Name = Thread 1 +5 +50 +10 +100 +15 +150 +20 +200 +25 +250 diff --git a/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/.classpath b/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/.project b/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/.project new file mode 100644 index 000000000..aaa873735 --- /dev/null +++ b/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/.project @@ -0,0 +1,17 @@ + + + SynchronizationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/bin/SynchronizationDemo.class b/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/bin/SynchronizationDemo.class new file mode 100644 index 000000000..cbac441b8 Binary files /dev/null and b/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/bin/SynchronizationDemo.class differ diff --git a/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/bin/Table.class b/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/bin/Table.class new file mode 100644 index 000000000..201d4e362 Binary files /dev/null and b/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/bin/Table.class differ diff --git a/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/bin/Thread1.class b/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/bin/Thread1.class new file mode 100644 index 000000000..307fc8405 Binary files /dev/null and b/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/bin/Thread1.class differ diff --git a/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/bin/Thread2.class b/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/bin/Thread2.class new file mode 100644 index 000000000..690d2038d Binary files /dev/null and b/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/bin/Thread2.class differ diff --git a/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/src/SynchronizationDemo.java b/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/src/SynchronizationDemo.java new file mode 100644 index 000000000..d9cb1404b --- /dev/null +++ b/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/src/SynchronizationDemo.java @@ -0,0 +1,16 @@ +import java.io.IOException; + +public class SynchronizationDemo +{ + + public static void main(String[] args) throws IOException + { + Table tableObj = new Table(); + Thread1 t1 = new Thread1(tableObj,"Thread 1"); + Thread2 t2 = new Thread2(tableObj,"Thread 2"); + t1.start(); + t2.start(); + + } + +} diff --git a/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/src/Table.java b/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/src/Table.java new file mode 100644 index 000000000..a398d9bb4 --- /dev/null +++ b/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/src/Table.java @@ -0,0 +1,48 @@ +public class Table +{ + + /* + * Method is synchronized + */ + public synchronized void printTable(int n) + { + System.out.println("Thread Name = " + + Thread.currentThread().getName()); + for (int i = 1; i <= 5; i++) + { + System.out.println(n * i); + try + { + Thread.sleep(400); + } + catch (Exception e) + { + System.out.println(e); + } + } + } + + /* + * Method is not synchronized. + */ + /*public void printTable(int n) + { + System.out.println("Thread Name = " + + Thread.currentThread().getName()); + for (int i = 1; i <= 5; i++) + { + System.out.println(n * i); + try + { + Thread.sleep(400); + } + catch (Exception e) + { + System.out.println(e); + } + } + }*/ + + + +} diff --git a/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/src/Thread1.java b/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/src/Thread1.java new file mode 100644 index 000000000..2d0b40ac5 --- /dev/null +++ b/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/src/Thread1.java @@ -0,0 +1,16 @@ +public class Thread1 extends Thread +{ + private Table t; + + public Thread1(Table t,String threadName) + { + super(threadName); + this.t = t; + } + + public void run() + { + t.printTable(5); + } + +} diff --git a/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/src/Thread2.java b/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/src/Thread2.java new file mode 100644 index 000000000..daed704db --- /dev/null +++ b/BasicJava/Synchronization_Method_V1_Demo_App/SynchronizationDemo/src/Thread2.java @@ -0,0 +1,16 @@ +public class Thread2 extends Thread +{ + private Table t; + + public Thread2(Table t,String threadName) + { + super(threadName); + this.t = t; + } + + public void run() + { + t.printTable(50); + } + +} diff --git a/BasicJava/Synchronization_Method_V2_Demo_App/Output.txt b/BasicJava/Synchronization_Method_V2_Demo_App/Output.txt new file mode 100644 index 000000000..8df762ec8 --- /dev/null +++ b/BasicJava/Synchronization_Method_V2_Demo_App/Output.txt @@ -0,0 +1,36 @@ +------------------------------------- +If printTable method is synchronized, +then below will be the output: +------------------------------------- + +Thread Name = Thread 1 +5 +10 +15 +20 +25 +Thread Name = Thread 2 +100 +200 +300 +400 +500 + +----------------------------------------- +If printTable method is not synchronized, +then below will be the output: +----------------------------------------- + +Thread Name = Thread 1 +5 +Thread Name = Thread 2 +100 +10 +200 +15 +300 +20 +400 +25 +500 + diff --git a/BasicJava/Synchronization_Method_V2_Demo_App/SynchronizationDemo/.classpath b/BasicJava/Synchronization_Method_V2_Demo_App/SynchronizationDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/Synchronization_Method_V2_Demo_App/SynchronizationDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/Synchronization_Method_V2_Demo_App/SynchronizationDemo/.project b/BasicJava/Synchronization_Method_V2_Demo_App/SynchronizationDemo/.project new file mode 100644 index 000000000..aaa873735 --- /dev/null +++ b/BasicJava/Synchronization_Method_V2_Demo_App/SynchronizationDemo/.project @@ -0,0 +1,17 @@ + + + SynchronizationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/Synchronization_Method_V2_Demo_App/SynchronizationDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/Synchronization_Method_V2_Demo_App/SynchronizationDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/Synchronization_Method_V2_Demo_App/SynchronizationDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/Synchronization_Method_V2_Demo_App/SynchronizationDemo/bin/SynchronizationDemo$1.class b/BasicJava/Synchronization_Method_V2_Demo_App/SynchronizationDemo/bin/SynchronizationDemo$1.class new file mode 100644 index 000000000..1f0a6c223 Binary files /dev/null and b/BasicJava/Synchronization_Method_V2_Demo_App/SynchronizationDemo/bin/SynchronizationDemo$1.class differ diff --git a/BasicJava/Synchronization_Method_V2_Demo_App/SynchronizationDemo/bin/SynchronizationDemo$2.class b/BasicJava/Synchronization_Method_V2_Demo_App/SynchronizationDemo/bin/SynchronizationDemo$2.class new file mode 100644 index 000000000..9cf3d2b57 Binary files /dev/null and b/BasicJava/Synchronization_Method_V2_Demo_App/SynchronizationDemo/bin/SynchronizationDemo$2.class differ diff --git a/BasicJava/Synchronization_Method_V2_Demo_App/SynchronizationDemo/bin/SynchronizationDemo.class b/BasicJava/Synchronization_Method_V2_Demo_App/SynchronizationDemo/bin/SynchronizationDemo.class new file mode 100644 index 000000000..8de52d279 Binary files /dev/null and b/BasicJava/Synchronization_Method_V2_Demo_App/SynchronizationDemo/bin/SynchronizationDemo.class differ diff --git a/BasicJava/Synchronization_Method_V2_Demo_App/SynchronizationDemo/bin/Table.class b/BasicJava/Synchronization_Method_V2_Demo_App/SynchronizationDemo/bin/Table.class new file mode 100644 index 000000000..495e4644b Binary files /dev/null and b/BasicJava/Synchronization_Method_V2_Demo_App/SynchronizationDemo/bin/Table.class differ diff --git a/BasicJava/Synchronization_Method_V2_Demo_App/SynchronizationDemo/src/SynchronizationDemo.java b/BasicJava/Synchronization_Method_V2_Demo_App/SynchronizationDemo/src/SynchronizationDemo.java new file mode 100644 index 000000000..eb5ae88d8 --- /dev/null +++ b/BasicJava/Synchronization_Method_V2_Demo_App/SynchronizationDemo/src/SynchronizationDemo.java @@ -0,0 +1,32 @@ +import java.io.IOException; + +public class SynchronizationDemo +{ + + public static void main(String[] args) throws IOException + { + Table tableObj = new Table(); + + /* + * Created the two threads by annonymous class. + */ + Thread t1 = new Thread("Thread 1") + { + public void run() + { + tableObj.printTable(5); + } + }; + Thread t2 = new Thread("Thread 2") + { + public void run() + { + tableObj.printTable(100); + } + }; + + t1.start(); + t2.start(); + } + +} diff --git a/BasicJava/Synchronization_Method_V2_Demo_App/SynchronizationDemo/src/Table.java b/BasicJava/Synchronization_Method_V2_Demo_App/SynchronizationDemo/src/Table.java new file mode 100644 index 000000000..2260d8186 --- /dev/null +++ b/BasicJava/Synchronization_Method_V2_Demo_App/SynchronizationDemo/src/Table.java @@ -0,0 +1,45 @@ +public class Table +{ + /* + * Method is synchronized + */ + /*public synchronized void printTable(int n) + { + System.out.println("Thread Name = " + + Thread.currentThread().getName()); + for (int i = 1; i <= 5; i++) + { + System.out.println(n * i); + try + { + Thread.sleep(1000); + } + catch (Exception e) + { + System.out.println(e); + } + } + }*/ + + /* + * Method is not synchronized. + */ + public void printTable(int n) + { + System.out.println("Thread Name = " + + Thread.currentThread().getName()); + for (int i = 1; i <= 5; i++) + { + System.out.println(n * i); + try + { + Thread.sleep(400); + } + catch (Exception e) + { + System.out.println(e); + } + } + } + +} diff --git a/BasicJava/Synchronization_Method_V3_Demo_App/Output.txt b/BasicJava/Synchronization_Method_V3_Demo_App/Output.txt new file mode 100644 index 000000000..b54db024b --- /dev/null +++ b/BasicJava/Synchronization_Method_V3_Demo_App/Output.txt @@ -0,0 +1,23 @@ +------------------------------------- +If showMessage method is synchronized, +then below will be the output: +------------------------------------- + +Thread Name = Thread-0 +[welcome] +Thread Name = Thread-2 +[Peter] +Thread Name = Thread-1 +[Hello] + +----------------------------------------- +If showMessage method is not synchronized, +then below will be the output: +----------------------------------------- + +Thread Name = Thread-0 +[welcomeThread Name = Thread-2 +Thread Name = Thread-1 +[Hello[Peter] +] +] diff --git a/BasicJava/Synchronization_Method_V3_Demo_App/SynchronizationDemo/.classpath b/BasicJava/Synchronization_Method_V3_Demo_App/SynchronizationDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/Synchronization_Method_V3_Demo_App/SynchronizationDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/Synchronization_Method_V3_Demo_App/SynchronizationDemo/.project b/BasicJava/Synchronization_Method_V3_Demo_App/SynchronizationDemo/.project new file mode 100644 index 000000000..aaa873735 --- /dev/null +++ b/BasicJava/Synchronization_Method_V3_Demo_App/SynchronizationDemo/.project @@ -0,0 +1,17 @@ + + + SynchronizationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/Synchronization_Method_V3_Demo_App/SynchronizationDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/Synchronization_Method_V3_Demo_App/SynchronizationDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/Synchronization_Method_V3_Demo_App/SynchronizationDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/Synchronization_Method_V3_Demo_App/SynchronizationDemo/bin/DisplayMessage.class b/BasicJava/Synchronization_Method_V3_Demo_App/SynchronizationDemo/bin/DisplayMessage.class new file mode 100644 index 000000000..0690456d4 Binary files /dev/null and b/BasicJava/Synchronization_Method_V3_Demo_App/SynchronizationDemo/bin/DisplayMessage.class differ diff --git a/BasicJava/Synchronization_Method_V3_Demo_App/SynchronizationDemo/bin/DisplayThread.class b/BasicJava/Synchronization_Method_V3_Demo_App/SynchronizationDemo/bin/DisplayThread.class new file mode 100644 index 000000000..87a0b96bd Binary files /dev/null and b/BasicJava/Synchronization_Method_V3_Demo_App/SynchronizationDemo/bin/DisplayThread.class differ diff --git a/BasicJava/Synchronization_Method_V3_Demo_App/SynchronizationDemo/bin/SynchronizationDemo.class b/BasicJava/Synchronization_Method_V3_Demo_App/SynchronizationDemo/bin/SynchronizationDemo.class new file mode 100644 index 000000000..a85f06a09 Binary files /dev/null and b/BasicJava/Synchronization_Method_V3_Demo_App/SynchronizationDemo/bin/SynchronizationDemo.class differ diff --git a/BasicJava/Synchronization_Method_V3_Demo_App/SynchronizationDemo/src/DisplayMessage.java b/BasicJava/Synchronization_Method_V3_Demo_App/SynchronizationDemo/src/DisplayMessage.java new file mode 100644 index 000000000..bf0cfec65 --- /dev/null +++ b/BasicJava/Synchronization_Method_V3_Demo_App/SynchronizationDemo/src/DisplayMessage.java @@ -0,0 +1,23 @@ +public class DisplayMessage +{ + + /* + * Method is synchronized + */ + public synchronized void showMessage(String msg) + { + System.out.println("Thread Name = " + + Thread.currentThread().getName()); + System.out.print("[" + msg); + try + { + Thread.sleep(1000); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + System.out.println("]"); + } + +} diff --git a/BasicJava/Synchronization_Method_V3_Demo_App/SynchronizationDemo/src/DisplayThread.java b/BasicJava/Synchronization_Method_V3_Demo_App/SynchronizationDemo/src/DisplayThread.java new file mode 100644 index 000000000..005206d13 --- /dev/null +++ b/BasicJava/Synchronization_Method_V3_Demo_App/SynchronizationDemo/src/DisplayThread.java @@ -0,0 +1,16 @@ +public class DisplayThread extends Thread +{ + private String msg; + private DisplayMessage displayMessage; + + public DisplayThread(DisplayMessage displayMessage, String msg) + { + this.displayMessage = displayMessage; + this.msg = msg; + } + + public void run() + { + displayMessage.showMessage(msg); + } +} diff --git a/BasicJava/Synchronization_Method_V3_Demo_App/SynchronizationDemo/src/SynchronizationDemo.java b/BasicJava/Synchronization_Method_V3_Demo_App/SynchronizationDemo/src/SynchronizationDemo.java new file mode 100644 index 000000000..5a95d8941 --- /dev/null +++ b/BasicJava/Synchronization_Method_V3_Demo_App/SynchronizationDemo/src/SynchronizationDemo.java @@ -0,0 +1,13 @@ +public class SynchronizationDemo +{ + public static void main(String[] args) + { + DisplayMessage displayMessage = new DisplayMessage(); + DisplayThread thread1 = new DisplayThread(displayMessage, "welcome"); + DisplayThread thread2 = new DisplayThread(displayMessage, "Hello"); + DisplayThread thread3 = new DisplayThread(displayMessage, "Peter"); + thread1.start(); + thread2.start(); + thread3.start(); + } +} \ No newline at end of file diff --git a/BasicJava/Synchronization_Method_V4_Demo_App/Output.txt b/BasicJava/Synchronization_Method_V4_Demo_App/Output.txt new file mode 100644 index 000000000..1c6cc5aa2 --- /dev/null +++ b/BasicJava/Synchronization_Method_V4_Demo_App/Output.txt @@ -0,0 +1,39 @@ +------------------------------------- +If printCount method is synchronized, +then below will be the output: +------------------------------------- + +Thread Name = Thread1 +Counter --- 5 +Counter --- 4 +Counter --- 3 +Counter --- 2 +Counter --- 1 + +Thread Name = Thread2 +Counter --- 5 +Counter --- 4 +Counter --- 3 +Counter --- 2 +Counter --- 1 + +----------------------------------------- +If printCount method is not synchronized, +then below will be the output: +----------------------------------------- + +Thread Name = Thread1 +Counter --- 5 +Thread Name = Thread2 +Counter --- 5 +Counter --- 4 +Counter --- 4 +Counter --- 3 +Counter --- 3 +Counter --- 2 +Counter --- 2 +Counter --- 1 +Counter --- 1 + + + diff --git a/BasicJava/Synchronization_Method_V4_Demo_App/SynchronizationDemo/.classpath b/BasicJava/Synchronization_Method_V4_Demo_App/SynchronizationDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/Synchronization_Method_V4_Demo_App/SynchronizationDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/Synchronization_Method_V4_Demo_App/SynchronizationDemo/.project b/BasicJava/Synchronization_Method_V4_Demo_App/SynchronizationDemo/.project new file mode 100644 index 000000000..aaa873735 --- /dev/null +++ b/BasicJava/Synchronization_Method_V4_Demo_App/SynchronizationDemo/.project @@ -0,0 +1,17 @@ + + + SynchronizationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/Synchronization_Method_V4_Demo_App/SynchronizationDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/Synchronization_Method_V4_Demo_App/SynchronizationDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/Synchronization_Method_V4_Demo_App/SynchronizationDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/Synchronization_Method_V4_Demo_App/SynchronizationDemo/bin/DisplayCounter.class b/BasicJava/Synchronization_Method_V4_Demo_App/SynchronizationDemo/bin/DisplayCounter.class new file mode 100644 index 000000000..56561336b Binary files /dev/null and b/BasicJava/Synchronization_Method_V4_Demo_App/SynchronizationDemo/bin/DisplayCounter.class differ diff --git a/BasicJava/Synchronization_Method_V4_Demo_App/SynchronizationDemo/bin/DisplayThread.class b/BasicJava/Synchronization_Method_V4_Demo_App/SynchronizationDemo/bin/DisplayThread.class new file mode 100644 index 000000000..c518b695b Binary files /dev/null and b/BasicJava/Synchronization_Method_V4_Demo_App/SynchronizationDemo/bin/DisplayThread.class differ diff --git a/BasicJava/Synchronization_Method_V4_Demo_App/SynchronizationDemo/bin/SynchronizationDemo.class b/BasicJava/Synchronization_Method_V4_Demo_App/SynchronizationDemo/bin/SynchronizationDemo.class new file mode 100644 index 000000000..f0e39d24c Binary files /dev/null and b/BasicJava/Synchronization_Method_V4_Demo_App/SynchronizationDemo/bin/SynchronizationDemo.class differ diff --git a/BasicJava/Synchronization_Method_V4_Demo_App/SynchronizationDemo/src/DisplayCounter.java b/BasicJava/Synchronization_Method_V4_Demo_App/SynchronizationDemo/src/DisplayCounter.java new file mode 100644 index 000000000..2973f3266 --- /dev/null +++ b/BasicJava/Synchronization_Method_V4_Demo_App/SynchronizationDemo/src/DisplayCounter.java @@ -0,0 +1,24 @@ +public class DisplayCounter +{ + + public synchronized void printCount() + { + + try + { + System.out.println("Thread Name = " + + Thread.currentThread().getName()); + for (int i = 5; i > 0; i--) + { + System.out.println("Counter --- " + i); + Thread.sleep(500); + } + System.out.println(); + } + catch (Exception e) + { + e.printStackTrace(); + } + + } +} diff --git a/BasicJava/Synchronization_Method_V4_Demo_App/SynchronizationDemo/src/DisplayThread.java b/BasicJava/Synchronization_Method_V4_Demo_App/SynchronizationDemo/src/DisplayThread.java new file mode 100644 index 000000000..c34ca5a2e --- /dev/null +++ b/BasicJava/Synchronization_Method_V4_Demo_App/SynchronizationDemo/src/DisplayThread.java @@ -0,0 +1,16 @@ +public class DisplayThread extends Thread +{ + private DisplayCounter dc; + + public DisplayThread(String name, DisplayCounter dc) + { + super.setName(name); + this.dc = dc; + } + + public void run() + { + dc.printCount(); + } + +} diff --git a/BasicJava/Synchronization_Method_V4_Demo_App/SynchronizationDemo/src/SynchronizationDemo.java b/BasicJava/Synchronization_Method_V4_Demo_App/SynchronizationDemo/src/SynchronizationDemo.java new file mode 100644 index 000000000..3ac5c15af --- /dev/null +++ b/BasicJava/Synchronization_Method_V4_Demo_App/SynchronizationDemo/src/SynchronizationDemo.java @@ -0,0 +1,13 @@ +public class SynchronizationDemo +{ + public static void main(String[] args) + { + DisplayCounter displayCounter = new DisplayCounter(); + + DisplayThread thread1 = new DisplayThread("Thread1", displayCounter); + DisplayThread thread2 = new DisplayThread("Thread2", displayCounter); + + thread1.start(); + thread2.start(); + } +} \ No newline at end of file diff --git a/BasicJava/SystemDemo_ArrayCopy_App/Output.txt b/BasicJava/SystemDemo_ArrayCopy_App/Output.txt new file mode 100644 index 000000000..fe3a733b1 --- /dev/null +++ b/BasicJava/SystemDemo_ArrayCopy_App/Output.txt @@ -0,0 +1,2 @@ +Before copy, destArray = 1,2,3,4, +After copy, destArray = 30,40,50,4, \ No newline at end of file diff --git a/BasicJava/SystemDemo_ArrayCopy_App/SystemDemo/.classpath b/BasicJava/SystemDemo_ArrayCopy_App/SystemDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/SystemDemo_ArrayCopy_App/SystemDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/SystemDemo_ArrayCopy_App/SystemDemo/.project b/BasicJava/SystemDemo_ArrayCopy_App/SystemDemo/.project new file mode 100644 index 000000000..93392a3d7 --- /dev/null +++ b/BasicJava/SystemDemo_ArrayCopy_App/SystemDemo/.project @@ -0,0 +1,17 @@ + + + SystemDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/SystemDemo_ArrayCopy_App/SystemDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/SystemDemo_ArrayCopy_App/SystemDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/SystemDemo_ArrayCopy_App/SystemDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/SystemDemo_ArrayCopy_App/SystemDemo/bin/ArrayCopyDemo.class b/BasicJava/SystemDemo_ArrayCopy_App/SystemDemo/bin/ArrayCopyDemo.class new file mode 100644 index 000000000..361fa1a46 Binary files /dev/null and b/BasicJava/SystemDemo_ArrayCopy_App/SystemDemo/bin/ArrayCopyDemo.class differ diff --git a/BasicJava/SystemDemo_ArrayCopy_App/SystemDemo/src/ArrayCopyDemo.java b/BasicJava/SystemDemo_ArrayCopy_App/SystemDemo/src/ArrayCopyDemo.java new file mode 100644 index 000000000..4848e6c7b --- /dev/null +++ b/BasicJava/SystemDemo_ArrayCopy_App/SystemDemo/src/ArrayCopyDemo.java @@ -0,0 +1,44 @@ +/* + * public static void arraycopy(Object src, int srcPos, + * Object dest, int destPos, int length) + * + * Parameters: + * ----------- + * + * src - the source array. + * srcPos - starting position in the source array. + * dest - the destination array. + * destPos - starting position in the destination data. + * length - the number of array elements to be copied. + */ + +public class ArrayCopyDemo +{ + + public static void main(String[] args) + { + int srcArray[] = + { 30, 40, 50 }; + int destArray[] = + { 1, 2, 3, 4 }; + + System.out.print("Before copy, destArray = "); + for (int i : destArray) + { + System.out.print(i + ","); + } + + /* + * Copies an array from the specified source array, + * beginning at the specified position, to the + * specified position of the destination array. + */ + System.arraycopy(srcArray, 0, destArray, 0, 3); + System.out.print("\nAfter copy, destArray = "); + for (int i : destArray) + { + System.out.print(i + ","); + } + + } +} \ No newline at end of file diff --git a/BasicJava/SystemDemo_CTinMS_App/Output.txt b/BasicJava/SystemDemo_CTinMS_App/Output.txt new file mode 100644 index 000000000..d757d38a2 --- /dev/null +++ b/BasicJava/SystemDemo_CTinMS_App/Output.txt @@ -0,0 +1,2 @@ +Current Time in milliseconds = 1488772077364 +Current date and Time = Mon Mar 06 09:17:57 IST 2017 diff --git a/BasicJava/SystemDemo_CTinMS_App/SystemDemo/.classpath b/BasicJava/SystemDemo_CTinMS_App/SystemDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/SystemDemo_CTinMS_App/SystemDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/SystemDemo_CTinMS_App/SystemDemo/.project b/BasicJava/SystemDemo_CTinMS_App/SystemDemo/.project new file mode 100644 index 000000000..93392a3d7 --- /dev/null +++ b/BasicJava/SystemDemo_CTinMS_App/SystemDemo/.project @@ -0,0 +1,17 @@ + + + SystemDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/SystemDemo_CTinMS_App/SystemDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/SystemDemo_CTinMS_App/SystemDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/SystemDemo_CTinMS_App/SystemDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/SystemDemo_CTinMS_App/SystemDemo/bin/SystemDemo.class b/BasicJava/SystemDemo_CTinMS_App/SystemDemo/bin/SystemDemo.class new file mode 100644 index 000000000..aec6db5c5 Binary files /dev/null and b/BasicJava/SystemDemo_CTinMS_App/SystemDemo/bin/SystemDemo.class differ diff --git a/BasicJava/SystemDemo_CTinMS_App/SystemDemo/src/SystemDemo.java b/BasicJava/SystemDemo_CTinMS_App/SystemDemo/src/SystemDemo.java new file mode 100644 index 000000000..5853c6368 --- /dev/null +++ b/BasicJava/SystemDemo_CTinMS_App/SystemDemo/src/SystemDemo.java @@ -0,0 +1,19 @@ +import java.io.IOException; +import java.util.Date; + +public class SystemDemo +{ + + public static void main(String[] args) throws IOException + { + /* + * Returns the current time in milliseconds. + */ + long currentTimeInms = System.currentTimeMillis(); + System.out.println("Current Time in milliseconds = " + currentTimeInms); + + Date date = new Date(currentTimeInms); + System.out.println("Current date and Time = "+date); + + } +} \ No newline at end of file diff --git a/BasicJava/SystemDemo_exit_App/Output.txt b/BasicJava/SystemDemo_exit_App/Output.txt new file mode 100644 index 000000000..b45c68847 --- /dev/null +++ b/BasicJava/SystemDemo_exit_App/Output.txt @@ -0,0 +1 @@ +Arithmetic Exception: You can't divide an integer by 0 diff --git a/BasicJava/SystemDemo_exit_App/SystemDemo/.classpath b/BasicJava/SystemDemo_exit_App/SystemDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/SystemDemo_exit_App/SystemDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/SystemDemo_exit_App/SystemDemo/.project b/BasicJava/SystemDemo_exit_App/SystemDemo/.project new file mode 100644 index 000000000..93392a3d7 --- /dev/null +++ b/BasicJava/SystemDemo_exit_App/SystemDemo/.project @@ -0,0 +1,17 @@ + + + SystemDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/SystemDemo_exit_App/SystemDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/SystemDemo_exit_App/SystemDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/SystemDemo_exit_App/SystemDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/SystemDemo_exit_App/SystemDemo/bin/ExitDemo.class b/BasicJava/SystemDemo_exit_App/SystemDemo/bin/ExitDemo.class new file mode 100644 index 000000000..66fb2f083 Binary files /dev/null and b/BasicJava/SystemDemo_exit_App/SystemDemo/bin/ExitDemo.class differ diff --git a/BasicJava/SystemDemo_exit_App/SystemDemo/src/ExitDemo.java b/BasicJava/SystemDemo_exit_App/SystemDemo/src/ExitDemo.java new file mode 100644 index 000000000..0ffa30cd3 --- /dev/null +++ b/BasicJava/SystemDemo_exit_App/SystemDemo/src/ExitDemo.java @@ -0,0 +1,45 @@ +/* + * public static void exit(int status) + * + * Parameters: + * ----------- + * + * status - exit status. + */ + +public class ExitDemo +{ + + public static void main(String[] args) + { + try + { + int num1 = 30, num2 = 0; + int output = num1 / num2; + System.out.println("Result = " + output); + } + catch (ArithmeticException e) + { + System.out + .println("Arithmetic Exception: You can't divide an integer by 0"); + + /* + * Terminates the currently running Java Virtual + * Machine.The argument serves as a status code; + * by convention, a nonzero status code + * indicates abnormal termination. + * + * This method calls the exit method in class + * Runtime. This method never returns normally. + * + * The call System.exit(n) is effectively + * equivalent to the call: + * Runtime.getRuntime().exit(n) + */ + System.exit(0); + } + + System.out.println("Welcome to india.."); + + } +} \ No newline at end of file diff --git a/BasicJava/SystemDemo_time_App/SystemDemo/.classpath b/BasicJava/SystemDemo_time_App/SystemDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/SystemDemo_time_App/SystemDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/SystemDemo_time_App/SystemDemo/.project b/BasicJava/SystemDemo_time_App/SystemDemo/.project new file mode 100644 index 000000000..93392a3d7 --- /dev/null +++ b/BasicJava/SystemDemo_time_App/SystemDemo/.project @@ -0,0 +1,17 @@ + + + SystemDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/SystemDemo_time_App/SystemDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/SystemDemo_time_App/SystemDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/SystemDemo_time_App/SystemDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/SystemDemo_time_App/SystemDemo/bin/TimeDemo.class b/BasicJava/SystemDemo_time_App/SystemDemo/bin/TimeDemo.class new file mode 100644 index 000000000..a1b28bc72 Binary files /dev/null and b/BasicJava/SystemDemo_time_App/SystemDemo/bin/TimeDemo.class differ diff --git a/BasicJava/SystemDemo_time_App/SystemDemo/bin/TimeDiffDemo.class b/BasicJava/SystemDemo_time_App/SystemDemo/bin/TimeDiffDemo.class new file mode 100644 index 000000000..6001f4073 Binary files /dev/null and b/BasicJava/SystemDemo_time_App/SystemDemo/bin/TimeDiffDemo.class differ diff --git a/BasicJava/SystemDemo_time_App/SystemDemo/src/TimeDemo.java b/BasicJava/SystemDemo_time_App/SystemDemo/src/TimeDemo.java new file mode 100644 index 000000000..b367f908f --- /dev/null +++ b/BasicJava/SystemDemo_time_App/SystemDemo/src/TimeDemo.java @@ -0,0 +1,23 @@ +import java.io.IOException; + +public class TimeDemo +{ + + public static void main(String[] args) throws IOException + { + /* + * Returns the current value of the system timer, in + * nanoseconds + */ + System.out.print("time in nanoseconds = "); + System.out.println(System.nanoTime()); + + /* + * Returns the current value of the system timer, in + * milliseconds + */ + System.out.print("time in milliseconds = "); + System.out.println(System.currentTimeMillis()); + + } +} \ No newline at end of file diff --git a/BasicJava/SystemDemo_time_App/SystemDemo/src/TimeDiffDemo.java b/BasicJava/SystemDemo_time_App/SystemDemo/src/TimeDiffDemo.java new file mode 100644 index 000000000..695eccd41 --- /dev/null +++ b/BasicJava/SystemDemo_time_App/SystemDemo/src/TimeDiffDemo.java @@ -0,0 +1,23 @@ +public class TimeDiffDemo +{ + + public static void main(String[] args) throws InterruptedException + { + long startTime = System.currentTimeMillis(); + + int i = 1; + while (i < 1000) + { + Thread.sleep(10); + ++i; + } + + long endTime = System.currentTimeMillis(); + + long timeDiff = endTime - startTime; + + System.out.println("timeDiff in ms = " + timeDiff); + + } + +} diff --git a/BasicJava/SystemDemo_time_App/TimeDemo_Output.txt b/BasicJava/SystemDemo_time_App/TimeDemo_Output.txt new file mode 100644 index 000000000..d00fd06f9 --- /dev/null +++ b/BasicJava/SystemDemo_time_App/TimeDemo_Output.txt @@ -0,0 +1,2 @@ +time in nanoseconds = 8765309144714 +time in milliseconds = 1488772824057 diff --git a/BasicJava/SystemDemo_time_App/TimeDiffDemo_Output.txt b/BasicJava/SystemDemo_time_App/TimeDiffDemo_Output.txt new file mode 100644 index 000000000..e4d49d52f --- /dev/null +++ b/BasicJava/SystemDemo_time_App/TimeDiffDemo_Output.txt @@ -0,0 +1 @@ +timeDiff in ms = 10428 diff --git a/BasicJava/System_getProperty_App/Output.txt b/BasicJava/System_getProperty_App/Output.txt new file mode 100644 index 000000000..964dcf691 --- /dev/null +++ b/BasicJava/System_getProperty_App/Output.txt @@ -0,0 +1,2 @@ +value = Windows 7 +value1 = null diff --git a/BasicJava/System_getProperty_App/PropertiesDemo/.classpath b/BasicJava/System_getProperty_App/PropertiesDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/System_getProperty_App/PropertiesDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/System_getProperty_App/PropertiesDemo/.project b/BasicJava/System_getProperty_App/PropertiesDemo/.project new file mode 100644 index 000000000..4a6f3ffb3 --- /dev/null +++ b/BasicJava/System_getProperty_App/PropertiesDemo/.project @@ -0,0 +1,17 @@ + + + PropertiesDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/System_getProperty_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/System_getProperty_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/System_getProperty_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/System_getProperty_App/PropertiesDemo/bin/PropertiesDemo.class b/BasicJava/System_getProperty_App/PropertiesDemo/bin/PropertiesDemo.class new file mode 100644 index 000000000..7b52a5ef1 Binary files /dev/null and b/BasicJava/System_getProperty_App/PropertiesDemo/bin/PropertiesDemo.class differ diff --git a/BasicJava/System_getProperty_App/PropertiesDemo/src/PropertiesDemo.java b/BasicJava/System_getProperty_App/PropertiesDemo/src/PropertiesDemo.java new file mode 100644 index 000000000..a1d085525 --- /dev/null +++ b/BasicJava/System_getProperty_App/PropertiesDemo/src/PropertiesDemo.java @@ -0,0 +1,26 @@ +/* + * public static String getProperty(String key) + * + * Parameters: + * ---------- + * + * key - the name of the system property. + */ + +public class PropertiesDemo +{ + + public static void main(String[] args) + { + /* + * Gets the system property indicated by the + * specified key. + */ + String value = System.getProperty("os.name"); + System.out.println("value = " + value); + + String value1 = System.getProperty("a.b"); + System.out.println("value1 = " + value1); + + } +} \ No newline at end of file diff --git a/BasicJava/System_getProperty_default_App/Output.txt b/BasicJava/System_getProperty_default_App/Output.txt new file mode 100644 index 000000000..f2de4b225 --- /dev/null +++ b/BasicJava/System_getProperty_default_App/Output.txt @@ -0,0 +1,2 @@ +value1 = hello +value2 = Windows 7 diff --git a/BasicJava/System_getProperty_default_App/PropertiesDemo/.classpath b/BasicJava/System_getProperty_default_App/PropertiesDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/System_getProperty_default_App/PropertiesDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/System_getProperty_default_App/PropertiesDemo/.project b/BasicJava/System_getProperty_default_App/PropertiesDemo/.project new file mode 100644 index 000000000..4a6f3ffb3 --- /dev/null +++ b/BasicJava/System_getProperty_default_App/PropertiesDemo/.project @@ -0,0 +1,17 @@ + + + PropertiesDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/System_getProperty_default_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/System_getProperty_default_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/System_getProperty_default_App/PropertiesDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/System_getProperty_default_App/PropertiesDemo/bin/PropertiesDemo.class b/BasicJava/System_getProperty_default_App/PropertiesDemo/bin/PropertiesDemo.class new file mode 100644 index 000000000..0fabc50ca Binary files /dev/null and b/BasicJava/System_getProperty_default_App/PropertiesDemo/bin/PropertiesDemo.class differ diff --git a/BasicJava/System_getProperty_default_App/PropertiesDemo/src/PropertiesDemo.java b/BasicJava/System_getProperty_default_App/PropertiesDemo/src/PropertiesDemo.java new file mode 100644 index 000000000..98bd4c372 --- /dev/null +++ b/BasicJava/System_getProperty_default_App/PropertiesDemo/src/PropertiesDemo.java @@ -0,0 +1,30 @@ +/* + * public static String getProperty(String key, String + * def) + * + * Parameters: + * ---------- + * + * key - the name of the system property. + * def - a default value. + */ + +public class PropertiesDemo +{ + + public static void main(String[] args) + { + /* + * Gets the system property indicated by the + * specified key.if not present it will return + * default value. + */ + String value1 = System.getProperty("a.b", "hello"); + System.out.println("value1 = " + value1); + + + String value2 = System.getProperty("os.name", "hello"); + System.out.println("value2 = " + value2); + + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_CachedThreadPool_App/Output.txt b/BasicJava/ThreadDemo_CachedThreadPool_App/Output.txt new file mode 100644 index 000000000..29e655d3a --- /dev/null +++ b/BasicJava/ThreadDemo_CachedThreadPool_App/Output.txt @@ -0,0 +1,28 @@ +pool-1-thread-2 taskNumber : 1, percent complete: 0 +pool-1-thread-1 taskNumber : 0, percent complete: 0 +pool-1-thread-3 taskNumber : 2, percent complete: 0 +pool-1-thread-4 taskNumber : 3, percent complete: 0 +pool-1-thread-2 taskNumber : 1, percent complete: 20 +pool-1-thread-4 taskNumber : 3, percent complete: 20 +pool-1-thread-1 taskNumber : 0, percent complete: 20 +pool-1-thread-3 taskNumber : 2, percent complete: 20 +pool-1-thread-4 taskNumber : 3, percent complete: 40 +pool-1-thread-3 taskNumber : 2, percent complete: 40 +pool-1-thread-2 taskNumber : 1, percent complete: 40 +pool-1-thread-4 taskNumber : 3, percent complete: 60 +pool-1-thread-3 taskNumber : 2, percent complete: 60 +pool-1-thread-2 taskNumber : 1, percent complete: 60 +pool-1-thread-1 taskNumber : 0, percent complete: 40 +pool-1-thread-2 taskNumber : 1, percent complete: 80 +pool-1-thread-3 taskNumber : 2, percent complete: 80 +pool-1-thread-2 taskNumber : 1, percent complete: 100 +pool-1-thread-4 taskNumber : 3, percent complete: 80 +pool-1-thread-1 taskNumber : 0, percent complete: 60 +pool-1-thread-4 taskNumber : 3, percent complete: 100 +pool-1-thread-3 taskNumber : 2, percent complete: 100 +pool-1-thread-1 taskNumber : 0, percent complete: 80 +pool-1-thread-1 taskNumber : 0, percent complete: 100 +Ending task : 0 +Ending task : 1 +Ending task : 2 +Ending task : 3 diff --git a/BasicJava/ThreadDemo_CachedThreadPool_App/ThreadDemo/.classpath b/BasicJava/ThreadDemo_CachedThreadPool_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_CachedThreadPool_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_CachedThreadPool_App/ThreadDemo/.project b/BasicJava/ThreadDemo_CachedThreadPool_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_CachedThreadPool_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_CachedThreadPool_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_CachedThreadPool_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_CachedThreadPool_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_CachedThreadPool_App/ThreadDemo/bin/CallableTask.class b/BasicJava/ThreadDemo_CachedThreadPool_App/ThreadDemo/bin/CallableTask.class new file mode 100644 index 000000000..f1f5a0e95 Binary files /dev/null and b/BasicJava/ThreadDemo_CachedThreadPool_App/ThreadDemo/bin/CallableTask.class differ diff --git a/BasicJava/ThreadDemo_CachedThreadPool_App/ThreadDemo/bin/CallableWorkerThread.class b/BasicJava/ThreadDemo_CachedThreadPool_App/ThreadDemo/bin/CallableWorkerThread.class new file mode 100644 index 000000000..7c3b0c873 Binary files /dev/null and b/BasicJava/ThreadDemo_CachedThreadPool_App/ThreadDemo/bin/CallableWorkerThread.class differ diff --git a/BasicJava/ThreadDemo_CachedThreadPool_App/ThreadDemo/bin/ThreadPoolTest.class b/BasicJava/ThreadDemo_CachedThreadPool_App/ThreadDemo/bin/ThreadPoolTest.class new file mode 100644 index 000000000..4488d67ab Binary files /dev/null and b/BasicJava/ThreadDemo_CachedThreadPool_App/ThreadDemo/bin/ThreadPoolTest.class differ diff --git a/BasicJava/ThreadDemo_CachedThreadPool_App/ThreadDemo/src/CallableTask.java b/BasicJava/ThreadDemo_CachedThreadPool_App/ThreadDemo/src/CallableTask.java new file mode 100644 index 000000000..363c813ff --- /dev/null +++ b/BasicJava/ThreadDemo_CachedThreadPool_App/ThreadDemo/src/CallableTask.java @@ -0,0 +1,30 @@ +import java.util.concurrent.Callable; + +public class CallableTask implements Callable +{ + private int taskNumber; + + CallableTask(int taskNumber) + { + this.taskNumber = taskNumber; + } + + public Integer call() + { + for (int i = 0; i <= 100; i += 20) + { + // Perform some work ... + System.out.println(Thread.currentThread().getName() + + " taskNumber : " + taskNumber + ", percent complete: " + + i); + try + { + Thread.sleep((int) (Math.random() * 1000)); + } + catch (InterruptedException e) + { + } + } + return (taskNumber); + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_CachedThreadPool_App/ThreadDemo/src/ThreadPoolTest.java b/BasicJava/ThreadDemo_CachedThreadPool_App/ThreadDemo/src/ThreadPoolTest.java new file mode 100644 index 000000000..81d0bf6a5 --- /dev/null +++ b/BasicJava/ThreadDemo_CachedThreadPool_App/ThreadDemo/src/ThreadPoolTest.java @@ -0,0 +1,32 @@ +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +public class ThreadPoolTest +{ + public static void main(String[] args) + { + int numOfCallableTasks = 4; + + ExecutorService executorService = Executors.newCachedThreadPool(); + CallableTask callableTasks[] = new CallableTask[numOfCallableTasks]; + Future futures[] = new Future[numOfCallableTasks]; + + for (int i = 0; i < numOfCallableTasks; i++) + { + callableTasks[i] = new CallableTask(i); + futures[i] = executorService.submit(callableTasks[i]); + } + for (int i = 0; i < numOfCallableTasks; i++) + { + try + { + System.out.println("Ending task : " + futures[i].get()); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_Handle_Interrupted_Exe_App/Output.txt b/BasicJava/ThreadDemo_Handle_Interrupted_Exe_App/Output.txt new file mode 100644 index 000000000..613e0ce06 --- /dev/null +++ b/BasicJava/ThreadDemo_Handle_Interrupted_Exe_App/Output.txt @@ -0,0 +1,3 @@ +Going to sleep... +Exception handled +Thread is running... diff --git a/BasicJava/ThreadDemo_Handle_Interrupted_Exe_App/ThreadDemo/.classpath b/BasicJava/ThreadDemo_Handle_Interrupted_Exe_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_Handle_Interrupted_Exe_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_Handle_Interrupted_Exe_App/ThreadDemo/.project b/BasicJava/ThreadDemo_Handle_Interrupted_Exe_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_Handle_Interrupted_Exe_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_Handle_Interrupted_Exe_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_Handle_Interrupted_Exe_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_Handle_Interrupted_Exe_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_Handle_Interrupted_Exe_App/ThreadDemo/bin/DisplayThread.class b/BasicJava/ThreadDemo_Handle_Interrupted_Exe_App/ThreadDemo/bin/DisplayThread.class new file mode 100644 index 000000000..37c7ed4af Binary files /dev/null and b/BasicJava/ThreadDemo_Handle_Interrupted_Exe_App/ThreadDemo/bin/DisplayThread.class differ diff --git a/BasicJava/ThreadDemo_Handle_Interrupted_Exe_App/ThreadDemo/src/DisplayThread.java b/BasicJava/ThreadDemo_Handle_Interrupted_Exe_App/ThreadDemo/src/DisplayThread.java new file mode 100644 index 000000000..d8cb6144a --- /dev/null +++ b/BasicJava/ThreadDemo_Handle_Interrupted_Exe_App/ThreadDemo/src/DisplayThread.java @@ -0,0 +1,42 @@ +/* + * Example of interrupting a thread that doesn't stop + * working + * + * In this example, after interrupting the thread, we + * handle the exception, so it will break out the + * sleeping but will not stop working. + */ + +class DisplayThread extends Thread +{ + + public void run() + { + try + { + System.out.println("Going to sleep..."); + Thread.sleep(1000); + System.out.println("Welcome to India..."); + } + catch (InterruptedException e) + { + System.out.println("Exception handled"); + } + System.out.println("Thread is running..."); + } + + public static void main(String args[]) + { + DisplayThread t1 = new DisplayThread(); + t1.start(); + try + { + t1.interrupt(); + } + catch (Exception e) + { + e.printStackTrace(); + } + + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_Interrupt_not_affect_App/Output.txt b/BasicJava/ThreadDemo_Interrupt_not_affect_App/Output.txt new file mode 100644 index 000000000..f00c965d8 --- /dev/null +++ b/BasicJava/ThreadDemo_Interrupt_not_affect_App/Output.txt @@ -0,0 +1,10 @@ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 diff --git a/BasicJava/ThreadDemo_Interrupt_not_affect_App/ThreadDemo/.classpath b/BasicJava/ThreadDemo_Interrupt_not_affect_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_Interrupt_not_affect_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_Interrupt_not_affect_App/ThreadDemo/.project b/BasicJava/ThreadDemo_Interrupt_not_affect_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_Interrupt_not_affect_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_Interrupt_not_affect_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_Interrupt_not_affect_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_Interrupt_not_affect_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_Interrupt_not_affect_App/ThreadDemo/bin/DisplayThread.class b/BasicJava/ThreadDemo_Interrupt_not_affect_App/ThreadDemo/bin/DisplayThread.class new file mode 100644 index 000000000..b88ff84fc Binary files /dev/null and b/BasicJava/ThreadDemo_Interrupt_not_affect_App/ThreadDemo/bin/DisplayThread.class differ diff --git a/BasicJava/ThreadDemo_Interrupt_not_affect_App/ThreadDemo/src/DisplayThread.java b/BasicJava/ThreadDemo_Interrupt_not_affect_App/ThreadDemo/src/DisplayThread.java new file mode 100644 index 000000000..e5190f782 --- /dev/null +++ b/BasicJava/ThreadDemo_Interrupt_not_affect_App/ThreadDemo/src/DisplayThread.java @@ -0,0 +1,26 @@ +/* + * Example of interrupting thread that behaves normally. + * + * If thread is not in sleeping or waiting state, + * calling the interrupt() method sets the interrupted + * flag to true that can be used to stop the thread by + * the java programmer later. + */ +class DisplayThread extends Thread +{ + public void run() + { + for (int i = 1; i <= 10; i++) + { + System.out.println(i); + } + } + + public static void main(String args[]) + { + DisplayThread t1 = new DisplayThread(); + t1.start(); + + t1.interrupt(); + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_Interrupting_Thread_App/Output.txt b/BasicJava/ThreadDemo_Interrupting_Thread_App/Output.txt new file mode 100644 index 000000000..2fa7a3130 --- /dev/null +++ b/BasicJava/ThreadDemo_Interrupting_Thread_App/Output.txt @@ -0,0 +1,4 @@ +Exception in thread "Thread-0" Going to sleep... +java.lang.RuntimeException: Thread interrupted... +java.lang.InterruptedException: sleep interrupted + at DisplayThread.run(DisplayThread.java:38) diff --git a/BasicJava/ThreadDemo_Interrupting_Thread_App/ThreadDemo/.classpath b/BasicJava/ThreadDemo_Interrupting_Thread_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_Interrupting_Thread_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_Interrupting_Thread_App/ThreadDemo/.project b/BasicJava/ThreadDemo_Interrupting_Thread_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_Interrupting_Thread_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_Interrupting_Thread_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_Interrupting_Thread_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_Interrupting_Thread_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_Interrupting_Thread_App/ThreadDemo/bin/DisplayThread.class b/BasicJava/ThreadDemo_Interrupting_Thread_App/ThreadDemo/bin/DisplayThread.class new file mode 100644 index 000000000..126ab0e6b Binary files /dev/null and b/BasicJava/ThreadDemo_Interrupting_Thread_App/ThreadDemo/bin/DisplayThread.class differ diff --git a/BasicJava/ThreadDemo_Interrupting_Thread_App/ThreadDemo/src/DisplayThread.java b/BasicJava/ThreadDemo_Interrupting_Thread_App/ThreadDemo/src/DisplayThread.java new file mode 100644 index 000000000..0c5ac4b01 --- /dev/null +++ b/BasicJava/ThreadDemo_Interrupting_Thread_App/ThreadDemo/src/DisplayThread.java @@ -0,0 +1,43 @@ +/* + * Example of interrupting a thread that stops + * working. + * + * In this example, after interrupting the thread, we + * are propagating it, so it will stop working. If we + * don't want to stop the thread, we can handle it where + * sleep() or wait() method is invoked. + */ +class DisplayThread extends Thread +{ + + public static void main(String args[]) + { + DisplayThread t1 = new DisplayThread(); + t1.start(); + try + { + t1.interrupt(); + } + catch (Exception e) + { + e.printStackTrace(); + } + + } + + public void run() + { + try + { + System.out.println("Going to sleep..."); + Thread.sleep(1000); + System.out.println("Welcome to India..."); + } + catch (InterruptedException e) + { + throw new RuntimeException("Thread interrupted... " + e); + } + + } + +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_MultipleTask_MT_App/MultitaskingRunnable_Output.txt b/BasicJava/ThreadDemo_MultipleTask_MT_App/MultitaskingRunnable_Output.txt new file mode 100644 index 000000000..a062dfc2c --- /dev/null +++ b/BasicJava/ThreadDemo_MultipleTask_MT_App/MultitaskingRunnable_Output.txt @@ -0,0 +1,2 @@ +task 1 run by = Task One Thread +task 2 run by = Task two Thread diff --git a/BasicJava/ThreadDemo_MultipleTask_MT_App/MultitaskingThread_Output.txt b/BasicJava/ThreadDemo_MultipleTask_MT_App/MultitaskingThread_Output.txt new file mode 100644 index 000000000..a062dfc2c --- /dev/null +++ b/BasicJava/ThreadDemo_MultipleTask_MT_App/MultitaskingThread_Output.txt @@ -0,0 +1,2 @@ +task 1 run by = Task One Thread +task 2 run by = Task two Thread diff --git a/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/.classpath b/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/.project b/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/bin/MultitaskingRunnable.class b/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/bin/MultitaskingRunnable.class new file mode 100644 index 000000000..d1f0b5c14 Binary files /dev/null and b/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/bin/MultitaskingRunnable.class differ diff --git a/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/bin/MultitaskingThread.class b/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/bin/MultitaskingThread.class new file mode 100644 index 000000000..72500c5a6 Binary files /dev/null and b/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/bin/MultitaskingThread.class differ diff --git a/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/bin/TaskOneRunnable.class b/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/bin/TaskOneRunnable.class new file mode 100644 index 000000000..0b5b011ce Binary files /dev/null and b/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/bin/TaskOneRunnable.class differ diff --git a/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/bin/TaskOneThread.class b/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/bin/TaskOneThread.class new file mode 100644 index 000000000..74bfba376 Binary files /dev/null and b/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/bin/TaskOneThread.class differ diff --git a/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/bin/TaskTwoRunnable.class b/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/bin/TaskTwoRunnable.class new file mode 100644 index 000000000..bf28953e1 Binary files /dev/null and b/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/bin/TaskTwoRunnable.class differ diff --git a/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/bin/TaskTwoThread.class b/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/bin/TaskTwoThread.class new file mode 100644 index 000000000..d851bbf66 Binary files /dev/null and b/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/bin/TaskTwoThread.class differ diff --git a/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/src/MultitaskingRunnable.java b/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/src/MultitaskingRunnable.java new file mode 100644 index 000000000..56dcdb482 --- /dev/null +++ b/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/src/MultitaskingRunnable.java @@ -0,0 +1,36 @@ +class TaskOneRunnable implements Runnable +{ + + public void run() + { + System.out.println("task 1 run by = " + + Thread.currentThread().getName()); + } +} + +class TaskTwoRunnable implements Runnable +{ + public void run() + { + System.out.println("task 2 run by = " + + Thread.currentThread().getName()); + } +} + +public class MultitaskingRunnable +{ + + public static void main(String[] args) + { + TaskOneRunnable taskOneRunnable = new TaskOneRunnable(); + TaskTwoRunnable taskTwoRunnable = new TaskTwoRunnable(); + + Thread t1 = new Thread(taskOneRunnable,"Task One Thread"); + Thread t2 = new Thread(taskTwoRunnable,"Task two Thread"); + + t1.start(); + t2.start(); + + } + +} diff --git a/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/src/MultitaskingThread.java b/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/src/MultitaskingThread.java new file mode 100644 index 000000000..e931d7d35 --- /dev/null +++ b/BasicJava/ThreadDemo_MultipleTask_MT_App/ThreadDemo/src/MultitaskingThread.java @@ -0,0 +1,46 @@ +class TaskOneThread extends Thread +{ + TaskOneThread(String threadName) + { + super(threadName); + } + + public void run() + { + System.out.println("task 1 run by = " + this.getName()); + } +} + +class TaskTwoThread extends Thread +{ + + TaskTwoThread(String threadName) + { + super(threadName); + } + + public void run() + { + System.out.println("task 2 run by = " + this.getName()); + } +} + +/* + * How to perform multiple tasks by multiple threads (multitasking in + * multithreading)? + * + * Program of performing two tasks by two threads + */ +public class MultitaskingThread +{ + + public static void main(String args[]) throws InterruptedException + { + TaskOneThread t1 = new TaskOneThread("Task One Thread"); + TaskTwoThread t2 = new TaskTwoThread("Task two Thread"); + + t1.start(); + t2.start(); + } + +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/MultitaskingRunnable_Output.txt b/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/MultitaskingRunnable_Output.txt new file mode 100644 index 000000000..d805f6f8d --- /dev/null +++ b/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/MultitaskingRunnable_Output.txt @@ -0,0 +1,2 @@ +task 1 run by = Thread-0 +task 2 run by = Thread-1 diff --git a/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/MultitaskingThread_Output.txt b/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/MultitaskingThread_Output.txt new file mode 100644 index 000000000..d805f6f8d --- /dev/null +++ b/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/MultitaskingThread_Output.txt @@ -0,0 +1,2 @@ +task 1 run by = Thread-0 +task 2 run by = Thread-1 diff --git a/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/.classpath b/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/.project b/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/bin/MultitaskingRunnable$1.class b/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/bin/MultitaskingRunnable$1.class new file mode 100644 index 000000000..8d100a49c Binary files /dev/null and b/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/bin/MultitaskingRunnable$1.class differ diff --git a/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/bin/MultitaskingRunnable$2.class b/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/bin/MultitaskingRunnable$2.class new file mode 100644 index 000000000..368320d59 Binary files /dev/null and b/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/bin/MultitaskingRunnable$2.class differ diff --git a/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/bin/MultitaskingRunnable.class b/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/bin/MultitaskingRunnable.class new file mode 100644 index 000000000..5e824dc31 Binary files /dev/null and b/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/bin/MultitaskingRunnable.class differ diff --git a/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/bin/MultitaskingThread$1.class b/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/bin/MultitaskingThread$1.class new file mode 100644 index 000000000..99f7f9fd1 Binary files /dev/null and b/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/bin/MultitaskingThread$1.class differ diff --git a/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/bin/MultitaskingThread$2.class b/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/bin/MultitaskingThread$2.class new file mode 100644 index 000000000..1bccb05e6 Binary files /dev/null and b/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/bin/MultitaskingThread$2.class differ diff --git a/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/bin/MultitaskingThread.class b/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/bin/MultitaskingThread.class new file mode 100644 index 000000000..3c30e2c46 Binary files /dev/null and b/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/bin/MultitaskingThread.class differ diff --git a/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/src/MultitaskingRunnable.java b/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/src/MultitaskingRunnable.java new file mode 100644 index 000000000..0f52b4596 --- /dev/null +++ b/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/src/MultitaskingRunnable.java @@ -0,0 +1,45 @@ +/* + * How to perform multiple tasks by multiple threads + * (multitasking in multithreading)? + * + * Program of performing two tasks by two threads + */ +public class MultitaskingRunnable +{ + + public static void main(String[] args) + { + /* + * annonymous class that implements Runnable + * interface + */ + Runnable r1 = new Runnable() + { + public void run() + { + System.out.println("task 1 run by = " + + Thread.currentThread().getName()); + } + }; + /* + * annonymous class that implements Runnable + * interface + */ + Runnable r2 = new Runnable() + { + public void run() + { + System.out.println("task 2 run by = " + + Thread.currentThread().getName()); + } + }; + + Thread t1 = new Thread(r1); + Thread t2 = new Thread(r2); + + t1.start(); + t2.start(); + + } + +} diff --git a/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/src/MultitaskingThread.java b/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/src/MultitaskingThread.java new file mode 100644 index 000000000..3819e716a --- /dev/null +++ b/BasicJava/ThreadDemo_MultipleTask_MT_annonymous_App/ThreadDemo/src/MultitaskingThread.java @@ -0,0 +1,40 @@ +/* + * How to perform multiple tasks by multiple threads + * (multitasking in multithreading)? + * + * Program of performing two tasks by two threads + */ +public class MultitaskingThread +{ + + public static void main(String args[]) throws InterruptedException + { + /* + * annonymous class that extends Thread class + */ + Thread t1 = new Thread() + { + public void run() + { + System.out.println("task 1 run by = " + + Thread.currentThread().getName()); + } + }; + /* + * annonymous class that extends Thread class + */ + Thread t2 = new Thread() + { + public void run() + { + System.out.println("task 2 run by = " + + Thread.currentThread().getName()); + } + }; + + t1.start(); + t2.start(); + + } + +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_Priority_App/Output.txt b/BasicJava/ThreadDemo_Priority_App/Output.txt new file mode 100644 index 000000000..7c093d79c --- /dev/null +++ b/BasicJava/ThreadDemo_Priority_App/Output.txt @@ -0,0 +1,6 @@ +Thread name = Thread-1, Thread Priority = 5 + +Thread name = Thread-0, Thread Priority = 1 + +Thread name = Thread-2, Thread Priority = 10 + diff --git a/BasicJava/ThreadDemo_Priority_App/ThreadDemo/.classpath b/BasicJava/ThreadDemo_Priority_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_Priority_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_Priority_App/ThreadDemo/.project b/BasicJava/ThreadDemo_Priority_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_Priority_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_Priority_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_Priority_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_Priority_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_Priority_App/ThreadDemo/bin/DisplayThread.class b/BasicJava/ThreadDemo_Priority_App/ThreadDemo/bin/DisplayThread.class new file mode 100644 index 000000000..473325719 Binary files /dev/null and b/BasicJava/ThreadDemo_Priority_App/ThreadDemo/bin/DisplayThread.class differ diff --git a/BasicJava/ThreadDemo_Priority_App/ThreadDemo/src/DisplayThread.java b/BasicJava/ThreadDemo_Priority_App/ThreadDemo/src/DisplayThread.java new file mode 100644 index 000000000..f8a539478 --- /dev/null +++ b/BasicJava/ThreadDemo_Priority_App/ThreadDemo/src/DisplayThread.java @@ -0,0 +1,26 @@ +class DisplayThread extends Thread +{ + public static void main(String args[]) + { + DisplayThread displayThread1 = new DisplayThread(); + DisplayThread displayThread2 = new DisplayThread(); + DisplayThread displayThread3 = new DisplayThread(); + + displayThread1.setPriority(Thread.MIN_PRIORITY); + displayThread2.setPriority(Thread.NORM_PRIORITY); + displayThread3.setPriority(Thread.MAX_PRIORITY); + + displayThread1.start(); + displayThread2.start(); + displayThread3.start(); + + } + + public void run() + { + System.out.println("Thread name = " + Thread.currentThread().getName() + + ", Thread Priority = " + Thread.currentThread().getPriority() + + "\n"); + + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_ShutdownHook_V1_App/AnnonymousShutdownHook_Output.txt b/BasicJava/ThreadDemo_ShutdownHook_V1_App/AnnonymousShutdownHook_Output.txt new file mode 100644 index 000000000..d0ce3254e --- /dev/null +++ b/BasicJava/ThreadDemo_ShutdownHook_V1_App/AnnonymousShutdownHook_Output.txt @@ -0,0 +1,2 @@ +Now main thread sleeping... press ctrl+c to exit +Shut down hook task is completed.. diff --git a/BasicJava/ThreadDemo_ShutdownHook_V1_App/ShutdownHookDemo_Output.txt b/BasicJava/ThreadDemo_ShutdownHook_V1_App/ShutdownHookDemo_Output.txt new file mode 100644 index 000000000..d0ce3254e --- /dev/null +++ b/BasicJava/ThreadDemo_ShutdownHook_V1_App/ShutdownHookDemo_Output.txt @@ -0,0 +1,2 @@ +Now main thread sleeping... press ctrl+c to exit +Shut down hook task is completed.. diff --git a/BasicJava/ThreadDemo_ShutdownHook_V1_App/ThreadDemo/.classpath b/BasicJava/ThreadDemo_ShutdownHook_V1_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_ShutdownHook_V1_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_ShutdownHook_V1_App/ThreadDemo/.project b/BasicJava/ThreadDemo_ShutdownHook_V1_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_ShutdownHook_V1_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_ShutdownHook_V1_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_ShutdownHook_V1_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_ShutdownHook_V1_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_ShutdownHook_V1_App/ThreadDemo/bin/AnnonymousShutdownHook$1.class b/BasicJava/ThreadDemo_ShutdownHook_V1_App/ThreadDemo/bin/AnnonymousShutdownHook$1.class new file mode 100644 index 000000000..fd3c5eaac Binary files /dev/null and b/BasicJava/ThreadDemo_ShutdownHook_V1_App/ThreadDemo/bin/AnnonymousShutdownHook$1.class differ diff --git a/BasicJava/ThreadDemo_ShutdownHook_V1_App/ThreadDemo/bin/AnnonymousShutdownHook.class b/BasicJava/ThreadDemo_ShutdownHook_V1_App/ThreadDemo/bin/AnnonymousShutdownHook.class new file mode 100644 index 000000000..9ed9b30cc Binary files /dev/null and b/BasicJava/ThreadDemo_ShutdownHook_V1_App/ThreadDemo/bin/AnnonymousShutdownHook.class differ diff --git a/BasicJava/ThreadDemo_ShutdownHook_V1_App/ThreadDemo/bin/ShudownHookThread.class b/BasicJava/ThreadDemo_ShutdownHook_V1_App/ThreadDemo/bin/ShudownHookThread.class new file mode 100644 index 000000000..347299d55 Binary files /dev/null and b/BasicJava/ThreadDemo_ShutdownHook_V1_App/ThreadDemo/bin/ShudownHookThread.class differ diff --git a/BasicJava/ThreadDemo_ShutdownHook_V1_App/ThreadDemo/bin/ShutdownHookDemo.class b/BasicJava/ThreadDemo_ShutdownHook_V1_App/ThreadDemo/bin/ShutdownHookDemo.class new file mode 100644 index 000000000..3a8eafe3d Binary files /dev/null and b/BasicJava/ThreadDemo_ShutdownHook_V1_App/ThreadDemo/bin/ShutdownHookDemo.class differ diff --git a/BasicJava/ThreadDemo_ShutdownHook_V1_App/ThreadDemo/src/AnnonymousShutdownHook.java b/BasicJava/ThreadDemo_ShutdownHook_V1_App/ThreadDemo/src/AnnonymousShutdownHook.java new file mode 100644 index 000000000..6322c3e92 --- /dev/null +++ b/BasicJava/ThreadDemo_ShutdownHook_V1_App/ThreadDemo/src/AnnonymousShutdownHook.java @@ -0,0 +1,27 @@ +public class AnnonymousShutdownHook +{ + + public static void main(String[] args) + { + Runtime runtime = Runtime.getRuntime(); + + runtime.addShutdownHook(new Thread() + { + public void run() + { + System.out.println("Shut down hook task is completed.."); + } + }); + + System.out.println("Now main thread sleeping... press ctrl+c to exit"); + try + { + Thread.sleep(5000); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + +} diff --git a/BasicJava/ThreadDemo_ShutdownHook_V1_App/ThreadDemo/src/ShudownHookThread.java b/BasicJava/ThreadDemo_ShutdownHook_V1_App/ThreadDemo/src/ShudownHookThread.java new file mode 100644 index 000000000..c2a9e8df4 --- /dev/null +++ b/BasicJava/ThreadDemo_ShutdownHook_V1_App/ThreadDemo/src/ShudownHookThread.java @@ -0,0 +1,8 @@ +public class ShudownHookThread extends Thread +{ + + public void run() + { + System.out.println("Shut down hook task is completed.."); + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_ShutdownHook_V1_App/ThreadDemo/src/ShutdownHookDemo.java b/BasicJava/ThreadDemo_ShutdownHook_V1_App/ThreadDemo/src/ShutdownHookDemo.java new file mode 100644 index 000000000..7bc86e888 --- /dev/null +++ b/BasicJava/ThreadDemo_ShutdownHook_V1_App/ThreadDemo/src/ShutdownHookDemo.java @@ -0,0 +1,36 @@ +/* + * public void addShutdownHook(Thread hook) + * + * Parameters: + * ----------- + * + * hook - An initialized but unstarted Thread object + */ +public class ShutdownHookDemo +{ + public static void main(String[] args) + { + /* + * Returns the runtime object associated with the + * current Java application. + */ + Runtime runtime = Runtime.getRuntime(); + /* + * Registers a new virtual-machine shutdown hook. + */ + runtime.addShutdownHook(new ShudownHookThread()); + + System.out.println("Now main thread sleeping... press ctrl+c to exit"); + + try + { + Thread.sleep(5000); + } + catch (Exception e) + { + e.printStackTrace(); + } + + } + +} diff --git a/BasicJava/ThreadDemo_SingleTask_MT_App/MultitaskingRunnable_Output.txt b/BasicJava/ThreadDemo_SingleTask_MT_App/MultitaskingRunnable_Output.txt new file mode 100644 index 000000000..174634f63 --- /dev/null +++ b/BasicJava/ThreadDemo_SingleTask_MT_App/MultitaskingRunnable_Output.txt @@ -0,0 +1,2 @@ +task 1 Run by = Thread-0 +task 1 Run by = Thread-1 diff --git a/BasicJava/ThreadDemo_SingleTask_MT_App/MultitaskingThread_Output.txt b/BasicJava/ThreadDemo_SingleTask_MT_App/MultitaskingThread_Output.txt new file mode 100644 index 000000000..ef8884de3 --- /dev/null +++ b/BasicJava/ThreadDemo_SingleTask_MT_App/MultitaskingThread_Output.txt @@ -0,0 +1,3 @@ +task 1 Run by = Thread-0 +task 1 Run by = Thread-2 +task 1 Run by = Thread-1 diff --git a/BasicJava/ThreadDemo_SingleTask_MT_App/ThreadDemo/.classpath b/BasicJava/ThreadDemo_SingleTask_MT_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_SingleTask_MT_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_SingleTask_MT_App/ThreadDemo/.project b/BasicJava/ThreadDemo_SingleTask_MT_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_SingleTask_MT_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_SingleTask_MT_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_SingleTask_MT_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_SingleTask_MT_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_SingleTask_MT_App/ThreadDemo/bin/MultitaskingRunnable.class b/BasicJava/ThreadDemo_SingleTask_MT_App/ThreadDemo/bin/MultitaskingRunnable.class new file mode 100644 index 000000000..ea32613ff Binary files /dev/null and b/BasicJava/ThreadDemo_SingleTask_MT_App/ThreadDemo/bin/MultitaskingRunnable.class differ diff --git a/BasicJava/ThreadDemo_SingleTask_MT_App/ThreadDemo/bin/MultitaskingThread.class b/BasicJava/ThreadDemo_SingleTask_MT_App/ThreadDemo/bin/MultitaskingThread.class new file mode 100644 index 000000000..e27533e49 Binary files /dev/null and b/BasicJava/ThreadDemo_SingleTask_MT_App/ThreadDemo/bin/MultitaskingThread.class differ diff --git a/BasicJava/ThreadDemo_SingleTask_MT_App/ThreadDemo/src/MultitaskingRunnable.java b/BasicJava/ThreadDemo_SingleTask_MT_App/ThreadDemo/src/MultitaskingRunnable.java new file mode 100644 index 000000000..dedce79be --- /dev/null +++ b/BasicJava/ThreadDemo_SingleTask_MT_App/ThreadDemo/src/MultitaskingRunnable.java @@ -0,0 +1,24 @@ +/* + * Program of performing single task by multiple threads + */ +public class MultitaskingRunnable implements Runnable +{ + + public static void main(String[] args) + { + MultitaskingRunnable multitaskingRunnable = new MultitaskingRunnable(); + Thread t1 = new Thread(multitaskingRunnable); + Thread t2 = new Thread(multitaskingRunnable); + + t1.start(); + t2.start(); + + } + + public void run() + { + System.out.println("task 1" + " Run by = " + + Thread.currentThread().getName()); + } + +} diff --git a/BasicJava/ThreadDemo_SingleTask_MT_App/ThreadDemo/src/MultitaskingThread.java b/BasicJava/ThreadDemo_SingleTask_MT_App/ThreadDemo/src/MultitaskingThread.java new file mode 100644 index 000000000..b83d94c28 --- /dev/null +++ b/BasicJava/ThreadDemo_SingleTask_MT_App/ThreadDemo/src/MultitaskingThread.java @@ -0,0 +1,27 @@ +/* + * Program of performing single task by multiple threads + */ +public class MultitaskingThread extends Thread +{ + + public static void main(String args[]) throws InterruptedException + { + MultitaskingThread t1 = new MultitaskingThread(); + MultitaskingThread t2 = new MultitaskingThread(); + MultitaskingThread t3 = new MultitaskingThread(); + + t1.start(); + t2.start(); + t3.start(); + } + + /* + * If you have to perform single task by many threads, have only + * one run() method. + */ + public void run() + { + System.out.println("task 1" + " Run by = " + + Thread.currentThread().getName()); + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_Start_App/Output.txt b/BasicJava/ThreadDemo_Start_App/Output.txt new file mode 100644 index 000000000..5ac616a18 --- /dev/null +++ b/BasicJava/ThreadDemo_Start_App/Output.txt @@ -0,0 +1,11 @@ +main +Thread: 9 running +Thread: 2 running +Thread: 5 running +Thread: 6 running +Thread: 1 running +Thread: 8 running +Thread: 3 running +Thread: 4 running +Thread: 7 running +Thread: 0 running diff --git a/BasicJava/ThreadDemo_Start_App/ThreadDemo/.classpath b/BasicJava/ThreadDemo_Start_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_Start_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_Start_App/ThreadDemo/.project b/BasicJava/ThreadDemo_Start_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_Start_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_Start_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_Start_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_Start_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_Start_App/ThreadDemo/bin/ThreadExample$1.class b/BasicJava/ThreadDemo_Start_App/ThreadDemo/bin/ThreadExample$1.class new file mode 100644 index 000000000..92551faef Binary files /dev/null and b/BasicJava/ThreadDemo_Start_App/ThreadDemo/bin/ThreadExample$1.class differ diff --git a/BasicJava/ThreadDemo_Start_App/ThreadDemo/bin/ThreadExample.class b/BasicJava/ThreadDemo_Start_App/ThreadDemo/bin/ThreadExample.class new file mode 100644 index 000000000..470528ef4 Binary files /dev/null and b/BasicJava/ThreadDemo_Start_App/ThreadDemo/bin/ThreadExample.class differ diff --git a/BasicJava/ThreadDemo_Start_App/ThreadDemo/src/ThreadExample.java b/BasicJava/ThreadDemo_Start_App/ThreadDemo/src/ThreadExample.java new file mode 100644 index 000000000..04b3a72be --- /dev/null +++ b/BasicJava/ThreadDemo_Start_App/ThreadDemo/src/ThreadExample.java @@ -0,0 +1,36 @@ +public class ThreadExample +{ + public static void main(String[] args) + { + /* + * It prints out the name of the thread executing + * the main() method. This thread is assigned by the + * JVM. + */ + System.out.println(Thread.currentThread().getName()); + + /* + * It starts up 10 threads and give them all a + * number as name ("" + i). Each thread then prints + * its name out, and then stops executing. + */ + for (int i = 0; i < 10; i++) + { + new Thread("" + i) + { + public void run() + { + try + { + Thread.sleep(100); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + System.out.println("Thread: " + getName() + " running"); + } + }.start(); + } + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_TG_ActiveCount_App/Output.txt b/BasicJava/ThreadDemo_TG_ActiveCount_App/Output.txt new file mode 100644 index 000000000..baca45e1e --- /dev/null +++ b/BasicJava/ThreadDemo_TG_ActiveCount_App/Output.txt @@ -0,0 +1,7 @@ +Active threads in "Child ThreadGroup" = 3 +Active threads in "Parent ThreadGroup" = 5 +Run by = thread2 +Run by = thread4 +Run by = thread3 +Run by = thread5 +Run by = thread1 diff --git a/BasicJava/ThreadDemo_TG_ActiveCount_App/ThreadDemo/.classpath b/BasicJava/ThreadDemo_TG_ActiveCount_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_TG_ActiveCount_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_TG_ActiveCount_App/ThreadDemo/.project b/BasicJava/ThreadDemo_TG_ActiveCount_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_TG_ActiveCount_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_TG_ActiveCount_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_TG_ActiveCount_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_TG_ActiveCount_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_TG_ActiveCount_App/ThreadDemo/bin/MyRunnable.class b/BasicJava/ThreadDemo_TG_ActiveCount_App/ThreadDemo/bin/MyRunnable.class new file mode 100644 index 000000000..b000e8bbe Binary files /dev/null and b/BasicJava/ThreadDemo_TG_ActiveCount_App/ThreadDemo/bin/MyRunnable.class differ diff --git a/BasicJava/ThreadDemo_TG_ActiveCount_App/ThreadDemo/bin/ThreadGroupDemo.class b/BasicJava/ThreadDemo_TG_ActiveCount_App/ThreadDemo/bin/ThreadGroupDemo.class new file mode 100644 index 000000000..6ee99da23 Binary files /dev/null and b/BasicJava/ThreadDemo_TG_ActiveCount_App/ThreadDemo/bin/ThreadGroupDemo.class differ diff --git a/BasicJava/ThreadDemo_TG_ActiveCount_App/ThreadDemo/src/MyRunnable.java b/BasicJava/ThreadDemo_TG_ActiveCount_App/ThreadDemo/src/MyRunnable.java new file mode 100644 index 000000000..3a2563222 --- /dev/null +++ b/BasicJava/ThreadDemo_TG_ActiveCount_App/ThreadDemo/src/MyRunnable.java @@ -0,0 +1,16 @@ + +public class MyRunnable implements Runnable +{ + public void run() + { + try + { + Thread.sleep(1000); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + System.out.println("Run by = "+Thread.currentThread().getName()); + } +} diff --git a/BasicJava/ThreadDemo_TG_ActiveCount_App/ThreadDemo/src/ThreadGroupDemo.java b/BasicJava/ThreadDemo_TG_ActiveCount_App/ThreadDemo/src/ThreadGroupDemo.java new file mode 100644 index 000000000..776a84520 --- /dev/null +++ b/BasicJava/ThreadDemo_TG_ActiveCount_App/ThreadDemo/src/ThreadGroupDemo.java @@ -0,0 +1,39 @@ +/* + * public int activeCount() + * + * Returns an estimate of the number of active threads + * in this thread group and its subgroups. + */ +public class ThreadGroupDemo +{ + public static void main(String[] args) throws InterruptedException + { + MyRunnable myRunnable = new MyRunnable(); + + ThreadGroup parentTg = new ThreadGroup("Parent ThreadGroup"); + + Thread t1 = new Thread(parentTg, myRunnable, "thread1"); + Thread t2 = new Thread(parentTg, myRunnable, "thread2"); + + t1.start(); + t2.start(); + + ThreadGroup childTg = new ThreadGroup(parentTg, "Child ThreadGroup"); + + Thread t3 = new Thread(childTg, myRunnable, "thread3"); + t3.start(); + Thread t4 = new Thread(childTg, myRunnable, "thread4"); + t4.start(); + Thread t5 = new Thread(childTg, myRunnable, "thread5"); + t5.start(); + + // display the number of active threads + System.out.println("Active threads in \"" + childTg.getName() + "\" = " + + childTg.activeCount()); + + // display the number of active threads + System.out.println("Active threads in \"" + parentTg.getName() + + "\" = " + parentTg.activeCount()); + + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_TG_Name_App/Output.txt b/BasicJava/ThreadDemo_TG_Name_App/Output.txt new file mode 100644 index 000000000..8a1bb9b02 --- /dev/null +++ b/BasicJava/ThreadDemo_TG_Name_App/Output.txt @@ -0,0 +1,5 @@ +Run by = thread1 , Thread Group Name = Parent ThreadGroup +Run by = thread2 , Thread Group Name = Parent ThreadGroup +Run by = thread5 , Thread Group Name = Child ThreadGroup +Run by = thread3 , Thread Group Name = Child ThreadGroup +Run by = thread4 , Thread Group Name = Child ThreadGroup diff --git a/BasicJava/ThreadDemo_TG_Name_App/ThreadDemo/.classpath b/BasicJava/ThreadDemo_TG_Name_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_TG_Name_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_TG_Name_App/ThreadDemo/.project b/BasicJava/ThreadDemo_TG_Name_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_TG_Name_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_TG_Name_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_TG_Name_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_TG_Name_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_TG_Name_App/ThreadDemo/bin/MyRunnable.class b/BasicJava/ThreadDemo_TG_Name_App/ThreadDemo/bin/MyRunnable.class new file mode 100644 index 000000000..db061d487 Binary files /dev/null and b/BasicJava/ThreadDemo_TG_Name_App/ThreadDemo/bin/MyRunnable.class differ diff --git a/BasicJava/ThreadDemo_TG_Name_App/ThreadDemo/bin/ThreadGroupDemo.class b/BasicJava/ThreadDemo_TG_Name_App/ThreadDemo/bin/ThreadGroupDemo.class new file mode 100644 index 000000000..931391ae9 Binary files /dev/null and b/BasicJava/ThreadDemo_TG_Name_App/ThreadDemo/bin/ThreadGroupDemo.class differ diff --git a/BasicJava/ThreadDemo_TG_Name_App/ThreadDemo/src/MyRunnable.java b/BasicJava/ThreadDemo_TG_Name_App/ThreadDemo/src/MyRunnable.java new file mode 100644 index 000000000..b6a2f4d34 --- /dev/null +++ b/BasicJava/ThreadDemo_TG_Name_App/ThreadDemo/src/MyRunnable.java @@ -0,0 +1,23 @@ +public class MyRunnable implements Runnable +{ + public void run() + { + try + { + Thread.sleep(1000); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + String threadName = Thread.currentThread().getName(); + /* + * Returns the name of this thread group. + */ + String threadGroupName = Thread.currentThread().getThreadGroup() + .getName(); + + System.out.println("Run by = " + threadName + " , Thread Group Name = " + + threadGroupName); + } +} diff --git a/BasicJava/ThreadDemo_TG_Name_App/ThreadDemo/src/ThreadGroupDemo.java b/BasicJava/ThreadDemo_TG_Name_App/ThreadDemo/src/ThreadGroupDemo.java new file mode 100644 index 000000000..9bbcacd86 --- /dev/null +++ b/BasicJava/ThreadDemo_TG_Name_App/ThreadDemo/src/ThreadGroupDemo.java @@ -0,0 +1,26 @@ +public class ThreadGroupDemo +{ + public static void main(String[] args) throws InterruptedException + { + MyRunnable myRunnable = new MyRunnable(); + + ThreadGroup parentTg = new ThreadGroup("Parent ThreadGroup"); + + Thread t1 = new Thread(parentTg, myRunnable, "thread1"); + Thread t2 = new Thread(parentTg, myRunnable, "thread2"); + + t1.start(); + t2.start(); + + ThreadGroup childTg = new ThreadGroup(parentTg, "Child ThreadGroup"); + + Thread t3 = new Thread(childTg, myRunnable, "thread3"); + Thread t4 = new Thread(childTg, myRunnable, "thread4"); + Thread t5 = new Thread(childTg, myRunnable, "thread5"); + + t3.start(); + t4.start(); + t5.start(); + + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_TG_hierarchy_App/Output.txt b/BasicJava/ThreadDemo_TG_hierarchy_App/Output.txt new file mode 100644 index 000000000..6df39b69d --- /dev/null +++ b/BasicJava/ThreadDemo_TG_hierarchy_App/Output.txt @@ -0,0 +1,15 @@ +Run by = thread3 , Thread GroupName = Child ThreadGroup + , Parent Thread GroupName = Parent ThreadGroup + +Run by = thread2 , Thread GroupName = Parent ThreadGroup + , Parent Thread GroupName = main + +Run by = thread1 , Thread GroupName = Parent ThreadGroup + , Parent Thread GroupName = main + +Run by = thread5 , Thread GroupName = Child ThreadGroup + , Parent Thread GroupName = Parent ThreadGroup + +Run by = thread4 , Thread GroupName = Child ThreadGroup + , Parent Thread GroupName = Parent ThreadGroup + diff --git a/BasicJava/ThreadDemo_TG_hierarchy_App/ThreadDemo/.classpath b/BasicJava/ThreadDemo_TG_hierarchy_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_TG_hierarchy_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_TG_hierarchy_App/ThreadDemo/.project b/BasicJava/ThreadDemo_TG_hierarchy_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_TG_hierarchy_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_TG_hierarchy_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_TG_hierarchy_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_TG_hierarchy_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_TG_hierarchy_App/ThreadDemo/bin/MyRunnable.class b/BasicJava/ThreadDemo_TG_hierarchy_App/ThreadDemo/bin/MyRunnable.class new file mode 100644 index 000000000..748ec877b Binary files /dev/null and b/BasicJava/ThreadDemo_TG_hierarchy_App/ThreadDemo/bin/MyRunnable.class differ diff --git a/BasicJava/ThreadDemo_TG_hierarchy_App/ThreadDemo/bin/ThreadGroupDemo.class b/BasicJava/ThreadDemo_TG_hierarchy_App/ThreadDemo/bin/ThreadGroupDemo.class new file mode 100644 index 000000000..931391ae9 Binary files /dev/null and b/BasicJava/ThreadDemo_TG_hierarchy_App/ThreadDemo/bin/ThreadGroupDemo.class differ diff --git a/BasicJava/ThreadDemo_TG_hierarchy_App/ThreadDemo/src/MyRunnable.java b/BasicJava/ThreadDemo_TG_hierarchy_App/ThreadDemo/src/MyRunnable.java new file mode 100644 index 000000000..6dd941349 --- /dev/null +++ b/BasicJava/ThreadDemo_TG_hierarchy_App/ThreadDemo/src/MyRunnable.java @@ -0,0 +1,28 @@ +public class MyRunnable implements Runnable +{ + public void run() + { + try + { + Thread.sleep(1000); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + String threadName = Thread.currentThread().getName(); + /* + * Returns the name of this thread group. + */ + String threadGroupName = Thread.currentThread().getThreadGroup() + .getName(); + + String parentThreadGroupName = Thread.currentThread().getThreadGroup() + .getParent().getName(); + + System.out.println("Run by = " + threadName + " , Thread GroupName = " + + threadGroupName + "\n , Parent Thread GroupName = " + + parentThreadGroupName+"\n"); + + } +} diff --git a/BasicJava/ThreadDemo_TG_hierarchy_App/ThreadDemo/src/ThreadGroupDemo.java b/BasicJava/ThreadDemo_TG_hierarchy_App/ThreadDemo/src/ThreadGroupDemo.java new file mode 100644 index 000000000..e802f8c7e --- /dev/null +++ b/BasicJava/ThreadDemo_TG_hierarchy_App/ThreadDemo/src/ThreadGroupDemo.java @@ -0,0 +1,26 @@ +public class ThreadGroupDemo +{ + public static void main(String[] args) throws InterruptedException + { + MyRunnable myRunnable = new MyRunnable(); + + ThreadGroup parentTg = new ThreadGroup("Parent ThreadGroup"); + + Thread t1 = new Thread(parentTg, myRunnable, "thread1"); + Thread t2 = new Thread(parentTg, myRunnable, "thread2"); + + t1.start(); + t2.start(); + + ThreadGroup childTg = new ThreadGroup(parentTg, "Child ThreadGroup"); + + Thread t3 = new Thread(childTg, myRunnable, "thread3"); + Thread t4 = new Thread(childTg, myRunnable, "thread4"); + Thread t5 = new Thread(childTg, myRunnable, "thread5"); + + t3.start(); + t4.start(); + t5.start(); + + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_TG_parentOf_App/Output.txt b/BasicJava/ThreadDemo_TG_parentOf_App/Output.txt new file mode 100644 index 000000000..2f2aec81c --- /dev/null +++ b/BasicJava/ThreadDemo_TG_parentOf_App/Output.txt @@ -0,0 +1,4 @@ +Parent ThreadGroup is the parent of Child ThreadGroup? true +Child ThreadGroup is the parent of Parent ThreadGroup? false +Run by = thread2 +Run by = thread1 diff --git a/BasicJava/ThreadDemo_TG_parentOf_App/ThreadDemo/.classpath b/BasicJava/ThreadDemo_TG_parentOf_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_TG_parentOf_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_TG_parentOf_App/ThreadDemo/.project b/BasicJava/ThreadDemo_TG_parentOf_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_TG_parentOf_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_TG_parentOf_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_TG_parentOf_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_TG_parentOf_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_TG_parentOf_App/ThreadDemo/bin/MyRunnable.class b/BasicJava/ThreadDemo_TG_parentOf_App/ThreadDemo/bin/MyRunnable.class new file mode 100644 index 000000000..b327ab23b Binary files /dev/null and b/BasicJava/ThreadDemo_TG_parentOf_App/ThreadDemo/bin/MyRunnable.class differ diff --git a/BasicJava/ThreadDemo_TG_parentOf_App/ThreadDemo/bin/ThreadGroupDemo.class b/BasicJava/ThreadDemo_TG_parentOf_App/ThreadDemo/bin/ThreadGroupDemo.class new file mode 100644 index 000000000..fabc3c531 Binary files /dev/null and b/BasicJava/ThreadDemo_TG_parentOf_App/ThreadDemo/bin/ThreadGroupDemo.class differ diff --git a/BasicJava/ThreadDemo_TG_parentOf_App/ThreadDemo/src/MyRunnable.java b/BasicJava/ThreadDemo_TG_parentOf_App/ThreadDemo/src/MyRunnable.java new file mode 100644 index 000000000..b798d75eb --- /dev/null +++ b/BasicJava/ThreadDemo_TG_parentOf_App/ThreadDemo/src/MyRunnable.java @@ -0,0 +1,18 @@ +public class MyRunnable implements Runnable +{ + public void run() + { + try + { + Thread.sleep(1000); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + String threadName = Thread.currentThread().getName(); + + System.out.println("Run by = " + threadName ); + + } +} diff --git a/BasicJava/ThreadDemo_TG_parentOf_App/ThreadDemo/src/ThreadGroupDemo.java b/BasicJava/ThreadDemo_TG_parentOf_App/ThreadDemo/src/ThreadGroupDemo.java new file mode 100644 index 000000000..35ff1dc72 --- /dev/null +++ b/BasicJava/ThreadDemo_TG_parentOf_App/ThreadDemo/src/ThreadGroupDemo.java @@ -0,0 +1,35 @@ +/* + * public final boolean parentOf(ThreadGroup g) + * + * Tests if this thread group is either the thread group + * argument or one of its ancestor thread groups. + */ +public class ThreadGroupDemo +{ + public static void main(String[] args) throws InterruptedException + { + MyRunnable myRunnable = new MyRunnable(); + + ThreadGroup parentTg = new ThreadGroup("Parent ThreadGroup"); + + Thread t1 = new Thread(parentTg, myRunnable, "thread1"); + + t1.start(); + + ThreadGroup childTg = new ThreadGroup(parentTg, "Child ThreadGroup"); + + Thread t2 = new Thread(childTg, myRunnable, "thread2"); + + t2.start(); + + // determine which ThreadGroup is parent + boolean isParent = parentTg.parentOf(childTg); + System.out.println(parentTg.getName() + " is the parent of " + + childTg.getName() + "? " + isParent); + + isParent = childTg.parentOf(parentTg); + System.out.println(childTg.getName() + " is the parent of " + + parentTg.getName() + "? " + isParent); + + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_ThreadGroup_App/Output.txt b/BasicJava/ThreadDemo_ThreadGroup_App/Output.txt new file mode 100644 index 000000000..cddc8f8ae --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadGroup_App/Output.txt @@ -0,0 +1,8 @@ +Thread Group Name: Group A +Run by = thread3 +java.lang.ThreadGroup[name=Group A,maxpri=10] +Run by = thread2 +Run by = thread1 + Thread[thread1,5,Group A] + Thread[thread2,5,Group A] + Thread[thread3,5,Group A] diff --git a/BasicJava/ThreadDemo_ThreadGroup_App/ThreadDemo/.classpath b/BasicJava/ThreadDemo_ThreadGroup_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadGroup_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_ThreadGroup_App/ThreadDemo/.project b/BasicJava/ThreadDemo_ThreadGroup_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadGroup_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_ThreadGroup_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_ThreadGroup_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadGroup_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_ThreadGroup_App/ThreadDemo/bin/MyRunnable.class b/BasicJava/ThreadDemo_ThreadGroup_App/ThreadDemo/bin/MyRunnable.class new file mode 100644 index 000000000..6d36cc150 Binary files /dev/null and b/BasicJava/ThreadDemo_ThreadGroup_App/ThreadDemo/bin/MyRunnable.class differ diff --git a/BasicJava/ThreadDemo_ThreadGroup_App/ThreadDemo/bin/ThreadGroupDemo.class b/BasicJava/ThreadDemo_ThreadGroup_App/ThreadDemo/bin/ThreadGroupDemo.class new file mode 100644 index 000000000..96be952de Binary files /dev/null and b/BasicJava/ThreadDemo_ThreadGroup_App/ThreadDemo/bin/ThreadGroupDemo.class differ diff --git a/BasicJava/ThreadDemo_ThreadGroup_App/ThreadDemo/src/MyRunnable.java b/BasicJava/ThreadDemo_ThreadGroup_App/ThreadDemo/src/MyRunnable.java new file mode 100644 index 000000000..4ff31ce84 --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadGroup_App/ThreadDemo/src/MyRunnable.java @@ -0,0 +1,8 @@ + +public class MyRunnable implements Runnable +{ + public void run() + { + System.out.println("Run by = "+Thread.currentThread().getName()); + } +} diff --git a/BasicJava/ThreadDemo_ThreadGroup_App/ThreadDemo/src/ThreadGroupDemo.java b/BasicJava/ThreadDemo_ThreadGroup_App/ThreadDemo/src/ThreadGroupDemo.java new file mode 100644 index 000000000..ae2ec0028 --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadGroup_App/ThreadDemo/src/ThreadGroupDemo.java @@ -0,0 +1,30 @@ +public class ThreadGroupDemo +{ + + public static void main(String[] args) throws InterruptedException + { + MyRunnable myRunnable = new MyRunnable(); + + ThreadGroup tg = new ThreadGroup("Group A"); + + Thread t1 = new Thread(tg, myRunnable, "thread1"); + Thread t2 = new Thread(tg, myRunnable, "thread2"); + Thread t3 = new Thread(tg, myRunnable, "thread3"); + + t1.start(); + t2.start(); + t3.start(); + + /* + * Returns the name of this thread group. + */ + String threadGroupName = tg.getName(); + System.out.println("Thread Group Name: " + threadGroupName); + /* + * Prints information about this thread group to the + * standard output. + */ + tg.list(); + + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_ThreadPoolExecutor_App/Output.txt b/BasicJava/ThreadDemo_ThreadPoolExecutor_App/Output.txt new file mode 100644 index 000000000..917cdbe59 --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadPoolExecutor_App/Output.txt @@ -0,0 +1,28 @@ +pool-1-thread-1 Start. taskNumber = task1 +pool-1-thread-2 Start. taskNumber = task2 +pool-1-thread-3 Start. taskNumber = task5 +task7 is rejected +task8 is rejected +pool-1-thread-4 Start. taskNumber = task6 +task9 is rejected +task10 is rejected +[monitor] [0/2] Active: 0, Completed: 0, Task: 5, isShutdown: false, isTerminated: false +[monitor] [4/2] Active: 4, Completed: 0, Task: 6, isShutdown: false, isTerminated: false +pool-1-thread-1 End of taskNumber =task1 +pool-1-thread-1 Start. taskNumber = task3 +pool-1-thread-2 End of taskNumber =task2 +pool-1-thread-2 Start. taskNumber = task4 +pool-1-thread-3 End of taskNumber =task5 +pool-1-thread-4 End of taskNumber =task6 +[monitor] [4/2] Active: 2, Completed: 4, Task: 6, isShutdown: false, isTerminated: false +[monitor] [4/2] Active: 2, Completed: 4, Task: 6, isShutdown: false, isTerminated: false +pool-1-thread-1 End of taskNumber =task3 +pool-1-thread-2 End of taskNumber =task4 +[monitor] [4/2] Active: 0, Completed: 6, Task: 6, isShutdown: false, isTerminated: false +[monitor] [2/2] Active: 0, Completed: 6, Task: 6, isShutdown: false, isTerminated: false +[monitor] [2/2] Active: 0, Completed: 6, Task: 6, isShutdown: false, isTerminated: false +[monitor] [2/2] Active: 0, Completed: 6, Task: 6, isShutdown: false, isTerminated: false +[monitor] [2/2] Active: 0, Completed: 6, Task: 6, isShutdown: false, isTerminated: false +[monitor] [2/2] Active: 0, Completed: 6, Task: 6, isShutdown: false, isTerminated: false +[monitor] [0/2] Active: 0, Completed: 6, Task: 6, isShutdown: true, isTerminated: true +[monitor] [0/2] Active: 0, Completed: 6, Task: 6, isShutdown: true, isTerminated: true diff --git a/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/.classpath b/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/.project b/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/bin/MonitorThread.class b/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/bin/MonitorThread.class new file mode 100644 index 000000000..9cd0cd894 Binary files /dev/null and b/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/bin/MonitorThread.class differ diff --git a/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/bin/RejectedExecutionHandlerImpl.class b/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/bin/RejectedExecutionHandlerImpl.class new file mode 100644 index 000000000..ec022407c Binary files /dev/null and b/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/bin/RejectedExecutionHandlerImpl.class differ diff --git a/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/bin/RunnableTask.class b/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/bin/RunnableTask.class new file mode 100644 index 000000000..0479116c4 Binary files /dev/null and b/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/bin/RunnableTask.class differ diff --git a/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/bin/ThreadPool.class b/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/bin/ThreadPool.class new file mode 100644 index 000000000..1d7927072 Binary files /dev/null and b/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/bin/ThreadPool.class differ diff --git a/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/bin/WorkerThread.class b/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/bin/WorkerThread.class new file mode 100644 index 000000000..247365e06 Binary files /dev/null and b/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/bin/WorkerThread.class differ diff --git a/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/src/MonitorThread.java b/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/src/MonitorThread.java new file mode 100644 index 000000000..0870e0c7c --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/src/MonitorThread.java @@ -0,0 +1,47 @@ +import java.util.concurrent.ThreadPoolExecutor; + +public class MonitorThread implements Runnable +{ + private ThreadPoolExecutor executor; + + private int seconds; + + private boolean run = true; + + public MonitorThread(ThreadPoolExecutor executor, int delay) + { + this.executor = executor; + this.seconds = delay; + } + + public void shutdown() + { + this.run = false; + } + + @Override + public void run() + { + while (run) + { + System.out.println(String.format( + "[monitor] [%d/%d] Active: %d, Completed: %d, " + + "Task: %d, isShutdown: %s, isTerminated: %s", + this.executor.getPoolSize(), + this.executor.getCorePoolSize(), + this.executor.getActiveCount(), + this.executor.getCompletedTaskCount(), + this.executor.getTaskCount(), this.executor.isShutdown(), + this.executor.isTerminated())); + try + { + Thread.sleep(seconds * 1000); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + } + + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/src/RejectedExecutionHandlerImpl.java b/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/src/RejectedExecutionHandlerImpl.java new file mode 100644 index 000000000..739970a0d --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/src/RejectedExecutionHandlerImpl.java @@ -0,0 +1,11 @@ +import java.util.concurrent.RejectedExecutionHandler; +import java.util.concurrent.ThreadPoolExecutor; + +public class RejectedExecutionHandlerImpl implements RejectedExecutionHandler +{ + @Override + public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) + { + System.out.println(r.toString() + " is rejected"); + } +} diff --git a/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/src/RunnableTask.java b/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/src/RunnableTask.java new file mode 100644 index 000000000..6f14fdae5 --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/src/RunnableTask.java @@ -0,0 +1,38 @@ +public class RunnableTask implements Runnable +{ + + private String taskNumber; + + public RunnableTask(String taskNumber) + { + this.taskNumber = taskNumber; + } + + @Override + public void run() + { + System.out.println(Thread.currentThread().getName() + + " Start. taskNumber = " + taskNumber); + processCommand(); + System.out.println(Thread.currentThread().getName() + + " End of taskNumber =" + taskNumber); + } + + private void processCommand() + { + try + { + Thread.sleep(5000); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + } + + @Override + public String toString() + { + return this.taskNumber; + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/src/ThreadPool.java b/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/src/ThreadPool.java new file mode 100644 index 000000000..90665f27c --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadPoolExecutor_App/ThreadDemo/src/ThreadPool.java @@ -0,0 +1,37 @@ +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.Executors; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +public class ThreadPool +{ + + public static void main(String[] args) throws InterruptedException + { + // RejectedExecutionHandler implementation + RejectedExecutionHandlerImpl rejectionHandler = new RejectedExecutionHandlerImpl(); + // Get the ThreadFactory implementation to use + ThreadFactory threadFactory = Executors.defaultThreadFactory(); + // creating the ThreadPoolExecutor + ThreadPoolExecutor executorPool = new ThreadPoolExecutor(2, 4, 10, + TimeUnit.SECONDS, new ArrayBlockingQueue(2), + threadFactory, rejectionHandler); + // start the monitoring thread + MonitorThread monitor = new MonitorThread(executorPool, 3); + Thread monitorThread = new Thread(monitor); + monitorThread.start(); + // submit work to the thread pool + for (int i = 1; i <= 10; i++) + { + executorPool.execute(new RunnableTask("task" + i)); + } + + Thread.sleep(30000); + // shut down the pool + executorPool.shutdown(); + // shut down the monitor thread + Thread.sleep(5000); + monitor.shutdown(); + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_ThreadPool_App/Output.txt b/BasicJava/ThreadDemo_ThreadPool_App/Output.txt new file mode 100644 index 000000000..4f3577a16 --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadPool_App/Output.txt @@ -0,0 +1,21 @@ +pool-1-thread-1 (Start) message = Hello 0 +pool-1-thread-2 (Start) message = Hello 1 +pool-1-thread-3 (Start) message = Hello 2 +pool-1-thread-2 (End) +pool-1-thread-2 (Start) message = Hello 3 +pool-1-thread-1 (End) +pool-1-thread-1 (Start) message = Hello 4 +pool-1-thread-3 (End) +pool-1-thread-3 (Start) message = Hello 5 +pool-1-thread-2 (End) +pool-1-thread-2 (Start) message = Hello 6 +pool-1-thread-1 (End) +pool-1-thread-1 (Start) message = Hello 7 +pool-1-thread-3 (End) +pool-1-thread-3 (Start) message = Hello 8 +pool-1-thread-2 (End) +pool-1-thread-2 (Start) message = Hello 9 +pool-1-thread-1 (End) +pool-1-thread-3 (End) +pool-1-thread-2 (End) +Finished all threads diff --git a/BasicJava/ThreadDemo_ThreadPool_App/ThreadDemo/.classpath b/BasicJava/ThreadDemo_ThreadPool_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadPool_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_ThreadPool_App/ThreadDemo/.project b/BasicJava/ThreadDemo_ThreadPool_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadPool_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_ThreadPool_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_ThreadPool_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadPool_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_ThreadPool_App/ThreadDemo/bin/ThreadPoolDemo.class b/BasicJava/ThreadDemo_ThreadPool_App/ThreadDemo/bin/ThreadPoolDemo.class new file mode 100644 index 000000000..c56caf5ff Binary files /dev/null and b/BasicJava/ThreadDemo_ThreadPool_App/ThreadDemo/bin/ThreadPoolDemo.class differ diff --git a/BasicJava/ThreadDemo_ThreadPool_App/ThreadDemo/bin/WorkerThread.class b/BasicJava/ThreadDemo_ThreadPool_App/ThreadDemo/bin/WorkerThread.class new file mode 100644 index 000000000..4051028ed Binary files /dev/null and b/BasicJava/ThreadDemo_ThreadPool_App/ThreadDemo/bin/WorkerThread.class differ diff --git a/BasicJava/ThreadDemo_ThreadPool_App/ThreadDemo/src/ThreadPoolDemo.java b/BasicJava/ThreadDemo_ThreadPool_App/ThreadDemo/src/ThreadPoolDemo.java new file mode 100644 index 000000000..2f1abc741 --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadPool_App/ThreadDemo/src/ThreadPoolDemo.java @@ -0,0 +1,22 @@ +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class ThreadPoolDemo +{ + + public static void main(String[] args) + { + ExecutorService executorService = Executors.newFixedThreadPool(3); + for (int i = 0; i < 10; i++) + { + WorkerThread workerThread = new WorkerThread("Hello " + i); + executorService.execute(workerThread); + } + executorService.shutdown(); + while (!executorService.isTerminated()) + { + + } + System.out.println("Finished all threads"); + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_ThreadPool_App/ThreadDemo/src/WorkerThread.java b/BasicJava/ThreadDemo_ThreadPool_App/ThreadDemo/src/WorkerThread.java new file mode 100644 index 000000000..ca9eca5e4 --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadPool_App/ThreadDemo/src/WorkerThread.java @@ -0,0 +1,30 @@ +class WorkerThread implements Runnable +{ + private String message; + + public WorkerThread(String message) + { + this.message = message; + } + + public void run() + { + System.out.println(Thread.currentThread().getName() + + " (Start) message = " + message); + processmessage(); + System.out.println(Thread.currentThread().getName() + " (End)"); + } + + private void processmessage() + { + try + { + Thread.sleep(2000); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + } + +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_ThreadPool_V2_App/Output.txt b/BasicJava/ThreadDemo_ThreadPool_V2_App/Output.txt new file mode 100644 index 000000000..26d9ef351 --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadPool_V2_App/Output.txt @@ -0,0 +1,24 @@ +pool-1-thread-1 = RunnableTask number: 0, percent complete: 0 +pool-1-thread-2 = RunnableTask number: 1, percent complete: 0 +pool-1-thread-1 = RunnableTask number: 0, percent complete: 20 +pool-1-thread-2 = RunnableTask number: 1, percent complete: 20 +pool-1-thread-2 = RunnableTask number: 1, percent complete: 40 +pool-1-thread-1 = RunnableTask number: 0, percent complete: 40 +pool-1-thread-1 = RunnableTask number: 0, percent complete: 60 +pool-1-thread-2 = RunnableTask number: 1, percent complete: 60 +pool-1-thread-1 = RunnableTask number: 0, percent complete: 80 +pool-1-thread-2 = RunnableTask number: 1, percent complete: 80 +pool-1-thread-1 = RunnableTask number: 0, percent complete: 100 +pool-1-thread-2 = RunnableTask number: 1, percent complete: 100 +pool-1-thread-2 = RunnableTask number: 2, percent complete: 0 +pool-1-thread-1 = RunnableTask number: 3, percent complete: 0 +pool-1-thread-2 = RunnableTask number: 2, percent complete: 20 +pool-1-thread-1 = RunnableTask number: 3, percent complete: 20 +pool-1-thread-1 = RunnableTask number: 3, percent complete: 40 +pool-1-thread-2 = RunnableTask number: 2, percent complete: 40 +pool-1-thread-1 = RunnableTask number: 3, percent complete: 60 +pool-1-thread-2 = RunnableTask number: 2, percent complete: 60 +pool-1-thread-2 = RunnableTask number: 2, percent complete: 80 +pool-1-thread-1 = RunnableTask number: 3, percent complete: 80 +pool-1-thread-1 = RunnableTask number: 3, percent complete: 100 +pool-1-thread-2 = RunnableTask number: 2, percent complete: 100 diff --git a/BasicJava/ThreadDemo_ThreadPool_V2_App/ThreadDemo/.classpath b/BasicJava/ThreadDemo_ThreadPool_V2_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadPool_V2_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_ThreadPool_V2_App/ThreadDemo/.project b/BasicJava/ThreadDemo_ThreadPool_V2_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadPool_V2_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_ThreadPool_V2_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_ThreadPool_V2_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadPool_V2_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_ThreadPool_V2_App/ThreadDemo/bin/RunnableTask.class b/BasicJava/ThreadDemo_ThreadPool_V2_App/ThreadDemo/bin/RunnableTask.class new file mode 100644 index 000000000..b36297b23 Binary files /dev/null and b/BasicJava/ThreadDemo_ThreadPool_V2_App/ThreadDemo/bin/RunnableTask.class differ diff --git a/BasicJava/ThreadDemo_ThreadPool_V2_App/ThreadDemo/bin/ThreadPoolTest.class b/BasicJava/ThreadDemo_ThreadPool_V2_App/ThreadDemo/bin/ThreadPoolTest.class new file mode 100644 index 000000000..ab788941f Binary files /dev/null and b/BasicJava/ThreadDemo_ThreadPool_V2_App/ThreadDemo/bin/ThreadPoolTest.class differ diff --git a/BasicJava/ThreadDemo_ThreadPool_V2_App/ThreadDemo/src/RunnableTask.java b/BasicJava/ThreadDemo_ThreadPool_V2_App/ThreadDemo/src/RunnableTask.java new file mode 100644 index 000000000..2adcb43e5 --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadPool_V2_App/ThreadDemo/src/RunnableTask.java @@ -0,0 +1,34 @@ +/* + * Here is a runnable task. This task performs some work and + * then periodically reports what percent of the work it has + * completed: + */ + +public class RunnableTask implements Runnable +{ + private int taskNumber; + + public RunnableTask(int taskNumber) + { + this.taskNumber = taskNumber; + } + + public void run() + { + for (int i = 0; i <= 100; i += 20) + { + // Perform some work ... + System.out.println(Thread.currentThread().getName() + + " = RunnableTask number: " + taskNumber + + ", percent complete: " + i); + try + { + Thread.sleep(3000); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + } + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_ThreadPool_V2_App/ThreadDemo/src/ThreadPoolTest.java b/BasicJava/ThreadDemo_ThreadPool_V2_App/ThreadDemo/src/ThreadPoolTest.java new file mode 100644 index 000000000..12b90db72 --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadPool_V2_App/ThreadDemo/src/ThreadPoolTest.java @@ -0,0 +1,22 @@ +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class ThreadPoolTest +{ + + public static void main(String[] args) + { + int numRunnableTask = 4; + int threadPoolSize = 2; + + ExecutorService tpes = Executors.newFixedThreadPool(threadPoolSize); + + RunnableTask[] runnableTasks = new RunnableTask[numRunnableTask]; + for (int i = 0; i < numRunnableTask; i++) + { + runnableTasks[i] = new RunnableTask(i); + tpes.execute(runnableTasks[i]); + } + tpes.shutdown(); + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_ThreadPool_V3_App/Output.txt b/BasicJava/ThreadDemo_ThreadPool_V3_App/Output.txt new file mode 100644 index 000000000..30974468f --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadPool_V3_App/Output.txt @@ -0,0 +1,21 @@ +pool-1-thread-2 Start. taskNumber = 1 +pool-1-thread-4 Start. taskNumber = 3 +pool-1-thread-3 Start. taskNumber = 2 +pool-1-thread-1 Start. taskNumber = 0 +pool-1-thread-5 Start. taskNumber = 4 +pool-1-thread-2 End of taskNumber = 1 +pool-1-thread-2 Start. taskNumber = 5 +pool-1-thread-4 End of taskNumber = 3 +pool-1-thread-4 Start. taskNumber = 6 +pool-1-thread-1 End of taskNumber = 0 +pool-1-thread-1 Start. taskNumber = 7 +pool-1-thread-5 End of taskNumber = 4 +pool-1-thread-5 Start. taskNumber = 8 +pool-1-thread-3 End of taskNumber = 2 +pool-1-thread-3 Start. taskNumber = 9 +pool-1-thread-4 End of taskNumber = 6 +pool-1-thread-2 End of taskNumber = 5 +pool-1-thread-3 End of taskNumber = 9 +pool-1-thread-1 End of taskNumber = 7 +pool-1-thread-5 End of taskNumber = 8 +Finished all threads diff --git a/BasicJava/ThreadDemo_ThreadPool_V3_App/ThreadDemo/.classpath b/BasicJava/ThreadDemo_ThreadPool_V3_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadPool_V3_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_ThreadPool_V3_App/ThreadDemo/.project b/BasicJava/ThreadDemo_ThreadPool_V3_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadPool_V3_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_ThreadPool_V3_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_ThreadPool_V3_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadPool_V3_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_ThreadPool_V3_App/ThreadDemo/bin/RunnableTask.class b/BasicJava/ThreadDemo_ThreadPool_V3_App/ThreadDemo/bin/RunnableTask.class new file mode 100644 index 000000000..0479116c4 Binary files /dev/null and b/BasicJava/ThreadDemo_ThreadPool_V3_App/ThreadDemo/bin/RunnableTask.class differ diff --git a/BasicJava/ThreadDemo_ThreadPool_V3_App/ThreadDemo/bin/SimpleThreadPool.class b/BasicJava/ThreadDemo_ThreadPool_V3_App/ThreadDemo/bin/SimpleThreadPool.class new file mode 100644 index 000000000..01f6bfd2c Binary files /dev/null and b/BasicJava/ThreadDemo_ThreadPool_V3_App/ThreadDemo/bin/SimpleThreadPool.class differ diff --git a/BasicJava/ThreadDemo_ThreadPool_V3_App/ThreadDemo/src/RunnableTask.java b/BasicJava/ThreadDemo_ThreadPool_V3_App/ThreadDemo/src/RunnableTask.java new file mode 100644 index 000000000..6f14fdae5 --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadPool_V3_App/ThreadDemo/src/RunnableTask.java @@ -0,0 +1,38 @@ +public class RunnableTask implements Runnable +{ + + private String taskNumber; + + public RunnableTask(String taskNumber) + { + this.taskNumber = taskNumber; + } + + @Override + public void run() + { + System.out.println(Thread.currentThread().getName() + + " Start. taskNumber = " + taskNumber); + processCommand(); + System.out.println(Thread.currentThread().getName() + + " End of taskNumber =" + taskNumber); + } + + private void processCommand() + { + try + { + Thread.sleep(5000); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + } + + @Override + public String toString() + { + return this.taskNumber; + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_ThreadPool_V3_App/ThreadDemo/src/SimpleThreadPool.java b/BasicJava/ThreadDemo_ThreadPool_V3_App/ThreadDemo/src/SimpleThreadPool.java new file mode 100644 index 000000000..3dbbf4381 --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadPool_V3_App/ThreadDemo/src/SimpleThreadPool.java @@ -0,0 +1,21 @@ +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class SimpleThreadPool +{ + + public static void main(String[] args) + { + ExecutorService executor = Executors.newFixedThreadPool(5); + for (int i = 0; i < 10; i++) + { + Runnable runnableTask = new RunnableTask(" " + i); + executor.execute(runnableTask); + } + executor.shutdown(); + while (!executor.isTerminated()) + { + } + System.out.println("Finished all threads"); + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_ThreadPool_V5_App/Output.txt b/BasicJava/ThreadDemo_ThreadPool_V5_App/Output.txt new file mode 100644 index 000000000..1ced6ab9a --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadPool_V5_App/Output.txt @@ -0,0 +1,23 @@ +Main Thread starts +* +* +* +* +* +M +M +M +M +M +N +N +N +N +N +S +S +S +S +S + +Main Thread Ends diff --git a/BasicJava/ThreadDemo_ThreadPool_V5_App/ThreadDemo/.classpath b/BasicJava/ThreadDemo_ThreadPool_V5_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadPool_V5_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_ThreadPool_V5_App/ThreadDemo/.project b/BasicJava/ThreadDemo_ThreadPool_V5_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadPool_V5_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_ThreadPool_V5_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_ThreadPool_V5_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadPool_V5_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_ThreadPool_V5_App/ThreadDemo/bin/PrintCharTask.class b/BasicJava/ThreadDemo_ThreadPool_V5_App/ThreadDemo/bin/PrintCharTask.class new file mode 100644 index 000000000..8526fcb09 Binary files /dev/null and b/BasicJava/ThreadDemo_ThreadPool_V5_App/ThreadDemo/bin/PrintCharTask.class differ diff --git a/BasicJava/ThreadDemo_ThreadPool_V5_App/ThreadDemo/bin/Threadpool.class b/BasicJava/ThreadDemo_ThreadPool_V5_App/ThreadDemo/bin/Threadpool.class new file mode 100644 index 000000000..d4d1cdad2 Binary files /dev/null and b/BasicJava/ThreadDemo_ThreadPool_V5_App/ThreadDemo/bin/Threadpool.class differ diff --git a/BasicJava/ThreadDemo_ThreadPool_V5_App/ThreadDemo/src/PrintCharTask.java b/BasicJava/ThreadDemo_ThreadPool_V5_App/ThreadDemo/src/PrintCharTask.java new file mode 100644 index 000000000..61ea0dd16 --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadPool_V5_App/ThreadDemo/src/PrintCharTask.java @@ -0,0 +1,19 @@ +class PrintCharTask implements Runnable +{ + private char character; + private int noOfTimes; + + PrintCharTask(char ch, int n) + { + character = ch; + noOfTimes = n; + } + + public void run() + { + for (int i = 0; i < noOfTimes; i++) + { + System.out.println(character + " "); + } + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_ThreadPool_V5_App/ThreadDemo/src/Threadpool.java b/BasicJava/ThreadDemo_ThreadPool_V5_App/ThreadDemo/src/Threadpool.java new file mode 100644 index 000000000..b8856974f --- /dev/null +++ b/BasicJava/ThreadDemo_ThreadPool_V5_App/ThreadDemo/src/Threadpool.java @@ -0,0 +1,37 @@ +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +class Threadpool +{ + public static void main(String[] args) + { + System.out.println("Main Thread starts"); + ExecutorService threadExecutor = Executors.newFixedThreadPool(2); + + PrintCharTask taskl = new PrintCharTask('*', 5); + PrintCharTask task2 = new PrintCharTask('S', 5); + PrintCharTask task3 = new PrintCharTask('M', 5); + PrintCharTask task4 = new PrintCharTask('N', 5); + + threadExecutor.execute(taskl); + threadExecutor.execute(task2); + threadExecutor.execute(task3); + threadExecutor.execute(task4); + /* + * Tells the threadExecutor to shutdown. No new task + * can be accepted but the existing task will + * continue to finish. + */ + threadExecutor.shutdown(); + /* + * In order to ensure that the main thread finishes + * last i.e. all tasks are finished before the main + * thread terminates, we put the below while + * statement. + */ + while (!threadExecutor.isTerminated()) + { + } + System.out.println("\nMain Thread Ends"); + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_daemon_app/Output.txt b/BasicJava/ThreadDemo_daemon_app/Output.txt new file mode 100644 index 000000000..334c05d53 --- /dev/null +++ b/BasicJava/ThreadDemo_daemon_app/Output.txt @@ -0,0 +1,3 @@ +user thread = Thread 2 +user thread = Thread 3 +Daemon thread = Thread 1 diff --git a/BasicJava/ThreadDemo_daemon_app/ThreadDemo/.classpath b/BasicJava/ThreadDemo_daemon_app/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_daemon_app/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_daemon_app/ThreadDemo/.project b/BasicJava/ThreadDemo_daemon_app/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_daemon_app/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_daemon_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_daemon_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_daemon_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_daemon_app/ThreadDemo/bin/DisplayThread.class b/BasicJava/ThreadDemo_daemon_app/ThreadDemo/bin/DisplayThread.class new file mode 100644 index 000000000..c05eaec1c Binary files /dev/null and b/BasicJava/ThreadDemo_daemon_app/ThreadDemo/bin/DisplayThread.class differ diff --git a/BasicJava/ThreadDemo_daemon_app/ThreadDemo/src/DisplayThread.java b/BasicJava/ThreadDemo_daemon_app/ThreadDemo/src/DisplayThread.java new file mode 100644 index 000000000..d89556799 --- /dev/null +++ b/BasicJava/ThreadDemo_daemon_app/ThreadDemo/src/DisplayThread.java @@ -0,0 +1,55 @@ +/* + * public final void setDaemon(boolean on) + * + * Parameters: + * ----------- + * + * on - if true, marks this thread as a + * daemon thread + */ + +public class DisplayThread extends Thread +{ + + public void run() + { + /* + * Tests if this thread is a daemon thread. + */ + if (Thread.currentThread().isDaemon()) + { + System.out.println("Daemon thread = " + + Thread.currentThread().getName()); + } + else + { + System.out.println("user thread = " + + Thread.currentThread().getName()); + } + } + + public static void main(String[] args) + { + DisplayThread t1 = new DisplayThread(); + t1.setName("Thread 1"); + DisplayThread t2 = new DisplayThread(); + t2.setName("Thread 2"); + DisplayThread t3 = new DisplayThread(); + t3.setName("Thread 3"); + + /* + * Marks this thread as either a daemon thread or a + * user thread. The Java Virtual Machine exits when + * the only threads running are all daemon threads. + * This method must be invoked before the thread is + * started. + * + * Now t1 is daemon thread + */ + t1.setDaemon(true); + + t1.start(); + t2.start(); + t3.start(); + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_daemon_exp_app/Output.txt b/BasicJava/ThreadDemo_daemon_exp_app/Output.txt new file mode 100644 index 000000000..c9e5992eb --- /dev/null +++ b/BasicJava/ThreadDemo_daemon_exp_app/Output.txt @@ -0,0 +1,4 @@ +Exception in thread "main" java.lang.IllegalThreadStateException + at java.lang.Thread.setDaemon(Thread.java:1352) + at DisplayThread.main(DisplayThread.java:51) +user thread = Thread 1 diff --git a/BasicJava/ThreadDemo_daemon_exp_app/ThreadDemo/.classpath b/BasicJava/ThreadDemo_daemon_exp_app/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_daemon_exp_app/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_daemon_exp_app/ThreadDemo/.project b/BasicJava/ThreadDemo_daemon_exp_app/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_daemon_exp_app/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_daemon_exp_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_daemon_exp_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_daemon_exp_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_daemon_exp_app/ThreadDemo/bin/DisplayThread.class b/BasicJava/ThreadDemo_daemon_exp_app/ThreadDemo/bin/DisplayThread.class new file mode 100644 index 000000000..d247f8331 Binary files /dev/null and b/BasicJava/ThreadDemo_daemon_exp_app/ThreadDemo/bin/DisplayThread.class differ diff --git a/BasicJava/ThreadDemo_daemon_exp_app/ThreadDemo/src/DisplayThread.java b/BasicJava/ThreadDemo_daemon_exp_app/ThreadDemo/src/DisplayThread.java new file mode 100644 index 000000000..acb1dd9b3 --- /dev/null +++ b/BasicJava/ThreadDemo_daemon_exp_app/ThreadDemo/src/DisplayThread.java @@ -0,0 +1,55 @@ +/* + * public final void setDaemon(boolean on) + * + * Parameters: + * ----------- + * + * on - if true, marks this thread as a + * daemon thread + */ + +public class DisplayThread extends Thread +{ + + public void run() + { + /* + * Tests if this thread is a daemon thread. + */ + if (Thread.currentThread().isDaemon()) + { + System.out.println("Daemon thread = " + + Thread.currentThread().getName()); + } + else + { + System.out.println("user thread = " + + Thread.currentThread().getName()); + } + } + + public static void main(String[] args) + { + DisplayThread t1 = new DisplayThread(); + t1.setName("Thread 1"); + DisplayThread t2 = new DisplayThread(); + t2.setName("Thread 2"); + DisplayThread t3 = new DisplayThread(); + t3.setName("Thread 3"); + + t1.start(); + + /* + * If you want to make a user thread as Daemon, it + * must not be started otherwise it will throw + * IllegalThreadStateException. + * + * below line will throw + * IllegalThreadStateException, because t1 thread is + * started already. + */ + t1.setDaemon(true); + t2.start(); + t3.start(); + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_default_priority_App/Output.txt b/BasicJava/ThreadDemo_default_priority_App/Output.txt new file mode 100644 index 000000000..a2dcf6c4a --- /dev/null +++ b/BasicJava/ThreadDemo_default_priority_App/Output.txt @@ -0,0 +1,4 @@ +Thread name =Thread-1, Thread Priority = 5 + +Thread name =Thread-0, Thread Priority = 5 + diff --git a/BasicJava/ThreadDemo_default_priority_App/ThreadDemo/.classpath b/BasicJava/ThreadDemo_default_priority_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_default_priority_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_default_priority_App/ThreadDemo/.project b/BasicJava/ThreadDemo_default_priority_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_default_priority_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_default_priority_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_default_priority_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_default_priority_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_default_priority_App/ThreadDemo/bin/DisplayThread.class b/BasicJava/ThreadDemo_default_priority_App/ThreadDemo/bin/DisplayThread.class new file mode 100644 index 000000000..cbb4ab2aa Binary files /dev/null and b/BasicJava/ThreadDemo_default_priority_App/ThreadDemo/bin/DisplayThread.class differ diff --git a/BasicJava/ThreadDemo_default_priority_App/ThreadDemo/src/DisplayThread.java b/BasicJava/ThreadDemo_default_priority_App/ThreadDemo/src/DisplayThread.java new file mode 100644 index 000000000..84579239f --- /dev/null +++ b/BasicJava/ThreadDemo_default_priority_App/ThreadDemo/src/DisplayThread.java @@ -0,0 +1,20 @@ +class DisplayThread extends Thread +{ + + public static void main(String args[]) + { + DisplayThread displayThread1 = new DisplayThread(); + DisplayThread displayThread2 = new DisplayThread(); + + displayThread1.start(); + displayThread2.start(); + } + + public void run() + { + System.out.println("Thread name =" + Thread.currentThread().getName() + + ", Thread Priority = " + Thread.currentThread().getPriority() + + "\n"); + + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_interrupt_how_App/Output.txt b/BasicJava/ThreadDemo_interrupt_how_App/Output.txt new file mode 100644 index 000000000..05f0b5ff2 --- /dev/null +++ b/BasicJava/ThreadDemo_interrupt_how_App/Output.txt @@ -0,0 +1,8 @@ +Executing Thread-0 +Thread-0 interrupted: +java.lang.InterruptedException: sleep interrupted + +Executing Thread-1 +Thread-1 interrupted: +java.lang.InterruptedException: sleep interrupted + diff --git a/BasicJava/ThreadDemo_interrupt_how_App/ThreadDemo/.classpath b/BasicJava/ThreadDemo_interrupt_how_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_interrupt_how_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_interrupt_how_App/ThreadDemo/.project b/BasicJava/ThreadDemo_interrupt_how_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_interrupt_how_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_interrupt_how_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_interrupt_how_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_interrupt_how_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_interrupt_how_App/ThreadDemo/bin/MyRunnable.class b/BasicJava/ThreadDemo_interrupt_how_App/ThreadDemo/bin/MyRunnable.class new file mode 100644 index 000000000..52018bf97 Binary files /dev/null and b/BasicJava/ThreadDemo_interrupt_how_App/ThreadDemo/bin/MyRunnable.class differ diff --git a/BasicJava/ThreadDemo_interrupt_how_App/ThreadDemo/bin/ThreadDemo.class b/BasicJava/ThreadDemo_interrupt_how_App/ThreadDemo/bin/ThreadDemo.class new file mode 100644 index 000000000..a2224c40d Binary files /dev/null and b/BasicJava/ThreadDemo_interrupt_how_App/ThreadDemo/bin/ThreadDemo.class differ diff --git a/BasicJava/ThreadDemo_interrupt_how_App/ThreadDemo/src/MyRunnable.java b/BasicJava/ThreadDemo_interrupt_how_App/ThreadDemo/src/MyRunnable.java new file mode 100644 index 000000000..483ef7e02 --- /dev/null +++ b/BasicJava/ThreadDemo_interrupt_how_App/ThreadDemo/src/MyRunnable.java @@ -0,0 +1,48 @@ +public class MyRunnable implements Runnable +{ + + Thread t; + + public MyRunnable() + { + + t = new Thread(this); + System.out.println("Executing " + t.getName()); + // this will call run() fucntion + t.start(); + + /* + * Tests whether the current thread has been + * interrupted. + */ + if (!t.interrupted()) + { + // Interrupts this thread. + t.interrupt(); + } + // block until other threads finish + try + { + t.join(); + } + catch (InterruptedException e) + { + } + } + + public void run() + { + try + { + while (true) + { + Thread.sleep(1000); + } + } + catch (InterruptedException e) + { + System.out.println(t.getName() + " interrupted:"); + System.out.println(e.toString() + "\n"); + } + } +} diff --git a/BasicJava/ThreadDemo_interrupt_how_App/ThreadDemo/src/ThreadDemo.java b/BasicJava/ThreadDemo_interrupt_how_App/ThreadDemo/src/ThreadDemo.java new file mode 100644 index 000000000..b2ff812fb --- /dev/null +++ b/BasicJava/ThreadDemo_interrupt_how_App/ThreadDemo/src/ThreadDemo.java @@ -0,0 +1,9 @@ +public class ThreadDemo +{ + + public static void main(String args[]) + { + new MyRunnable(); + new MyRunnable(); + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_interrupted_methods_App/Output.txt b/BasicJava/ThreadDemo_interrupted_methods_App/Output.txt new file mode 100644 index 000000000..b3383b9c3 --- /dev/null +++ b/BasicJava/ThreadDemo_interrupted_methods_App/Output.txt @@ -0,0 +1,3 @@ +Before Thread.interrupted() is called = true +After Thread.interrupted() is called = false +code for interrupted thread diff --git a/BasicJava/ThreadDemo_interrupted_methods_App/ThreadDemo/.classpath b/BasicJava/ThreadDemo_interrupted_methods_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_interrupted_methods_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_interrupted_methods_App/ThreadDemo/.project b/BasicJava/ThreadDemo_interrupted_methods_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_interrupted_methods_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_interrupted_methods_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_interrupted_methods_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_interrupted_methods_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_interrupted_methods_App/ThreadDemo/bin/DisplayThread.class b/BasicJava/ThreadDemo_interrupted_methods_App/ThreadDemo/bin/DisplayThread.class new file mode 100644 index 000000000..b7154e670 Binary files /dev/null and b/BasicJava/ThreadDemo_interrupted_methods_App/ThreadDemo/bin/DisplayThread.class differ diff --git a/BasicJava/ThreadDemo_interrupted_methods_App/ThreadDemo/src/DisplayThread.java b/BasicJava/ThreadDemo_interrupted_methods_App/ThreadDemo/src/DisplayThread.java new file mode 100644 index 000000000..59c179c73 --- /dev/null +++ b/BasicJava/ThreadDemo_interrupted_methods_App/ThreadDemo/src/DisplayThread.java @@ -0,0 +1,38 @@ +class DisplayThread extends Thread +{ + public void run() + { + + /* + * Tests whether this thread has been interrupted. + * The interrupted status of the thread is + * unaffected by this method. + */ + System.out.println("Before Thread.interrupted() is called = " + + Thread.currentThread().isInterrupted()); + + /* + * Tests whether the current thread has been + * interrupted. The interrupted status of the thread + * is cleared by this method. + */ + if (Thread.interrupted()) + { + + System.out.println("After Thread.interrupted() is called = " + + Thread.currentThread().isInterrupted()); + System.out.println("code for interrupted thread"); + } + else + { + System.out.println("code for normal thread"); + } + } + + public static void main(String args[]) + { + DisplayThread t1 = new DisplayThread(); + t1.start(); + t1.interrupt(); + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_isAlive_App/Output.txt b/BasicJava/ThreadDemo_isAlive_App/Output.txt new file mode 100644 index 000000000..4ae2ae971 --- /dev/null +++ b/BasicJava/ThreadDemo_isAlive_App/Output.txt @@ -0,0 +1,2 @@ +Thread-0 - isAlive = true +Thread-0 - isAlive after join = false diff --git a/BasicJava/ThreadDemo_isAlive_App/ThreadDemo/.classpath b/BasicJava/ThreadDemo_isAlive_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_isAlive_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_isAlive_App/ThreadDemo/.project b/BasicJava/ThreadDemo_isAlive_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_isAlive_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_isAlive_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_isAlive_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_isAlive_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_isAlive_App/ThreadDemo/bin/MyRunnable.class b/BasicJava/ThreadDemo_isAlive_App/ThreadDemo/bin/MyRunnable.class new file mode 100644 index 000000000..b312f2abe Binary files /dev/null and b/BasicJava/ThreadDemo_isAlive_App/ThreadDemo/bin/MyRunnable.class differ diff --git a/BasicJava/ThreadDemo_isAlive_App/ThreadDemo/bin/ThreadDemo.class b/BasicJava/ThreadDemo_isAlive_App/ThreadDemo/bin/ThreadDemo.class new file mode 100644 index 000000000..3a5139915 Binary files /dev/null and b/BasicJava/ThreadDemo_isAlive_App/ThreadDemo/bin/ThreadDemo.class differ diff --git a/BasicJava/ThreadDemo_isAlive_App/ThreadDemo/src/MyRunnable.java b/BasicJava/ThreadDemo_isAlive_App/ThreadDemo/src/MyRunnable.java new file mode 100644 index 000000000..76b58c4d1 --- /dev/null +++ b/BasicJava/ThreadDemo_isAlive_App/ThreadDemo/src/MyRunnable.java @@ -0,0 +1,10 @@ +public class MyRunnable implements Runnable +{ + + public void run() + { + Thread t = Thread.currentThread(); + // tests if this thread is alive + System.out.println(t.getName()+" - isAlive = " + t.isAlive()); + } +} diff --git a/BasicJava/ThreadDemo_isAlive_App/ThreadDemo/src/ThreadDemo.java b/BasicJava/ThreadDemo_isAlive_App/ThreadDemo/src/ThreadDemo.java new file mode 100644 index 000000000..958b7a982 --- /dev/null +++ b/BasicJava/ThreadDemo_isAlive_App/ThreadDemo/src/ThreadDemo.java @@ -0,0 +1,17 @@ +public class ThreadDemo +{ + + public static void main(String args[]) throws InterruptedException + { + Thread t = new Thread(new MyRunnable()); + + // this will call run() function + t.start(); + + // waits for this thread to die + t.join(); + + // tests if this thread is alive + System.out.println(t.getName()+" - isAlive after join = " + t.isAlive()); + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_join_app/Output.txt b/BasicJava/ThreadDemo_join_app/Output.txt new file mode 100644 index 000000000..ed5b7d479 --- /dev/null +++ b/BasicJava/ThreadDemo_join_app/Output.txt @@ -0,0 +1,15 @@ +Thread-0 = 1 +Thread-0 = 2 +Thread-0 = 3 +Thread-0 = 4 +Thread-0 = 5 +Thread-1 = 1 +Thread-2 = 1 +Thread-1 = 2 +Thread-2 = 2 +Thread-1 = 3 +Thread-2 = 3 +Thread-2 = 4 +Thread-1 = 4 +Thread-2 = 5 +Thread-1 = 5 diff --git a/BasicJava/ThreadDemo_join_app/ThreadDemo/.classpath b/BasicJava/ThreadDemo_join_app/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_join_app/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_join_app/ThreadDemo/.project b/BasicJava/ThreadDemo_join_app/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_join_app/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_join_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_join_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_join_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_join_app/ThreadDemo/bin/DisplayNumberThread.class b/BasicJava/ThreadDemo_join_app/ThreadDemo/bin/DisplayNumberThread.class new file mode 100644 index 000000000..86234465e Binary files /dev/null and b/BasicJava/ThreadDemo_join_app/ThreadDemo/bin/DisplayNumberThread.class differ diff --git a/BasicJava/ThreadDemo_join_app/ThreadDemo/src/DisplayNumberThread.java b/BasicJava/ThreadDemo_join_app/ThreadDemo/src/DisplayNumberThread.java new file mode 100644 index 000000000..2b4bde658 --- /dev/null +++ b/BasicJava/ThreadDemo_join_app/ThreadDemo/src/DisplayNumberThread.java @@ -0,0 +1,40 @@ +class DisplayNumberThread extends Thread +{ + public void run() + { + for (int i = 1; i <= 5; i++) + { + try + { + Thread.sleep(500); + } + catch (Exception e) + { + e.printStackTrace(); + } + System.out.println(this.getName() + " = " +i); + } + } + + public static void main(String args[]) + { + DisplayNumberThread dnt1 = new DisplayNumberThread(); + DisplayNumberThread dnt2 = new DisplayNumberThread(); + DisplayNumberThread dnt3 = new DisplayNumberThread(); + dnt1.start(); + try + { + /* + * Waits for this thread to die. + */ + dnt1.join(); + } + catch (Exception e) + { + e.printStackTrace(); + } + + dnt2.start(); + dnt3.start(); + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_join_ms_app/Output.txt b/BasicJava/ThreadDemo_join_ms_app/Output.txt new file mode 100644 index 000000000..ce9bc8794 --- /dev/null +++ b/BasicJava/ThreadDemo_join_ms_app/Output.txt @@ -0,0 +1,15 @@ +Thread-0 = 1 +Thread-0 = 2 +Thread-0 = 3 +Thread-0 = 4 +Thread-0 = 5 +Thread-1 = 1 +Thread-2 = 1 +Thread-2 = 2 +Thread-1 = 2 +Thread-1 = 3 +Thread-2 = 3 +Thread-2 = 4 +Thread-1 = 4 +Thread-1 = 5 +Thread-2 = 5 diff --git a/BasicJava/ThreadDemo_join_ms_app/ThreadDemo/.classpath b/BasicJava/ThreadDemo_join_ms_app/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_join_ms_app/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_join_ms_app/ThreadDemo/.project b/BasicJava/ThreadDemo_join_ms_app/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_join_ms_app/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_join_ms_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_join_ms_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_join_ms_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_join_ms_app/ThreadDemo/bin/DisplayNumberThread.class b/BasicJava/ThreadDemo_join_ms_app/ThreadDemo/bin/DisplayNumberThread.class new file mode 100644 index 000000000..4dceb4fa8 Binary files /dev/null and b/BasicJava/ThreadDemo_join_ms_app/ThreadDemo/bin/DisplayNumberThread.class differ diff --git a/BasicJava/ThreadDemo_join_ms_app/ThreadDemo/src/DisplayNumberThread.java b/BasicJava/ThreadDemo_join_ms_app/ThreadDemo/src/DisplayNumberThread.java new file mode 100644 index 000000000..1f0bec0c9 --- /dev/null +++ b/BasicJava/ThreadDemo_join_ms_app/ThreadDemo/src/DisplayNumberThread.java @@ -0,0 +1,41 @@ +class DisplayNumberThread extends Thread +{ + public static void main(String args[]) + { + DisplayNumberThread dnt1 = new DisplayNumberThread(); + DisplayNumberThread dnt2 = new DisplayNumberThread(); + DisplayNumberThread dnt3 = new DisplayNumberThread(); + dnt1.start(); + try + { + /* + * Waits at most millis milliseconds for this + * thread to die. + */ + dnt1.join(2500); + } + catch (Exception e) + { + e.printStackTrace(); + } + + dnt2.start(); + dnt3.start(); + } + + public void run() + { + for (int i = 1; i <= 5; i++) + { + try + { + Thread.sleep(500); + } + catch (Exception e) + { + e.printStackTrace(); + } + System.out.println(this.getName() + " = " + i); + } + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_run_directly_app/DisplayNumberThread_Output.txt b/BasicJava/ThreadDemo_run_directly_app/DisplayNumberThread_Output.txt new file mode 100644 index 000000000..a634e606f --- /dev/null +++ b/BasicJava/ThreadDemo_run_directly_app/DisplayNumberThread_Output.txt @@ -0,0 +1,8 @@ +1 +2 +3 +4 +1 +2 +3 +4 diff --git a/BasicJava/ThreadDemo_run_directly_app/DisplayThread_Output.txt b/BasicJava/ThreadDemo_run_directly_app/DisplayThread_Output.txt new file mode 100644 index 000000000..7e4683b26 --- /dev/null +++ b/BasicJava/ThreadDemo_run_directly_app/DisplayThread_Output.txt @@ -0,0 +1 @@ +Hello by diff --git a/BasicJava/ThreadDemo_run_directly_app/ThreadDemo/.classpath b/BasicJava/ThreadDemo_run_directly_app/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_run_directly_app/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_run_directly_app/ThreadDemo/.project b/BasicJava/ThreadDemo_run_directly_app/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_run_directly_app/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_run_directly_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_run_directly_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_run_directly_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_run_directly_app/ThreadDemo/bin/DisplayNumberThread.class b/BasicJava/ThreadDemo_run_directly_app/ThreadDemo/bin/DisplayNumberThread.class new file mode 100644 index 000000000..54fd2400c Binary files /dev/null and b/BasicJava/ThreadDemo_run_directly_app/ThreadDemo/bin/DisplayNumberThread.class differ diff --git a/BasicJava/ThreadDemo_run_directly_app/ThreadDemo/bin/DisplayThread.class b/BasicJava/ThreadDemo_run_directly_app/ThreadDemo/bin/DisplayThread.class new file mode 100644 index 000000000..f6cc0042c Binary files /dev/null and b/BasicJava/ThreadDemo_run_directly_app/ThreadDemo/bin/DisplayThread.class differ diff --git a/BasicJava/ThreadDemo_run_directly_app/ThreadDemo/src/DisplayNumberThread.java b/BasicJava/ThreadDemo_run_directly_app/ThreadDemo/src/DisplayNumberThread.java new file mode 100644 index 000000000..a2ba7965c --- /dev/null +++ b/BasicJava/ThreadDemo_run_directly_app/ThreadDemo/src/DisplayNumberThread.java @@ -0,0 +1,29 @@ +public class DisplayNumberThread extends Thread +{ + + public static void main(String[] args) + { + DisplayNumberThread displayNumberThread1 = new DisplayNumberThread(); + DisplayNumberThread displayNumberThread2 = new DisplayNumberThread(); + displayNumberThread1.run(); + displayNumberThread2.run(); + + } + + public void run() + { + for (int i = 1; i < 5; i++) + { + try + { + Thread.sleep(1000); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + System.out.println(i); + } + } + +} diff --git a/BasicJava/ThreadDemo_run_directly_app/ThreadDemo/src/DisplayThread.java b/BasicJava/ThreadDemo_run_directly_app/ThreadDemo/src/DisplayThread.java new file mode 100644 index 000000000..4cb779890 --- /dev/null +++ b/BasicJava/ThreadDemo_run_directly_app/ThreadDemo/src/DisplayThread.java @@ -0,0 +1,20 @@ +class DisplayThread extends Thread +{ + + public static void main(String args[]) + { + DisplayThread displayThread = new DisplayThread(); + + /* + * fine, but does not start a separate call stack + */ + displayThread.run(); + + } + + public void run() + { + System.out.println("Hello by "); + } + +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_simplethreads_app/Output.txt b/BasicJava/ThreadDemo_simplethreads_app/Output.txt new file mode 100644 index 000000000..5c7259679 --- /dev/null +++ b/BasicJava/ThreadDemo_simplethreads_app/Output.txt @@ -0,0 +1,23 @@ +main: Starting MessageLoop thread +main: Waiting for MessageLoop thread to finish +main: Still waiting... +main: Still waiting... +main: Still waiting... +main: Still waiting... +main: Still waiting... +Thread-0: Peter goes to Japan +main: Still waiting... +main: Still waiting... +main: Still waiting... +main: Still waiting... +Thread-0: Hello welcome to india +main: Still waiting... +main: Still waiting... +main: Still waiting... +main: Still waiting... +Thread-0: Twinkle Twinkle little star +main: Still waiting... +main: Still waiting... +main: Still waiting... +Thread-0: John is a super man +main: Finally! diff --git a/BasicJava/ThreadDemo_simplethreads_app/ThreadDemo/.classpath b/BasicJava/ThreadDemo_simplethreads_app/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_simplethreads_app/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_simplethreads_app/ThreadDemo/.project b/BasicJava/ThreadDemo_simplethreads_app/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_simplethreads_app/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_simplethreads_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_simplethreads_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_simplethreads_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_simplethreads_app/ThreadDemo/bin/SimpleThreads$MessageLoop.class b/BasicJava/ThreadDemo_simplethreads_app/ThreadDemo/bin/SimpleThreads$MessageLoop.class new file mode 100644 index 000000000..69c2c74bc Binary files /dev/null and b/BasicJava/ThreadDemo_simplethreads_app/ThreadDemo/bin/SimpleThreads$MessageLoop.class differ diff --git a/BasicJava/ThreadDemo_simplethreads_app/ThreadDemo/bin/SimpleThreads.class b/BasicJava/ThreadDemo_simplethreads_app/ThreadDemo/bin/SimpleThreads.class new file mode 100644 index 000000000..80761fe25 Binary files /dev/null and b/BasicJava/ThreadDemo_simplethreads_app/ThreadDemo/bin/SimpleThreads.class differ diff --git a/BasicJava/ThreadDemo_simplethreads_app/ThreadDemo/src/SimpleThreads.java b/BasicJava/ThreadDemo_simplethreads_app/ThreadDemo/src/SimpleThreads.java new file mode 100644 index 000000000..b3271ce42 --- /dev/null +++ b/BasicJava/ThreadDemo_simplethreads_app/ThreadDemo/src/SimpleThreads.java @@ -0,0 +1,105 @@ +/* + * SimpleThreads consists of two threads. The first is + * the main thread that every Java application has. The + * main thread creates a new thread from the Runnable + * object, MessageLoop, and waits for it to finish. If + * the MessageLoop thread takes too long to finish, the + * main thread interrupts it. + * + * The MessageLoop thread prints out a series of + * messages. If interrupted before it has printed all + * its messages, the MessageLoop thread prints a message + * and exits. + */ + +public class SimpleThreads +{ + + /* + * Display a message, preceded by the name of the + * current thread + */ + static void threadMessage(String message) + { + String threadName = Thread.currentThread().getName(); + System.out.format("%s: %s%n", threadName, message); + } + + private static class MessageLoop implements Runnable + { + public void run() + { + String importantInfo[] = + { "Peter goes to Japan", "Hello welcome to india", + "Twinkle Twinkle little star", "John is a super man" }; + try + { + for (int i = 0; i < importantInfo.length; i++) + { + // Pause for 4 seconds + Thread.sleep(4000); + // Print a message + threadMessage(importantInfo[i]); + } + } + catch (InterruptedException e) + { + threadMessage("I wasn't done!"); + } + } + } + + public static void main(String args[]) throws InterruptedException + { + + // Delay, in milliseconds before + // we interrupt MessageLoop + // thread (default one hour). + long patience = 1000 * 60 * 60; + + // If command line argument + // present, gives patience + // in seconds. + if (args.length > 0) + { + try + { + patience = Long.parseLong(args[0]) * 1000; + } + catch (NumberFormatException e) + { + System.err.println("Argument must be an integer."); + System.exit(1); + } + } + + threadMessage("Starting MessageLoop thread"); + long startTime = System.currentTimeMillis(); + Thread t = new Thread(new MessageLoop()); + t.start(); + + threadMessage("Waiting for MessageLoop thread to finish"); + /* + * loop until MessageLoop thread exits + */ + while (t.isAlive()) + { + threadMessage("Still waiting..."); + /* + * Wait maximum of 1 second for MessageLoop + * thread to finish. + */ + t.join(1000); + if (((System.currentTimeMillis() - startTime) > patience) + && t.isAlive()) + { + threadMessage("Tired of waiting!"); + t.interrupt(); + // Shouldn't be long now + // -- wait indefinitely + t.join(); + } + } + threadMessage("Finally!"); + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_sleep_App/Output.txt b/BasicJava/ThreadDemo_sleep_App/Output.txt new file mode 100644 index 000000000..4f26e06b0 --- /dev/null +++ b/BasicJava/ThreadDemo_sleep_App/Output.txt @@ -0,0 +1,4 @@ +Before sleep of = DisplayThread-1 +Before sleep of = DisplayThread-2 +After sleep of = DisplayThread-2 +After sleep of = DisplayThread-1 diff --git a/BasicJava/ThreadDemo_sleep_App/ThreadDemo/.classpath b/BasicJava/ThreadDemo_sleep_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_sleep_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_sleep_App/ThreadDemo/.project b/BasicJava/ThreadDemo_sleep_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_sleep_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_sleep_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_sleep_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_sleep_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_sleep_App/ThreadDemo/bin/DisplayThread.class b/BasicJava/ThreadDemo_sleep_App/ThreadDemo/bin/DisplayThread.class new file mode 100644 index 000000000..0da5e2e76 Binary files /dev/null and b/BasicJava/ThreadDemo_sleep_App/ThreadDemo/bin/DisplayThread.class differ diff --git a/BasicJava/ThreadDemo_sleep_App/ThreadDemo/src/DisplayThread.java b/BasicJava/ThreadDemo_sleep_App/ThreadDemo/src/DisplayThread.java new file mode 100644 index 000000000..51e222eb8 --- /dev/null +++ b/BasicJava/ThreadDemo_sleep_App/ThreadDemo/src/DisplayThread.java @@ -0,0 +1,40 @@ +class DisplayThread extends Thread +{ + public DisplayThread(String threadName) + { + super(threadName); + } + + public static void main(String args[]) + { + DisplayThread displayThread1 = new DisplayThread("DisplayThread-1"); + DisplayThread displayThread2 = new DisplayThread("DisplayThread-2"); + + displayThread1.start(); + displayThread2.start(); + } + + public void run() + { + + System.out.println("Before sleep of = " + this.getName()); + try + { + /* + * Causes the currently executing thread to + * sleep (temporarily cease execution) for the + * specified number of milliseconds, subject to + * the precision and accuracy of system timers + * and schedulers. The thread does not lose + * ownership of any monitors. + */ + Thread.sleep(10000); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + System.out.println("After sleep of = " + this.getName()); + } + +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_sleep_pause_App/Output.txt b/BasicJava/ThreadDemo_sleep_pause_App/Output.txt new file mode 100644 index 000000000..9c37539a0 --- /dev/null +++ b/BasicJava/ThreadDemo_sleep_pause_App/Output.txt @@ -0,0 +1,4 @@ +Hello good morning +Did you eat +I am going to walk +Good night diff --git a/BasicJava/ThreadDemo_sleep_pause_App/ThreadDemo/.classpath b/BasicJava/ThreadDemo_sleep_pause_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_sleep_pause_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_sleep_pause_App/ThreadDemo/.project b/BasicJava/ThreadDemo_sleep_pause_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_sleep_pause_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_sleep_pause_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_sleep_pause_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_sleep_pause_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_sleep_pause_App/ThreadDemo/bin/DisplayNumberThread.class b/BasicJava/ThreadDemo_sleep_pause_App/ThreadDemo/bin/DisplayNumberThread.class new file mode 100644 index 000000000..54fd2400c Binary files /dev/null and b/BasicJava/ThreadDemo_sleep_pause_App/ThreadDemo/bin/DisplayNumberThread.class differ diff --git a/BasicJava/ThreadDemo_sleep_pause_App/ThreadDemo/bin/SleepMessages.class b/BasicJava/ThreadDemo_sleep_pause_App/ThreadDemo/bin/SleepMessages.class new file mode 100644 index 000000000..3481af36c Binary files /dev/null and b/BasicJava/ThreadDemo_sleep_pause_App/ThreadDemo/bin/SleepMessages.class differ diff --git a/BasicJava/ThreadDemo_sleep_pause_App/ThreadDemo/src/SleepMessages.java b/BasicJava/ThreadDemo_sleep_pause_App/ThreadDemo/src/SleepMessages.java new file mode 100644 index 000000000..6290946c1 --- /dev/null +++ b/BasicJava/ThreadDemo_sleep_pause_App/ThreadDemo/src/SleepMessages.java @@ -0,0 +1,18 @@ +public class SleepMessages +{ + public static void main(String args[]) throws InterruptedException + { + String messages[] = + { "Hello good morning", "Did you eat", "I am going to walk", + "Good night" }; + + for (String message : messages) + { + // Pause for 5 seconds + Thread.sleep(5000); + // Print a message + System.out.println(message); + } + + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_start_twice_App/Output.txt b/BasicJava/ThreadDemo_start_twice_App/Output.txt new file mode 100644 index 000000000..8e3725db2 --- /dev/null +++ b/BasicJava/ThreadDemo_start_twice_App/Output.txt @@ -0,0 +1,4 @@ +Hello by = Thread-0 +Exception in thread "main" java.lang.IllegalThreadStateException + at java.lang.Thread.start(Thread.java:705) + at DisplayThread.main(DisplayThread.java:9) diff --git a/BasicJava/ThreadDemo_start_twice_App/ThreadDemo/.classpath b/BasicJava/ThreadDemo_start_twice_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_start_twice_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_start_twice_App/ThreadDemo/.project b/BasicJava/ThreadDemo_start_twice_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_start_twice_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_start_twice_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_start_twice_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_start_twice_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_start_twice_App/ThreadDemo/bin/DisplayThread.class b/BasicJava/ThreadDemo_start_twice_App/ThreadDemo/bin/DisplayThread.class new file mode 100644 index 000000000..871a974ad Binary files /dev/null and b/BasicJava/ThreadDemo_start_twice_App/ThreadDemo/bin/DisplayThread.class differ diff --git a/BasicJava/ThreadDemo_start_twice_App/ThreadDemo/src/DisplayThread.java b/BasicJava/ThreadDemo_start_twice_App/ThreadDemo/src/DisplayThread.java new file mode 100644 index 000000000..651211b7c --- /dev/null +++ b/BasicJava/ThreadDemo_start_twice_App/ThreadDemo/src/DisplayThread.java @@ -0,0 +1,17 @@ +class DisplayThread extends Thread +{ + + public static void main(String args[]) + { + DisplayThread displayThread = new DisplayThread(); + + displayThread.start(); + displayThread.start(); + } + + public void run() + { + System.out.println("Hello by = " + this.getName()); + } + +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_state_App/Output.txt b/BasicJava/ThreadDemo_state_App/Output.txt new file mode 100644 index 000000000..5f5138c3f --- /dev/null +++ b/BasicJava/ThreadDemo_state_App/Output.txt @@ -0,0 +1 @@ +Thread Name = Thread-0 , state = RUNNABLE diff --git a/BasicJava/ThreadDemo_state_App/ThreadDemo/.classpath b/BasicJava/ThreadDemo_state_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_state_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_state_App/ThreadDemo/.project b/BasicJava/ThreadDemo_state_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_state_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_state_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_state_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_state_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_state_App/ThreadDemo/bin/MyRunnable.class b/BasicJava/ThreadDemo_state_App/ThreadDemo/bin/MyRunnable.class new file mode 100644 index 000000000..89aeb73fc Binary files /dev/null and b/BasicJava/ThreadDemo_state_App/ThreadDemo/bin/MyRunnable.class differ diff --git a/BasicJava/ThreadDemo_state_App/ThreadDemo/bin/ThreadDemo.class b/BasicJava/ThreadDemo_state_App/ThreadDemo/bin/ThreadDemo.class new file mode 100644 index 000000000..3eff3cf81 Binary files /dev/null and b/BasicJava/ThreadDemo_state_App/ThreadDemo/bin/ThreadDemo.class differ diff --git a/BasicJava/ThreadDemo_state_App/ThreadDemo/src/MyRunnable.java b/BasicJava/ThreadDemo_state_App/ThreadDemo/src/MyRunnable.java new file mode 100644 index 000000000..9ec32096c --- /dev/null +++ b/BasicJava/ThreadDemo_state_App/ThreadDemo/src/MyRunnable.java @@ -0,0 +1,12 @@ +public class MyRunnable implements Runnable +{ + public void run() + { + /* + * Returns the state of this thread. + */ + Thread.State state = Thread.currentThread().getState(); + System.out.print("Thread Name = " + Thread.currentThread().getName()); + System.out.println(" , state = " + state); + } +} diff --git a/BasicJava/ThreadDemo_state_App/ThreadDemo/src/ThreadDemo.java b/BasicJava/ThreadDemo_state_App/ThreadDemo/src/ThreadDemo.java new file mode 100644 index 000000000..a5503357e --- /dev/null +++ b/BasicJava/ThreadDemo_state_App/ThreadDemo/src/ThreadDemo.java @@ -0,0 +1,10 @@ +public class ThreadDemo +{ + + public static void main(String args[]) + { + Thread t = new Thread(new MyRunnable()); + // this will call run() function + t.start(); + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_static_sync_method_anonymous_App/Output.txt b/BasicJava/ThreadDemo_static_sync_method_anonymous_App/Output.txt new file mode 100644 index 000000000..0731def9e --- /dev/null +++ b/BasicJava/ThreadDemo_static_sync_method_anonymous_App/Output.txt @@ -0,0 +1,14 @@ +Thread-0 +1 +2 +3 +4 +5 +------------------------ +Thread-1 +10 +20 +30 +40 +50 +------------------------ diff --git a/BasicJava/ThreadDemo_static_sync_method_anonymous_App/ThreadDemo/.classpath b/BasicJava/ThreadDemo_static_sync_method_anonymous_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_static_sync_method_anonymous_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_static_sync_method_anonymous_App/ThreadDemo/.project b/BasicJava/ThreadDemo_static_sync_method_anonymous_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_static_sync_method_anonymous_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_static_sync_method_anonymous_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_static_sync_method_anonymous_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_static_sync_method_anonymous_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_static_sync_method_anonymous_App/ThreadDemo/bin/StaticSynchronizationDemo$1.class b/BasicJava/ThreadDemo_static_sync_method_anonymous_App/ThreadDemo/bin/StaticSynchronizationDemo$1.class new file mode 100644 index 000000000..4c50f8560 Binary files /dev/null and b/BasicJava/ThreadDemo_static_sync_method_anonymous_App/ThreadDemo/bin/StaticSynchronizationDemo$1.class differ diff --git a/BasicJava/ThreadDemo_static_sync_method_anonymous_App/ThreadDemo/bin/StaticSynchronizationDemo$2.class b/BasicJava/ThreadDemo_static_sync_method_anonymous_App/ThreadDemo/bin/StaticSynchronizationDemo$2.class new file mode 100644 index 000000000..b78ab5f83 Binary files /dev/null and b/BasicJava/ThreadDemo_static_sync_method_anonymous_App/ThreadDemo/bin/StaticSynchronizationDemo$2.class differ diff --git a/BasicJava/ThreadDemo_static_sync_method_anonymous_App/ThreadDemo/bin/StaticSynchronizationDemo.class b/BasicJava/ThreadDemo_static_sync_method_anonymous_App/ThreadDemo/bin/StaticSynchronizationDemo.class new file mode 100644 index 000000000..d2770c898 Binary files /dev/null and b/BasicJava/ThreadDemo_static_sync_method_anonymous_App/ThreadDemo/bin/StaticSynchronizationDemo.class differ diff --git a/BasicJava/ThreadDemo_static_sync_method_anonymous_App/ThreadDemo/bin/Table.class b/BasicJava/ThreadDemo_static_sync_method_anonymous_App/ThreadDemo/bin/Table.class new file mode 100644 index 000000000..df3e2cd7b Binary files /dev/null and b/BasicJava/ThreadDemo_static_sync_method_anonymous_App/ThreadDemo/bin/Table.class differ diff --git a/BasicJava/ThreadDemo_static_sync_method_anonymous_App/ThreadDemo/src/StaticSynchronizationDemo.java b/BasicJava/ThreadDemo_static_sync_method_anonymous_App/ThreadDemo/src/StaticSynchronizationDemo.java new file mode 100644 index 000000000..15556cfbe --- /dev/null +++ b/BasicJava/ThreadDemo_static_sync_method_anonymous_App/ThreadDemo/src/StaticSynchronizationDemo.java @@ -0,0 +1,50 @@ +/* + * In this example, we are using anonymous class to create the threads. + */ + +class Table +{ + + synchronized static void printTable(int n) + { + System.out.println(Thread.currentThread().getName()); + for (int i = 1; i <= 5; i++) + { + System.out.println(n * i); + try + { + Thread.sleep(400); + } + catch (Exception e) + { + } + } + System.out.println("------------------------"); + } +} + +public class StaticSynchronizationDemo +{ + public static void main(String t[]) + { + Thread t1 = new Thread() + { + public void run() + { + Table.printTable(1); + } + }; + + Thread t2 = new Thread() + { + public void run() + { + Table.printTable(10); + } + }; + + t1.start(); + t2.start(); + + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_static_synchronization_block_App/Output.txt b/BasicJava/ThreadDemo_static_synchronization_block_App/Output.txt new file mode 100644 index 000000000..0731def9e --- /dev/null +++ b/BasicJava/ThreadDemo_static_synchronization_block_App/Output.txt @@ -0,0 +1,14 @@ +Thread-0 +1 +2 +3 +4 +5 +------------------------ +Thread-1 +10 +20 +30 +40 +50 +------------------------ diff --git a/BasicJava/ThreadDemo_static_synchronization_block_App/ThreadDemo/.classpath b/BasicJava/ThreadDemo_static_synchronization_block_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_static_synchronization_block_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_static_synchronization_block_App/ThreadDemo/.project b/BasicJava/ThreadDemo_static_synchronization_block_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_static_synchronization_block_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_static_synchronization_block_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_static_synchronization_block_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_static_synchronization_block_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_static_synchronization_block_App/ThreadDemo/bin/StaticSynchronizationDemo$1.class b/BasicJava/ThreadDemo_static_synchronization_block_App/ThreadDemo/bin/StaticSynchronizationDemo$1.class new file mode 100644 index 000000000..7adffd08f Binary files /dev/null and b/BasicJava/ThreadDemo_static_synchronization_block_App/ThreadDemo/bin/StaticSynchronizationDemo$1.class differ diff --git a/BasicJava/ThreadDemo_static_synchronization_block_App/ThreadDemo/bin/StaticSynchronizationDemo$2.class b/BasicJava/ThreadDemo_static_synchronization_block_App/ThreadDemo/bin/StaticSynchronizationDemo$2.class new file mode 100644 index 000000000..d11dfffaf Binary files /dev/null and b/BasicJava/ThreadDemo_static_synchronization_block_App/ThreadDemo/bin/StaticSynchronizationDemo$2.class differ diff --git a/BasicJava/ThreadDemo_static_synchronization_block_App/ThreadDemo/bin/StaticSynchronizationDemo.class b/BasicJava/ThreadDemo_static_synchronization_block_App/ThreadDemo/bin/StaticSynchronizationDemo.class new file mode 100644 index 000000000..4da9d0aed Binary files /dev/null and b/BasicJava/ThreadDemo_static_synchronization_block_App/ThreadDemo/bin/StaticSynchronizationDemo.class differ diff --git a/BasicJava/ThreadDemo_static_synchronization_block_App/ThreadDemo/bin/Table.class b/BasicJava/ThreadDemo_static_synchronization_block_App/ThreadDemo/bin/Table.class new file mode 100644 index 000000000..73b9a87eb Binary files /dev/null and b/BasicJava/ThreadDemo_static_synchronization_block_App/ThreadDemo/bin/Table.class differ diff --git a/BasicJava/ThreadDemo_static_synchronization_block_App/ThreadDemo/src/StaticSynchronizationDemo.java b/BasicJava/ThreadDemo_static_synchronization_block_App/ThreadDemo/src/StaticSynchronizationDemo.java new file mode 100644 index 000000000..f94315c28 --- /dev/null +++ b/BasicJava/ThreadDemo_static_synchronization_block_App/ThreadDemo/src/StaticSynchronizationDemo.java @@ -0,0 +1,52 @@ +class Table +{ + + static void printTable(int n) + { + /* + * The block synchronizes on the lock of the object + * denoted by the reference .class name .class + */ + synchronized (Table.class) + { + System.out.println(Thread.currentThread().getName()); + for (int i = 1; i <= 5; i++) + { + System.out.println(n * i); + try + { + Thread.sleep(400); + } + catch (Exception e) + { + } + } + System.out.println("------------------------"); + } + } +} + +public class StaticSynchronizationDemo +{ + public static void main(String t[]) + { + Thread t1 = new Thread() + { + public void run() + { + Table.printTable(1); + } + }; + + Thread t2 = new Thread() + { + public void run() + { + Table.printTable(10); + } + }; + + t1.start(); + t2.start(); + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_static_synchronization_method_App/Output.txt b/BasicJava/ThreadDemo_static_synchronization_method_App/Output.txt new file mode 100644 index 000000000..cffc62db8 --- /dev/null +++ b/BasicJava/ThreadDemo_static_synchronization_method_App/Output.txt @@ -0,0 +1,14 @@ +Thread-1 +10 +20 +30 +40 +50 +------------------------ +Thread-0 +1 +2 +3 +4 +5 +------------------------ diff --git a/BasicJava/ThreadDemo_static_synchronization_method_App/ThreadDemo/.classpath b/BasicJava/ThreadDemo_static_synchronization_method_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_static_synchronization_method_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_static_synchronization_method_App/ThreadDemo/.project b/BasicJava/ThreadDemo_static_synchronization_method_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_static_synchronization_method_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_static_synchronization_method_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_static_synchronization_method_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_static_synchronization_method_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_static_synchronization_method_App/ThreadDemo/bin/MyThread1.class b/BasicJava/ThreadDemo_static_synchronization_method_App/ThreadDemo/bin/MyThread1.class new file mode 100644 index 000000000..ec769ce2b Binary files /dev/null and b/BasicJava/ThreadDemo_static_synchronization_method_App/ThreadDemo/bin/MyThread1.class differ diff --git a/BasicJava/ThreadDemo_static_synchronization_method_App/ThreadDemo/bin/MyThread2.class b/BasicJava/ThreadDemo_static_synchronization_method_App/ThreadDemo/bin/MyThread2.class new file mode 100644 index 000000000..0420a1f83 Binary files /dev/null and b/BasicJava/ThreadDemo_static_synchronization_method_App/ThreadDemo/bin/MyThread2.class differ diff --git a/BasicJava/ThreadDemo_static_synchronization_method_App/ThreadDemo/bin/StaticSynchronizationDemo.class b/BasicJava/ThreadDemo_static_synchronization_method_App/ThreadDemo/bin/StaticSynchronizationDemo.class new file mode 100644 index 000000000..3db21630f Binary files /dev/null and b/BasicJava/ThreadDemo_static_synchronization_method_App/ThreadDemo/bin/StaticSynchronizationDemo.class differ diff --git a/BasicJava/ThreadDemo_static_synchronization_method_App/ThreadDemo/bin/Table.class b/BasicJava/ThreadDemo_static_synchronization_method_App/ThreadDemo/bin/Table.class new file mode 100644 index 000000000..1b4619739 Binary files /dev/null and b/BasicJava/ThreadDemo_static_synchronization_method_App/ThreadDemo/bin/Table.class differ diff --git a/BasicJava/ThreadDemo_static_synchronization_method_App/ThreadDemo/src/StaticSynchronizationDemo.java b/BasicJava/ThreadDemo_static_synchronization_method_App/ThreadDemo/src/StaticSynchronizationDemo.java new file mode 100644 index 000000000..0babf7002 --- /dev/null +++ b/BasicJava/ThreadDemo_static_synchronization_method_App/ThreadDemo/src/StaticSynchronizationDemo.java @@ -0,0 +1,52 @@ +class Table +{ + + /* + * We are applying synchronized keyword on the static + * method to perform static synchronization. + */ + synchronized static void printTable(int n) + { + System.out.println(Thread.currentThread().getName()); + for (int i = 1; i <= 5; i++) + { + System.out.println(n * i); + try + { + Thread.sleep(400); + } + catch (Exception e) + { + } + } + System.out.println("------------------------"); + } +} + +class MyThread1 extends Thread +{ + public void run() + { + Table.printTable(1); + } +} + +class MyThread2 extends Thread +{ + public void run() + { + Table.printTable(10); + } +} + +public class StaticSynchronizationDemo +{ + public static void main(String t[]) + { + MyThread1 t1 = new MyThread1(); + MyThread2 t2 = new MyThread2(); + t1.start(); + t2.start(); + + } +} \ No newline at end of file diff --git a/BasicJava/ThreadDemo_yield_App/Output.txt b/BasicJava/ThreadDemo_yield_App/Output.txt new file mode 100644 index 000000000..6f7053652 --- /dev/null +++ b/BasicJava/ThreadDemo_yield_App/Output.txt @@ -0,0 +1,6 @@ +Thread 1 yielding control... +Thread 1 has finished executing. +Thread 2 yielding control... +Thread 3 yielding control... +Thread 3 has finished executing. +Thread 2 has finished executing. diff --git a/BasicJava/ThreadDemo_yield_App/ThreadDemo/.classpath b/BasicJava/ThreadDemo_yield_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ThreadDemo_yield_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ThreadDemo_yield_App/ThreadDemo/.project b/BasicJava/ThreadDemo_yield_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/ThreadDemo_yield_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ThreadDemo_yield_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ThreadDemo_yield_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ThreadDemo_yield_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ThreadDemo_yield_App/ThreadDemo/bin/MyRunnable.class b/BasicJava/ThreadDemo_yield_App/ThreadDemo/bin/MyRunnable.class new file mode 100644 index 000000000..f667856eb Binary files /dev/null and b/BasicJava/ThreadDemo_yield_App/ThreadDemo/bin/MyRunnable.class differ diff --git a/BasicJava/ThreadDemo_yield_App/ThreadDemo/bin/ThreadDemo.class b/BasicJava/ThreadDemo_yield_App/ThreadDemo/bin/ThreadDemo.class new file mode 100644 index 000000000..934116116 Binary files /dev/null and b/BasicJava/ThreadDemo_yield_App/ThreadDemo/bin/ThreadDemo.class differ diff --git a/BasicJava/ThreadDemo_yield_App/ThreadDemo/src/MyRunnable.java b/BasicJava/ThreadDemo_yield_App/ThreadDemo/src/MyRunnable.java new file mode 100644 index 000000000..0b6e1aae9 --- /dev/null +++ b/BasicJava/ThreadDemo_yield_App/ThreadDemo/src/MyRunnable.java @@ -0,0 +1,44 @@ +public class MyRunnable implements Runnable +{ + + Thread t; + + public MyRunnable(String str) + { + + t = new Thread(this, str); + // this will call run() function + t.start(); + } + + public void run() + { + for (int i = 0; i < 5; i++) + { + /* + * Yields control to another thread every 5 + * iterations + */ + if ((i % 5) == 0) + { + System.out.println(Thread.currentThread().getName() + + " yielding control..."); + + /* + * Causes the currently executing thread + * object to temporarily pause and allow + * other threads to execute. + * + * A hint to the scheduler that the current + * thread is willing to yield its current + * use of a processor. The scheduler is free + * to ignore this hint. + */ + Thread.yield(); + } + + } + System.out.println(Thread.currentThread().getName() + + " has finished executing."); + } +} diff --git a/BasicJava/ThreadDemo_yield_App/ThreadDemo/src/ThreadDemo.java b/BasicJava/ThreadDemo_yield_App/ThreadDemo/src/ThreadDemo.java new file mode 100644 index 000000000..3a0e52094 --- /dev/null +++ b/BasicJava/ThreadDemo_yield_App/ThreadDemo/src/ThreadDemo.java @@ -0,0 +1,10 @@ +public class ThreadDemo +{ + + public static void main(String args[]) throws InterruptedException + { + new MyRunnable("Thread 1"); + new MyRunnable("Thread 2"); + new MyRunnable("Thread 3"); + } +} \ No newline at end of file diff --git a/BasicJava/Thread_CurrentThread_app/DisplayThread_Output.txt b/BasicJava/Thread_CurrentThread_app/DisplayThread_Output.txt new file mode 100644 index 000000000..d7018bef6 --- /dev/null +++ b/BasicJava/Thread_CurrentThread_app/DisplayThread_Output.txt @@ -0,0 +1,2 @@ +Run by = DisplayThread-1 +Run by = DisplayThread-2 diff --git a/BasicJava/Thread_CurrentThread_app/HelloRunnable_Output.txt b/BasicJava/Thread_CurrentThread_app/HelloRunnable_Output.txt new file mode 100644 index 000000000..ebd7b6bda --- /dev/null +++ b/BasicJava/Thread_CurrentThread_app/HelloRunnable_Output.txt @@ -0,0 +1,2 @@ +Run by = HelloRunnableThread-1 +Run by = HelloRunnableThread-2 diff --git a/BasicJava/Thread_CurrentThread_app/ThreadDemo/.classpath b/BasicJava/Thread_CurrentThread_app/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/Thread_CurrentThread_app/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/Thread_CurrentThread_app/ThreadDemo/.project b/BasicJava/Thread_CurrentThread_app/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/Thread_CurrentThread_app/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/Thread_CurrentThread_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/Thread_CurrentThread_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/Thread_CurrentThread_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/Thread_CurrentThread_app/ThreadDemo/bin/DisplayThread.class b/BasicJava/Thread_CurrentThread_app/ThreadDemo/bin/DisplayThread.class new file mode 100644 index 000000000..39bd3ac27 Binary files /dev/null and b/BasicJava/Thread_CurrentThread_app/ThreadDemo/bin/DisplayThread.class differ diff --git a/BasicJava/Thread_CurrentThread_app/ThreadDemo/bin/HelloRunnable.class b/BasicJava/Thread_CurrentThread_app/ThreadDemo/bin/HelloRunnable.class new file mode 100644 index 000000000..229f448dd Binary files /dev/null and b/BasicJava/Thread_CurrentThread_app/ThreadDemo/bin/HelloRunnable.class differ diff --git a/BasicJava/Thread_CurrentThread_app/ThreadDemo/src/DisplayThread.java b/BasicJava/Thread_CurrentThread_app/ThreadDemo/src/DisplayThread.java new file mode 100644 index 000000000..8956ffdbc --- /dev/null +++ b/BasicJava/Thread_CurrentThread_app/ThreadDemo/src/DisplayThread.java @@ -0,0 +1,29 @@ +public class DisplayThread extends Thread +{ + + public DisplayThread(String threadName) + { + super(threadName); + } + + public static void main(String[] args) + { + DisplayThread displayThread1 = new DisplayThread("DisplayThread-1"); + displayThread1.start(); + + DisplayThread displayThread2 = new DisplayThread("DisplayThread-2"); + displayThread2.start(); + + } + + public void run() + { + /* + * Returns a reference to the currently executing + * thread object. + */ + Thread thread = Thread.currentThread(); + String threadName = thread.getName(); + System.out.println("Run by = " + threadName); + } +} diff --git a/BasicJava/Thread_CurrentThread_app/ThreadDemo/src/HelloRunnable.java b/BasicJava/Thread_CurrentThread_app/ThreadDemo/src/HelloRunnable.java new file mode 100644 index 000000000..b046251df --- /dev/null +++ b/BasicJava/Thread_CurrentThread_app/ThreadDemo/src/HelloRunnable.java @@ -0,0 +1,39 @@ +/* + * public Thread(Runnable target, String name) + * + * Parameters: + * ----------- + * + * target - the object whose run method is invoked when + * this thread is started. If null, this thread's run + * method is invoked. + * + * name - the name of the new thread + */ + +public class HelloRunnable implements Runnable +{ + + public static void main(String args[]) + { + HelloRunnable helloRunnable1 = new HelloRunnable(); + Thread thread1 = new Thread(helloRunnable1, "HelloRunnableThread-1"); + thread1.start(); + + HelloRunnable helloRunnable2 = new HelloRunnable(); + Thread thread2 = new Thread(helloRunnable2, "HelloRunnableThread-2"); + thread2.start(); + } + + @Override + public void run() + { + /* + * Returns a reference to the currently executing + * thread object. + */ + Thread thread = Thread.currentThread(); + String threadName = thread.getName(); + System.out.println("Run by = " + threadName); + } +} \ No newline at end of file diff --git a/BasicJava/Thread_DeadLockDemo_App/DeadLockDemo/.classpath b/BasicJava/Thread_DeadLockDemo_App/DeadLockDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/Thread_DeadLockDemo_App/DeadLockDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/Thread_DeadLockDemo_App/DeadLockDemo/.project b/BasicJava/Thread_DeadLockDemo_App/DeadLockDemo/.project new file mode 100644 index 000000000..fe7f8d862 --- /dev/null +++ b/BasicJava/Thread_DeadLockDemo_App/DeadLockDemo/.project @@ -0,0 +1,17 @@ + + + DeadLockDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/Thread_DeadLockDemo_App/DeadLockDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/Thread_DeadLockDemo_App/DeadLockDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/Thread_DeadLockDemo_App/DeadLockDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/Thread_DeadLockDemo_App/DeadLockDemo/bin/Deadlock$1.class b/BasicJava/Thread_DeadLockDemo_App/DeadLockDemo/bin/Deadlock$1.class new file mode 100644 index 000000000..cc0fe863d Binary files /dev/null and b/BasicJava/Thread_DeadLockDemo_App/DeadLockDemo/bin/Deadlock$1.class differ diff --git a/BasicJava/Thread_DeadLockDemo_App/DeadLockDemo/bin/Deadlock$2.class b/BasicJava/Thread_DeadLockDemo_App/DeadLockDemo/bin/Deadlock$2.class new file mode 100644 index 000000000..b2abdb4d3 Binary files /dev/null and b/BasicJava/Thread_DeadLockDemo_App/DeadLockDemo/bin/Deadlock$2.class differ diff --git a/BasicJava/Thread_DeadLockDemo_App/DeadLockDemo/bin/Deadlock.class b/BasicJava/Thread_DeadLockDemo_App/DeadLockDemo/bin/Deadlock.class new file mode 100644 index 000000000..2f30e930a Binary files /dev/null and b/BasicJava/Thread_DeadLockDemo_App/DeadLockDemo/bin/Deadlock.class differ diff --git a/BasicJava/Thread_DeadLockDemo_App/DeadLockDemo/src/Deadlock.java b/BasicJava/Thread_DeadLockDemo_App/DeadLockDemo/src/Deadlock.java new file mode 100644 index 000000000..75c60025e --- /dev/null +++ b/BasicJava/Thread_DeadLockDemo_App/DeadLockDemo/src/Deadlock.java @@ -0,0 +1,65 @@ +public class Deadlock +{ + public static void main(String[] args) + { + final String resource1 = "Hello"; + final String resource2 = "Peter"; + + /* + * t1 tries to lock resource1 then resource2 + */ + Thread t1 = new Thread() + { + public void run() + { + synchronized (resource1) + { + System.out.println("Thread 1: locked resource 1"); + + try + { + Thread.sleep(100); + } + catch (Exception e) + { + } + + synchronized (resource2) + { + System.out.println("Thread 1: locked resource 2"); + } + } + } + }; + + /* + * t2 tries to lock resource2 then resource1 + */ + Thread t2 = new Thread() + { + public void run() + { + synchronized (resource2) + { + System.out.println("Thread 2: locked resource 2"); + + try + { + Thread.sleep(100); + } + catch (Exception e) + { + } + + synchronized (resource1) + { + System.out.println("Thread 2: locked resource 1"); + } + } + } + }; + + t1.start(); + t2.start(); + } +} \ No newline at end of file diff --git a/BasicJava/Thread_DeadLockDemo_App/Output.txt b/BasicJava/Thread_DeadLockDemo_App/Output.txt new file mode 100644 index 000000000..c7b48e78f --- /dev/null +++ b/BasicJava/Thread_DeadLockDemo_App/Output.txt @@ -0,0 +1,2 @@ +Thread 1: locked resource 1 +Thread 2: locked resource 2 diff --git a/BasicJava/Thread_Id_App/Output.txt b/BasicJava/Thread_Id_App/Output.txt new file mode 100644 index 000000000..ea0052e2e --- /dev/null +++ b/BasicJava/Thread_Id_App/Output.txt @@ -0,0 +1,3 @@ +id = 11, Name = Thread-1 +id = 12, Name = Thread-2 +id = 10, Name = Thread-0 diff --git a/BasicJava/Thread_Id_App/ThreadDemo/.classpath b/BasicJava/Thread_Id_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/Thread_Id_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/Thread_Id_App/ThreadDemo/.project b/BasicJava/Thread_Id_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/Thread_Id_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/Thread_Id_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/Thread_Id_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/Thread_Id_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/Thread_Id_App/ThreadDemo/bin/DisplayNumberThread.class b/BasicJava/Thread_Id_App/ThreadDemo/bin/DisplayNumberThread.class new file mode 100644 index 000000000..19ed8f7b6 Binary files /dev/null and b/BasicJava/Thread_Id_App/ThreadDemo/bin/DisplayNumberThread.class differ diff --git a/BasicJava/Thread_Id_App/ThreadDemo/src/DisplayNumberThread.java b/BasicJava/Thread_Id_App/ThreadDemo/src/DisplayNumberThread.java new file mode 100644 index 000000000..9a59a8914 --- /dev/null +++ b/BasicJava/Thread_Id_App/ThreadDemo/src/DisplayNumberThread.java @@ -0,0 +1,31 @@ +/* + * public long getId() + * + * Returns the identifier of this Thread. The thread ID + * is a positive long number generated when this thread + * was created. The thread ID is unique and remains + * unchanged during its lifetime. When a thread is + * terminated, this thread ID may be reused. + * + * Returns: this thread's ID. + */ + +class DisplayNumberThread extends Thread +{ + + public void run() + { + System.out.println("id = " + this.getId() + ", Name = " + + this.getName()); + } + + public static void main(String args[]) + { + DisplayNumberThread dnt1 = new DisplayNumberThread(); + DisplayNumberThread dnt2 = new DisplayNumberThread(); + DisplayNumberThread dnt3 = new DisplayNumberThread(); + dnt1.start(); + dnt2.start(); + dnt3.start(); + } +} \ No newline at end of file diff --git a/BasicJava/Thread_InterthreadCommunitcation_App/Output.txt b/BasicJava/Thread_InterthreadCommunitcation_App/Output.txt new file mode 100644 index 000000000..46a904f25 --- /dev/null +++ b/BasicJava/Thread_InterthreadCommunitcation_App/Output.txt @@ -0,0 +1,5 @@ +Going to withdraw... +Less balance; waiting for deposit... +Going to deposit... +Deposit completed... +Withdraw completed... diff --git a/BasicJava/Thread_InterthreadCommunitcation_App/ThreadDemo/.classpath b/BasicJava/Thread_InterthreadCommunitcation_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/Thread_InterthreadCommunitcation_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/Thread_InterthreadCommunitcation_App/ThreadDemo/.project b/BasicJava/Thread_InterthreadCommunitcation_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/Thread_InterthreadCommunitcation_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/Thread_InterthreadCommunitcation_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/Thread_InterthreadCommunitcation_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/Thread_InterthreadCommunitcation_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/Thread_InterthreadCommunitcation_App/ThreadDemo/bin/BankAccount.class b/BasicJava/Thread_InterthreadCommunitcation_App/ThreadDemo/bin/BankAccount.class new file mode 100644 index 000000000..a144ea570 Binary files /dev/null and b/BasicJava/Thread_InterthreadCommunitcation_App/ThreadDemo/bin/BankAccount.class differ diff --git a/BasicJava/Thread_InterthreadCommunitcation_App/ThreadDemo/bin/InterthreadCommunitcationDemo$1.class b/BasicJava/Thread_InterthreadCommunitcation_App/ThreadDemo/bin/InterthreadCommunitcationDemo$1.class new file mode 100644 index 000000000..7a25aa030 Binary files /dev/null and b/BasicJava/Thread_InterthreadCommunitcation_App/ThreadDemo/bin/InterthreadCommunitcationDemo$1.class differ diff --git a/BasicJava/Thread_InterthreadCommunitcation_App/ThreadDemo/bin/InterthreadCommunitcationDemo$2.class b/BasicJava/Thread_InterthreadCommunitcation_App/ThreadDemo/bin/InterthreadCommunitcationDemo$2.class new file mode 100644 index 000000000..6c097cc7f Binary files /dev/null and b/BasicJava/Thread_InterthreadCommunitcation_App/ThreadDemo/bin/InterthreadCommunitcationDemo$2.class differ diff --git a/BasicJava/Thread_InterthreadCommunitcation_App/ThreadDemo/bin/InterthreadCommunitcationDemo.class b/BasicJava/Thread_InterthreadCommunitcation_App/ThreadDemo/bin/InterthreadCommunitcationDemo.class new file mode 100644 index 000000000..af13b8c0e Binary files /dev/null and b/BasicJava/Thread_InterthreadCommunitcation_App/ThreadDemo/bin/InterthreadCommunitcationDemo.class differ diff --git a/BasicJava/Thread_InterthreadCommunitcation_App/ThreadDemo/src/BankAccount.java b/BasicJava/Thread_InterthreadCommunitcation_App/ThreadDemo/src/BankAccount.java new file mode 100644 index 000000000..c6fbf36ac --- /dev/null +++ b/BasicJava/Thread_InterthreadCommunitcation_App/ThreadDemo/src/BankAccount.java @@ -0,0 +1,32 @@ +class BankAccount +{ + private int amount = 10000; + + synchronized void withdraw(int amount) + { + System.out.println("Going to withdraw..."); + + if (this.amount < amount) + { + System.out.println("Less balance; waiting for deposit..."); + try + { + wait(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + this.amount -= amount; + System.out.println("Withdraw completed..."); + } + + synchronized void deposit(int amount) + { + System.out.println("Going to deposit..."); + this.amount += amount; + System.out.println("Deposit completed... "); + notify(); + } +} \ No newline at end of file diff --git a/BasicJava/Thread_InterthreadCommunitcation_App/ThreadDemo/src/InterthreadCommunitcationDemo.java b/BasicJava/Thread_InterthreadCommunitcation_App/ThreadDemo/src/InterthreadCommunitcationDemo.java new file mode 100644 index 000000000..067717689 --- /dev/null +++ b/BasicJava/Thread_InterthreadCommunitcation_App/ThreadDemo/src/InterthreadCommunitcationDemo.java @@ -0,0 +1,24 @@ +class InterthreadCommunitcationDemo +{ + public static void main(String args[]) + { + final BankAccount bankAccount = new BankAccount(); + + new Thread("Thread 1") + { + public void run() + { + bankAccount.withdraw(50000); + } + }.start(); + + new Thread("Thread 2") + { + public void run() + { + bankAccount.deposit(80000); + } + }.start(); + + } +} \ No newline at end of file diff --git a/BasicJava/Thread_ReentrantDemo_App/Output.txt b/BasicJava/Thread_ReentrantDemo_App/Output.txt new file mode 100644 index 000000000..84826f50a --- /dev/null +++ b/BasicJava/Thread_ReentrantDemo_App/Output.txt @@ -0,0 +1 @@ +Hello Peter diff --git a/BasicJava/Thread_ReentrantDemo_App/ReentrantDemo/.classpath b/BasicJava/Thread_ReentrantDemo_App/ReentrantDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/Thread_ReentrantDemo_App/ReentrantDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/Thread_ReentrantDemo_App/ReentrantDemo/.project b/BasicJava/Thread_ReentrantDemo_App/ReentrantDemo/.project new file mode 100644 index 000000000..676b0e833 --- /dev/null +++ b/BasicJava/Thread_ReentrantDemo_App/ReentrantDemo/.project @@ -0,0 +1,17 @@ + + + ReentrantDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/Thread_ReentrantDemo_App/ReentrantDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/Thread_ReentrantDemo_App/ReentrantDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/Thread_ReentrantDemo_App/ReentrantDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/Thread_ReentrantDemo_App/ReentrantDemo/bin/DisplayMessage.class b/BasicJava/Thread_ReentrantDemo_App/ReentrantDemo/bin/DisplayMessage.class new file mode 100644 index 000000000..96dc17a0c Binary files /dev/null and b/BasicJava/Thread_ReentrantDemo_App/ReentrantDemo/bin/DisplayMessage.class differ diff --git a/BasicJava/Thread_ReentrantDemo_App/ReentrantDemo/bin/ReentrantExample$1.class b/BasicJava/Thread_ReentrantDemo_App/ReentrantDemo/bin/ReentrantExample$1.class new file mode 100644 index 000000000..11d3b0189 Binary files /dev/null and b/BasicJava/Thread_ReentrantDemo_App/ReentrantDemo/bin/ReentrantExample$1.class differ diff --git a/BasicJava/Thread_ReentrantDemo_App/ReentrantDemo/bin/ReentrantExample.class b/BasicJava/Thread_ReentrantDemo_App/ReentrantDemo/bin/ReentrantExample.class new file mode 100644 index 000000000..61416703c Binary files /dev/null and b/BasicJava/Thread_ReentrantDemo_App/ReentrantDemo/bin/ReentrantExample.class differ diff --git a/BasicJava/Thread_ReentrantDemo_App/ReentrantDemo/src/DisplayMessage.java b/BasicJava/Thread_ReentrantDemo_App/ReentrantDemo/src/DisplayMessage.java new file mode 100644 index 000000000..c5dc4e28a --- /dev/null +++ b/BasicJava/Thread_ReentrantDemo_App/ReentrantDemo/src/DisplayMessage.java @@ -0,0 +1,18 @@ +class DisplayMessage +{ + /* + * Declaring two synchronized method displayName() and + * displayHello().one synchronized method calling to + * another one. + */ + public synchronized void displayName() + { + displayHello(); + System.out.println("Peter"); + } + + public synchronized void displayHello() + { + System.out.print("Hello "); + } +} \ No newline at end of file diff --git a/BasicJava/Thread_ReentrantDemo_App/ReentrantDemo/src/ReentrantExample.java b/BasicJava/Thread_ReentrantDemo_App/ReentrantDemo/src/ReentrantExample.java new file mode 100644 index 000000000..6faf462f0 --- /dev/null +++ b/BasicJava/Thread_ReentrantDemo_App/ReentrantDemo/src/ReentrantExample.java @@ -0,0 +1,14 @@ +public class ReentrantExample +{ + public static void main(String args[]) + { + Thread t1 = new Thread() + { + public void run() + { + new DisplayMessage().displayName(); + } + }; + t1.start(); + } +} \ No newline at end of file diff --git a/BasicJava/Thread_create_Runnable_app/Output.txt b/BasicJava/Thread_create_Runnable_app/Output.txt new file mode 100644 index 000000000..71d5b4328 --- /dev/null +++ b/BasicJava/Thread_create_Runnable_app/Output.txt @@ -0,0 +1 @@ +Hello Peter.. diff --git a/BasicJava/Thread_create_Runnable_app/ThreadDemo/.classpath b/BasicJava/Thread_create_Runnable_app/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/Thread_create_Runnable_app/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/Thread_create_Runnable_app/ThreadDemo/.project b/BasicJava/Thread_create_Runnable_app/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/Thread_create_Runnable_app/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/Thread_create_Runnable_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/Thread_create_Runnable_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/Thread_create_Runnable_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/Thread_create_Runnable_app/ThreadDemo/bin/DisplayRunnable.class b/BasicJava/Thread_create_Runnable_app/ThreadDemo/bin/DisplayRunnable.class new file mode 100644 index 000000000..b20ff12fc Binary files /dev/null and b/BasicJava/Thread_create_Runnable_app/ThreadDemo/bin/DisplayRunnable.class differ diff --git a/BasicJava/Thread_create_Runnable_app/ThreadDemo/src/DisplayRunnable.java b/BasicJava/Thread_create_Runnable_app/ThreadDemo/src/DisplayRunnable.java new file mode 100644 index 000000000..daf4265cb --- /dev/null +++ b/BasicJava/Thread_create_Runnable_app/ThreadDemo/src/DisplayRunnable.java @@ -0,0 +1,28 @@ +/* + * If you are not extending the Thread class,your class + * object would not be treated as a thread object.So you + * need to explicitly create Thread class object.We are + * passing the object of your class that implements + * Runnable so that your class run() method may execute. + */ +public class DisplayRunnable implements Runnable +{ + public static void main(String args[]) + { + DisplayRunnable displayRunnable = new DisplayRunnable(); + Thread thread = new Thread(displayRunnable); + thread.start(); + } + + /* + * When an object implementing interface Runnable is + * used to create a thread, starting the thread causes + * the object's run method to be called in that + * separately executing thread. + */ + @Override + public void run() + { + System.out.println("Hello Peter.."); + } +} \ No newline at end of file diff --git a/BasicJava/Thread_create_ex_thread_app/Output.txt b/BasicJava/Thread_create_ex_thread_app/Output.txt new file mode 100644 index 000000000..c189c6bce --- /dev/null +++ b/BasicJava/Thread_create_ex_thread_app/Output.txt @@ -0,0 +1 @@ +Welcome to india diff --git a/BasicJava/Thread_create_ex_thread_app/ThreadDemo/.classpath b/BasicJava/Thread_create_ex_thread_app/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/Thread_create_ex_thread_app/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/Thread_create_ex_thread_app/ThreadDemo/.project b/BasicJava/Thread_create_ex_thread_app/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/Thread_create_ex_thread_app/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/Thread_create_ex_thread_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/Thread_create_ex_thread_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/Thread_create_ex_thread_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/Thread_create_ex_thread_app/ThreadDemo/bin/DisplayThread.class b/BasicJava/Thread_create_ex_thread_app/ThreadDemo/bin/DisplayThread.class new file mode 100644 index 000000000..473e914ba Binary files /dev/null and b/BasicJava/Thread_create_ex_thread_app/ThreadDemo/bin/DisplayThread.class differ diff --git a/BasicJava/Thread_create_ex_thread_app/ThreadDemo/src/DisplayThread.java b/BasicJava/Thread_create_ex_thread_app/ThreadDemo/src/DisplayThread.java new file mode 100644 index 000000000..3e84da44e --- /dev/null +++ b/BasicJava/Thread_create_ex_thread_app/ThreadDemo/src/DisplayThread.java @@ -0,0 +1,26 @@ +class DisplayThread extends Thread +{ + + public static void main(String args[]) + { + /* + * Allocates a new Thread object. + */ + DisplayThread displayThread = new DisplayThread(); + /* + * Causes this thread to begin execution; the Java + * Virtual Machine calls the run method of this + * thread + */ + displayThread.start(); + } + + /* + * Subclasses of Thread should override run() method. + */ + @Override + public void run() + { + System.out.println("Welcome to india"); + } +} \ No newline at end of file diff --git a/BasicJava/Thread_create_two_ways_app/HelloRunnable_Output.txt b/BasicJava/Thread_create_two_ways_app/HelloRunnable_Output.txt new file mode 100644 index 000000000..fde5cc4dd --- /dev/null +++ b/BasicJava/Thread_create_two_ways_app/HelloRunnable_Output.txt @@ -0,0 +1 @@ +Hello from a thread! diff --git a/BasicJava/Thread_create_two_ways_app/HelloThread_Output.txt b/BasicJava/Thread_create_two_ways_app/HelloThread_Output.txt new file mode 100644 index 000000000..fde5cc4dd --- /dev/null +++ b/BasicJava/Thread_create_two_ways_app/HelloThread_Output.txt @@ -0,0 +1 @@ +Hello from a thread! diff --git a/BasicJava/Thread_create_two_ways_app/ThreadDemo/.classpath b/BasicJava/Thread_create_two_ways_app/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/Thread_create_two_ways_app/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/Thread_create_two_ways_app/ThreadDemo/.project b/BasicJava/Thread_create_two_ways_app/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/Thread_create_two_ways_app/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/Thread_create_two_ways_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/Thread_create_two_ways_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/Thread_create_two_ways_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/Thread_create_two_ways_app/ThreadDemo/bin/HelloRunnable.class b/BasicJava/Thread_create_two_ways_app/ThreadDemo/bin/HelloRunnable.class new file mode 100644 index 000000000..2475be158 Binary files /dev/null and b/BasicJava/Thread_create_two_ways_app/ThreadDemo/bin/HelloRunnable.class differ diff --git a/BasicJava/Thread_create_two_ways_app/ThreadDemo/bin/HelloThread.class b/BasicJava/Thread_create_two_ways_app/ThreadDemo/bin/HelloThread.class new file mode 100644 index 000000000..e440d11de Binary files /dev/null and b/BasicJava/Thread_create_two_ways_app/ThreadDemo/bin/HelloThread.class differ diff --git a/BasicJava/Thread_create_two_ways_app/ThreadDemo/src/HelloRunnable.java b/BasicJava/Thread_create_two_ways_app/ThreadDemo/src/HelloRunnable.java new file mode 100644 index 000000000..e12806cf5 --- /dev/null +++ b/BasicJava/Thread_create_two_ways_app/ThreadDemo/src/HelloRunnable.java @@ -0,0 +1,16 @@ +public class HelloRunnable implements Runnable +{ + + public static void main(String args[]) + { + HelloRunnable helloRunnable = new HelloRunnable(); + Thread thread = new Thread(helloRunnable); + thread.start(); + } + + @Override + public void run() + { + System.out.println("Hello from a thread!"); + } +} \ No newline at end of file diff --git a/BasicJava/Thread_create_two_ways_app/ThreadDemo/src/HelloThread.java b/BasicJava/Thread_create_two_ways_app/ThreadDemo/src/HelloThread.java new file mode 100644 index 000000000..f82e0a78d --- /dev/null +++ b/BasicJava/Thread_create_two_ways_app/ThreadDemo/src/HelloThread.java @@ -0,0 +1,16 @@ +public class HelloThread extends Thread +{ + + public static void main(String args[]) + { + HelloThread helloThread = new HelloThread(); + helloThread.start(); + } + + @Override + public void run() + { + System.out.println("Hello from a thread!"); + } + +} \ No newline at end of file diff --git a/BasicJava/Thread_names_app/DisplayThread_Output.txt b/BasicJava/Thread_names_app/DisplayThread_Output.txt new file mode 100644 index 000000000..4d71449ef --- /dev/null +++ b/BasicJava/Thread_names_app/DisplayThread_Output.txt @@ -0,0 +1,2 @@ +Run by = DisplayThread_100 +Run by = DisplayThread_200 diff --git a/BasicJava/Thread_names_app/HelloRunnable_Output.txt b/BasicJava/Thread_names_app/HelloRunnable_Output.txt new file mode 100644 index 000000000..0356c841e --- /dev/null +++ b/BasicJava/Thread_names_app/HelloRunnable_Output.txt @@ -0,0 +1,2 @@ +Thread Name = HelloRunnableThread +Hello from a thread! diff --git a/BasicJava/Thread_names_app/HelloThread_Output.txt b/BasicJava/Thread_names_app/HelloThread_Output.txt new file mode 100644 index 000000000..b5a1ca98c --- /dev/null +++ b/BasicJava/Thread_names_app/HelloThread_Output.txt @@ -0,0 +1 @@ +Thread Name = Thread-0 diff --git a/BasicJava/Thread_names_app/ThreadDemo/.classpath b/BasicJava/Thread_names_app/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/Thread_names_app/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/Thread_names_app/ThreadDemo/.project b/BasicJava/Thread_names_app/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/Thread_names_app/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/Thread_names_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/Thread_names_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/Thread_names_app/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/Thread_names_app/ThreadDemo/bin/DisplayThread.class b/BasicJava/Thread_names_app/ThreadDemo/bin/DisplayThread.class new file mode 100644 index 000000000..755e51b2c Binary files /dev/null and b/BasicJava/Thread_names_app/ThreadDemo/bin/DisplayThread.class differ diff --git a/BasicJava/Thread_names_app/ThreadDemo/bin/HelloRunnable.class b/BasicJava/Thread_names_app/ThreadDemo/bin/HelloRunnable.class new file mode 100644 index 000000000..788350040 Binary files /dev/null and b/BasicJava/Thread_names_app/ThreadDemo/bin/HelloRunnable.class differ diff --git a/BasicJava/Thread_names_app/ThreadDemo/bin/HelloThread.class b/BasicJava/Thread_names_app/ThreadDemo/bin/HelloThread.class new file mode 100644 index 000000000..c0dc68ee6 Binary files /dev/null and b/BasicJava/Thread_names_app/ThreadDemo/bin/HelloThread.class differ diff --git a/BasicJava/Thread_names_app/ThreadDemo/src/DisplayThread.java b/BasicJava/Thread_names_app/ThreadDemo/src/DisplayThread.java new file mode 100644 index 000000000..a471d3a7b --- /dev/null +++ b/BasicJava/Thread_names_app/ThreadDemo/src/DisplayThread.java @@ -0,0 +1,26 @@ +public class DisplayThread extends Thread +{ + + public DisplayThread(String threadName) + { + super(threadName); + } + + public static void main(String[] args) + { + DisplayThread displayThread1 = new DisplayThread("DisplayThread_100"); + displayThread1.start(); + + DisplayThread displayThread2 = new DisplayThread("DisplayThread_200"); + displayThread2.start(); + + } + + public void run() + { + /* + * Returns this thread's name. + */ + System.out.println("Run by = " + this.getName()); + } +} diff --git a/BasicJava/Thread_names_app/ThreadDemo/src/HelloRunnable.java b/BasicJava/Thread_names_app/ThreadDemo/src/HelloRunnable.java new file mode 100644 index 000000000..f381789d0 --- /dev/null +++ b/BasicJava/Thread_names_app/ThreadDemo/src/HelloRunnable.java @@ -0,0 +1,33 @@ +/* + * public Thread(Runnable target, String name) + * + * Parameters: + * ----------- + * + * target - the object whose run method is invoked when + * this thread is started. If null, this thread's run + * method is invoked. + * + * name - the name of the new thread + */ + +public class HelloRunnable implements Runnable +{ + + public static void main(String args[]) + { + HelloRunnable helloRunnable = new HelloRunnable(); + Thread thread = new Thread(helloRunnable, "HelloRunnableThread"); + thread.start(); + /* + * Returns this thread's name. + */ + System.out.println("Thread Name = " + thread.getName()); + } + + @Override + public void run() + { + System.out.println("Hello from a thread!"); + } +} \ No newline at end of file diff --git a/BasicJava/Thread_names_app/ThreadDemo/src/HelloThread.java b/BasicJava/Thread_names_app/ThreadDemo/src/HelloThread.java new file mode 100644 index 000000000..61003123a --- /dev/null +++ b/BasicJava/Thread_names_app/ThreadDemo/src/HelloThread.java @@ -0,0 +1,18 @@ +public class HelloThread extends Thread +{ + + public static void main(String args[]) + { + HelloThread helloThread = new HelloThread(); + helloThread.start(); + } + + public void run() + { + /* + * Returns this thread's name. + */ + System.out.println("Thread Name = " + this.getName()); + } + +} \ No newline at end of file diff --git a/BasicJava/Thread_setName_App/Output.txt b/BasicJava/Thread_setName_App/Output.txt new file mode 100644 index 000000000..e396c46d1 --- /dev/null +++ b/BasicJava/Thread_setName_App/Output.txt @@ -0,0 +1,9 @@ +Before setting the thread name. +dnt1 thread Name = Thread-0 +dnt2 thread Name = Thread-1 +Hi +Hi + +After setting the thread name. +dnt1 thread Name = DisplayNumberThread1 +dnt2 thread Name = DisplayNumberThread2 diff --git a/BasicJava/Thread_setName_App/ThreadDemo/.classpath b/BasicJava/Thread_setName_App/ThreadDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/Thread_setName_App/ThreadDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/Thread_setName_App/ThreadDemo/.project b/BasicJava/Thread_setName_App/ThreadDemo/.project new file mode 100644 index 000000000..521585672 --- /dev/null +++ b/BasicJava/Thread_setName_App/ThreadDemo/.project @@ -0,0 +1,17 @@ + + + ThreadDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/Thread_setName_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/Thread_setName_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/Thread_setName_App/ThreadDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/Thread_setName_App/ThreadDemo/bin/DisplayNumberThread.class b/BasicJava/Thread_setName_App/ThreadDemo/bin/DisplayNumberThread.class new file mode 100644 index 000000000..ef6c62e40 Binary files /dev/null and b/BasicJava/Thread_setName_App/ThreadDemo/bin/DisplayNumberThread.class differ diff --git a/BasicJava/Thread_setName_App/ThreadDemo/src/DisplayNumberThread.java b/BasicJava/Thread_setName_App/ThreadDemo/src/DisplayNumberThread.java new file mode 100644 index 000000000..9b2a3ca48 --- /dev/null +++ b/BasicJava/Thread_setName_App/ThreadDemo/src/DisplayNumberThread.java @@ -0,0 +1,33 @@ +class DisplayNumberThread extends Thread +{ + + public static void main(String args[]) + { + DisplayNumberThread dnt1 = new DisplayNumberThread(); + DisplayNumberThread dnt2 = new DisplayNumberThread(); + + System.out.println("Before setting the thread name."); + System.out.println("dnt1 thread Name = " + dnt1.getName()); + System.out.println("dnt2 thread Name = " + dnt2.getName()); + + dnt1.start(); + dnt2.start(); + + /* + * Changes the name of this thread to be equal to + * the argument name. + */ + dnt1.setName("DisplayNumberThread1"); + dnt2.setName("DisplayNumberThread2"); + + System.out.println("\nAfter setting the thread name."); + System.out.println("dnt1 thread Name = " + dnt1.getName()); + System.out.println("dnt2 thread Name = " + dnt2.getName()); + + } + + public void run() + { + System.out.println("Hi"); + } +} \ No newline at end of file diff --git a/BasicJava/UnBoxingDemo_App/BoxingDemo/.classpath b/BasicJava/UnBoxingDemo_App/BoxingDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/UnBoxingDemo_App/BoxingDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/UnBoxingDemo_App/BoxingDemo/.project b/BasicJava/UnBoxingDemo_App/BoxingDemo/.project new file mode 100644 index 000000000..c91619eea --- /dev/null +++ b/BasicJava/UnBoxingDemo_App/BoxingDemo/.project @@ -0,0 +1,17 @@ + + + BoxingDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/UnBoxingDemo_App/BoxingDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/UnBoxingDemo_App/BoxingDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/UnBoxingDemo_App/BoxingDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/UnBoxingDemo_App/BoxingDemo/bin/UnBoxingDemo.class b/BasicJava/UnBoxingDemo_App/BoxingDemo/bin/UnBoxingDemo.class new file mode 100644 index 000000000..d2485714d Binary files /dev/null and b/BasicJava/UnBoxingDemo_App/BoxingDemo/bin/UnBoxingDemo.class differ diff --git a/BasicJava/UnBoxingDemo_App/BoxingDemo/src/UnBoxingDemo.java b/BasicJava/UnBoxingDemo_App/BoxingDemo/src/UnBoxingDemo.java new file mode 100644 index 000000000..06eb02484 --- /dev/null +++ b/BasicJava/UnBoxingDemo_App/BoxingDemo/src/UnBoxingDemo.java @@ -0,0 +1,29 @@ +import java.util.ArrayList; +import java.util.List; + +public class UnBoxingDemo +{ + + public static void main(String[] args) + { + Integer integerObj = new Integer(-8); + + // 1. Unboxing through method invocation + int absVal = absoluteValue(integerObj); + System.out.println("absolute value of " + integerObj + " = " + absVal); + + List list = new ArrayList<>(); + list.add(new Double(12.3)); + + // 2. Unboxing through assignment + double doubleValue = list.get(0); + System.out.println("doubleValue = " + doubleValue); + + } + + public static int absoluteValue(int i) + { + return (i < 0) ? -i : i; + } + +} diff --git a/BasicJava/UnBoxingDemo_App/Output.txt b/BasicJava/UnBoxingDemo_App/Output.txt new file mode 100644 index 000000000..3f2af83ed --- /dev/null +++ b/BasicJava/UnBoxingDemo_App/Output.txt @@ -0,0 +1,2 @@ +absolute value of -8 = 8 +doubleValue = 12.3 diff --git a/BasicJava/UnBoxingDemo_list_App/BoxingDemo/.classpath b/BasicJava/UnBoxingDemo_list_App/BoxingDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/UnBoxingDemo_list_App/BoxingDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/UnBoxingDemo_list_App/BoxingDemo/.project b/BasicJava/UnBoxingDemo_list_App/BoxingDemo/.project new file mode 100644 index 000000000..c91619eea --- /dev/null +++ b/BasicJava/UnBoxingDemo_list_App/BoxingDemo/.project @@ -0,0 +1,17 @@ + + + BoxingDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/UnBoxingDemo_list_App/BoxingDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/UnBoxingDemo_list_App/BoxingDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/UnBoxingDemo_list_App/BoxingDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/UnBoxingDemo_list_App/BoxingDemo/bin/UnBoxingDemo.class b/BasicJava/UnBoxingDemo_list_App/BoxingDemo/bin/UnBoxingDemo.class new file mode 100644 index 000000000..791cbc950 Binary files /dev/null and b/BasicJava/UnBoxingDemo_list_App/BoxingDemo/bin/UnBoxingDemo.class differ diff --git a/BasicJava/UnBoxingDemo_list_App/BoxingDemo/src/UnBoxingDemo.java b/BasicJava/UnBoxingDemo_list_App/BoxingDemo/src/UnBoxingDemo.java new file mode 100644 index 000000000..5e80ebdec --- /dev/null +++ b/BasicJava/UnBoxingDemo_list_App/BoxingDemo/src/UnBoxingDemo.java @@ -0,0 +1,20 @@ +import java.util.ArrayList; +import java.util.List; + +public class UnBoxingDemo +{ + + public static void main(String[] args) + { + List list = new ArrayList<>(); + list.add(new Integer(1)); + list.add(new Integer(2)); + for (Integer integerObj : list) + { + int i = integerObj; // Unboxing + System.out.println(i); + } + + } + +} diff --git a/BasicJava/UnBoxingDemo_list_App/Output.txt b/BasicJava/UnBoxingDemo_list_App/Output.txt new file mode 100644 index 000000000..1191247b6 --- /dev/null +++ b/BasicJava/UnBoxingDemo_list_App/Output.txt @@ -0,0 +1,2 @@ +1 +2 diff --git a/BasicJava/ZoneDateTimeDemo_Intro/Output.txt b/BasicJava/ZoneDateTimeDemo_Intro/Output.txt new file mode 100644 index 000000000..36eedff64 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_Intro/Output.txt @@ -0,0 +1,12 @@ +2018-02-05T09:58:45.137+05:30[Asia/Calcutta] +Year = 2018 +Month = FEBRUARY +Month Value = 2 +getDayOfMonth = 5 +Hour = 9 +Min = 58 +Second = 45 +Nano Second = 137000000 +Offset = +05:30 +DayOfYear = 36 +DayOfWeek = MONDAY diff --git a/BasicJava/ZoneDateTimeDemo_Intro/ZoneDateTimeDemo/.classpath b/BasicJava/ZoneDateTimeDemo_Intro/ZoneDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_Intro/ZoneDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ZoneDateTimeDemo_Intro/ZoneDateTimeDemo/.project b/BasicJava/ZoneDateTimeDemo_Intro/ZoneDateTimeDemo/.project new file mode 100644 index 000000000..47ef13e1d --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_Intro/ZoneDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + ZoneDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ZoneDateTimeDemo_Intro/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ZoneDateTimeDemo_Intro/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_Intro/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ZoneDateTimeDemo_Intro/ZoneDateTimeDemo/bin/ZoneDateTimeDemo.class b/BasicJava/ZoneDateTimeDemo_Intro/ZoneDateTimeDemo/bin/ZoneDateTimeDemo.class new file mode 100644 index 000000000..5892c29aa Binary files /dev/null and b/BasicJava/ZoneDateTimeDemo_Intro/ZoneDateTimeDemo/bin/ZoneDateTimeDemo.class differ diff --git a/BasicJava/ZoneDateTimeDemo_Intro/ZoneDateTimeDemo/src/ZoneDateTimeDemo.java b/BasicJava/ZoneDateTimeDemo_Intro/ZoneDateTimeDemo/src/ZoneDateTimeDemo.java new file mode 100644 index 000000000..9d5ce9503 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_Intro/ZoneDateTimeDemo/src/ZoneDateTimeDemo.java @@ -0,0 +1,29 @@ +import java.time.ZonedDateTime; + +public class ZoneDateTimeDemo +{ + + public static void main(String[] args) + { + /* + * Returns:the current date-time using the system clock, not + * null. + */ + ZonedDateTime zonedDateTime = ZonedDateTime.now(); + System.out.println(zonedDateTime); + + System.out.println("Year = "+zonedDateTime.getYear()); + System.out.println("Month = "+zonedDateTime.getMonth()); + System.out.println("Month Value = "+zonedDateTime.getMonthValue()); + System.out.println("getDayOfMonth = "+zonedDateTime.getDayOfMonth()); + System.out.println("Hour = "+zonedDateTime.getHour()); + System.out.println("Min = "+zonedDateTime.getMinute()); + System.out.println("Second = "+zonedDateTime.getSecond()); + System.out.println("Nano Second = "+zonedDateTime.getNano()); + System.out.println("Offset = "+zonedDateTime.getOffset()); + System.out.println("DayOfYear = "+zonedDateTime.getDayOfYear()); + System.out.println("DayOfWeek = "+zonedDateTime.getDayOfWeek()); + + } + +} diff --git a/BasicJava/ZoneDateTimeDemo_format/Output.txt b/BasicJava/ZoneDateTimeDemo_format/Output.txt new file mode 100644 index 000000000..341784e5a --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_format/Output.txt @@ -0,0 +1,3 @@ +2018-02-07T10:13:52.561+05:30[Asia/Calcutta] +ISO_DATE = 2018-02-07+05:30 +ISO_TIME = 10:13:52.561+05:30 diff --git a/BasicJava/ZoneDateTimeDemo_format/ZoneDateTimeDemo/.classpath b/BasicJava/ZoneDateTimeDemo_format/ZoneDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_format/ZoneDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ZoneDateTimeDemo_format/ZoneDateTimeDemo/.project b/BasicJava/ZoneDateTimeDemo_format/ZoneDateTimeDemo/.project new file mode 100644 index 000000000..47ef13e1d --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_format/ZoneDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + ZoneDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ZoneDateTimeDemo_format/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ZoneDateTimeDemo_format/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_format/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ZoneDateTimeDemo_format/ZoneDateTimeDemo/bin/ZoneDateTimeDemo.class b/BasicJava/ZoneDateTimeDemo_format/ZoneDateTimeDemo/bin/ZoneDateTimeDemo.class new file mode 100644 index 000000000..1f1e12f79 Binary files /dev/null and b/BasicJava/ZoneDateTimeDemo_format/ZoneDateTimeDemo/bin/ZoneDateTimeDemo.class differ diff --git a/BasicJava/ZoneDateTimeDemo_format/ZoneDateTimeDemo/src/ZoneDateTimeDemo.java b/BasicJava/ZoneDateTimeDemo_format/ZoneDateTimeDemo/src/ZoneDateTimeDemo.java new file mode 100644 index 000000000..4113f0334 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_format/ZoneDateTimeDemo/src/ZoneDateTimeDemo.java @@ -0,0 +1,32 @@ +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; + +public class ZoneDateTimeDemo +{ + + public static void main(String[] args) + { + + ZonedDateTime zonedDateTime = ZonedDateTime.now(); + System.out.println(zonedDateTime); + + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ISO_DATE; + + /* + * Parameters: + * + * formatter - the formatter to use, not null + * + * Returns: + * + * the formatted date-time string, not null + */ + String formatedDateTime = zonedDateTime.format(dateTimeFormatter); + System.out.println("ISO_DATE = "+formatedDateTime); + + dateTimeFormatter = DateTimeFormatter.ISO_TIME; + formatedDateTime = zonedDateTime.format(dateTimeFormatter); + System.out.println("ISO_TIME = "+formatedDateTime); + } + +} diff --git a/BasicJava/ZoneDateTimeDemo_from/Output.txt b/BasicJava/ZoneDateTimeDemo_from/Output.txt new file mode 100644 index 000000000..c16fa966a --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_from/Output.txt @@ -0,0 +1,2 @@ +2018-02-08T09:26:27.428+05:30 +2018-02-08T09:26:27.428+05:30 diff --git a/BasicJava/ZoneDateTimeDemo_from/ZoneDateTimeDemo/.classpath b/BasicJava/ZoneDateTimeDemo_from/ZoneDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_from/ZoneDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ZoneDateTimeDemo_from/ZoneDateTimeDemo/.project b/BasicJava/ZoneDateTimeDemo_from/ZoneDateTimeDemo/.project new file mode 100644 index 000000000..47ef13e1d --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_from/ZoneDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + ZoneDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ZoneDateTimeDemo_from/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ZoneDateTimeDemo_from/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_from/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ZoneDateTimeDemo_from/ZoneDateTimeDemo/bin/ZoneDateTimeDemo.class b/BasicJava/ZoneDateTimeDemo_from/ZoneDateTimeDemo/bin/ZoneDateTimeDemo.class new file mode 100644 index 000000000..5814ea026 Binary files /dev/null and b/BasicJava/ZoneDateTimeDemo_from/ZoneDateTimeDemo/bin/ZoneDateTimeDemo.class differ diff --git a/BasicJava/ZoneDateTimeDemo_from/ZoneDateTimeDemo/src/ZoneDateTimeDemo.java b/BasicJava/ZoneDateTimeDemo_from/ZoneDateTimeDemo/src/ZoneDateTimeDemo.java new file mode 100644 index 000000000..66279074e --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_from/ZoneDateTimeDemo/src/ZoneDateTimeDemo.java @@ -0,0 +1,26 @@ +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +public class ZoneDateTimeDemo +{ + + public static void main(String[] args) + { + + OffsetDateTime offsetDateTime = OffsetDateTime.now(); + System.out.println(offsetDateTime); + + /* + * Parameters: + * + * temporal - the temporal object to convert, not null + * + * Returns: + * + * the zoned date-time, not null + */ + ZonedDateTime zonedDateTime = ZonedDateTime.from(offsetDateTime); + System.out.println(zonedDateTime); + } + +} diff --git a/BasicJava/ZoneDateTimeDemo_get_field/Output.txt b/BasicJava/ZoneDateTimeDemo_get_field/Output.txt new file mode 100644 index 000000000..8dc71f836 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_get_field/Output.txt @@ -0,0 +1,3 @@ +2018-02-08T09:42:24.807+05:30[Asia/Calcutta] +dayOfMonth = 8 +monthOfYear = 2 diff --git a/BasicJava/ZoneDateTimeDemo_get_field/ZoneDateTimeDemo/.classpath b/BasicJava/ZoneDateTimeDemo_get_field/ZoneDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_get_field/ZoneDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ZoneDateTimeDemo_get_field/ZoneDateTimeDemo/.project b/BasicJava/ZoneDateTimeDemo_get_field/ZoneDateTimeDemo/.project new file mode 100644 index 000000000..47ef13e1d --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_get_field/ZoneDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + ZoneDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ZoneDateTimeDemo_get_field/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ZoneDateTimeDemo_get_field/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_get_field/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ZoneDateTimeDemo_get_field/ZoneDateTimeDemo/bin/ZoneDateTimeDemo.class b/BasicJava/ZoneDateTimeDemo_get_field/ZoneDateTimeDemo/bin/ZoneDateTimeDemo.class new file mode 100644 index 000000000..a3f71a8d7 Binary files /dev/null and b/BasicJava/ZoneDateTimeDemo_get_field/ZoneDateTimeDemo/bin/ZoneDateTimeDemo.class differ diff --git a/BasicJava/ZoneDateTimeDemo_get_field/ZoneDateTimeDemo/src/ZoneDateTimeDemo.java b/BasicJava/ZoneDateTimeDemo_get_field/ZoneDateTimeDemo/src/ZoneDateTimeDemo.java new file mode 100644 index 000000000..2494efe6b --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_get_field/ZoneDateTimeDemo/src/ZoneDateTimeDemo.java @@ -0,0 +1,28 @@ +import java.time.ZonedDateTime; +import java.time.temporal.ChronoField; + +public class ZoneDateTimeDemo +{ + + public static void main(String[] args) + { + ZonedDateTime zonedDateTime = ZonedDateTime.now(); + System.out.println(zonedDateTime); + + /* + * Parameters: + * + * field - the field to get, not null + * + * Returns: + * + * the value for the field + */ + int dayOfMonth = zonedDateTime.get(ChronoField.DAY_OF_MONTH); + System.out.println("dayOfMonth = " + dayOfMonth); + + int monthOfYear = zonedDateTime.get(ChronoField.MONTH_OF_YEAR); + System.out.println("monthOfYear = " + monthOfYear); + } + +} diff --git a/BasicJava/ZoneDateTimeDemo_isafter_before/Output.txt b/BasicJava/ZoneDateTimeDemo_isafter_before/Output.txt new file mode 100644 index 000000000..1f49b7aef --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_isafter_before/Output.txt @@ -0,0 +1,5 @@ +2016-02-03T12:30:30+01:00 +2017-02-03T12:30:30+01:00 +false +false +true diff --git a/BasicJava/ZoneDateTimeDemo_isafter_before/ZoneDateTimeDemo/.classpath b/BasicJava/ZoneDateTimeDemo_isafter_before/ZoneDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_isafter_before/ZoneDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ZoneDateTimeDemo_isafter_before/ZoneDateTimeDemo/.project b/BasicJava/ZoneDateTimeDemo_isafter_before/ZoneDateTimeDemo/.project new file mode 100644 index 000000000..47ef13e1d --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_isafter_before/ZoneDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + ZoneDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ZoneDateTimeDemo_isafter_before/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ZoneDateTimeDemo_isafter_before/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_isafter_before/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ZoneDateTimeDemo_isafter_before/ZoneDateTimeDemo/bin/ZoneDateTimeDemo.class b/BasicJava/ZoneDateTimeDemo_isafter_before/ZoneDateTimeDemo/bin/ZoneDateTimeDemo.class new file mode 100644 index 000000000..927efc705 Binary files /dev/null and b/BasicJava/ZoneDateTimeDemo_isafter_before/ZoneDateTimeDemo/bin/ZoneDateTimeDemo.class differ diff --git a/BasicJava/ZoneDateTimeDemo_isafter_before/ZoneDateTimeDemo/src/ZoneDateTimeDemo.java b/BasicJava/ZoneDateTimeDemo_isafter_before/ZoneDateTimeDemo/src/ZoneDateTimeDemo.java new file mode 100644 index 000000000..a5487a7c6 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_isafter_before/ZoneDateTimeDemo/src/ZoneDateTimeDemo.java @@ -0,0 +1,38 @@ +import java.time.ZonedDateTime; + +public class ZoneDateTimeDemo +{ + + public static void main(String[] args) + { + + ZonedDateTime zonedDateTime1 = ZonedDateTime + .parse("2016-02-03T12:30:30+01:00"); + + System.out.println(zonedDateTime1); + + ZonedDateTime zonedDateTime2 = ZonedDateTime + .parse("2017-02-03T12:30:30+01:00"); + + System.out.println(zonedDateTime2); + + /* + * Returns:true if this is equal to the other date-time + */ + System.out.println(zonedDateTime1.equals(zonedDateTime2)); + + /* + * Returns:true if this date-time is after the specified + * date-time + */ + System.out.println(zonedDateTime1.isAfter(zonedDateTime2)); + + /* + * Returns:true if this date-time is before the specified + * date-time + */ + + System.out.println(zonedDateTime1.isBefore(zonedDateTime2)); + } + +} diff --git a/BasicJava/ZoneDateTimeDemo_minus/Output.txt b/BasicJava/ZoneDateTimeDemo_minus/Output.txt new file mode 100644 index 000000000..58209ba7e --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_minus/Output.txt @@ -0,0 +1,10 @@ +Current date and time = 2018-02-05T10:11:57.559+05:30[Asia/Calcutta] + +Year changed = 2016-02-05T10:11:57.559+05:30[Asia/Calcutta] +Month changed = 2015-11-05T10:11:57.559+05:30[Asia/Calcutta] +Day changed = 2015-10-31T10:11:57.559+05:30[Asia/Calcutta] +Hour changed = 2015-10-31T09:11:57.559+05:30[Asia/Calcutta] +Min changed = 2015-10-31T09:01:57.559+05:30[Asia/Calcutta] +Sec changed = 2015-10-31T09:01:37.559+05:30[Asia/Calcutta] +NanoSec changed = 2015-10-31T09:01:37.558999950+05:30[Asia/Calcutta] +Week changed = 2015-10-10T09:01:37.558999950+05:30[Asia/Calcutta] diff --git a/BasicJava/ZoneDateTimeDemo_minus/ZoneDateTimeDemo/.classpath b/BasicJava/ZoneDateTimeDemo_minus/ZoneDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_minus/ZoneDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ZoneDateTimeDemo_minus/ZoneDateTimeDemo/.project b/BasicJava/ZoneDateTimeDemo_minus/ZoneDateTimeDemo/.project new file mode 100644 index 000000000..47ef13e1d --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_minus/ZoneDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + ZoneDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ZoneDateTimeDemo_minus/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ZoneDateTimeDemo_minus/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_minus/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ZoneDateTimeDemo_minus/ZoneDateTimeDemo/bin/ZoneDateTimeDemo.class b/BasicJava/ZoneDateTimeDemo_minus/ZoneDateTimeDemo/bin/ZoneDateTimeDemo.class new file mode 100644 index 000000000..c589d090b Binary files /dev/null and b/BasicJava/ZoneDateTimeDemo_minus/ZoneDateTimeDemo/bin/ZoneDateTimeDemo.class differ diff --git a/BasicJava/ZoneDateTimeDemo_minus/ZoneDateTimeDemo/src/ZoneDateTimeDemo.java b/BasicJava/ZoneDateTimeDemo_minus/ZoneDateTimeDemo/src/ZoneDateTimeDemo.java new file mode 100644 index 000000000..0bf559189 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_minus/ZoneDateTimeDemo/src/ZoneDateTimeDemo.java @@ -0,0 +1,40 @@ +import java.time.ZonedDateTime; + +public class ZoneDateTimeDemo +{ + + public static void main(String[] args) + { + /* + * Returns:the current date-time using the system clock, not + * null. + */ + ZonedDateTime zonedDateTime1 = ZonedDateTime.now(); + System.out.println("Current date and time = " + zonedDateTime1); + + ZonedDateTime zonedDateTime2 = zonedDateTime1.minusYears(2); + System.out.println("\nYear changed = " + zonedDateTime2); + + ZonedDateTime zonedDateTime3 = zonedDateTime2.minusMonths(3); + System.out.println("Month changed = " + zonedDateTime3); + + ZonedDateTime zonedDateTime4 = zonedDateTime3.minusDays(5); + System.out.println("Day changed = " + zonedDateTime4); + + ZonedDateTime zonedDateTime5 = zonedDateTime4.minusHours(1); + System.out.println("Hour changed = " + zonedDateTime5); + + ZonedDateTime zonedDateTime6 = zonedDateTime5.minusMinutes(10); + System.out.println("Min changed = " + zonedDateTime6); + + ZonedDateTime zonedDateTime7 = zonedDateTime6.minusSeconds(20); + System.out.println("Sec changed = " + zonedDateTime7); + + ZonedDateTime zonedDateTime8 = zonedDateTime7.minusNanos(50); + System.out.println("NanoSec changed = " + zonedDateTime8); + + ZonedDateTime zonedDateTime9 = zonedDateTime8.minusWeeks(3); + System.out.println("Week changed = " + zonedDateTime9); + } + +} diff --git a/BasicJava/ZoneDateTimeDemo_now_methods/Output.txt b/BasicJava/ZoneDateTimeDemo_now_methods/Output.txt new file mode 100644 index 000000000..85a363c8c --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_now_methods/Output.txt @@ -0,0 +1,4 @@ +SystemClock[Z] +2018-02-08T04:30:10.162Z +Asia/Calcutta +2018-02-08T10:02:26.163+05:30[Asia/Calcutta] diff --git a/BasicJava/ZoneDateTimeDemo_now_methods/ZoneDateTimeDemo/.classpath b/BasicJava/ZoneDateTimeDemo_now_methods/ZoneDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_now_methods/ZoneDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ZoneDateTimeDemo_now_methods/ZoneDateTimeDemo/.project b/BasicJava/ZoneDateTimeDemo_now_methods/ZoneDateTimeDemo/.project new file mode 100644 index 000000000..47ef13e1d --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_now_methods/ZoneDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + ZoneDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ZoneDateTimeDemo_now_methods/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ZoneDateTimeDemo_now_methods/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_now_methods/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ZoneDateTimeDemo_now_methods/ZoneDateTimeDemo/bin/ZoneDateTimeDemo.class b/BasicJava/ZoneDateTimeDemo_now_methods/ZoneDateTimeDemo/bin/ZoneDateTimeDemo.class new file mode 100644 index 000000000..6a27a1a0d Binary files /dev/null and b/BasicJava/ZoneDateTimeDemo_now_methods/ZoneDateTimeDemo/bin/ZoneDateTimeDemo.class differ diff --git a/BasicJava/ZoneDateTimeDemo_now_methods/ZoneDateTimeDemo/src/ZoneDateTimeDemo.java b/BasicJava/ZoneDateTimeDemo_now_methods/ZoneDateTimeDemo/src/ZoneDateTimeDemo.java new file mode 100644 index 000000000..c2be42c24 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_now_methods/ZoneDateTimeDemo/src/ZoneDateTimeDemo.java @@ -0,0 +1,47 @@ +import java.time.Clock; +import java.time.ZoneId; +import java.time.ZonedDateTime; + +public class ZoneDateTimeDemo +{ + + public static void main(String[] args) + { + Clock clock = Clock.systemUTC(); + System.out.println(clock); + + /* + * Obtains the current date-time from the specified clock. + * + * Parameters: + * + * clock - the clock to use, not null + * + * Returns: + * + * the current date-time, not null + */ + ZonedDateTime zonedDateTime1 = ZonedDateTime.now(clock); + System.out.println(zonedDateTime1); + + ZoneId zoneId = ZoneId.systemDefault(); + System.out.println(zoneId); + + /* + * Obtains the current date-time from the system clock in the + * specified time-zone. + * + * Parameters: + * + * zone - the zone ID to use, not null + * + * Returns: + * + * the current date-time using the system clock, not null + * + */ + ZonedDateTime zonedDateTime2 = ZonedDateTime.now(zoneId); + System.out.println(zonedDateTime2); + } + +} diff --git a/BasicJava/ZoneDateTimeDemo_ofInstant_methods/ZoneDateTimeDemo/.classpath b/BasicJava/ZoneDateTimeDemo_ofInstant_methods/ZoneDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_ofInstant_methods/ZoneDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ZoneDateTimeDemo_ofInstant_methods/ZoneDateTimeDemo/.project b/BasicJava/ZoneDateTimeDemo_ofInstant_methods/ZoneDateTimeDemo/.project new file mode 100644 index 000000000..47ef13e1d --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_ofInstant_methods/ZoneDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + ZoneDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ZoneDateTimeDemo_ofInstant_methods/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ZoneDateTimeDemo_ofInstant_methods/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_ofInstant_methods/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ZoneDateTimeDemo_ofInstant_methods/ZoneDateTimeDemo/bin/ZoneDateTimeDemo1.class b/BasicJava/ZoneDateTimeDemo_ofInstant_methods/ZoneDateTimeDemo/bin/ZoneDateTimeDemo1.class new file mode 100644 index 000000000..c2cd8f3e3 Binary files /dev/null and b/BasicJava/ZoneDateTimeDemo_ofInstant_methods/ZoneDateTimeDemo/bin/ZoneDateTimeDemo1.class differ diff --git a/BasicJava/ZoneDateTimeDemo_ofInstant_methods/ZoneDateTimeDemo/bin/ZoneDateTimeDemo2.class b/BasicJava/ZoneDateTimeDemo_ofInstant_methods/ZoneDateTimeDemo/bin/ZoneDateTimeDemo2.class new file mode 100644 index 000000000..639517ed8 Binary files /dev/null and b/BasicJava/ZoneDateTimeDemo_ofInstant_methods/ZoneDateTimeDemo/bin/ZoneDateTimeDemo2.class differ diff --git a/BasicJava/ZoneDateTimeDemo_ofInstant_methods/ZoneDateTimeDemo/src/ZoneDateTimeDemo1.java b/BasicJava/ZoneDateTimeDemo_ofInstant_methods/ZoneDateTimeDemo/src/ZoneDateTimeDemo1.java new file mode 100644 index 000000000..d9df73923 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_ofInstant_methods/ZoneDateTimeDemo/src/ZoneDateTimeDemo1.java @@ -0,0 +1,36 @@ +import java.time.Instant; +import java.time.ZoneId; +import java.time.ZonedDateTime; + +public class ZoneDateTimeDemo1 +{ + + public static void main(String[] args) + { + Instant instant = Instant.now(); + System.out.println(instant); + + ZoneId zoneId = ZoneId.systemDefault(); + System.out.println(zoneId); + + /* + * + * Obtains an instance of ZonedDateTime from an Instant. + * + * Parameters: + * + * instant - the instant to create the date-time from, not + * null + * + * zone - the time-zone, not null + * + * Returns: + * + * the zoned date-time, not null + */ + ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(instant, zoneId); + System.out.println(zonedDateTime); + + } + +} diff --git a/BasicJava/ZoneDateTimeDemo_ofInstant_methods/ZoneDateTimeDemo/src/ZoneDateTimeDemo2.java b/BasicJava/ZoneDateTimeDemo_ofInstant_methods/ZoneDateTimeDemo/src/ZoneDateTimeDemo2.java new file mode 100644 index 000000000..d121384fb --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_ofInstant_methods/ZoneDateTimeDemo/src/ZoneDateTimeDemo2.java @@ -0,0 +1,41 @@ +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; + +public class ZoneDateTimeDemo2 +{ + + public static void main(String[] args) + { + + LocalDateTime localDateTime = LocalDateTime.now(); + System.out.println(localDateTime); + + ZoneOffset zoneOffset = ZoneOffset.UTC; + System.out.println(zoneOffset); + + ZoneId zoneId = ZoneId.systemDefault(); + System.out.println(zoneId); + + /* + * Parameters: + * + * localDateTime - the local date-time, not null + * + * offset - the zone offset, not null + * + * zone - the time-zone, not null + * + * Returns: + * + * the zoned date-time, not null + * + */ + + ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(localDateTime, + zoneOffset, zoneId); + System.out.println(zonedDateTime); + } + +} diff --git a/BasicJava/ZoneDateTimeDemo_ofInstant_methods/ZoneDateTimeDemo1_Output.txt b/BasicJava/ZoneDateTimeDemo_ofInstant_methods/ZoneDateTimeDemo1_Output.txt new file mode 100644 index 000000000..209c4cac8 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_ofInstant_methods/ZoneDateTimeDemo1_Output.txt @@ -0,0 +1,3 @@ +2018-02-11T04:05:47.632Z +Asia/Calcutta +2018-02-11T09:35:47.632+05:30[Asia/Calcutta] diff --git a/BasicJava/ZoneDateTimeDemo_ofInstant_methods/ZoneDateTimeDemo2_Output.txt b/BasicJava/ZoneDateTimeDemo_ofInstant_methods/ZoneDateTimeDemo2_Output.txt new file mode 100644 index 000000000..92edff0ba --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_ofInstant_methods/ZoneDateTimeDemo2_Output.txt @@ -0,0 +1,4 @@ +2018-02-11T09:35:59.355 +Z +Asia/Calcutta +2018-02-11T15:05:59.355+05:30[Asia/Calcutta] diff --git a/BasicJava/ZoneDateTimeDemo_ofLocal_strict/ZoneDateTimeDemo/.classpath b/BasicJava/ZoneDateTimeDemo_ofLocal_strict/ZoneDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_ofLocal_strict/ZoneDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ZoneDateTimeDemo_ofLocal_strict/ZoneDateTimeDemo/.project b/BasicJava/ZoneDateTimeDemo_ofLocal_strict/ZoneDateTimeDemo/.project new file mode 100644 index 000000000..47ef13e1d --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_ofLocal_strict/ZoneDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + ZoneDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ZoneDateTimeDemo_ofLocal_strict/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ZoneDateTimeDemo_ofLocal_strict/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_ofLocal_strict/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ZoneDateTimeDemo_ofLocal_strict/ZoneDateTimeDemo/bin/ZoneDateTimeDemo1.class b/BasicJava/ZoneDateTimeDemo_ofLocal_strict/ZoneDateTimeDemo/bin/ZoneDateTimeDemo1.class new file mode 100644 index 000000000..055a99d1b Binary files /dev/null and b/BasicJava/ZoneDateTimeDemo_ofLocal_strict/ZoneDateTimeDemo/bin/ZoneDateTimeDemo1.class differ diff --git a/BasicJava/ZoneDateTimeDemo_ofLocal_strict/ZoneDateTimeDemo/bin/ZoneDateTimeDemo2.class b/BasicJava/ZoneDateTimeDemo_ofLocal_strict/ZoneDateTimeDemo/bin/ZoneDateTimeDemo2.class new file mode 100644 index 000000000..15086bff2 Binary files /dev/null and b/BasicJava/ZoneDateTimeDemo_ofLocal_strict/ZoneDateTimeDemo/bin/ZoneDateTimeDemo2.class differ diff --git a/BasicJava/ZoneDateTimeDemo_ofLocal_strict/ZoneDateTimeDemo/src/ZoneDateTimeDemo1.java b/BasicJava/ZoneDateTimeDemo_ofLocal_strict/ZoneDateTimeDemo/src/ZoneDateTimeDemo1.java new file mode 100644 index 000000000..913ab8c98 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_ofLocal_strict/ZoneDateTimeDemo/src/ZoneDateTimeDemo1.java @@ -0,0 +1,39 @@ +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; + +public class ZoneDateTimeDemo1 +{ + + public static void main(String[] args) + { + LocalDateTime localDateTime = LocalDateTime.now(); + System.out.println(localDateTime); + + ZoneId zoneId = ZoneId.systemDefault(); + System.out.println(zoneId); + + ZoneOffset zoneOffSet = ZoneOffset.UTC; + System.out.println(zoneOffSet); + + /* + * Parameters: + * + * localDateTime - the local date-time, not null + * + * zone - the time-zone, not null + * + * preferredOffset - the zone offset, null if no preference + * + * Returns: + * + * the zoned date-time, not null + */ + ZonedDateTime zonedDateTime = ZonedDateTime.ofLocal(localDateTime, + zoneId, zoneOffSet); + System.out.println(zonedDateTime); + + } + +} diff --git a/BasicJava/ZoneDateTimeDemo_ofLocal_strict/ZoneDateTimeDemo/src/ZoneDateTimeDemo2.java b/BasicJava/ZoneDateTimeDemo_ofLocal_strict/ZoneDateTimeDemo/src/ZoneDateTimeDemo2.java new file mode 100644 index 000000000..c1bd55856 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_ofLocal_strict/ZoneDateTimeDemo/src/ZoneDateTimeDemo2.java @@ -0,0 +1,40 @@ +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; + +public class ZoneDateTimeDemo2 +{ + + public static void main(String[] args) + { + LocalDateTime localDateTime = LocalDateTime.now(); + System.out.println(localDateTime); + + ZoneId zoneId = ZoneId.of("Z"); + System.out.println(zoneId); + + ZoneOffset zoneOffSet = ZoneOffset.UTC; + System.out.println(zoneOffSet); + + /* + * Parameters: + * + * localDateTime - the local date-time, not null + * + * offset - the zone offset, not null + * + * zone - the time-zone, not null + * + * Returns: + * + * the zoned date-time, not null + * + */ + + ZonedDateTime zonedDateTime = ZonedDateTime.ofStrict(localDateTime, + zoneOffSet, zoneId); + System.out.println(zonedDateTime); + } + +} diff --git a/BasicJava/ZoneDateTimeDemo_ofLocal_strict/ZoneDateTimeDemo1_Output.txt b/BasicJava/ZoneDateTimeDemo_ofLocal_strict/ZoneDateTimeDemo1_Output.txt new file mode 100644 index 000000000..54277b7a2 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_ofLocal_strict/ZoneDateTimeDemo1_Output.txt @@ -0,0 +1,4 @@ +2018-02-11T09:52:38.932 +Asia/Calcutta +Z +2018-02-11T09:52:38.932+05:30[Asia/Calcutta] diff --git a/BasicJava/ZoneDateTimeDemo_ofLocal_strict/ZoneDateTimeDemo2_Output.txt b/BasicJava/ZoneDateTimeDemo_ofLocal_strict/ZoneDateTimeDemo2_Output.txt new file mode 100644 index 000000000..6eeede117 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_ofLocal_strict/ZoneDateTimeDemo2_Output.txt @@ -0,0 +1,4 @@ +2018-02-11T09:52:49.746 +Z +Z +2018-02-11T09:52:49.746Z diff --git a/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo/.classpath b/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo/.project b/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo/.project new file mode 100644 index 000000000..47ef13e1d --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + ZoneDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo/bin/ZoneDateTimeDemo1.class b/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo/bin/ZoneDateTimeDemo1.class new file mode 100644 index 000000000..ae0bd5b4a Binary files /dev/null and b/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo/bin/ZoneDateTimeDemo1.class differ diff --git a/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo/bin/ZoneDateTimeDemo2.class b/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo/bin/ZoneDateTimeDemo2.class new file mode 100644 index 000000000..3d89863cc Binary files /dev/null and b/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo/bin/ZoneDateTimeDemo2.class differ diff --git a/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo/bin/ZoneDateTimeDemo3.class b/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo/bin/ZoneDateTimeDemo3.class new file mode 100644 index 000000000..194b696ac Binary files /dev/null and b/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo/bin/ZoneDateTimeDemo3.class differ diff --git a/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo/src/ZoneDateTimeDemo1.java b/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo/src/ZoneDateTimeDemo1.java new file mode 100644 index 000000000..ff2bb65ce --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo/src/ZoneDateTimeDemo1.java @@ -0,0 +1,41 @@ +import java.time.ZoneId; +import java.time.ZonedDateTime; + +public class ZoneDateTimeDemo1 +{ + + public static void main(String[] args) + { + + /* + * Parameters: + * + * year - the year to represent, from MIN_YEAR to MAX_YEAR + * + * month - the month-of-year to represent, from 1 (January) to + * 12 (December) + * + * dayOfMonth - the day-of-month to represent, from 1 to 31 + * + * hour - the hour-of-day to represent, from 0 to 23 + * + * minute - the minute-of-hour to represent, from 0 to 59 + * + * second - the second-of-minute to represent, from 0 to 59 + * + * nanoOfSecond - the nano-of-second to represent, from 0 to + * 999,999,999 + * + * zone - the time-zone, not null + * + * Returns: the offset date-time, not null + * + */ + + ZonedDateTime zonedDateTime = ZonedDateTime.of(2018, 2, 3, 6, 30, 40, + 50000, ZoneId.systemDefault()); + System.out.println(zonedDateTime); + + } + +} diff --git a/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo/src/ZoneDateTimeDemo2.java b/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo/src/ZoneDateTimeDemo2.java new file mode 100644 index 000000000..52b9f14e7 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo/src/ZoneDateTimeDemo2.java @@ -0,0 +1,35 @@ +import java.time.LocalDate; +import java.time.LocalTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; + +public class ZoneDateTimeDemo2 +{ + + public static void main(String[] args) + { + + LocalDate localDate = LocalDate.parse("2017-02-03"); + LocalTime localTime = LocalTime.parse("12:30:30"); + + /* + * Parameters: + * + * date - the local date, not null + * + * time - the local time, not null + * + * zone - the time-zone, not null + * + * Returns: + * + * the offset date-time, not null + * + */ + + ZonedDateTime zonedDateTime = ZonedDateTime.of(localDate, localTime,ZoneId.systemDefault()); + System.out.println(zonedDateTime); + + } + +} diff --git a/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo/src/ZoneDateTimeDemo3.java b/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo/src/ZoneDateTimeDemo3.java new file mode 100644 index 000000000..adff79943 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo/src/ZoneDateTimeDemo3.java @@ -0,0 +1,30 @@ +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; + +public class ZoneDateTimeDemo3 +{ + + public static void main(String[] args) + { + + LocalDateTime localDateTime = LocalDateTime.now(); + + /* + * Parameters: + * + * localDateTime - the local date-time, not null + * + * zone - the time-zone, not null + * + * Returns: + * + * the zoned date-time, not null + */ + ZonedDateTime zonedDateTime = ZonedDateTime.of(localDateTime, + ZoneId.systemDefault()); + System.out.println(zonedDateTime); + + } + +} diff --git a/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo1_Output.txt b/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo1_Output.txt new file mode 100644 index 000000000..b7cdd534b --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo1_Output.txt @@ -0,0 +1 @@ +2018-02-03T06:30:40.000050+05:30[Asia/Calcutta] diff --git a/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo2_Output.txt b/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo2_Output.txt new file mode 100644 index 000000000..bb2c6e947 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo2_Output.txt @@ -0,0 +1 @@ +2017-02-03T12:30:30+05:30[Asia/Calcutta] diff --git a/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo3_Output.txt b/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo3_Output.txt new file mode 100644 index 000000000..2207584be --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_of_methods/ZoneDateTimeDemo3_Output.txt @@ -0,0 +1 @@ +2018-02-09T09:59:31.014+05:30[Asia/Calcutta] diff --git a/BasicJava/ZoneDateTimeDemo_plus/Output.txt b/BasicJava/ZoneDateTimeDemo_plus/Output.txt new file mode 100644 index 000000000..29902ac90 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_plus/Output.txt @@ -0,0 +1,10 @@ +Current date and time = 2018-02-06T09:23:30.033+05:30[Asia/Calcutta] + +Year changed = 2020-02-06T09:23:30.033+05:30[Asia/Calcutta] +Month changed = 2020-05-06T09:23:30.033+05:30[Asia/Calcutta] +Day changed = 2020-05-11T09:23:30.033+05:30[Asia/Calcutta] +Hour changed = 2020-05-11T10:23:30.033+05:30[Asia/Calcutta] +Min changed = 2020-05-11T10:33:30.033+05:30[Asia/Calcutta] +Sec changed = 2020-05-11T10:33:50.033+05:30[Asia/Calcutta] +NanoSec changed = 2020-05-11T10:33:50.033000050+05:30[Asia/Calcutta] +Week changed = 2020-06-01T10:33:50.033000050+05:30[Asia/Calcutta] diff --git a/BasicJava/ZoneDateTimeDemo_plus/ZoneDateTimeDemo/.classpath b/BasicJava/ZoneDateTimeDemo_plus/ZoneDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_plus/ZoneDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ZoneDateTimeDemo_plus/ZoneDateTimeDemo/.project b/BasicJava/ZoneDateTimeDemo_plus/ZoneDateTimeDemo/.project new file mode 100644 index 000000000..47ef13e1d --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_plus/ZoneDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + ZoneDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ZoneDateTimeDemo_plus/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ZoneDateTimeDemo_plus/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_plus/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ZoneDateTimeDemo_plus/ZoneDateTimeDemo/bin/ZoneDateTimeDemo.class b/BasicJava/ZoneDateTimeDemo_plus/ZoneDateTimeDemo/bin/ZoneDateTimeDemo.class new file mode 100644 index 000000000..2028fb464 Binary files /dev/null and b/BasicJava/ZoneDateTimeDemo_plus/ZoneDateTimeDemo/bin/ZoneDateTimeDemo.class differ diff --git a/BasicJava/ZoneDateTimeDemo_plus/ZoneDateTimeDemo/src/ZoneDateTimeDemo.java b/BasicJava/ZoneDateTimeDemo_plus/ZoneDateTimeDemo/src/ZoneDateTimeDemo.java new file mode 100644 index 000000000..c659b0323 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_plus/ZoneDateTimeDemo/src/ZoneDateTimeDemo.java @@ -0,0 +1,40 @@ +import java.time.ZonedDateTime; + +public class ZoneDateTimeDemo +{ + + public static void main(String[] args) + { + /* + * Returns:the current date-time using the system clock, not + * null. + */ + ZonedDateTime zonedDateTime1 = ZonedDateTime.now(); + System.out.println("Current date and time = "+zonedDateTime1); + + ZonedDateTime zonedDateTime2 = zonedDateTime1.plusYears(2); + System.out.println("\nYear changed = "+zonedDateTime2); + + ZonedDateTime zonedDateTime3 = zonedDateTime2.plusMonths(3); + System.out.println("Month changed = "+zonedDateTime3); + + ZonedDateTime zonedDateTime4 = zonedDateTime3.plusDays(5); + System.out.println("Day changed = "+zonedDateTime4); + + ZonedDateTime zonedDateTime5 = zonedDateTime4.plusHours(1); + System.out.println("Hour changed = "+zonedDateTime5); + + ZonedDateTime zonedDateTime6 = zonedDateTime5.plusMinutes(10); + System.out.println("Min changed = "+zonedDateTime6); + + ZonedDateTime zonedDateTime7 = zonedDateTime6.plusSeconds(20); + System.out.println("Sec changed = "+zonedDateTime7); + + ZonedDateTime zonedDateTime8 = zonedDateTime7.plusNanos(50); + System.out.println("NanoSec changed = "+zonedDateTime8); + + ZonedDateTime zonedDateTime9 = zonedDateTime8.plusWeeks(3); + System.out.println("Week changed = "+zonedDateTime9); + } + +} diff --git a/BasicJava/ZoneDateTimeDemo_with/Output.txt b/BasicJava/ZoneDateTimeDemo_with/Output.txt new file mode 100644 index 000000000..78fd4f9dc --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_with/Output.txt @@ -0,0 +1,9 @@ +zonedDateTime1 = 2017-02-03T10:15:30+01:00 + +Year changed = 2018-02-03T10:15:30+01:00 +Month changed = 2018-10-03T10:15:30+01:00 +Day changed = 2018-10-25T10:15:30+01:00 +Hour changed = 2018-10-25T01:15:30+01:00 +Min changed = 2018-10-25T01:10:30+01:00 +Sec changed = 2018-10-25T01:10:20+01:00 +NanoSec changed = 2018-10-25T01:10:20.000000050+01:00 diff --git a/BasicJava/ZoneDateTimeDemo_with/ZoneDateTimeDemo/.classpath b/BasicJava/ZoneDateTimeDemo_with/ZoneDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_with/ZoneDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ZoneDateTimeDemo_with/ZoneDateTimeDemo/.project b/BasicJava/ZoneDateTimeDemo_with/ZoneDateTimeDemo/.project new file mode 100644 index 000000000..47ef13e1d --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_with/ZoneDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + ZoneDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ZoneDateTimeDemo_with/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ZoneDateTimeDemo_with/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_with/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ZoneDateTimeDemo_with/ZoneDateTimeDemo/bin/ZoneDateTimeDemo.class b/BasicJava/ZoneDateTimeDemo_with/ZoneDateTimeDemo/bin/ZoneDateTimeDemo.class new file mode 100644 index 000000000..21c26c824 Binary files /dev/null and b/BasicJava/ZoneDateTimeDemo_with/ZoneDateTimeDemo/bin/ZoneDateTimeDemo.class differ diff --git a/BasicJava/ZoneDateTimeDemo_with/ZoneDateTimeDemo/src/ZoneDateTimeDemo.java b/BasicJava/ZoneDateTimeDemo_with/ZoneDateTimeDemo/src/ZoneDateTimeDemo.java new file mode 100644 index 000000000..0ccd85607 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_with/ZoneDateTimeDemo/src/ZoneDateTimeDemo.java @@ -0,0 +1,33 @@ +import java.time.ZonedDateTime; + +public class ZoneDateTimeDemo +{ + + public static void main(String[] args) + { + ZonedDateTime zonedDateTime1 = ZonedDateTime.parse("2017-02-03T10:15:30+01:00"); + System.out.println("zonedDateTime1 = "+zonedDateTime1); + + ZonedDateTime zonedDateTime2 = zonedDateTime1.withYear(2018); + System.out.println("\nYear changed = "+zonedDateTime2); + + ZonedDateTime zonedDateTime3 = zonedDateTime2.withMonth(10); + System.out.println("Month changed = "+zonedDateTime3); + + ZonedDateTime zonedDateTime4 = zonedDateTime3.withDayOfMonth(25); + System.out.println("Day changed = "+zonedDateTime4); + + ZonedDateTime zonedDateTime5 = zonedDateTime4.withHour(1); + System.out.println("Hour changed = "+zonedDateTime5); + + ZonedDateTime zonedDateTime6 = zonedDateTime5.withMinute(10); + System.out.println("Min changed = "+zonedDateTime6); + + ZonedDateTime zonedDateTime7 = zonedDateTime6.withSecond(20); + System.out.println("Sec changed = "+zonedDateTime7); + + ZonedDateTime zonedDateTime8 = zonedDateTime7.withNano(50); + System.out.println("NanoSec changed = "+zonedDateTime8); + } + +} diff --git a/BasicJava/ZoneDateTimeDemo_withdayofyear/Output.txt b/BasicJava/ZoneDateTimeDemo_withdayofyear/Output.txt new file mode 100644 index 000000000..b27819fd8 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_withdayofyear/Output.txt @@ -0,0 +1,2 @@ +zonedDateTime1 = 2017-02-03T10:15:30+01:00 +DayOfYear changed = 2017-05-30T10:15:30+01:00 diff --git a/BasicJava/ZoneDateTimeDemo_withdayofyear/ZoneDateTimeDemo/.classpath b/BasicJava/ZoneDateTimeDemo_withdayofyear/ZoneDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_withdayofyear/ZoneDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ZoneDateTimeDemo_withdayofyear/ZoneDateTimeDemo/.project b/BasicJava/ZoneDateTimeDemo_withdayofyear/ZoneDateTimeDemo/.project new file mode 100644 index 000000000..47ef13e1d --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_withdayofyear/ZoneDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + ZoneDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ZoneDateTimeDemo_withdayofyear/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ZoneDateTimeDemo_withdayofyear/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_withdayofyear/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ZoneDateTimeDemo_withdayofyear/ZoneDateTimeDemo/bin/ZoneDateTimeDemo.class b/BasicJava/ZoneDateTimeDemo_withdayofyear/ZoneDateTimeDemo/bin/ZoneDateTimeDemo.class new file mode 100644 index 000000000..b7bbe1ba2 Binary files /dev/null and b/BasicJava/ZoneDateTimeDemo_withdayofyear/ZoneDateTimeDemo/bin/ZoneDateTimeDemo.class differ diff --git a/BasicJava/ZoneDateTimeDemo_withdayofyear/ZoneDateTimeDemo/src/ZoneDateTimeDemo.java b/BasicJava/ZoneDateTimeDemo_withdayofyear/ZoneDateTimeDemo/src/ZoneDateTimeDemo.java new file mode 100644 index 000000000..0a85502d5 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_withdayofyear/ZoneDateTimeDemo/src/ZoneDateTimeDemo.java @@ -0,0 +1,29 @@ +import java.time.ZonedDateTime; + +public class ZoneDateTimeDemo +{ + + public static void main(String[] args) + { + + ZonedDateTime zonedDateTime1 = ZonedDateTime + .parse("2017-02-03T10:15:30+01:00"); + + System.out.println("zonedDateTime1 = " + zonedDateTime1); + /* + * Parameters: + * + * dayOfYear - the day-of-year to set in the result, from 1 to + * 365-366 + * + * Returns: + * + * a ZonedDateTime based on this date with the requested day, + * not null + */ + ZonedDateTime zonedDateTime2 = zonedDateTime1.withDayOfYear(150); + System.out.println("DayOfYear changed = " + zonedDateTime2); + + } + +} diff --git a/BasicJava/ZoneDateTimeDemo_withzone/ZoneDateTimeDemo/.classpath b/BasicJava/ZoneDateTimeDemo_withzone/ZoneDateTimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_withzone/ZoneDateTimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ZoneDateTimeDemo_withzone/ZoneDateTimeDemo/.project b/BasicJava/ZoneDateTimeDemo_withzone/ZoneDateTimeDemo/.project new file mode 100644 index 000000000..47ef13e1d --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_withzone/ZoneDateTimeDemo/.project @@ -0,0 +1,17 @@ + + + ZoneDateTimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ZoneDateTimeDemo_withzone/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ZoneDateTimeDemo_withzone/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_withzone/ZoneDateTimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ZoneDateTimeDemo_withzone/ZoneDateTimeDemo/bin/ZoneDateTimeDemo1.class b/BasicJava/ZoneDateTimeDemo_withzone/ZoneDateTimeDemo/bin/ZoneDateTimeDemo1.class new file mode 100644 index 000000000..2ad8fe40e Binary files /dev/null and b/BasicJava/ZoneDateTimeDemo_withzone/ZoneDateTimeDemo/bin/ZoneDateTimeDemo1.class differ diff --git a/BasicJava/ZoneDateTimeDemo_withzone/ZoneDateTimeDemo/bin/ZoneDateTimeDemo2.class b/BasicJava/ZoneDateTimeDemo_withzone/ZoneDateTimeDemo/bin/ZoneDateTimeDemo2.class new file mode 100644 index 000000000..7912628f8 Binary files /dev/null and b/BasicJava/ZoneDateTimeDemo_withzone/ZoneDateTimeDemo/bin/ZoneDateTimeDemo2.class differ diff --git a/BasicJava/ZoneDateTimeDemo_withzone/ZoneDateTimeDemo/src/ZoneDateTimeDemo1.java b/BasicJava/ZoneDateTimeDemo_withzone/ZoneDateTimeDemo/src/ZoneDateTimeDemo1.java new file mode 100644 index 000000000..92495012a --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_withzone/ZoneDateTimeDemo/src/ZoneDateTimeDemo1.java @@ -0,0 +1,35 @@ +import java.time.ZoneId; +import java.time.ZonedDateTime; + +public class ZoneDateTimeDemo1 +{ + + public static void main(String[] args) + { + + ZonedDateTime zonedDateTime1 = ZonedDateTime.now(); + System.out.println(zonedDateTime1); + + ZoneId zoneId = ZoneId.of("Z"); + System.out.println(zoneId); + + /* + * Parameters: + * + * zone - the time-zone to change to, not null + * + * Returns: + * + * a ZonedDateTime based on this date-time with the + * requested zone, not null + * + * If the zone ID equals 'Z', the result is ZoneOffset.UTC. + */ + ZonedDateTime zonedDateTime2 = zonedDateTime1 + .withZoneSameInstant(zoneId); + + System.out.println(zonedDateTime2); + + } + +} diff --git a/BasicJava/ZoneDateTimeDemo_withzone/ZoneDateTimeDemo/src/ZoneDateTimeDemo2.java b/BasicJava/ZoneDateTimeDemo_withzone/ZoneDateTimeDemo/src/ZoneDateTimeDemo2.java new file mode 100644 index 000000000..b2a170835 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_withzone/ZoneDateTimeDemo/src/ZoneDateTimeDemo2.java @@ -0,0 +1,35 @@ +import java.time.ZoneId; +import java.time.ZonedDateTime; + +public class ZoneDateTimeDemo2 +{ + + public static void main(String[] args) + { + + ZonedDateTime zonedDateTime1 = ZonedDateTime.now(); + System.out.println(zonedDateTime1); + + ZoneId zoneId = ZoneId.of("Z"); + System.out.println(zoneId); + + /* + * Parameters: + * + * zone - the time-zone to change to, not null + * + * Returns: + * + * a ZonedDateTime based on this date-time with the + * requested zone, not null + * + * If the zone ID equals 'Z', the result is ZoneOffset.UTC. + */ + ZonedDateTime zonedDateTime2 = zonedDateTime1 + .withZoneSameLocal(zoneId); + + System.out.println(zonedDateTime2); + + } + +} diff --git a/BasicJava/ZoneDateTimeDemo_withzone/ZoneDateTimeDemo1.txt b/BasicJava/ZoneDateTimeDemo_withzone/ZoneDateTimeDemo1.txt new file mode 100644 index 000000000..567a2c831 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_withzone/ZoneDateTimeDemo1.txt @@ -0,0 +1,3 @@ +2018-02-07T09:41:43.370+05:30[Asia/Calcutta] +Z +2018-02-07T04:11:43.370Z diff --git a/BasicJava/ZoneDateTimeDemo_withzone/ZoneDateTimeDemo2.txt b/BasicJava/ZoneDateTimeDemo_withzone/ZoneDateTimeDemo2.txt new file mode 100644 index 000000000..5f4221e07 --- /dev/null +++ b/BasicJava/ZoneDateTimeDemo_withzone/ZoneDateTimeDemo2.txt @@ -0,0 +1,3 @@ +2018-02-07T09:42:07.865+05:30[Asia/Calcutta] +Z +2018-02-07T09:42:07.865Z diff --git a/BasicJava/ZoneIdDemo_getAvailableZoneIds/Output.txt b/BasicJava/ZoneIdDemo_getAvailableZoneIds/Output.txt new file mode 100644 index 000000000..b08f68e0e --- /dev/null +++ b/BasicJava/ZoneIdDemo_getAvailableZoneIds/Output.txt @@ -0,0 +1,600 @@ +Asia/Aden +America/Cuiaba +Etc/GMT+9 +Etc/GMT+8 +Africa/Nairobi +America/Marigot +Asia/Aqtau +Pacific/Kwajalein +America/El_Salvador +Asia/Pontianak +Africa/Cairo +Pacific/Pago_Pago +Africa/Mbabane +Asia/Kuching +Pacific/Honolulu +Pacific/Rarotonga +America/Guatemala +Australia/Hobart +Europe/London +America/Belize +America/Panama +Asia/Chungking +America/Managua +America/Indiana/Petersburg +Asia/Yerevan +Europe/Brussels +GMT +Europe/Warsaw +America/Chicago +Asia/Kashgar +Chile/Continental +Pacific/Yap +CET +Etc/GMT-1 +Etc/GMT-0 +Europe/Jersey +America/Tegucigalpa +Etc/GMT-5 +Europe/Istanbul +America/Eirunepe +Etc/GMT-4 +America/Miquelon +Etc/GMT-3 +Europe/Luxembourg +Etc/GMT-2 +Etc/GMT-9 +America/Argentina/Catamarca +Etc/GMT-8 +Etc/GMT-7 +Etc/GMT-6 +Europe/Zaporozhye +Canada/Yukon +Canada/Atlantic +Atlantic/St_Helena +Australia/Tasmania +Libya +Europe/Guernsey +America/Grand_Turk +US/Pacific-New +Asia/Samarkand +America/Argentina/Cordoba +Asia/Phnom_Penh +Africa/Kigali +Asia/Almaty +US/Alaska +Asia/Dubai +Europe/Isle_of_Man +America/Araguaina +Cuba +Asia/Novosibirsk +America/Argentina/Salta +Etc/GMT+3 +Africa/Tunis +Etc/GMT+2 +Etc/GMT+1 +Pacific/Fakaofo +Africa/Tripoli +Etc/GMT+0 +Israel +Africa/Banjul +Etc/GMT+7 +Indian/Comoro +Etc/GMT+6 +Etc/GMT+5 +Etc/GMT+4 +Pacific/Port_Moresby +US/Arizona +Antarctica/Syowa +Indian/Reunion +Pacific/Palau +Europe/Kaliningrad +America/Montevideo +Africa/Windhoek +Asia/Karachi +Africa/Mogadishu +Australia/Perth +Brazil/East +Etc/GMT +Asia/Chita +Pacific/Easter +Antarctica/Davis +Antarctica/McMurdo +Asia/Macao +America/Manaus +Africa/Freetown +Europe/Bucharest +Asia/Tomsk +America/Argentina/Mendoza +Asia/Macau +Europe/Malta +Mexico/BajaSur +Pacific/Tahiti +Africa/Asmera +Europe/Busingen +America/Argentina/Rio_Gallegos +Africa/Malabo +Europe/Skopje +America/Catamarca +America/Godthab +Europe/Sarajevo +Australia/ACT +GB-Eire +Africa/Lagos +America/Cordoba +Europe/Rome +Asia/Dacca +Indian/Mauritius +Pacific/Samoa +America/Regina +America/Fort_Wayne +America/Dawson_Creek +Africa/Algiers +Europe/Mariehamn +America/St_Johns +America/St_Thomas +Europe/Zurich +America/Anguilla +Asia/Dili +America/Denver +Africa/Bamako +Europe/Saratov +GB +Mexico/General +Pacific/Wallis +Europe/Gibraltar +Africa/Conakry +Africa/Lubumbashi +Asia/Istanbul +America/Havana +NZ-CHAT +Asia/Choibalsan +America/Porto_Acre +Asia/Omsk +Europe/Vaduz +US/Michigan +Asia/Dhaka +America/Barbados +Europe/Tiraspol +Atlantic/Cape_Verde +Asia/Yekaterinburg +America/Louisville +Pacific/Johnston +Pacific/Chatham +Europe/Ljubljana +America/Sao_Paulo +Asia/Jayapura +America/Curacao +Asia/Dushanbe +America/Guyana +America/Guayaquil +America/Martinique +Portugal +Europe/Berlin +Europe/Moscow +Europe/Chisinau +America/Puerto_Rico +America/Rankin_Inlet +Pacific/Ponape +Europe/Stockholm +Europe/Budapest +America/Argentina/Jujuy +Australia/Eucla +Asia/Shanghai +Universal +Europe/Zagreb +America/Port_of_Spain +Europe/Helsinki +Asia/Beirut +Asia/Tel_Aviv +Pacific/Bougainville +US/Central +Africa/Sao_Tome +Indian/Chagos +America/Cayenne +Asia/Yakutsk +Pacific/Galapagos +Australia/North +Europe/Paris +Africa/Ndjamena +Pacific/Fiji +America/Rainy_River +Indian/Maldives +Australia/Yancowinna +SystemV/AST4 +Asia/Oral +America/Yellowknife +Pacific/Enderbury +America/Juneau +Australia/Victoria +America/Indiana/Vevay +Asia/Tashkent +Asia/Jakarta +Africa/Ceuta +Asia/Barnaul +America/Recife +America/Buenos_Aires +America/Noronha +America/Swift_Current +Australia/Adelaide +America/Metlakatla +Africa/Djibouti +America/Paramaribo +Europe/Simferopol +Europe/Sofia +Africa/Nouakchott +Europe/Prague +America/Indiana/Vincennes +Antarctica/Mawson +America/Kralendijk +Antarctica/Troll +Europe/Samara +Indian/Christmas +America/Antigua +Pacific/Gambier +America/Indianapolis +America/Inuvik +America/Iqaluit +Pacific/Funafuti +UTC +Antarctica/Macquarie +Canada/Pacific +America/Moncton +Africa/Gaborone +Pacific/Chuuk +Asia/Pyongyang +America/St_Vincent +Asia/Gaza +Etc/Universal +PST8PDT +Atlantic/Faeroe +Asia/Qyzylorda +Canada/Newfoundland +America/Kentucky/Louisville +America/Yakutat +Asia/Ho_Chi_Minh +Antarctica/Casey +Europe/Copenhagen +Africa/Asmara +Atlantic/Azores +Europe/Vienna +ROK +Pacific/Pitcairn +America/Mazatlan +Australia/Queensland +Pacific/Nauru +Europe/Tirane +Asia/Kolkata +SystemV/MST7 +Australia/Canberra +MET +Australia/Broken_Hill +Europe/Riga +America/Dominica +Africa/Abidjan +America/Mendoza +America/Santarem +Kwajalein +America/Asuncion +Asia/Ulan_Bator +NZ +America/Boise +Australia/Currie +EST5EDT +Pacific/Guam +Pacific/Wake +Atlantic/Bermuda +America/Costa_Rica +America/Dawson +Asia/Chongqing +Eire +Europe/Amsterdam +America/Indiana/Knox +America/North_Dakota/Beulah +Africa/Accra +Atlantic/Faroe +Mexico/BajaNorte +America/Maceio +Etc/UCT +Pacific/Apia +GMT0 +America/Atka +Pacific/Niue +Canada/East-Saskatchewan +Australia/Lord_Howe +Europe/Dublin +Pacific/Truk +MST7MDT +America/Monterrey +America/Nassau +America/Jamaica +Asia/Bishkek +America/Atikokan +Atlantic/Stanley +Australia/NSW +US/Hawaii +SystemV/CST6 +Indian/Mahe +Asia/Aqtobe +America/Sitka +Asia/Vladivostok +Africa/Libreville +Africa/Maputo +Zulu +America/Kentucky/Monticello +Africa/El_Aaiun +Africa/Ouagadougou +America/Coral_Harbour +Pacific/Marquesas +Brazil/West +America/Aruba +America/North_Dakota/Center +America/Cayman +Asia/Ulaanbaatar +Asia/Baghdad +Europe/San_Marino +America/Indiana/Tell_City +America/Tijuana +Pacific/Saipan +SystemV/YST9 +Africa/Douala +America/Chihuahua +America/Ojinaga +Asia/Hovd +America/Anchorage +Chile/EasterIsland +America/Halifax +Antarctica/Rothera +America/Indiana/Indianapolis +US/Mountain +Asia/Damascus +America/Argentina/San_Luis +America/Santiago +Asia/Baku +America/Argentina/Ushuaia +Atlantic/Reykjavik +Africa/Brazzaville +Africa/Porto-Novo +America/La_Paz +Antarctica/DumontDUrville +Asia/Taipei +Antarctica/South_Pole +Asia/Manila +Asia/Bangkok +Africa/Dar_es_Salaam +Poland +Atlantic/Madeira +Antarctica/Palmer +America/Thunder_Bay +Africa/Addis_Ababa +Asia/Yangon +Europe/Uzhgorod +Brazil/DeNoronha +Asia/Ashkhabad +Etc/Zulu +America/Indiana/Marengo +America/Creston +America/Punta_Arenas +America/Mexico_City +Antarctica/Vostok +Asia/Jerusalem +Europe/Andorra +US/Samoa +PRC +Asia/Vientiane +Pacific/Kiritimati +America/Matamoros +America/Blanc-Sablon +Asia/Riyadh +Iceland +Pacific/Pohnpei +Asia/Ujung_Pandang +Atlantic/South_Georgia +Europe/Lisbon +Asia/Harbin +Europe/Oslo +Asia/Novokuznetsk +CST6CDT +Atlantic/Canary +America/Knox_IN +Asia/Kuwait +SystemV/HST10 +Pacific/Efate +Africa/Lome +America/Bogota +America/Menominee +America/Adak +Pacific/Norfolk +Europe/Kirov +America/Resolute +Pacific/Tarawa +Africa/Kampala +Asia/Krasnoyarsk +Greenwich +SystemV/EST5 +America/Edmonton +Europe/Podgorica +Australia/South +Canada/Central +Africa/Bujumbura +America/Santo_Domingo +US/Eastern +Europe/Minsk +Pacific/Auckland +Africa/Casablanca +America/Glace_Bay +Canada/Eastern +Asia/Qatar +Europe/Kiev +Singapore +Asia/Magadan +SystemV/PST8 +America/Port-au-Prince +Europe/Belfast +America/St_Barthelemy +Asia/Ashgabat +Africa/Luanda +America/Nipigon +Atlantic/Jan_Mayen +Brazil/Acre +Asia/Muscat +Asia/Bahrain +Europe/Vilnius +America/Fortaleza +Etc/GMT0 +US/East-Indiana +America/Hermosillo +America/Cancun +Africa/Maseru +Pacific/Kosrae +Africa/Kinshasa +Asia/Kathmandu +Asia/Seoul +Australia/Sydney +America/Lima +Australia/LHI +America/St_Lucia +Europe/Madrid +America/Bahia_Banderas +America/Montserrat +Asia/Brunei +America/Santa_Isabel +Canada/Mountain +America/Cambridge_Bay +Asia/Colombo +Australia/West +Indian/Antananarivo +Australia/Brisbane +Indian/Mayotte +US/Indiana-Starke +Asia/Urumqi +US/Aleutian +Europe/Volgograd +America/Lower_Princes +America/Vancouver +Africa/Blantyre +America/Rio_Branco +America/Danmarkshavn +America/Detroit +America/Thule +Africa/Lusaka +Asia/Hong_Kong +Iran +America/Argentina/La_Rioja +Africa/Dakar +SystemV/CST6CDT +America/Tortola +America/Porto_Velho +Asia/Sakhalin +Etc/GMT+10 +America/Scoresbysund +Asia/Kamchatka +Asia/Thimbu +Africa/Harare +Etc/GMT+12 +Etc/GMT+11 +Navajo +America/Nome +Europe/Tallinn +Turkey +Africa/Khartoum +Africa/Johannesburg +Africa/Bangui +Europe/Belgrade +Jamaica +Africa/Bissau +Asia/Tehran +WET +Europe/Astrakhan +Africa/Juba +America/Campo_Grande +America/Belem +Etc/Greenwich +Asia/Saigon +America/Ensenada +Pacific/Midway +America/Jujuy +Africa/Timbuktu +America/Bahia +America/Goose_Bay +America/Virgin +America/Pangnirtung +Asia/Katmandu +America/Phoenix +Africa/Niamey +America/Whitehorse +Pacific/Noumea +Asia/Tbilisi +America/Montreal +Asia/Makassar +America/Argentina/San_Juan +Hongkong +UCT +Asia/Nicosia +America/Indiana/Winamac +SystemV/MST7MDT +America/Argentina/ComodRivadavia +America/Boa_Vista +America/Grenada +Asia/Atyrau +Australia/Darwin +Asia/Khandyga +Asia/Kuala_Lumpur +Asia/Famagusta +Asia/Thimphu +Asia/Rangoon +Europe/Bratislava +Asia/Calcutta +America/Argentina/Tucuman +Asia/Kabul +Indian/Cocos +Japan +Pacific/Tongatapu +America/New_York +Etc/GMT-12 +Etc/GMT-11 +Etc/GMT-10 +SystemV/YST9YDT +Europe/Ulyanovsk +Etc/GMT-14 +Etc/GMT-13 +W-SU +America/Merida +EET +America/Rosario +Canada/Saskatchewan +America/St_Kitts +Arctic/Longyearbyen +America/Fort_Nelson +America/Caracas +America/Guadeloupe +Asia/Hebron +Indian/Kerguelen +SystemV/PST8PDT +Africa/Monrovia +Asia/Ust-Nera +Egypt +Asia/Srednekolymsk +America/North_Dakota/New_Salem +Asia/Anadyr +Australia/Melbourne +Asia/Irkutsk +America/Shiprock +America/Winnipeg +Europe/Vatican +Asia/Amman +Etc/UTC +SystemV/AST4ADT +Asia/Tokyo +America/Toronto +Asia/Singapore +Australia/Lindeman +America/Los_Angeles +SystemV/EST5EDT +Pacific/Majuro +America/Argentina/Buenos_Aires +Europe/Nicosia +Pacific/Guadalcanal +Europe/Athens +US/Pacific +Europe/Monaco diff --git a/BasicJava/ZoneIdDemo_getAvailableZoneIds/ZoneIdDemo/.classpath b/BasicJava/ZoneIdDemo_getAvailableZoneIds/ZoneIdDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ZoneIdDemo_getAvailableZoneIds/ZoneIdDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ZoneIdDemo_getAvailableZoneIds/ZoneIdDemo/.project b/BasicJava/ZoneIdDemo_getAvailableZoneIds/ZoneIdDemo/.project new file mode 100644 index 000000000..c7e29bfaa --- /dev/null +++ b/BasicJava/ZoneIdDemo_getAvailableZoneIds/ZoneIdDemo/.project @@ -0,0 +1,17 @@ + + + ZoneIdDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ZoneIdDemo_getAvailableZoneIds/ZoneIdDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ZoneIdDemo_getAvailableZoneIds/ZoneIdDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ZoneIdDemo_getAvailableZoneIds/ZoneIdDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ZoneIdDemo_getAvailableZoneIds/ZoneIdDemo/bin/ZoneIdDemo.class b/BasicJava/ZoneIdDemo_getAvailableZoneIds/ZoneIdDemo/bin/ZoneIdDemo.class new file mode 100644 index 000000000..291ad521f Binary files /dev/null and b/BasicJava/ZoneIdDemo_getAvailableZoneIds/ZoneIdDemo/bin/ZoneIdDemo.class differ diff --git a/BasicJava/ZoneIdDemo_getAvailableZoneIds/ZoneIdDemo/src/ZoneIdDemo.java b/BasicJava/ZoneIdDemo_getAvailableZoneIds/ZoneIdDemo/src/ZoneIdDemo.java new file mode 100644 index 000000000..790b29ff6 --- /dev/null +++ b/BasicJava/ZoneIdDemo_getAvailableZoneIds/ZoneIdDemo/src/ZoneIdDemo.java @@ -0,0 +1,21 @@ +import java.time.ZoneId; +import java.util.Set; + +public class ZoneIdDemo +{ + + public static void main(String[] args) + { + /* + * Returns: + * + * a modifiable copy of the set of zone IDs, not null + */ + Set zoneIdSet = ZoneId.getAvailableZoneIds(); + for (String zoneId : zoneIdSet) + { + System.out.println(zoneId); + } + } + +} diff --git a/BasicJava/ZoneIdDemo_getDisplayName/Output.txt b/BasicJava/ZoneIdDemo_getDisplayName/Output.txt new file mode 100644 index 000000000..a93681d25 --- /dev/null +++ b/BasicJava/ZoneIdDemo_getDisplayName/Output.txt @@ -0,0 +1,3 @@ +displayName FULL = India Time +displayName SHORT = IT +displayName NARROW = Asia/Calcutta diff --git a/BasicJava/ZoneIdDemo_getDisplayName/ZoneIdDemo/.classpath b/BasicJava/ZoneIdDemo_getDisplayName/ZoneIdDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ZoneIdDemo_getDisplayName/ZoneIdDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ZoneIdDemo_getDisplayName/ZoneIdDemo/.project b/BasicJava/ZoneIdDemo_getDisplayName/ZoneIdDemo/.project new file mode 100644 index 000000000..c7e29bfaa --- /dev/null +++ b/BasicJava/ZoneIdDemo_getDisplayName/ZoneIdDemo/.project @@ -0,0 +1,17 @@ + + + ZoneIdDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ZoneIdDemo_getDisplayName/ZoneIdDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ZoneIdDemo_getDisplayName/ZoneIdDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ZoneIdDemo_getDisplayName/ZoneIdDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ZoneIdDemo_getDisplayName/ZoneIdDemo/bin/ZoneIdDemo.class b/BasicJava/ZoneIdDemo_getDisplayName/ZoneIdDemo/bin/ZoneIdDemo.class new file mode 100644 index 000000000..47d1636b4 Binary files /dev/null and b/BasicJava/ZoneIdDemo_getDisplayName/ZoneIdDemo/bin/ZoneIdDemo.class differ diff --git a/BasicJava/ZoneIdDemo_getDisplayName/ZoneIdDemo/src/ZoneIdDemo.java b/BasicJava/ZoneIdDemo_getDisplayName/ZoneIdDemo/src/ZoneIdDemo.java new file mode 100644 index 000000000..d51f60787 --- /dev/null +++ b/BasicJava/ZoneIdDemo_getDisplayName/ZoneIdDemo/src/ZoneIdDemo.java @@ -0,0 +1,34 @@ +import java.time.ZoneId; +import java.time.format.TextStyle; +import java.util.Locale; + +public class ZoneIdDemo +{ + + public static void main(String[] args) + { + ZoneId zoneId = ZoneId.systemDefault(); + + /* + * Parameters: + * + * style - the length of the text required, not null + * + * locale - the locale to use, not null + * + * Returns: + * + * the text value of the zone, not null + */ + String displayName = zoneId.getDisplayName(TextStyle.FULL, Locale.US); + System.out.println("displayName FULL = " + displayName); + + displayName = zoneId.getDisplayName(TextStyle.SHORT, Locale.US); + System.out.println("displayName SHORT = " + displayName); + + displayName = zoneId.getDisplayName(TextStyle.NARROW, Locale.US); + System.out.println("displayName NARROW = " + displayName); + + } + +} diff --git a/BasicJava/ZoneIdDemo_getId/Output.txt b/BasicJava/ZoneIdDemo_getId/Output.txt new file mode 100644 index 000000000..019f76267 --- /dev/null +++ b/BasicJava/ZoneIdDemo_getId/Output.txt @@ -0,0 +1 @@ +Asia/Calcutta diff --git a/BasicJava/ZoneIdDemo_getId/ZoneIdDemo/.classpath b/BasicJava/ZoneIdDemo_getId/ZoneIdDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ZoneIdDemo_getId/ZoneIdDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ZoneIdDemo_getId/ZoneIdDemo/.project b/BasicJava/ZoneIdDemo_getId/ZoneIdDemo/.project new file mode 100644 index 000000000..c7e29bfaa --- /dev/null +++ b/BasicJava/ZoneIdDemo_getId/ZoneIdDemo/.project @@ -0,0 +1,17 @@ + + + ZoneIdDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ZoneIdDemo_getId/ZoneIdDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ZoneIdDemo_getId/ZoneIdDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ZoneIdDemo_getId/ZoneIdDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ZoneIdDemo_getId/ZoneIdDemo/bin/ZoneIdDemo.class b/BasicJava/ZoneIdDemo_getId/ZoneIdDemo/bin/ZoneIdDemo.class new file mode 100644 index 000000000..0621205b3 Binary files /dev/null and b/BasicJava/ZoneIdDemo_getId/ZoneIdDemo/bin/ZoneIdDemo.class differ diff --git a/BasicJava/ZoneIdDemo_getId/ZoneIdDemo/src/ZoneIdDemo.java b/BasicJava/ZoneIdDemo_getId/ZoneIdDemo/src/ZoneIdDemo.java new file mode 100644 index 000000000..6df07f103 --- /dev/null +++ b/BasicJava/ZoneIdDemo_getId/ZoneIdDemo/src/ZoneIdDemo.java @@ -0,0 +1,20 @@ +import java.time.ZoneId; + +public class ZoneIdDemo +{ + + public static void main(String[] args) + { + /* + * Returns:the zone ID, not null + */ + ZoneId zoneId = ZoneId.systemDefault(); + + /* + * Returns:the time-zone unique ID, not null + */ + String strZoneId = zoneId.getId(); + System.out.println(strZoneId); + } + +} diff --git a/BasicJava/ZoneIdDemo_getRules/Output.txt b/BasicJava/ZoneIdDemo_getRules/Output.txt new file mode 100644 index 000000000..9d4bec0f0 --- /dev/null +++ b/BasicJava/ZoneIdDemo_getRules/Output.txt @@ -0,0 +1,2 @@ +Asia/Calcutta +ZoneRules[currentStandardOffset=+05:30] diff --git a/BasicJava/ZoneIdDemo_getRules/ZoneIdDemo/.classpath b/BasicJava/ZoneIdDemo_getRules/ZoneIdDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ZoneIdDemo_getRules/ZoneIdDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ZoneIdDemo_getRules/ZoneIdDemo/.project b/BasicJava/ZoneIdDemo_getRules/ZoneIdDemo/.project new file mode 100644 index 000000000..c7e29bfaa --- /dev/null +++ b/BasicJava/ZoneIdDemo_getRules/ZoneIdDemo/.project @@ -0,0 +1,17 @@ + + + ZoneIdDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ZoneIdDemo_getRules/ZoneIdDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ZoneIdDemo_getRules/ZoneIdDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ZoneIdDemo_getRules/ZoneIdDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ZoneIdDemo_getRules/ZoneIdDemo/bin/ZoneIdDemo.class b/BasicJava/ZoneIdDemo_getRules/ZoneIdDemo/bin/ZoneIdDemo.class new file mode 100644 index 000000000..fe31ddb0b Binary files /dev/null and b/BasicJava/ZoneIdDemo_getRules/ZoneIdDemo/bin/ZoneIdDemo.class differ diff --git a/BasicJava/ZoneIdDemo_getRules/ZoneIdDemo/src/ZoneIdDemo.java b/BasicJava/ZoneIdDemo_getRules/ZoneIdDemo/src/ZoneIdDemo.java new file mode 100644 index 000000000..6c3cf04ed --- /dev/null +++ b/BasicJava/ZoneIdDemo_getRules/ZoneIdDemo/src/ZoneIdDemo.java @@ -0,0 +1,19 @@ +import java.time.ZoneId; +import java.time.zone.ZoneRules; + +public class ZoneIdDemo +{ + + public static void main(String[] args) + { + ZoneId zoneId = ZoneId.systemDefault(); + System.out.println(zoneId); + + /* + * Returns:the rules, not null + */ + ZoneRules zoneRules = zoneId.getRules(); + System.out.println(zoneRules); + } + +} diff --git a/BasicJava/ZoneIdDemo_intro/Output.txt b/BasicJava/ZoneIdDemo_intro/Output.txt new file mode 100644 index 000000000..019f76267 --- /dev/null +++ b/BasicJava/ZoneIdDemo_intro/Output.txt @@ -0,0 +1 @@ +Asia/Calcutta diff --git a/BasicJava/ZoneIdDemo_intro/ZoneIdDemo/.classpath b/BasicJava/ZoneIdDemo_intro/ZoneIdDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ZoneIdDemo_intro/ZoneIdDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ZoneIdDemo_intro/ZoneIdDemo/.project b/BasicJava/ZoneIdDemo_intro/ZoneIdDemo/.project new file mode 100644 index 000000000..c7e29bfaa --- /dev/null +++ b/BasicJava/ZoneIdDemo_intro/ZoneIdDemo/.project @@ -0,0 +1,17 @@ + + + ZoneIdDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ZoneIdDemo_intro/ZoneIdDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ZoneIdDemo_intro/ZoneIdDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ZoneIdDemo_intro/ZoneIdDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ZoneIdDemo_intro/ZoneIdDemo/bin/ZoneIdDemo.class b/BasicJava/ZoneIdDemo_intro/ZoneIdDemo/bin/ZoneIdDemo.class new file mode 100644 index 000000000..d2f6ffdf1 Binary files /dev/null and b/BasicJava/ZoneIdDemo_intro/ZoneIdDemo/bin/ZoneIdDemo.class differ diff --git a/BasicJava/ZoneIdDemo_intro/ZoneIdDemo/src/ZoneIdDemo.java b/BasicJava/ZoneIdDemo_intro/ZoneIdDemo/src/ZoneIdDemo.java new file mode 100644 index 000000000..86c2d729e --- /dev/null +++ b/BasicJava/ZoneIdDemo_intro/ZoneIdDemo/src/ZoneIdDemo.java @@ -0,0 +1,16 @@ +import java.time.ZoneId; + +public class ZoneIdDemo +{ + + public static void main(String[] args) + { + /* + * Returns:the zone ID, not null + */ + ZoneId zoneId = ZoneId.systemDefault(); + System.out.println(zoneId); + + } + +} diff --git a/BasicJava/ZoneIdDemo_normalized/Output.txt b/BasicJava/ZoneIdDemo_normalized/Output.txt new file mode 100644 index 000000000..019f76267 --- /dev/null +++ b/BasicJava/ZoneIdDemo_normalized/Output.txt @@ -0,0 +1 @@ +Asia/Calcutta diff --git a/BasicJava/ZoneIdDemo_normalized/ZoneIdDemo/.classpath b/BasicJava/ZoneIdDemo_normalized/ZoneIdDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ZoneIdDemo_normalized/ZoneIdDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ZoneIdDemo_normalized/ZoneIdDemo/.project b/BasicJava/ZoneIdDemo_normalized/ZoneIdDemo/.project new file mode 100644 index 000000000..c7e29bfaa --- /dev/null +++ b/BasicJava/ZoneIdDemo_normalized/ZoneIdDemo/.project @@ -0,0 +1,17 @@ + + + ZoneIdDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ZoneIdDemo_normalized/ZoneIdDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ZoneIdDemo_normalized/ZoneIdDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ZoneIdDemo_normalized/ZoneIdDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ZoneIdDemo_normalized/ZoneIdDemo/bin/ZoneIdDemo.class b/BasicJava/ZoneIdDemo_normalized/ZoneIdDemo/bin/ZoneIdDemo.class new file mode 100644 index 000000000..18074009a Binary files /dev/null and b/BasicJava/ZoneIdDemo_normalized/ZoneIdDemo/bin/ZoneIdDemo.class differ diff --git a/BasicJava/ZoneIdDemo_normalized/ZoneIdDemo/src/ZoneIdDemo.java b/BasicJava/ZoneIdDemo_normalized/ZoneIdDemo/src/ZoneIdDemo.java new file mode 100644 index 000000000..747e5f2d5 --- /dev/null +++ b/BasicJava/ZoneIdDemo_normalized/ZoneIdDemo/src/ZoneIdDemo.java @@ -0,0 +1,17 @@ +import java.time.ZoneId; + +public class ZoneIdDemo +{ + + public static void main(String[] args) + { + ZoneId zoneId = ZoneId.systemDefault(); + + /* + * Returns a normalized ZoneId + */ + zoneId = zoneId.normalized(); + System.out.println(zoneId); + } + +} diff --git a/BasicJava/ZoneIdDemo_ofOffset/Output.txt b/BasicJava/ZoneIdDemo_ofOffset/Output.txt new file mode 100644 index 000000000..e2e777581 --- /dev/null +++ b/BasicJava/ZoneIdDemo_ofOffset/Output.txt @@ -0,0 +1 @@ +UTC diff --git a/BasicJava/ZoneIdDemo_ofOffset/ZoneIdDemo/.classpath b/BasicJava/ZoneIdDemo_ofOffset/ZoneIdDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ZoneIdDemo_ofOffset/ZoneIdDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ZoneIdDemo_ofOffset/ZoneIdDemo/.project b/BasicJava/ZoneIdDemo_ofOffset/ZoneIdDemo/.project new file mode 100644 index 000000000..c7e29bfaa --- /dev/null +++ b/BasicJava/ZoneIdDemo_ofOffset/ZoneIdDemo/.project @@ -0,0 +1,17 @@ + + + ZoneIdDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ZoneIdDemo_ofOffset/ZoneIdDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ZoneIdDemo_ofOffset/ZoneIdDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ZoneIdDemo_ofOffset/ZoneIdDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ZoneIdDemo_ofOffset/ZoneIdDemo/bin/ZoneIdDemo.class b/BasicJava/ZoneIdDemo_ofOffset/ZoneIdDemo/bin/ZoneIdDemo.class new file mode 100644 index 000000000..2f76e98c7 Binary files /dev/null and b/BasicJava/ZoneIdDemo_ofOffset/ZoneIdDemo/bin/ZoneIdDemo.class differ diff --git a/BasicJava/ZoneIdDemo_ofOffset/ZoneIdDemo/src/ZoneIdDemo.java b/BasicJava/ZoneIdDemo_ofOffset/ZoneIdDemo/src/ZoneIdDemo.java new file mode 100644 index 000000000..501b409a2 --- /dev/null +++ b/BasicJava/ZoneIdDemo_ofOffset/ZoneIdDemo/src/ZoneIdDemo.java @@ -0,0 +1,26 @@ +import java.time.ZoneId; +import java.time.ZoneOffset; + +public class ZoneIdDemo +{ + + public static void main(String[] args) + { + + /* + * Parameters: + * + * prefix - the time-zone ID, not null + * + * offset - the offset, not null + * + * Returns: + * + * the zone ID, not null + */ + ZoneId zoneId = ZoneId.ofOffset("UTC", ZoneOffset.UTC); + + System.out.println(zoneId); + } + +} diff --git a/BasicJava/ZoneIdDemo_of_method/Output.txt b/BasicJava/ZoneIdDemo_of_method/Output.txt new file mode 100644 index 000000000..9ea880cc7 --- /dev/null +++ b/BasicJava/ZoneIdDemo_of_method/Output.txt @@ -0,0 +1,5 @@ +Asia/Kolkata +2018-02-14T09:57:07.098 + +Australia/Sydney +2018-02-14T15:27:49.142 diff --git a/BasicJava/ZoneIdDemo_of_method/ZoneIdDemo/.classpath b/BasicJava/ZoneIdDemo_of_method/ZoneIdDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ZoneIdDemo_of_method/ZoneIdDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ZoneIdDemo_of_method/ZoneIdDemo/.project b/BasicJava/ZoneIdDemo_of_method/ZoneIdDemo/.project new file mode 100644 index 000000000..c7e29bfaa --- /dev/null +++ b/BasicJava/ZoneIdDemo_of_method/ZoneIdDemo/.project @@ -0,0 +1,17 @@ + + + ZoneIdDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ZoneIdDemo_of_method/ZoneIdDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ZoneIdDemo_of_method/ZoneIdDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ZoneIdDemo_of_method/ZoneIdDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ZoneIdDemo_of_method/ZoneIdDemo/bin/ZoneIdDemo.class b/BasicJava/ZoneIdDemo_of_method/ZoneIdDemo/bin/ZoneIdDemo.class new file mode 100644 index 000000000..1743162dd Binary files /dev/null and b/BasicJava/ZoneIdDemo_of_method/ZoneIdDemo/bin/ZoneIdDemo.class differ diff --git a/BasicJava/ZoneIdDemo_of_method/ZoneIdDemo/src/ZoneIdDemo.java b/BasicJava/ZoneIdDemo_of_method/ZoneIdDemo/src/ZoneIdDemo.java new file mode 100644 index 000000000..28bd7a0c9 --- /dev/null +++ b/BasicJava/ZoneIdDemo_of_method/ZoneIdDemo/src/ZoneIdDemo.java @@ -0,0 +1,31 @@ +import java.time.LocalDateTime; +import java.time.ZoneId; + +public class ZoneIdDemo +{ + + public static void main(String[] args) + { + /* + * Parameters: + * + * zoneId - the time-zone ID, not null + * + * Returns: + * + * the zone ID, not null + */ + ZoneId zoneId1 = ZoneId.of("Asia/Kolkata"); + System.out.println(zoneId1); + LocalDateTime localDateTime1 = LocalDateTime.now(zoneId1); + System.out.println(localDateTime1); + + System.out.println(); + + ZoneId zoneId2 = ZoneId.of("Australia/Sydney"); + System.out.println(zoneId2); + LocalDateTime localDateTime2 = LocalDateTime.now(zoneId2); + System.out.println(localDateTime2); + } + +} diff --git a/BasicJava/ZoneIdDemo_of_zone_id_hashMap/Output.txt b/BasicJava/ZoneIdDemo_of_zone_id_hashMap/Output.txt new file mode 100644 index 000000000..e2e777581 --- /dev/null +++ b/BasicJava/ZoneIdDemo_of_zone_id_hashMap/Output.txt @@ -0,0 +1 @@ +UTC diff --git a/BasicJava/ZoneIdDemo_of_zone_id_hashMap/ZoneIdDemo/.classpath b/BasicJava/ZoneIdDemo_of_zone_id_hashMap/ZoneIdDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ZoneIdDemo_of_zone_id_hashMap/ZoneIdDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ZoneIdDemo_of_zone_id_hashMap/ZoneIdDemo/.project b/BasicJava/ZoneIdDemo_of_zone_id_hashMap/ZoneIdDemo/.project new file mode 100644 index 000000000..c7e29bfaa --- /dev/null +++ b/BasicJava/ZoneIdDemo_of_zone_id_hashMap/ZoneIdDemo/.project @@ -0,0 +1,17 @@ + + + ZoneIdDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ZoneIdDemo_of_zone_id_hashMap/ZoneIdDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ZoneIdDemo_of_zone_id_hashMap/ZoneIdDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ZoneIdDemo_of_zone_id_hashMap/ZoneIdDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ZoneIdDemo_of_zone_id_hashMap/ZoneIdDemo/bin/ZoneIdDemo.class b/BasicJava/ZoneIdDemo_of_zone_id_hashMap/ZoneIdDemo/bin/ZoneIdDemo.class new file mode 100644 index 000000000..56a720a66 Binary files /dev/null and b/BasicJava/ZoneIdDemo_of_zone_id_hashMap/ZoneIdDemo/bin/ZoneIdDemo.class differ diff --git a/BasicJava/ZoneIdDemo_of_zone_id_hashMap/ZoneIdDemo/src/ZoneIdDemo.java b/BasicJava/ZoneIdDemo_of_zone_id_hashMap/ZoneIdDemo/src/ZoneIdDemo.java new file mode 100644 index 000000000..8c20e8e3c --- /dev/null +++ b/BasicJava/ZoneIdDemo_of_zone_id_hashMap/ZoneIdDemo/src/ZoneIdDemo.java @@ -0,0 +1,27 @@ +import java.time.ZoneId; +import java.util.HashMap; + +public class ZoneIdDemo +{ + + public static void main(String[] args) + { + + /* + * Parameters: + * + * zoneId - the time-zone ID, not null + * + * aliasMap - a map of alias zone IDs (typically + * abbreviations) to real zone IDs, not null + * + * Returns: + * + * the zone ID, not null + */ + ZoneId zoneId = ZoneId.of("UTC", new HashMap<>()); + + System.out.println(zoneId); + } + +} diff --git a/BasicJava/ZoneOffsetDemo_get_field/Output.txt b/BasicJava/ZoneOffsetDemo_get_field/Output.txt new file mode 100644 index 000000000..7a723d2d8 --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_get_field/Output.txt @@ -0,0 +1,2 @@ +zoneOffset = +01:00 +offsetSeconds = 3600 diff --git a/BasicJava/ZoneOffsetDemo_get_field/ZoneOffsetDemo/.classpath b/BasicJava/ZoneOffsetDemo_get_field/ZoneOffsetDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_get_field/ZoneOffsetDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ZoneOffsetDemo_get_field/ZoneOffsetDemo/.project b/BasicJava/ZoneOffsetDemo_get_field/ZoneOffsetDemo/.project new file mode 100644 index 000000000..51864dba3 --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_get_field/ZoneOffsetDemo/.project @@ -0,0 +1,17 @@ + + + ZoneOffsetDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ZoneOffsetDemo_get_field/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ZoneOffsetDemo_get_field/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_get_field/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ZoneOffsetDemo_get_field/ZoneOffsetDemo/bin/ZoneOffsetDemo.class b/BasicJava/ZoneOffsetDemo_get_field/ZoneOffsetDemo/bin/ZoneOffsetDemo.class new file mode 100644 index 000000000..68a9654a7 Binary files /dev/null and b/BasicJava/ZoneOffsetDemo_get_field/ZoneOffsetDemo/bin/ZoneOffsetDemo.class differ diff --git a/BasicJava/ZoneOffsetDemo_get_field/ZoneOffsetDemo/src/ZoneOffsetDemo.java b/BasicJava/ZoneOffsetDemo_get_field/ZoneOffsetDemo/src/ZoneOffsetDemo.java new file mode 100644 index 000000000..47b63b453 --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_get_field/ZoneOffsetDemo/src/ZoneOffsetDemo.java @@ -0,0 +1,26 @@ +import java.time.ZoneOffset; +import java.time.temporal.ChronoField; + +public class ZoneOffsetDemo +{ + + public static void main(String[] args) + { + + ZoneOffset zoneOffset = ZoneOffset.of("+01:00"); + System.out.println("zoneOffset = " + zoneOffset); + /* + * Parameters: + * + * field - the field to get, not null + * + * Returns: + * + * the value for the field + */ + int offsetSeconds = zoneOffset.get(ChronoField.OFFSET_SECONDS); + + System.out.println("offsetSeconds = " + offsetSeconds); + } + +} diff --git a/BasicJava/ZoneOffsetDemo_getrules/Output.txt b/BasicJava/ZoneOffsetDemo_getrules/Output.txt new file mode 100644 index 000000000..8a067c613 --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_getrules/Output.txt @@ -0,0 +1,2 @@ +zoneOffset = Z +ZoneRules[currentStandardOffset=Z] diff --git a/BasicJava/ZoneOffsetDemo_getrules/ZoneOffsetDemo/.classpath b/BasicJava/ZoneOffsetDemo_getrules/ZoneOffsetDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_getrules/ZoneOffsetDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ZoneOffsetDemo_getrules/ZoneOffsetDemo/.project b/BasicJava/ZoneOffsetDemo_getrules/ZoneOffsetDemo/.project new file mode 100644 index 000000000..51864dba3 --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_getrules/ZoneOffsetDemo/.project @@ -0,0 +1,17 @@ + + + ZoneOffsetDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ZoneOffsetDemo_getrules/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ZoneOffsetDemo_getrules/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_getrules/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ZoneOffsetDemo_getrules/ZoneOffsetDemo/bin/ZoneOffsetDemo.class b/BasicJava/ZoneOffsetDemo_getrules/ZoneOffsetDemo/bin/ZoneOffsetDemo.class new file mode 100644 index 000000000..f5126789e Binary files /dev/null and b/BasicJava/ZoneOffsetDemo_getrules/ZoneOffsetDemo/bin/ZoneOffsetDemo.class differ diff --git a/BasicJava/ZoneOffsetDemo_getrules/ZoneOffsetDemo/src/ZoneOffsetDemo.java b/BasicJava/ZoneOffsetDemo_getrules/ZoneOffsetDemo/src/ZoneOffsetDemo.java new file mode 100644 index 000000000..3609b1767 --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_getrules/ZoneOffsetDemo/src/ZoneOffsetDemo.java @@ -0,0 +1,21 @@ +import java.time.ZoneOffset; +import java.time.zone.ZoneRules; + +public class ZoneOffsetDemo +{ + + public static void main(String[] args) + { + + ZoneOffset zoneOffset = ZoneOffset.UTC; + System.out.println("zoneOffset = " + zoneOffset); + + /* + * Returns:the rules, not null + */ + ZoneRules zoneRules = zoneOffset.getRules(); + System.out.println(zoneRules); + + } + +} diff --git a/BasicJava/ZoneOffsetDemo_id_totalsec/ZoneOffsetDemo/.classpath b/BasicJava/ZoneOffsetDemo_id_totalsec/ZoneOffsetDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_id_totalsec/ZoneOffsetDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ZoneOffsetDemo_id_totalsec/ZoneOffsetDemo/.project b/BasicJava/ZoneOffsetDemo_id_totalsec/ZoneOffsetDemo/.project new file mode 100644 index 000000000..51864dba3 --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_id_totalsec/ZoneOffsetDemo/.project @@ -0,0 +1,17 @@ + + + ZoneOffsetDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ZoneOffsetDemo_id_totalsec/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ZoneOffsetDemo_id_totalsec/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_id_totalsec/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ZoneOffsetDemo_id_totalsec/ZoneOffsetDemo/bin/ZoneOffsetDemo1.class b/BasicJava/ZoneOffsetDemo_id_totalsec/ZoneOffsetDemo/bin/ZoneOffsetDemo1.class new file mode 100644 index 000000000..ddd6ca591 Binary files /dev/null and b/BasicJava/ZoneOffsetDemo_id_totalsec/ZoneOffsetDemo/bin/ZoneOffsetDemo1.class differ diff --git a/BasicJava/ZoneOffsetDemo_id_totalsec/ZoneOffsetDemo/bin/ZoneOffsetDemo2.class b/BasicJava/ZoneOffsetDemo_id_totalsec/ZoneOffsetDemo/bin/ZoneOffsetDemo2.class new file mode 100644 index 000000000..46441508a Binary files /dev/null and b/BasicJava/ZoneOffsetDemo_id_totalsec/ZoneOffsetDemo/bin/ZoneOffsetDemo2.class differ diff --git a/BasicJava/ZoneOffsetDemo_id_totalsec/ZoneOffsetDemo/src/ZoneOffsetDemo1.java b/BasicJava/ZoneOffsetDemo_id_totalsec/ZoneOffsetDemo/src/ZoneOffsetDemo1.java new file mode 100644 index 000000000..25072ea9a --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_id_totalsec/ZoneOffsetDemo/src/ZoneOffsetDemo1.java @@ -0,0 +1,19 @@ +import java.time.ZoneOffset; + +public class ZoneOffsetDemo1 +{ + + public static void main(String[] args) + { + + ZoneOffset zoneOffset = ZoneOffset.UTC; + System.out.println("zoneOffset = "+zoneOffset); + + /* + * Returns:the zone offset ID, not null + */ + String id = zoneOffset.getId(); + System.out.println("id = "+id); + } + +} diff --git a/BasicJava/ZoneOffsetDemo_id_totalsec/ZoneOffsetDemo/src/ZoneOffsetDemo2.java b/BasicJava/ZoneOffsetDemo_id_totalsec/ZoneOffsetDemo/src/ZoneOffsetDemo2.java new file mode 100644 index 000000000..7061c8220 --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_id_totalsec/ZoneOffsetDemo/src/ZoneOffsetDemo2.java @@ -0,0 +1,18 @@ +import java.time.ZoneOffset; + +public class ZoneOffsetDemo2 +{ + + public static void main(String[] args) + { + + ZoneOffset zoneOffset = ZoneOffset.of("+01:00"); + System.out.println("zoneOffset = "+zoneOffset); + /* + * Returns:the total zone offset amount in seconds + */ + int totalSeconds = zoneOffset.getTotalSeconds(); + System.out.println("totalSeconds = "+totalSeconds); + } + +} diff --git a/BasicJava/ZoneOffsetDemo_id_totalsec/ZoneOffsetDemo1_Output.txt b/BasicJava/ZoneOffsetDemo_id_totalsec/ZoneOffsetDemo1_Output.txt new file mode 100644 index 000000000..e4f1481d8 --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_id_totalsec/ZoneOffsetDemo1_Output.txt @@ -0,0 +1,2 @@ +zoneOffset = Z +id = Z diff --git a/BasicJava/ZoneOffsetDemo_id_totalsec/ZoneOffsetDemo2_Output.txt b/BasicJava/ZoneOffsetDemo_id_totalsec/ZoneOffsetDemo2_Output.txt new file mode 100644 index 000000000..4b97e9aa1 --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_id_totalsec/ZoneOffsetDemo2_Output.txt @@ -0,0 +1,2 @@ +zoneOffset = +01:00 +totalSeconds = 3600 diff --git a/BasicJava/ZoneOffsetDemo_intro/Output.txt b/BasicJava/ZoneOffsetDemo_intro/Output.txt new file mode 100644 index 000000000..ffb65462d --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_intro/Output.txt @@ -0,0 +1,3 @@ +zoneOffsetMin = -18:00 +zoneOffsetMax = +18:00 +zoneOffsetUtc = Z diff --git a/BasicJava/ZoneOffsetDemo_intro/ZoneOffsetDemo/.classpath b/BasicJava/ZoneOffsetDemo_intro/ZoneOffsetDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_intro/ZoneOffsetDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ZoneOffsetDemo_intro/ZoneOffsetDemo/.project b/BasicJava/ZoneOffsetDemo_intro/ZoneOffsetDemo/.project new file mode 100644 index 000000000..51864dba3 --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_intro/ZoneOffsetDemo/.project @@ -0,0 +1,17 @@ + + + ZoneOffsetDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ZoneOffsetDemo_intro/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ZoneOffsetDemo_intro/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_intro/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ZoneOffsetDemo_intro/ZoneOffsetDemo/bin/ZoneOffsetDemo.class b/BasicJava/ZoneOffsetDemo_intro/ZoneOffsetDemo/bin/ZoneOffsetDemo.class new file mode 100644 index 000000000..012899124 Binary files /dev/null and b/BasicJava/ZoneOffsetDemo_intro/ZoneOffsetDemo/bin/ZoneOffsetDemo.class differ diff --git a/BasicJava/ZoneOffsetDemo_intro/ZoneOffsetDemo/src/ZoneOffsetDemo.java b/BasicJava/ZoneOffsetDemo_intro/ZoneOffsetDemo/src/ZoneOffsetDemo.java new file mode 100644 index 000000000..b27a4f6c2 --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_intro/ZoneOffsetDemo/src/ZoneOffsetDemo.java @@ -0,0 +1,28 @@ +import java.time.ZoneOffset; + +public class ZoneOffsetDemo +{ + + public static void main(String[] args) + { + + /* + * Constant for the minimum supported offset. + */ + ZoneOffset zoneOffsetMin = ZoneOffset.MIN; + System.out.println("zoneOffsetMin = " + zoneOffsetMin); + + /* + * Constant for the maximum supported offset. + */ + ZoneOffset zoneOffsetMax = ZoneOffset.MAX; + System.out.println("zoneOffsetMax = " + zoneOffsetMax); + + /* + * The time-zone offset for UTC, with an ID of 'Z'. + */ + ZoneOffset zoneOffsetUtc = ZoneOffset.UTC; + System.out.println("zoneOffsetUtc = " + zoneOffsetUtc); + } + +} diff --git a/BasicJava/ZoneOffsetDemo_of/Output.txt b/BasicJava/ZoneOffsetDemo_of/Output.txt new file mode 100644 index 000000000..139ba3b7c --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_of/Output.txt @@ -0,0 +1 @@ +zoneOffset = +01:00 diff --git a/BasicJava/ZoneOffsetDemo_of/ZoneOffsetDemo/.classpath b/BasicJava/ZoneOffsetDemo_of/ZoneOffsetDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_of/ZoneOffsetDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ZoneOffsetDemo_of/ZoneOffsetDemo/.project b/BasicJava/ZoneOffsetDemo_of/ZoneOffsetDemo/.project new file mode 100644 index 000000000..51864dba3 --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_of/ZoneOffsetDemo/.project @@ -0,0 +1,17 @@ + + + ZoneOffsetDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ZoneOffsetDemo_of/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ZoneOffsetDemo_of/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_of/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ZoneOffsetDemo_of/ZoneOffsetDemo/bin/ZoneOffsetDemo.class b/BasicJava/ZoneOffsetDemo_of/ZoneOffsetDemo/bin/ZoneOffsetDemo.class new file mode 100644 index 000000000..feb434c96 Binary files /dev/null and b/BasicJava/ZoneOffsetDemo_of/ZoneOffsetDemo/bin/ZoneOffsetDemo.class differ diff --git a/BasicJava/ZoneOffsetDemo_of/ZoneOffsetDemo/src/ZoneOffsetDemo.java b/BasicJava/ZoneOffsetDemo_of/ZoneOffsetDemo/src/ZoneOffsetDemo.java new file mode 100644 index 000000000..beb8fd39b --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_of/ZoneOffsetDemo/src/ZoneOffsetDemo.java @@ -0,0 +1,25 @@ +import java.time.ZoneOffset; + +public class ZoneOffsetDemo +{ + + public static void main(String[] args) + { + + /* + * Parameters: + * + * offsetId - the offset ID, not null + * + * Returns: + * + * the zone-offset, not null + * + */ + ZoneOffset zoneOffset = ZoneOffset.of("+01:00"); + + System.out.println("zoneOffset = " + zoneOffset); + + } + +} diff --git a/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/.classpath b/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/.project b/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/.project new file mode 100644 index 000000000..51864dba3 --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/.project @@ -0,0 +1,17 @@ + + + ZoneOffsetDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/bin/ZoneOffsetDemo1.class b/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/bin/ZoneOffsetDemo1.class new file mode 100644 index 000000000..95f5080d2 Binary files /dev/null and b/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/bin/ZoneOffsetDemo1.class differ diff --git a/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/bin/ZoneOffsetDemo2.class b/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/bin/ZoneOffsetDemo2.class new file mode 100644 index 000000000..3089a1873 Binary files /dev/null and b/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/bin/ZoneOffsetDemo2.class differ diff --git a/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/bin/ZoneOffsetDemo3.class b/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/bin/ZoneOffsetDemo3.class new file mode 100644 index 000000000..2012b787b Binary files /dev/null and b/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/bin/ZoneOffsetDemo3.class differ diff --git a/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/bin/ZoneOffsetDemo4.class b/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/bin/ZoneOffsetDemo4.class new file mode 100644 index 000000000..f88e75dde Binary files /dev/null and b/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/bin/ZoneOffsetDemo4.class differ diff --git a/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/src/ZoneOffsetDemo1.java b/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/src/ZoneOffsetDemo1.java new file mode 100644 index 000000000..35fa49e09 --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/src/ZoneOffsetDemo1.java @@ -0,0 +1,23 @@ +import java.time.ZoneOffset; + +public class ZoneOffsetDemo1 +{ + + public static void main(String[] args) + { + + /* + * Parameters: + * + * hours - the time-zone offset in hours, from -18 to +18 + * + * Returns: + * + * the zone-offset, not null + */ + ZoneOffset zoneOffset = ZoneOffset.ofHours(4); + System.out.println("zoneOffset = " + zoneOffset); + + } + +} diff --git a/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/src/ZoneOffsetDemo2.java b/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/src/ZoneOffsetDemo2.java new file mode 100644 index 000000000..72649436b --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/src/ZoneOffsetDemo2.java @@ -0,0 +1,26 @@ +import java.time.ZoneOffset; + +public class ZoneOffsetDemo2 +{ + + public static void main(String[] args) + { + + /* + * Parameters: + * + * hours - the time-zone offset in hours, from -18 to +18 + * + * minutes - the time-zone offset in minutes, from 0 to ±59, + * sign matches hours + * + * Returns: + * + * the zone-offset, not null + */ + ZoneOffset zoneOffset = ZoneOffset.ofHoursMinutes(5, 30); + System.out.println("zoneOffset = " + zoneOffset); + + } + +} diff --git a/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/src/ZoneOffsetDemo3.java b/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/src/ZoneOffsetDemo3.java new file mode 100644 index 000000000..1b2840a47 --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/src/ZoneOffsetDemo3.java @@ -0,0 +1,29 @@ +import java.time.ZoneOffset; + +public class ZoneOffsetDemo3 +{ + + public static void main(String[] args) + { + + /* + * Parameters: + * + * hours - the time-zone offset in hours, from -18 to +18 + * + * minutes - the time-zone offset in minutes, from 0 to ±59, + * sign matches hours + * + * seconds - the time-zone offset in seconds, from 0 to ±59, + * sign matches hours and minutes + * + * Returns: + * + * the zone-offset, not null + */ + ZoneOffset zoneOffset = ZoneOffset.ofHoursMinutesSeconds(5,30,20); + System.out.println("zoneOffset = " + zoneOffset); + + } + +} diff --git a/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/src/ZoneOffsetDemo4.java b/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/src/ZoneOffsetDemo4.java new file mode 100644 index 000000000..75a27b180 --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo/src/ZoneOffsetDemo4.java @@ -0,0 +1,24 @@ +import java.time.ZoneOffset; + +public class ZoneOffsetDemo4 +{ + + public static void main(String[] args) + { + + /* + * Parameters: + * + * totalSeconds - the total time-zone offset in seconds, from + * -64800 to +64800 + * + * Returns: + * + * the zone-offset, not null + */ + ZoneOffset zoneOffset = ZoneOffset.ofTotalSeconds(7200); + System.out.println("zoneOffset = " + zoneOffset); + + } + +} diff --git a/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo1_Output.txt b/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo1_Output.txt new file mode 100644 index 000000000..3ee589358 --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo1_Output.txt @@ -0,0 +1 @@ +zoneOffset = +04:00 diff --git a/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo2_Output.txt b/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo2_Output.txt new file mode 100644 index 000000000..8f80bfd22 --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo2_Output.txt @@ -0,0 +1 @@ +zoneOffset = +05:30 diff --git a/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo3_Output.txt b/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo3_Output.txt new file mode 100644 index 000000000..8723dfa72 --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo3_Output.txt @@ -0,0 +1 @@ +zoneOffset = +05:30:20 diff --git a/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo4_Output.txt b/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo4_Output.txt new file mode 100644 index 000000000..55e28df88 --- /dev/null +++ b/BasicJava/ZoneOffsetDemo_ofhours_mins/ZoneOffsetDemo4_Output.txt @@ -0,0 +1 @@ +zoneOffset = +02:00 diff --git a/BasicJava_2018/CalendarDemo_Intro/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_Intro/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_Intro/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_Intro/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_Intro/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_Intro/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_Intro/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_Intro/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_Intro/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_Intro/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_Intro/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..f6584ea27 Binary files /dev/null and b/BasicJava_2018/CalendarDemo_Intro/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_Intro/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_Intro/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..98f35492e --- /dev/null +++ b/BasicJava_2018/CalendarDemo_Intro/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,25 @@ +import java.util.Calendar; +import java.util.Date; + +public class CalendarDemo +{ + public static void main(String[] args) + { + /* + * Gets a calendar using the default time zone and locale. The + * Calendar returned is based on the current time in the + * default time zone with the default FORMAT locale. + * + */ + Calendar cal = Calendar.getInstance(); + System.out.println(cal); + + /* + * Returns:a Date representing the time value. + */ + Date date = cal.getTime(); + System.out.print("Date and Time is = " + date); + + } + +} diff --git a/BasicJava_2018/CalendarDemo_Intro/Output.txt b/BasicJava_2018/CalendarDemo_Intro/Output.txt new file mode 100644 index 000000000..95d7652a2 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_Intro/Output.txt @@ -0,0 +1,2 @@ +java.util.GregorianCalendar[time=1526273176383,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Asia/Calcutta",offset=19800000,dstSavings=0,useDaylight=false,transitions=6,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2018,MONTH=4,WEEK_OF_YEAR=20,WEEK_OF_MONTH=3,DAY_OF_MONTH=14,DAY_OF_YEAR=134,DAY_OF_WEEK=2,DAY_OF_WEEK_IN_MONTH=2,AM_PM=0,HOUR=10,HOUR_OF_DAY=10,MINUTE=16,SECOND=16,MILLISECOND=383,ZONE_OFFSET=19800000,DST_OFFSET=0] +Date and Time is = Mon May 14 10:16:16 IST 2018 \ No newline at end of file diff --git a/BasicJava_2018/CalendarDemo_add/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_add/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_add/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_add/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_add/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_add/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_add/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_add/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_add/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_add/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_add/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..0133b150f Binary files /dev/null and b/BasicJava_2018/CalendarDemo_add/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_add/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_add/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..367d1130a --- /dev/null +++ b/BasicJava_2018/CalendarDemo_add/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,30 @@ +import java.util.Calendar; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + System.out.println("The current date is = " + cal.getTime()); + + /* + * Parameters: + * + * field - the calendar field. + * + * amount - the amount of date or time to be added to the field. + */ + + // add 20 days to the calendar + cal.add(Calendar.DATE, 20); + System.out.println("20 days later = " + cal.getTime()); + + // add 3 months to the calendar + cal.add(Calendar.MONTH, 3); + System.out.println("3 months later = " + cal.getTime()); + + // add 10 years to the calendar + cal.add(Calendar.YEAR, 10); + System.out.println("10 years later = " + cal.getTime()); + } +} diff --git a/BasicJava_2018/CalendarDemo_add/Output.txt b/BasicJava_2018/CalendarDemo_add/Output.txt new file mode 100644 index 000000000..efcc659a6 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_add/Output.txt @@ -0,0 +1,4 @@ +The current date is = Sat Jun 30 08:58:24 IST 2018 +20 days later = Fri Jul 20 08:58:24 IST 2018 +3 months later = Sat Oct 20 08:58:24 IST 2018 +10 years later = Fri Oct 20 08:58:24 IST 2028 diff --git a/BasicJava_2018/CalendarDemo_add_substract/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_add_substract/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_add_substract/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_add_substract/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_add_substract/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_add_substract/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_add_substract/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_add_substract/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_add_substract/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_add_substract/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_add_substract/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..7312752f9 Binary files /dev/null and b/BasicJava_2018/CalendarDemo_add_substract/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_add_substract/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_add_substract/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..e4d9d332c --- /dev/null +++ b/BasicJava_2018/CalendarDemo_add_substract/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,26 @@ +import java.util.Calendar; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + System.out.println("The current date is = " + cal.getTime()); + + /* + * Parameters: + * + * field - the calendar field. + * + * amount - the amount of date or time to be added to the field. + */ + + // subtract 3 months from the calendar + cal.add(Calendar.MONTH, -3); + System.out.println("3 months ago = " + cal.getTime()); + + // subtract 10 years from the calendar + cal.add(Calendar.YEAR, -10); + System.out.println("10 years ago = " + cal.getTime()); + } +} diff --git a/BasicJava_2018/CalendarDemo_add_substract/Output.txt b/BasicJava_2018/CalendarDemo_add_substract/Output.txt new file mode 100644 index 000000000..f68352d40 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_add_substract/Output.txt @@ -0,0 +1,3 @@ +The current date is = Sat Jun 30 09:07:01 IST 2018 +3 months ago = Fri Mar 30 09:07:01 IST 2018 +10 years ago = Sun Mar 30 09:07:01 IST 2008 diff --git a/BasicJava_2018/CalendarDemo_before_after/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_before_after/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_before_after/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_before_after/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_before_after/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_before_after/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_before_after/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_before_after/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_before_after/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_before_after/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_before_after/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..151fed208 Binary files /dev/null and b/BasicJava_2018/CalendarDemo_before_after/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_before_after/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_before_after/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..bed5f5daf --- /dev/null +++ b/BasicJava_2018/CalendarDemo_before_after/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,41 @@ +import java.util.Calendar; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal1 = Calendar.getInstance(); + System.out.println("Current date = " + cal1.getTime()); + + Calendar cal2 = Calendar.getInstance(); + cal2.set(Calendar.YEAR, 2030); + System.out.println("future date = " + cal2.getTime()); + + /* + * Parameters: + * + * when - the Object to be compared + * + * Returns: + * + * true if the time of this Calendar is before the time + * represented by when; false otherwise. + */ + boolean isBefore = cal1.before(cal2); + System.out.println("is cal1 before cal2 = " + isBefore); + + /* + * Parameters: + * + * when - the Object to be compared + * + * Returns: + * + * true if the time of this Calendar is after the time + * represented by when; false otherwise. + */ + boolean isAfter = cal1.after(cal2); + System.out.println("is cal1 After cal2 = " + isAfter); + + } +} diff --git a/BasicJava_2018/CalendarDemo_before_after/Output.txt b/BasicJava_2018/CalendarDemo_before_after/Output.txt new file mode 100644 index 000000000..ee4e1f70f --- /dev/null +++ b/BasicJava_2018/CalendarDemo_before_after/Output.txt @@ -0,0 +1,4 @@ +Current date = Tue Jul 03 09:39:19 IST 2018 +future date = Wed Jul 03 09:39:20 IST 2030 +is cal1 before cal2 = true +is cal1 After cal2 = false diff --git a/BasicJava_2018/CalendarDemo_clear/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_clear/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_clear/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_clear/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_clear/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_clear/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_clear/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_clear/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_clear/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_clear/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_clear/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..44083cfb0 Binary files /dev/null and b/BasicJava_2018/CalendarDemo_clear/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_clear/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_clear/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..95bdbd6ff --- /dev/null +++ b/BasicJava_2018/CalendarDemo_clear/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,19 @@ +import java.util.Calendar; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + + System.out.println("Before clear = " + cal.getTime()); + + /* + * use clear method to set all field values and time value as + * undefined. + */ + cal.clear(); + + System.out.println("After clear = " + cal.getTime()); + } +} diff --git a/BasicJava_2018/CalendarDemo_clear/Output.txt b/BasicJava_2018/CalendarDemo_clear/Output.txt new file mode 100644 index 000000000..666a3a08b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_clear/Output.txt @@ -0,0 +1,2 @@ +Before clear = Sun Jul 01 10:42:33 IST 2018 +After clear = Thu Jan 01 00:00:00 IST 1970 diff --git a/BasicJava_2018/CalendarDemo_clear_field/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_clear_field/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_clear_field/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_clear_field/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_clear_field/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_clear_field/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_clear_field/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_clear_field/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_clear_field/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_clear_field/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_clear_field/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..072b03140 Binary files /dev/null and b/BasicJava_2018/CalendarDemo_clear_field/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_clear_field/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_clear_field/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..286837f2a --- /dev/null +++ b/BasicJava_2018/CalendarDemo_clear_field/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,20 @@ +import java.util.Calendar; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + + System.out.println("Before clear = " + cal.getTime()); + + /* + * Parameters: + * + * field - the calendar field to be cleared. + */ + cal.clear(Calendar.YEAR); + + System.out.println("After clear = " + cal.getTime()); + } +} diff --git a/BasicJava_2018/CalendarDemo_clear_field/Output.txt b/BasicJava_2018/CalendarDemo_clear_field/Output.txt new file mode 100644 index 000000000..9566e4292 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_clear_field/Output.txt @@ -0,0 +1,2 @@ +Before clear = Sun Jul 01 10:50:38 IST 2018 +After clear = Wed Jul 01 10:50:38 IST 1970 diff --git a/BasicJava_2018/CalendarDemo_clone/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_clone/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_clone/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_clone/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_clone/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_clone/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_clone/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_clone/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_clone/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_clone/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_clone/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..8f139f6ca Binary files /dev/null and b/BasicJava_2018/CalendarDemo_clone/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_clone/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_clone/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..d58996923 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_clone/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,20 @@ +import java.util.Calendar; +import java.util.GregorianCalendar; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal1 = new GregorianCalendar(2013, 05, 20); + + System.out.println("cal1 = " + cal1.getTime()); + + /* + * Returns:a copy of this object. + */ + Calendar cal2 = (Calendar) cal1.clone(); + + System.out.println("Cloned cal2 = " + cal2.getTime()); + + } +} diff --git a/BasicJava_2018/CalendarDemo_clone/Output.txt b/BasicJava_2018/CalendarDemo_clone/Output.txt new file mode 100644 index 000000000..b469d6148 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_clone/Output.txt @@ -0,0 +1,2 @@ +cal1 = Thu Jun 20 00:00:00 IST 2013 +Cloned cal2 = Thu Jun 20 00:00:00 IST 2013 diff --git a/BasicJava_2018/CalendarDemo_compareTo/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_compareTo/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_compareTo/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_compareTo/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_compareTo/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_compareTo/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_compareTo/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_compareTo/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_compareTo/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_compareTo/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_compareTo/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..67720888c Binary files /dev/null and b/BasicJava_2018/CalendarDemo_compareTo/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_compareTo/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_compareTo/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..6ebf78330 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_compareTo/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,33 @@ +import java.util.Calendar; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal1 = Calendar.getInstance(); + System.out.println("Current date = " + cal1.getTime()); + + Calendar cal2 = Calendar.getInstance(); + cal2.set(Calendar.YEAR, 2030); + System.out.println("future date = " + cal2.getTime()); + + /* + * Parameters: + * + * anotherCalendar - the Calendar to be compared. + * + * Returns: + * + * the value 0 if the time represented by the argument is + * equal to the time represented by this Calendar; a value + * less than 0 if the time of this Calendar is before the time + * represented by the argument; and a value greater than 0 if + * the time of this Calendar is after the time represented by + * the argument. + */ + + int result = cal1.compareTo(cal2); + System.out.println("result = " + result); + + } +} diff --git a/BasicJava_2018/CalendarDemo_compareTo/Output.txt b/BasicJava_2018/CalendarDemo_compareTo/Output.txt new file mode 100644 index 000000000..0c1666f8b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_compareTo/Output.txt @@ -0,0 +1,3 @@ +Current date = Wed Jul 04 09:29:23 IST 2018 +future date = Thu Jul 04 09:29:24 IST 2030 +result = -1 diff --git a/BasicJava_2018/CalendarDemo_display_month_dayofweek/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_display_month_dayofweek/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_display_month_dayofweek/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_display_month_dayofweek/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_display_month_dayofweek/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_display_month_dayofweek/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_display_month_dayofweek/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_display_month_dayofweek/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_display_month_dayofweek/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_display_month_dayofweek/CalendarDemo/bin/CalendarDemo1.class b/BasicJava_2018/CalendarDemo_display_month_dayofweek/CalendarDemo/bin/CalendarDemo1.class new file mode 100644 index 000000000..daface4e7 Binary files /dev/null and b/BasicJava_2018/CalendarDemo_display_month_dayofweek/CalendarDemo/bin/CalendarDemo1.class differ diff --git a/BasicJava_2018/CalendarDemo_display_month_dayofweek/CalendarDemo/bin/CalendarDemo2.class b/BasicJava_2018/CalendarDemo_display_month_dayofweek/CalendarDemo/bin/CalendarDemo2.class new file mode 100644 index 000000000..7ae66a2ec Binary files /dev/null and b/BasicJava_2018/CalendarDemo_display_month_dayofweek/CalendarDemo/bin/CalendarDemo2.class differ diff --git a/BasicJava_2018/CalendarDemo_display_month_dayofweek/CalendarDemo/src/CalendarDemo1.java b/BasicJava_2018/CalendarDemo_display_month_dayofweek/CalendarDemo/src/CalendarDemo1.java new file mode 100644 index 000000000..7f89d708e --- /dev/null +++ b/BasicJava_2018/CalendarDemo_display_month_dayofweek/CalendarDemo/src/CalendarDemo1.java @@ -0,0 +1,60 @@ +import java.util.Calendar; + +public class CalendarDemo1 +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + System.out.println(cal.getTime()); + + int month = cal.get(Calendar.MONTH); + if (month == Calendar.JANUARY) + { + System.out.println("JANUARY"); + } + if (month == Calendar.FEBRUARY) + { + System.out.println("FEBRUARY"); + } + if (month == Calendar.MARCH) + { + System.out.println("MARCH"); + } + if (month == Calendar.APRIL) + { + System.out.println("APRIL"); + } + if (month == Calendar.MAY) + { + System.out.println("MAY"); + } + if (month == Calendar.JUNE) + { + System.out.println("JUNE"); + } + if (month == Calendar.JULY) + { + System.out.println("JULY"); + } + if (month == Calendar.AUGUST) + { + System.out.println("AUGUST"); + } + if (month == Calendar.SEPTEMBER) + { + System.out.println("SEPTEMBER"); + } + if (month == Calendar.OCTOBER) + { + System.out.println("OCTOBER"); + } + if (month == Calendar.NOVEMBER) + { + System.out.println("NOVEMBER"); + } + if (month == Calendar.DECEMBER) + { + System.out.println("DECEMBER"); + } + } +} diff --git a/BasicJava_2018/CalendarDemo_display_month_dayofweek/CalendarDemo/src/CalendarDemo2.java b/BasicJava_2018/CalendarDemo_display_month_dayofweek/CalendarDemo/src/CalendarDemo2.java new file mode 100644 index 000000000..4d02e9982 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_display_month_dayofweek/CalendarDemo/src/CalendarDemo2.java @@ -0,0 +1,41 @@ +import java.util.Calendar; + +public class CalendarDemo2 +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + System.out.println(cal.getTime()); + + int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK); + if (Calendar.SUNDAY == dayOfWeek) + { + System.out.println("SUNDAY"); + } + if (Calendar.MONDAY == dayOfWeek) + { + System.out.println("MONDAY"); + } + if (Calendar.TUESDAY == dayOfWeek) + { + System.out.println("TUESDAY"); + } + if (Calendar.WEDNESDAY == dayOfWeek) + { + System.out.println("WEDNESDAY"); + } + if (Calendar.THURSDAY == dayOfWeek) + { + System.out.println("THURSDAY"); + } + if (Calendar.FRIDAY == dayOfWeek) + { + System.out.println("FRIDAY"); + } + if (Calendar.SATURDAY == dayOfWeek) + { + System.out.println("SATURDAY"); + } + } + +} diff --git a/BasicJava_2018/CalendarDemo_display_month_dayofweek/CalendarDemo1_Output.txt b/BasicJava_2018/CalendarDemo_display_month_dayofweek/CalendarDemo1_Output.txt new file mode 100644 index 000000000..7b85a175f --- /dev/null +++ b/BasicJava_2018/CalendarDemo_display_month_dayofweek/CalendarDemo1_Output.txt @@ -0,0 +1,2 @@ +Sat Jul 07 09:18:04 IST 2018 +JULY diff --git a/BasicJava_2018/CalendarDemo_display_month_dayofweek/CalendarDemo2_Output.txt b/BasicJava_2018/CalendarDemo_display_month_dayofweek/CalendarDemo2_Output.txt new file mode 100644 index 000000000..c911f3ad0 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_display_month_dayofweek/CalendarDemo2_Output.txt @@ -0,0 +1,2 @@ +Sat Jul 07 09:18:11 IST 2018 +SATURDAY diff --git a/BasicJava_2018/CalendarDemo_equals/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_equals/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_equals/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_equals/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_equals/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_equals/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_equals/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_equals/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_equals/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_equals/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_equals/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..324a67378 Binary files /dev/null and b/BasicJava_2018/CalendarDemo_equals/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_equals/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_equals/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..ff175e027 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_equals/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,28 @@ +import java.util.Calendar; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal1 = Calendar.getInstance(); + System.out.println("Current date = " + cal1.getTime()); + + Calendar cal2 = Calendar.getInstance(); + cal2.set(Calendar.YEAR, 2030); + System.out.println("future date = " + cal2.getTime()); + + /* + * Parameters: + * + * obj - the object to compare with. + * + * Returns: + * + * true if this object is equal to obj; false otherwise. + */ + + boolean isEqual = cal1.equals(cal2); + System.out.println("is cal1 equals cal2 = " + isEqual); + + } +} diff --git a/BasicJava_2018/CalendarDemo_equals/Output.txt b/BasicJava_2018/CalendarDemo_equals/Output.txt new file mode 100644 index 000000000..ffb81a1c5 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_equals/Output.txt @@ -0,0 +1,3 @@ +Current date = Tue Jul 03 09:47:27 IST 2018 +future date = Wed Jul 03 09:47:34 IST 2030 +is cal1 equals cal2 = false diff --git a/BasicJava_2018/CalendarDemo_getActualMaximum/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_getActualMaximum/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getActualMaximum/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_getActualMaximum/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_getActualMaximum/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getActualMaximum/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_getActualMaximum/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_getActualMaximum/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getActualMaximum/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_getActualMaximum/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_getActualMaximum/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..6edae8eaa Binary files /dev/null and b/BasicJava_2018/CalendarDemo_getActualMaximum/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_getActualMaximum/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_getActualMaximum/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..84effe5a7 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getActualMaximum/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,30 @@ +import java.util.Calendar; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + + /* + * Parameters: + * + * field - the calendar field + * + * Returns: + * + * the maximum of the given calendar field for the time value + * of this Calendar + */ + + // get the maximum value that year field can have + int maxYear = cal.getActualMaximum(Calendar.YEAR); + System.out.println("Maximum year = " + maxYear); + + // get the maximum value that month field can have + int maxMonth = cal.getActualMaximum(Calendar.MONTH); + System.out.println("Maximum month = " + maxMonth); + + } + +} diff --git a/BasicJava_2018/CalendarDemo_getActualMaximum/Output.txt b/BasicJava_2018/CalendarDemo_getActualMaximum/Output.txt new file mode 100644 index 000000000..a351c3a45 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getActualMaximum/Output.txt @@ -0,0 +1,2 @@ +Maximum year = 292278994 +Maximum month = 11 diff --git a/BasicJava_2018/CalendarDemo_getActualMinimum/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_getActualMinimum/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getActualMinimum/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_getActualMinimum/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_getActualMinimum/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getActualMinimum/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_getActualMinimum/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_getActualMinimum/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getActualMinimum/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_getActualMinimum/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_getActualMinimum/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..703b12f11 Binary files /dev/null and b/BasicJava_2018/CalendarDemo_getActualMinimum/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_getActualMinimum/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_getActualMinimum/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..879de0e78 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getActualMinimum/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,32 @@ +import java.util.Calendar; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + + /* + * public int getActualMinimum(int field) + * + * Parameters: + * + * field - the calendar field + * + * Returns: + * + * the minimum of the given calendar field for the time value + * of this Calendar + */ + + // get the minimum value that year field can have + int minYear = cal.getActualMinimum(Calendar.YEAR); + System.out.println("Minimum year = " + minYear); + + // get the minimum value that month field can have + int minMonth = cal.getActualMinimum(Calendar.MONTH); + System.out.println("Minimum month = " + minMonth); + + } + +} diff --git a/BasicJava_2018/CalendarDemo_getActualMinimum/Output.txt b/BasicJava_2018/CalendarDemo_getActualMinimum/Output.txt new file mode 100644 index 000000000..62f653fcd --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getActualMinimum/Output.txt @@ -0,0 +1,2 @@ +Minimum year = 1 +Minimum month = 0 diff --git a/BasicJava_2018/CalendarDemo_getDisplayName/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_getDisplayName/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getDisplayName/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_getDisplayName/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_getDisplayName/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getDisplayName/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_getDisplayName/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_getDisplayName/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getDisplayName/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_getDisplayName/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_getDisplayName/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..e3e72e3a3 Binary files /dev/null and b/BasicJava_2018/CalendarDemo_getDisplayName/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_getDisplayName/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_getDisplayName/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..e00ba6a2f --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getDisplayName/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,44 @@ +import java.util.Calendar; +import java.util.Locale; + +/** + * public String getDisplayName(int field, int style, Locale locale) + * + * Returns the string representation of the calendar field value in + * the given style and locale. + * + * Parameters: + * + * field - the calendar field for which the string representation is + * returned + * + * style - the style applied to the string representation; one of + * SHORT_FORMAT (SHORT), SHORT_STANDALONE, LONG_FORMAT (LONG), + * LONG_STANDALONE, NARROW_FORMAT, or NARROW_STANDALONE. + * + * locale - the locale for the string representation (any calendar + * types specified by locale are ignored) + * + * Returns: + * + * the string representation of the given field in the given style, or + * null if no string representation is applicable. + */ +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + Locale locale = Locale.getDefault(); + System.out.println("locale = " + locale); + + String displayName = cal.getDisplayName(Calendar.DAY_OF_WEEK, + Calendar.LONG, locale); + System.out.println("Long format = " + displayName); + + displayName = cal.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, + locale); + System.out.println("Short format = " + displayName); + + } +} diff --git a/BasicJava_2018/CalendarDemo_getDisplayName/Output.txt b/BasicJava_2018/CalendarDemo_getDisplayName/Output.txt new file mode 100644 index 000000000..6421c7bb3 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getDisplayName/Output.txt @@ -0,0 +1,3 @@ +locale = en_US +Long format = Friday +Short format = Fri diff --git a/BasicJava_2018/CalendarDemo_getDisplayNames_map/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_getDisplayNames_map/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getDisplayNames_map/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_getDisplayNames_map/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_getDisplayNames_map/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getDisplayNames_map/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_getDisplayNames_map/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_getDisplayNames_map/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getDisplayNames_map/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_getDisplayNames_map/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_getDisplayNames_map/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..18e0d0f0d Binary files /dev/null and b/BasicJava_2018/CalendarDemo_getDisplayNames_map/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_getDisplayNames_map/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_getDisplayNames_map/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..21490e5e2 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getDisplayNames_map/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,39 @@ +import java.util.Calendar; +import java.util.Locale; +import java.util.Map; +/** + * public Map getDisplayNames(int field, int + * style, Locale locale) + * + * Parameters: + * + * field - the calendar field for which the display names are + * returned + * + * style - the style applied to the string representation; one + * of SHORT_FORMAT (SHORT), SHORT_STANDALONE, LONG_FORMAT + * (LONG), LONG_STANDALONE, NARROW_FORMAT, or + * NARROW_STANDALONE + * + * locale - the locale for the display names + * + * Returns: + * + * a Map containing all display names in style and locale and + * their field values, or null if no display names are defined + * for field + */ +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + Locale locale = Locale.getDefault(); + System.out.println(locale); + Map map = cal.getDisplayNames(Calendar.DAY_OF_WEEK, + Calendar.LONG, locale); + System.out.println(map); + + } + +} diff --git a/BasicJava_2018/CalendarDemo_getDisplayNames_map/Output.txt b/BasicJava_2018/CalendarDemo_getDisplayNames_map/Output.txt new file mode 100644 index 000000000..7fa82c493 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getDisplayNames_map/Output.txt @@ -0,0 +1,2 @@ +en_US +{Monday=2, Thursday=5, Friday=6, Sunday=1, Wednesday=4, Tuesday=3, Saturday=7} diff --git a/BasicJava_2018/CalendarDemo_getFirstDayOfWeek/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_getFirstDayOfWeek/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getFirstDayOfWeek/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_getFirstDayOfWeek/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_getFirstDayOfWeek/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getFirstDayOfWeek/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_getFirstDayOfWeek/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_getFirstDayOfWeek/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getFirstDayOfWeek/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_getFirstDayOfWeek/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_getFirstDayOfWeek/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..972e8d74b Binary files /dev/null and b/BasicJava_2018/CalendarDemo_getFirstDayOfWeek/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_getFirstDayOfWeek/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_getFirstDayOfWeek/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..dddbdaa11 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getFirstDayOfWeek/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,40 @@ +import java.util.Calendar; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + + /* + * Returns:the first day of the week. + */ + int firstDayOfTheWeek = cal.getFirstDayOfWeek(); + + System.out.println("firstDayOfTheWeek = " + firstDayOfTheWeek); + + switch (firstDayOfTheWeek) { + case (1): + System.out.println("Sunday"); + break; + case (2): + System.out.println("Monday"); + break; + case 3: + System.out.println("Tuesday"); + break; + case 4: + System.out.println("Wednesday"); + break; + case 5: + System.out.println("Thrusday"); + break; + case 6: + System.out.println("Friday"); + break; + case 7: + System.out.println("Saturday"); + break; + } + } +} diff --git a/BasicJava_2018/CalendarDemo_getFirstDayOfWeek/Output.txt b/BasicJava_2018/CalendarDemo_getFirstDayOfWeek/Output.txt new file mode 100644 index 000000000..6642604a6 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getFirstDayOfWeek/Output.txt @@ -0,0 +1,2 @@ +firstDayOfTheWeek = 1 +Sunday diff --git a/BasicJava_2018/CalendarDemo_getGreatestMinimum/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_getGreatestMinimum/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getGreatestMinimum/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_getGreatestMinimum/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_getGreatestMinimum/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getGreatestMinimum/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_getGreatestMinimum/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_getGreatestMinimum/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getGreatestMinimum/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_getGreatestMinimum/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_getGreatestMinimum/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..7ea7f52b5 Binary files /dev/null and b/BasicJava_2018/CalendarDemo_getGreatestMinimum/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_getGreatestMinimum/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_getGreatestMinimum/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..52d6ed498 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getGreatestMinimum/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,34 @@ +import java.util.Calendar; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + + /* + * Parameters: + * + * field - the calendar field. + * + * Returns: + * + * the highest minimum value for the given calendar field. + */ + int greatestMinimum = cal.getGreatestMinimum(Calendar.YEAR); + System.out.println("greatestMinimum = " + greatestMinimum); + + /* + * Parameters: + * + * field - the calendar field. + * + * Returns: + * + * the lowest maximum value for the given calendar field. + * + */ + int leastMaximum = cal.getLeastMaximum(Calendar.YEAR); + System.out.println("leastMaximum = " + leastMaximum); + } +} diff --git a/BasicJava_2018/CalendarDemo_getGreatestMinimum/Output.txt b/BasicJava_2018/CalendarDemo_getGreatestMinimum/Output.txt new file mode 100644 index 000000000..4353dcd80 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getGreatestMinimum/Output.txt @@ -0,0 +1,2 @@ +greatestMinimum = 1 +leastMaximum = 292269054 diff --git a/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo/bin/CalendarDemo1.class b/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo/bin/CalendarDemo1.class new file mode 100644 index 000000000..311f61fe3 Binary files /dev/null and b/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo/bin/CalendarDemo1.class differ diff --git a/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo/bin/CalendarDemo2.class b/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo/bin/CalendarDemo2.class new file mode 100644 index 000000000..6e9771ddd Binary files /dev/null and b/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo/bin/CalendarDemo2.class differ diff --git a/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo/bin/CalendarDemo3.class b/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo/bin/CalendarDemo3.class new file mode 100644 index 000000000..e6b8383fe Binary files /dev/null and b/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo/bin/CalendarDemo3.class differ diff --git a/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo/src/CalendarDemo1.java b/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo/src/CalendarDemo1.java new file mode 100644 index 000000000..763b65e98 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo/src/CalendarDemo1.java @@ -0,0 +1,33 @@ +import java.util.Calendar; +import java.util.Date; +import java.util.Locale; + +/** + * public static Calendar getInstance(Locale aLocale) + * + * Gets a calendar using the default time zone and specified locale. + * The Calendar returned is based on the current time in the default + * time zone with the given locale. + * + * Parameters: + * + * aLocale - the locale for the week data + * + * Returns: + * + * a Calendar. + */ + +public class CalendarDemo1 +{ + public static void main(String[] args) + { + + Calendar cal = Calendar.getInstance(Locale.FRENCH); + + Date date = cal.getTime(); + System.out.print("Date and Time is = " + date); + + } + +} diff --git a/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo/src/CalendarDemo2.java b/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo/src/CalendarDemo2.java new file mode 100644 index 000000000..34fa31043 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo/src/CalendarDemo2.java @@ -0,0 +1,35 @@ +import java.util.Calendar; +import java.util.Date; +import java.util.TimeZone; + +/** + * public static Calendar getInstance(TimeZone zone) + * + * Gets a calendar using the specified time zone and default locale. + * The Calendar returned is based on the current time in the given + * time zone with the default FORMAT locale. + * + * Parameters: + * + * zone - the time zone to use + * + * Returns: + * + * a Calendar. + * + */ +public class CalendarDemo2 +{ + public static void main(String[] args) + { + TimeZone timeZone = TimeZone.getDefault(); + System.out.println(timeZone.getDisplayName()); + + Calendar cal = Calendar.getInstance(timeZone); + + Date date = cal.getTime(); + System.out.print("Date and Time is = " + date); + + } + +} diff --git a/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo/src/CalendarDemo3.java b/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo/src/CalendarDemo3.java new file mode 100644 index 000000000..210106105 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo/src/CalendarDemo3.java @@ -0,0 +1,41 @@ +import java.util.Calendar; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; + +/** + * public static Calendar getInstance(TimeZone zone, Locale aLocale) + * + * Gets a calendar with the specified time zone and locale. The + * Calendar returned is based on the current time in the given time + * zone with the given locale. + * + * Parameters: + * + * zone - the time zone to use + * + * aLocale - the locale for the week data + * + * Returns: + * + * a Calendar. + */ + +public class CalendarDemo3 +{ + public static void main(String[] args) + { + Locale locale = Locale.US; + System.out.println(locale); + + TimeZone timeZone = TimeZone.getDefault(); + System.out.println(timeZone.getDisplayName()); + + Calendar cal = Calendar.getInstance(timeZone, locale); + + Date date = cal.getTime(); + System.out.print("Date and Time is = " + date); + + } + +} diff --git a/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo1_Output.txt b/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo1_Output.txt new file mode 100644 index 000000000..03c8ba5f6 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo1_Output.txt @@ -0,0 +1 @@ +Date and Time is = Tue May 15 09:34:16 IST 2018 \ No newline at end of file diff --git a/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo2_Output.txt b/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo2_Output.txt new file mode 100644 index 000000000..449dc8488 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo2_Output.txt @@ -0,0 +1,2 @@ +India Standard Time +Date and Time is = Tue May 15 09:34:25 IST 2018 \ No newline at end of file diff --git a/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo3_Output.txt b/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo3_Output.txt new file mode 100644 index 000000000..fd3e91bb6 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getInstance/CalendarDemo3_Output.txt @@ -0,0 +1,3 @@ +en_US +India Standard Time +Date and Time is = Tue May 15 09:34:35 IST 2018 \ No newline at end of file diff --git a/BasicJava_2018/CalendarDemo_getMaximum/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_getMaximum/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getMaximum/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_getMaximum/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_getMaximum/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getMaximum/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_getMaximum/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_getMaximum/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getMaximum/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_getMaximum/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_getMaximum/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..489f3cd67 Binary files /dev/null and b/BasicJava_2018/CalendarDemo_getMaximum/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_getMaximum/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_getMaximum/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..ed0dd8682 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getMaximum/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,26 @@ +import java.util.Calendar; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + + /* + * Parameters: + * + * field - the calendar field. + * + * Returns: + * + * the maximum value for the given calendar field. + */ + // return the maximum value for days + int max = cal.getMaximum(Calendar.DAY_OF_WEEK); + System.out.println("Maximum days = " + max); + + // return the maximum value for months + max = cal.getMaximum(Calendar.MONTH); + System.out.println("Maximum months = " + max); + } +} diff --git a/BasicJava_2018/CalendarDemo_getMaximum/Output.txt b/BasicJava_2018/CalendarDemo_getMaximum/Output.txt new file mode 100644 index 000000000..9af82763f --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getMaximum/Output.txt @@ -0,0 +1,2 @@ +Maximum days = 7 +Maximum months = 11 diff --git a/BasicJava_2018/CalendarDemo_getMinimalDaysInFirstWeek/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_getMinimalDaysInFirstWeek/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getMinimalDaysInFirstWeek/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_getMinimalDaysInFirstWeek/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_getMinimalDaysInFirstWeek/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getMinimalDaysInFirstWeek/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_getMinimalDaysInFirstWeek/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_getMinimalDaysInFirstWeek/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getMinimalDaysInFirstWeek/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_getMinimalDaysInFirstWeek/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_getMinimalDaysInFirstWeek/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..0310a7f5a Binary files /dev/null and b/BasicJava_2018/CalendarDemo_getMinimalDaysInFirstWeek/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_getMinimalDaysInFirstWeek/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_getMinimalDaysInFirstWeek/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..b49d89c7b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getMinimalDaysInFirstWeek/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,17 @@ +import java.util.Calendar; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + + /* + * Returns:the minimal days required in the first week of the + * year. + */ + int MinimalDaysInFirstWeek = cal.getMinimalDaysInFirstWeek(); + + System.out.println("MinimalDaysInFirstWeek = " + MinimalDaysInFirstWeek); + } +} diff --git a/BasicJava_2018/CalendarDemo_getMinimalDaysInFirstWeek/Output.txt b/BasicJava_2018/CalendarDemo_getMinimalDaysInFirstWeek/Output.txt new file mode 100644 index 000000000..e5a46b20a --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getMinimalDaysInFirstWeek/Output.txt @@ -0,0 +1 @@ +MinimalDaysInFirstWeek = 1 diff --git a/BasicJava_2018/CalendarDemo_getMinimum/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_getMinimum/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getMinimum/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_getMinimum/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_getMinimum/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getMinimum/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_getMinimum/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_getMinimum/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getMinimum/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_getMinimum/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_getMinimum/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..9cb3d0a97 Binary files /dev/null and b/BasicJava_2018/CalendarDemo_getMinimum/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_getMinimum/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_getMinimum/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..ce7042bd9 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getMinimum/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,28 @@ +import java.util.Calendar; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + + /* + * Parameters: + * + * field - the calendar field. + * + * Returns: + * + * the minimum value for the given calendar field. + */ + // return the minimum value for days + int min = cal.getMinimum(Calendar.DAY_OF_WEEK); + System.out.println("Minimum days = " + min); + + // return the minimum value for months + min = cal.getMinimum(Calendar.MONTH); + System.out.println("Minimum months = " + min); + + } + +} diff --git a/BasicJava_2018/CalendarDemo_getMinimum/Output.txt b/BasicJava_2018/CalendarDemo_getMinimum/Output.txt new file mode 100644 index 000000000..00b7a9eb6 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getMinimum/Output.txt @@ -0,0 +1,2 @@ +Minimum days = 1 +Minimum months = 0 diff --git a/BasicJava_2018/CalendarDemo_getTime/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_getTime/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getTime/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_getTime/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_getTime/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getTime/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_getTime/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_getTime/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getTime/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_getTime/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_getTime/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..4aafa0303 Binary files /dev/null and b/BasicJava_2018/CalendarDemo_getTime/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_getTime/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_getTime/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..13db0953b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getTime/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,18 @@ +import java.util.Calendar; +import java.util.Date; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + + /* + * Returns:a Date representing the time value. + */ + Date date = cal.getTime(); + System.out.println(" date = " + date); + + } + +} diff --git a/BasicJava_2018/CalendarDemo_getTime/Output.txt b/BasicJava_2018/CalendarDemo_getTime/Output.txt new file mode 100644 index 000000000..cda084ff9 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getTime/Output.txt @@ -0,0 +1 @@ + date = Fri Jun 08 09:39:50 IST 2018 diff --git a/BasicJava_2018/CalendarDemo_getTimeInMillis/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_getTimeInMillis/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getTimeInMillis/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_getTimeInMillis/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_getTimeInMillis/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getTimeInMillis/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_getTimeInMillis/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_getTimeInMillis/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getTimeInMillis/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_getTimeInMillis/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_getTimeInMillis/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..9f480823b Binary files /dev/null and b/BasicJava_2018/CalendarDemo_getTimeInMillis/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_getTimeInMillis/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_getTimeInMillis/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..f916a3e84 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getTimeInMillis/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,15 @@ +import java.util.Calendar; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + + /* + * Returns this Calendar's time value in milliseconds. + */ + long timeInMs = cal.getTimeInMillis(); + System.out.println("timeInMs = " + timeInMs); + } +} diff --git a/BasicJava_2018/CalendarDemo_getTimeInMillis/Output.txt b/BasicJava_2018/CalendarDemo_getTimeInMillis/Output.txt new file mode 100644 index 000000000..0ca2fe860 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getTimeInMillis/Output.txt @@ -0,0 +1 @@ +timeInMs = 1529554223354 diff --git a/BasicJava_2018/CalendarDemo_getTimeZone/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_getTimeZone/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getTimeZone/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_getTimeZone/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_getTimeZone/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getTimeZone/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_getTimeZone/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_getTimeZone/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getTimeZone/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_getTimeZone/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_getTimeZone/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..a7c86cc70 Binary files /dev/null and b/BasicJava_2018/CalendarDemo_getTimeZone/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_getTimeZone/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_getTimeZone/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..4a656cb48 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getTimeZone/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,18 @@ +import java.util.Calendar; +import java.util.TimeZone; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + + /* + * Returns:the time zone object associated with this calendar. + */ + TimeZone timeZone = cal.getTimeZone(); + + System.out.println("timeZone = " + timeZone.getDisplayName()); + } + +} diff --git a/BasicJava_2018/CalendarDemo_getTimeZone/Output.txt b/BasicJava_2018/CalendarDemo_getTimeZone/Output.txt new file mode 100644 index 000000000..43d522570 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getTimeZone/Output.txt @@ -0,0 +1 @@ +timeZone = India Standard Time diff --git a/BasicJava_2018/CalendarDemo_getWeekYear/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_getWeekYear/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getWeekYear/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_getWeekYear/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_getWeekYear/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getWeekYear/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_getWeekYear/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_getWeekYear/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getWeekYear/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_getWeekYear/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_getWeekYear/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..fd93d8f66 Binary files /dev/null and b/BasicJava_2018/CalendarDemo_getWeekYear/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_getWeekYear/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_getWeekYear/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..3c287695e --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getWeekYear/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,22 @@ +import java.util.Calendar; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + + /* + * Returns:the week year of this Calendar + */ + int weekYear = cal.getWeekYear(); + System.out.println("weekYear = " + weekYear); + + /* + * Returns:the number of weeks in the week year. + */ + long numberOfWeeks = cal.getWeeksInWeekYear(); + System.out.println("numberOfWeeks = " + numberOfWeeks); + } + +} diff --git a/BasicJava_2018/CalendarDemo_getWeekYear/Output.txt b/BasicJava_2018/CalendarDemo_getWeekYear/Output.txt new file mode 100644 index 000000000..4cff9637a --- /dev/null +++ b/BasicJava_2018/CalendarDemo_getWeekYear/Output.txt @@ -0,0 +1,2 @@ +weekYear = 2018 +numberOfWeeks = 52 diff --git a/BasicJava_2018/CalendarDemo_get_cal_fields_value/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_get_cal_fields_value/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_get_cal_fields_value/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_get_cal_fields_value/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_get_cal_fields_value/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_get_cal_fields_value/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_get_cal_fields_value/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_get_cal_fields_value/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_get_cal_fields_value/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_get_cal_fields_value/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_get_cal_fields_value/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..881c204a6 Binary files /dev/null and b/BasicJava_2018/CalendarDemo_get_cal_fields_value/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_get_cal_fields_value/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_get_cal_fields_value/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..125029b40 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_get_cal_fields_value/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,27 @@ +import java.util.Calendar; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + System.out.println(cal.getTime()); + + System.out.println("What day of the month = "+cal.get(Calendar.DATE)); + + System.out.println("What day of the month = "+cal.get(Calendar.DAY_OF_MONTH)); + + System.out.println("What day of the week = "+cal.get(Calendar.DAY_OF_WEEK)); + + System.out.println("What week in month = "+cal.get(Calendar.DAY_OF_WEEK_IN_MONTH)); + + System.out.println("What week in month = "+cal.get(Calendar.WEEK_OF_MONTH)); + + System.out.println("What day of the year = "+cal.get(Calendar.DAY_OF_YEAR)); + + System.out.println("What week of the year = "+cal.get(Calendar.WEEK_OF_YEAR)); + + System.out.println("What hour of the day = "+cal.get(Calendar.HOUR_OF_DAY)); + + } +} diff --git a/BasicJava_2018/CalendarDemo_get_cal_fields_value/Output.txt b/BasicJava_2018/CalendarDemo_get_cal_fields_value/Output.txt new file mode 100644 index 000000000..7af1c79e1 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_get_cal_fields_value/Output.txt @@ -0,0 +1,9 @@ +Sun Jul 08 08:50:01 IST 2018 +What day of the month = 8 +What day of the month = 8 +What day of the week = 1 +What week in month = 2 +What week in month = 2 +What day of the year = 189 +What week of the year = 28 +What hour of the day = 8 diff --git a/BasicJava_2018/CalendarDemo_get_field/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_get_field/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_get_field/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_get_field/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_get_field/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_get_field/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_get_field/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_get_field/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_get_field/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_get_field/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_get_field/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..8a16de298 Binary files /dev/null and b/BasicJava_2018/CalendarDemo_get_field/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_get_field/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_get_field/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..6ba858313 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_get_field/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,27 @@ +import java.util.Calendar; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + + /* + * public int get(int field) + * + * Parameters: + * + * field - the given calendar field. + * + * Returns: + * + * the value for the given calendar field. + */ + System.out.println("Calendar's Year: " + cal.get(Calendar.YEAR)); + // Month - 0[Jan] to 11[Dec] + System.out.println("Calendar's Month: " + cal.get(Calendar.MONTH)); + System.out.println("Calendar's Day: " + cal.get(Calendar.DAY_OF_MONTH)); + + } + +} diff --git a/BasicJava_2018/CalendarDemo_get_field/Output.txt b/BasicJava_2018/CalendarDemo_get_field/Output.txt new file mode 100644 index 000000000..697515aeb --- /dev/null +++ b/BasicJava_2018/CalendarDemo_get_field/Output.txt @@ -0,0 +1,3 @@ +Calendar's Year: 2018 +Calendar's Month: 4 +Calendar's Day: 16 diff --git a/BasicJava_2018/CalendarDemo_isLenient/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_isLenient/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_isLenient/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_isLenient/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_isLenient/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_isLenient/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_isLenient/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_isLenient/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_isLenient/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_isLenient/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_isLenient/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..f06692f13 Binary files /dev/null and b/BasicJava_2018/CalendarDemo_isLenient/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_isLenient/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_isLenient/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..fd20d0a73 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_isLenient/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,27 @@ +import java.util.Calendar; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + + /* + * Returns:true if the interpretation mode of this calendar is + * lenient; false otherwise. + */ + boolean isLenient = cal.isLenient(); + System.out.println("Calendar is lenient = " + isLenient); + + /* + * Parameters: + * + * lenient - true if the lenient mode is to be turned on; + * false if it is to be turned off. + */ + cal.setLenient(false); + + isLenient = cal.isLenient(); + System.out.println("Lenient after setting = " + isLenient); + } +} diff --git a/BasicJava_2018/CalendarDemo_isLenient/Output.txt b/BasicJava_2018/CalendarDemo_isLenient/Output.txt new file mode 100644 index 000000000..e797cda2c --- /dev/null +++ b/BasicJava_2018/CalendarDemo_isLenient/Output.txt @@ -0,0 +1,2 @@ +Calendar is lenient = true +Lenient after setting = false diff --git a/BasicJava_2018/CalendarDemo_isLenient_isWeekDateSupported/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_isLenient_isWeekDateSupported/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_isLenient_isWeekDateSupported/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_isLenient_isWeekDateSupported/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_isLenient_isWeekDateSupported/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_isLenient_isWeekDateSupported/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_isLenient_isWeekDateSupported/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_isLenient_isWeekDateSupported/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_isLenient_isWeekDateSupported/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_isLenient_isWeekDateSupported/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_isLenient_isWeekDateSupported/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..c0d6a967f Binary files /dev/null and b/BasicJava_2018/CalendarDemo_isLenient_isWeekDateSupported/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_isLenient_isWeekDateSupported/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_isLenient_isWeekDateSupported/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..10ec3ab17 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_isLenient_isWeekDateSupported/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,24 @@ +import java.util.Calendar; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + + /* + * Returns:true if the interpretation mode of this calendar is + * lenient; false otherwise. + */ + boolean isLenient = cal.isLenient(); + System.out.println("isLenient = " + isLenient); + + /* + * Returns:true if this Calendar supports week dates; false + * otherwise. + */ + boolean isWeekDaySupported = cal.isWeekDateSupported(); + System.out + .print("isWeekDaySupported = " + isWeekDaySupported); + } +} diff --git a/BasicJava_2018/CalendarDemo_isLenient_isWeekDateSupported/Output.txt b/BasicJava_2018/CalendarDemo_isLenient_isWeekDateSupported/Output.txt new file mode 100644 index 000000000..e1d080e0e --- /dev/null +++ b/BasicJava_2018/CalendarDemo_isLenient_isWeekDateSupported/Output.txt @@ -0,0 +1,2 @@ +isLenient = true +isWeekDaySupported = true \ No newline at end of file diff --git a/BasicJava_2018/CalendarDemo_isSet/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_isSet/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_isSet/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_isSet/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_isSet/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_isSet/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_isSet/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_isSet/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_isSet/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_isSet/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_isSet/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..0bd6b94c1 Binary files /dev/null and b/BasicJava_2018/CalendarDemo_isSet/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_isSet/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_isSet/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..8e6be20e0 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_isSet/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,30 @@ +import java.util.Calendar; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + + /* + * Parameters: + * + * field - the calendar field to test + * + * Returns: + * + * true if the given calendar field has a value set; false + * otherwise. + */ + + boolean result = cal.isSet(Calendar.DAY_OF_MONTH); + System.out.println("Day of month is set = " + result); + + // clear day of month + cal.clear(Calendar.DAY_OF_MONTH); + + + result = cal.isSet(Calendar.DAY_OF_MONTH); + System.out.println("Day of month is set = " + result); + } +} diff --git a/BasicJava_2018/CalendarDemo_isSet/Output.txt b/BasicJava_2018/CalendarDemo_isSet/Output.txt new file mode 100644 index 000000000..6c0e9577f --- /dev/null +++ b/BasicJava_2018/CalendarDemo_isSet/Output.txt @@ -0,0 +1,2 @@ +Day of month is set = true +Day of month is set = false diff --git a/BasicJava_2018/CalendarDemo_roll_amount/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_roll_amount/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_roll_amount/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_roll_amount/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_roll_amount/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_roll_amount/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_roll_amount/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_roll_amount/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_roll_amount/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_roll_amount/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_roll_amount/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..06399c409 Binary files /dev/null and b/BasicJava_2018/CalendarDemo_roll_amount/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_roll_amount/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_roll_amount/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..51dab61b9 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_roll_amount/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,28 @@ +import java.util.Calendar; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + cal.set(2017, 8, 24); + System.out.println("Month is " + cal.get(Calendar.MONTH)); + + /* + * Parameters: + * + * field - the calendar field. + * + * amount - the signed amount to add to the calendar field. + */ + cal.roll(Calendar.MONTH, 2); + + System.out.println( + "After rolling 2, Month is " + cal.get(Calendar.MONTH)); + + cal.roll(Calendar.MONTH, -4); + + System.out.println( + "After rolling -4, Month is " + cal.get(Calendar.MONTH)); + } +} diff --git a/BasicJava_2018/CalendarDemo_roll_amount/Output.txt b/BasicJava_2018/CalendarDemo_roll_amount/Output.txt new file mode 100644 index 000000000..09f498ff9 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_roll_amount/Output.txt @@ -0,0 +1,3 @@ +Month is 8 +After rolling 2, Month is 10 +After rolling -4, Month is 6 diff --git a/BasicJava_2018/CalendarDemo_roll_up_down/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_roll_up_down/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_roll_up_down/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_roll_up_down/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_roll_up_down/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_roll_up_down/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_roll_up_down/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_roll_up_down/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_roll_up_down/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_roll_up_down/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_roll_up_down/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..7ebce176a Binary files /dev/null and b/BasicJava_2018/CalendarDemo_roll_up_down/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_roll_up_down/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_roll_up_down/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..513ceb4cb --- /dev/null +++ b/BasicJava_2018/CalendarDemo_roll_up_down/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,28 @@ +import java.util.Calendar; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + cal.set(2017,8,24); + System.out.println("Month is " + cal.get(Calendar.MONTH)); + + /* + * Parameters: + * + * field - the time field. + * + * up - indicates if the value of the specified time field is + * to be rolled up or rolled down. Use true if rolling up, + * false otherwise. + */ + cal.roll(Calendar.MONTH, true); + + System.out.println("After roll up, Month is " + cal.get(Calendar.MONTH)); + + cal.roll(Calendar.MONTH, false); + + System.out.println("After roll down, Month is " + cal.get(Calendar.MONTH)); + } +} diff --git a/BasicJava_2018/CalendarDemo_roll_up_down/Output.txt b/BasicJava_2018/CalendarDemo_roll_up_down/Output.txt new file mode 100644 index 000000000..086211a41 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_roll_up_down/Output.txt @@ -0,0 +1,3 @@ +Month is 8 +After roll up, Month is 9 +After roll down, Month is 8 diff --git a/BasicJava_2018/CalendarDemo_set/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_set/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_set/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_set/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_set/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_set/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_set/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_set/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_set/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_set/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_set/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..716bdd475 Binary files /dev/null and b/BasicJava_2018/CalendarDemo_set/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_set/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_set/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..2f69dc084 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_set/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,26 @@ +import java.util.Calendar; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + + System.out.println("Current year is = " + cal.get(Calendar.YEAR)); + System.out.println("Current Month is = " + cal.get(Calendar.MONTH)); + + /* + * Parameters: + * + * field - the given calendar field. + * + * value - the value to be set for the given calendar field. + */ + + cal.set(Calendar.YEAR, 2013); + cal.set(Calendar.MONTH, 5); + + System.out.println("\nAltered year is = " + cal.get(Calendar.YEAR)); + System.out.println("Altered Month is = " + cal.get(Calendar.MONTH)); + } +} diff --git a/BasicJava_2018/CalendarDemo_set/Output.txt b/BasicJava_2018/CalendarDemo_set/Output.txt new file mode 100644 index 000000000..d483e9ddc --- /dev/null +++ b/BasicJava_2018/CalendarDemo_set/Output.txt @@ -0,0 +1,5 @@ +Current year is = 2018 +Current Month is = 5 + +Altered year is = 2013 +Altered Month is = 5 diff --git a/BasicJava_2018/CalendarDemo_setFirstDayOfWeek/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_setFirstDayOfWeek/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setFirstDayOfWeek/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_setFirstDayOfWeek/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_setFirstDayOfWeek/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setFirstDayOfWeek/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_setFirstDayOfWeek/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_setFirstDayOfWeek/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setFirstDayOfWeek/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_setFirstDayOfWeek/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_setFirstDayOfWeek/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..a7a14e8ce Binary files /dev/null and b/BasicJava_2018/CalendarDemo_setFirstDayOfWeek/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_setFirstDayOfWeek/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_setFirstDayOfWeek/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..77f31be41 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setFirstDayOfWeek/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,20 @@ +import java.util.Calendar; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + + int day = cal.getFirstDayOfWeek(); + System.out.println("Current first day of the week = " + day); + + /* + * Parameters:value - the given first day of the week. + */ + cal.setFirstDayOfWeek(Calendar.FRIDAY); + + day = cal.getFirstDayOfWeek(); + System.out.println("Altered first day of the week = " + day); + } +} diff --git a/BasicJava_2018/CalendarDemo_setFirstDayOfWeek/Output.txt b/BasicJava_2018/CalendarDemo_setFirstDayOfWeek/Output.txt new file mode 100644 index 000000000..52060c54a --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setFirstDayOfWeek/Output.txt @@ -0,0 +1,2 @@ +Current first day of the week = 1 +Altered first day of the week = 6 diff --git a/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo/bin/CalendarDemo1.class b/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo/bin/CalendarDemo1.class new file mode 100644 index 000000000..e1cecec63 Binary files /dev/null and b/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo/bin/CalendarDemo1.class differ diff --git a/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo/bin/CalendarDemo2.class b/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo/bin/CalendarDemo2.class new file mode 100644 index 000000000..bd3a0ed1f Binary files /dev/null and b/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo/bin/CalendarDemo2.class differ diff --git a/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo/bin/CalendarDemo3.class b/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo/bin/CalendarDemo3.class new file mode 100644 index 000000000..e96c5ce34 Binary files /dev/null and b/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo/bin/CalendarDemo3.class differ diff --git a/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo/src/CalendarDemo1.java b/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo/src/CalendarDemo1.java new file mode 100644 index 000000000..d03bcddaf --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo/src/CalendarDemo1.java @@ -0,0 +1,27 @@ +import java.util.Calendar; + +public class CalendarDemo1 +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + + System.out.println("Before set = " + cal.getTime()); + + /* + * Parameters: + * + * year - the value used to set the YEAR calendar field. + * + * month - the value used to set the MONTH calendar field. + * Month value is 0-based. e.g., 0 for January. + * + * date - the value used to set the DAY_OF_MONTH calendar + * field. + */ + cal.set(2000, 11, 14); + + // print the result + System.out.println("After set = " + cal.getTime()); + } +} diff --git a/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo/src/CalendarDemo2.java b/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo/src/CalendarDemo2.java new file mode 100644 index 000000000..17a516881 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo/src/CalendarDemo2.java @@ -0,0 +1,33 @@ +import java.util.Calendar; + +public class CalendarDemo2 +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + + System.out.println("Before set = " + cal.getTime()); + + /* + * Parameters: + * + * year - the value used to set the YEAR calendar field. + * + * month - the value used to set the MONTH calendar field. + * Month value is 0-based. e.g., 0 for January. + * + * date - the value used to set the DAY_OF_MONTH calendar + * field. + * + * hourOfDay - the value used to set the HOUR_OF_DAY calendar + * field. + * + * minute - the value used to set the MINUTE calendar field. + */ + cal.set(2000, 11, 14, 2, 30); + + // print the result + System.out.println("After set = " + cal.getTime()); + } + +} diff --git a/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo/src/CalendarDemo3.java b/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo/src/CalendarDemo3.java new file mode 100644 index 000000000..331be2ef1 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo/src/CalendarDemo3.java @@ -0,0 +1,35 @@ +import java.util.Calendar; + +public class CalendarDemo3 +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + + System.out.println("Before set = " + cal.getTime()); + + /* + * Parameters: + * + * year - the value used to set the YEAR calendar field. + * + * month - the value used to set the MONTH calendar field. + * Month value is 0-based. e.g., 0 for January. + * + * date - the value used to set the DAY_OF_MONTH calendar + * field. + * + * hourOfDay - the value used to set the HOUR_OF_DAY calendar + * field. + * + * minute - the value used to set the MINUTE calendar field. + * + * second - the value used to set the SECOND calendar field. + */ + cal.set(2000, 11, 15, 2, 30, 10); + + // print the result + System.out.println("After set = " + cal.getTime()); + } + +} diff --git a/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo1_Output.txt b/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo1_Output.txt new file mode 100644 index 000000000..8d07e838d --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo1_Output.txt @@ -0,0 +1,2 @@ +Before set = Tue Jun 26 09:42:15 IST 2018 +After set = Thu Dec 14 09:42:15 IST 2000 diff --git a/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo2_Output.txt b/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo2_Output.txt new file mode 100644 index 000000000..ff02ba395 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo2_Output.txt @@ -0,0 +1,2 @@ +Before set = Tue Jun 26 09:42:22 IST 2018 +After set = Thu Dec 14 02:30:22 IST 2000 diff --git a/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo3_Output.txt b/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo3_Output.txt new file mode 100644 index 000000000..d46ac9a45 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setMethods/CalendarDemo3_Output.txt @@ -0,0 +1,2 @@ +Before set = Tue Jun 26 09:42:33 IST 2018 +After set = Fri Dec 15 02:30:10 IST 2000 diff --git a/BasicJava_2018/CalendarDemo_setMinimalDaysInFirstWeek/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_setMinimalDaysInFirstWeek/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setMinimalDaysInFirstWeek/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_setMinimalDaysInFirstWeek/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_setMinimalDaysInFirstWeek/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setMinimalDaysInFirstWeek/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_setMinimalDaysInFirstWeek/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_setMinimalDaysInFirstWeek/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setMinimalDaysInFirstWeek/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_setMinimalDaysInFirstWeek/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_setMinimalDaysInFirstWeek/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..b2d9aa459 Binary files /dev/null and b/BasicJava_2018/CalendarDemo_setMinimalDaysInFirstWeek/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_setMinimalDaysInFirstWeek/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_setMinimalDaysInFirstWeek/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..e9cad26f3 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setMinimalDaysInFirstWeek/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,27 @@ +import java.util.Calendar; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + + /* + * Returns: the minimal days required in the first week of the + * year. + */ + int min = cal.getMinimalDaysInFirstWeek(); + System.out.println("Before set, Minimal Days in Week = " + min); + + /* + * Parameters: + * + * value - the given minimal days required in the first week + * of the year. + */ + cal.setMinimalDaysInFirstWeek(4); + + min = cal.getMinimalDaysInFirstWeek(); + System.out.println("After set, Minimal Days in Week = " + min); + } +} diff --git a/BasicJava_2018/CalendarDemo_setMinimalDaysInFirstWeek/Output.txt b/BasicJava_2018/CalendarDemo_setMinimalDaysInFirstWeek/Output.txt new file mode 100644 index 000000000..d01ac0183 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setMinimalDaysInFirstWeek/Output.txt @@ -0,0 +1,2 @@ +Before set, Minimal Days in Week = 1 +After set, Minimal Days in Week = 4 diff --git a/BasicJava_2018/CalendarDemo_setTime/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_setTime/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setTime/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_setTime/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_setTime/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setTime/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_setTime/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_setTime/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setTime/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_setTime/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_setTime/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..9a769cc60 Binary files /dev/null and b/BasicJava_2018/CalendarDemo_setTime/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_setTime/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_setTime/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..5cfe8bc94 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setTime/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,23 @@ +import java.util.Calendar; +import java.util.Date; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + cal.set(2013,3,10); + System.out.println("Before setting Time = " + cal.getTime()); + + Date date = new Date(); + + /* + * Parameters: + * + * date - the given Date. + */ + cal.setTime(date); + + System.out.println("After setting Time = " + cal.getTime()); + } +} diff --git a/BasicJava_2018/CalendarDemo_setTime/Output.txt b/BasicJava_2018/CalendarDemo_setTime/Output.txt new file mode 100644 index 000000000..6b2238599 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setTime/Output.txt @@ -0,0 +1,2 @@ +Before setting Time = Wed Apr 10 09:47:03 IST 2013 +After setting Time = Thu Jun 28 09:47:11 IST 2018 diff --git a/BasicJava_2018/CalendarDemo_setTimeInMillis/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_setTimeInMillis/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setTimeInMillis/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_setTimeInMillis/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_setTimeInMillis/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setTimeInMillis/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_setTimeInMillis/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_setTimeInMillis/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setTimeInMillis/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_setTimeInMillis/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_setTimeInMillis/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..93846e017 Binary files /dev/null and b/BasicJava_2018/CalendarDemo_setTimeInMillis/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_setTimeInMillis/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_setTimeInMillis/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..8c6cfcbe4 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setTimeInMillis/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,24 @@ +import java.util.Calendar; +import java.util.Date; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + cal.set(2013, 3, 10); + System.out.println("Before setting TimeInMillis = " + cal.getTime()); + + Date date = new Date(); + long ms = date.getTime(); + + /* + * Parameters: + * + * millis - the new time in UTC milliseconds from the epoch. + */ + cal.setTimeInMillis(ms); + + System.out.println("After setting TimeInMillis = " + cal.getTime()); + } +} diff --git a/BasicJava_2018/CalendarDemo_setTimeInMillis/Output.txt b/BasicJava_2018/CalendarDemo_setTimeInMillis/Output.txt new file mode 100644 index 000000000..d6e3e3cc8 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setTimeInMillis/Output.txt @@ -0,0 +1,2 @@ +Before setting TimeInMillis = Wed Apr 10 10:01:22 IST 2013 +After setting TimeInMillis = Thu Jun 28 10:01:34 IST 2018 diff --git a/BasicJava_2018/CalendarDemo_setTimeZone/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_setTimeZone/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setTimeZone/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_setTimeZone/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_setTimeZone/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setTimeZone/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_setTimeZone/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_setTimeZone/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setTimeZone/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_setTimeZone/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_setTimeZone/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..c1a7bfb2b Binary files /dev/null and b/BasicJava_2018/CalendarDemo_setTimeZone/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_setTimeZone/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_setTimeZone/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..3cefa0773 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setTimeZone/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,25 @@ +import java.util.Calendar; +import java.util.TimeZone; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + + System.out.println( + "Before setTimeZone = " + cal.getTimeZone().getDisplayName()); + + TimeZone timeZone = TimeZone.getTimeZone("GMT"); + + /* + * Parameters: + * + * value - the given time zone. + */ + cal.setTimeZone(timeZone); + + System.out.println( + "After setTimeZone = " + cal.getTimeZone().getDisplayName()); + } +} diff --git a/BasicJava_2018/CalendarDemo_setTimeZone/Output.txt b/BasicJava_2018/CalendarDemo_setTimeZone/Output.txt new file mode 100644 index 000000000..754b25618 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setTimeZone/Output.txt @@ -0,0 +1,2 @@ +Before setTimeZone = India Standard Time +After setTimeZone = Greenwich Mean Time diff --git a/BasicJava_2018/CalendarDemo_setWeekDate/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_setWeekDate/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setWeekDate/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_setWeekDate/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_setWeekDate/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setWeekDate/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_setWeekDate/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_setWeekDate/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setWeekDate/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_setWeekDate/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_setWeekDate/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..99f21c7ba Binary files /dev/null and b/BasicJava_2018/CalendarDemo_setWeekDate/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_setWeekDate/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_setWeekDate/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..cd3a0c7f4 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setWeekDate/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,23 @@ +import java.util.Calendar; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + System.out.println("Before setWeekDate = "+cal.getTime()); + + /* + * Parameters: + * + * weekYear - the week year + * + * weekOfYear - the week number based on weekYear + * + * dayOfWeek - the day of week value: one of the constants for + * the DAY_OF_WEEK field: SUNDAY, ..., SATURDAY. + */ + cal.setWeekDate(2013, 11, 4); + System.out.println("After setWeekDate = "+cal.getTime()); + } +} diff --git a/BasicJava_2018/CalendarDemo_setWeekDate/Output.txt b/BasicJava_2018/CalendarDemo_setWeekDate/Output.txt new file mode 100644 index 000000000..6c5306040 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_setWeekDate/Output.txt @@ -0,0 +1,2 @@ +Before setWeekDate = Fri Jun 29 09:47:50 IST 2018 +After setWeekDate = Wed Mar 13 09:47:50 IST 2013 diff --git a/BasicJava_2018/CalendarDemo_set_cal_fields_value/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_set_cal_fields_value/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_set_cal_fields_value/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_set_cal_fields_value/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_set_cal_fields_value/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_set_cal_fields_value/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_set_cal_fields_value/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_set_cal_fields_value/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_set_cal_fields_value/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_set_cal_fields_value/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_set_cal_fields_value/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..7dbbc033b Binary files /dev/null and b/BasicJava_2018/CalendarDemo_set_cal_fields_value/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_set_cal_fields_value/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_set_cal_fields_value/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..7471d5f21 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_set_cal_fields_value/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,21 @@ +import java.util.Calendar; + +public class CalendarDemo +{ + public static void main(String[] args) + { + Calendar cal = Calendar.getInstance(); + System.out.println("Before Set = " + cal.getTime()); + + cal.set(Calendar.HOUR, 10); + cal.set(Calendar.MINUTE, 29); + cal.set(Calendar.SECOND, 22); + + System.out.println("After Set = " + cal.getTime()); + + System.out.println("Hour = " + cal.get(Calendar.HOUR)); + System.out.println("Min = " + cal.get(Calendar.MINUTE)); + System.out.println("Sec = " + cal.get(Calendar.SECOND)); + + } +} diff --git a/BasicJava_2018/CalendarDemo_set_cal_fields_value/Output.txt b/BasicJava_2018/CalendarDemo_set_cal_fields_value/Output.txt new file mode 100644 index 000000000..daea9b8cc --- /dev/null +++ b/BasicJava_2018/CalendarDemo_set_cal_fields_value/Output.txt @@ -0,0 +1,5 @@ +Before Set = Sun Jul 08 09:01:59 IST 2018 +After Set = Sun Jul 08 10:29:22 IST 2018 +Hour = 10 +Min = 29 +Sec = 22 diff --git a/BasicJava_2018/CalendarDemo_util_getAvailableLocales/CalendarDemo/.classpath b/BasicJava_2018/CalendarDemo_util_getAvailableLocales/CalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_util_getAvailableLocales/CalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/CalendarDemo_util_getAvailableLocales/CalendarDemo/.project b/BasicJava_2018/CalendarDemo_util_getAvailableLocales/CalendarDemo/.project new file mode 100644 index 000000000..2c5b75698 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_util_getAvailableLocales/CalendarDemo/.project @@ -0,0 +1,17 @@ + + + CalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/CalendarDemo_util_getAvailableLocales/CalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/CalendarDemo_util_getAvailableLocales/CalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/CalendarDemo_util_getAvailableLocales/CalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/CalendarDemo_util_getAvailableLocales/CalendarDemo/bin/CalendarDemo.class b/BasicJava_2018/CalendarDemo_util_getAvailableLocales/CalendarDemo/bin/CalendarDemo.class new file mode 100644 index 000000000..8e4f021fd Binary files /dev/null and b/BasicJava_2018/CalendarDemo_util_getAvailableLocales/CalendarDemo/bin/CalendarDemo.class differ diff --git a/BasicJava_2018/CalendarDemo_util_getAvailableLocales/CalendarDemo/src/CalendarDemo.java b/BasicJava_2018/CalendarDemo_util_getAvailableLocales/CalendarDemo/src/CalendarDemo.java new file mode 100644 index 000000000..10c36078e --- /dev/null +++ b/BasicJava_2018/CalendarDemo_util_getAvailableLocales/CalendarDemo/src/CalendarDemo.java @@ -0,0 +1,21 @@ +import java.util.Calendar; +import java.util.Locale; + +public class CalendarDemo +{ + public static void main(String[] args) + { + /* + * public static Locale[] getAvailableLocales() + * + * Returns:An array of locales for which localized Calendar + * instances are available. + */ + Locale[] localeArray = Calendar.getAvailableLocales(); + + for (Locale locale : localeArray) + { + System.out.println(locale); + } + } +} diff --git a/BasicJava_2018/CalendarDemo_util_getAvailableLocales/Output.txt b/BasicJava_2018/CalendarDemo_util_getAvailableLocales/Output.txt new file mode 100644 index 000000000..0c60b1f0b --- /dev/null +++ b/BasicJava_2018/CalendarDemo_util_getAvailableLocales/Output.txt @@ -0,0 +1,160 @@ + +ar_AE +ar_JO +ar_SY +hr_HR +fr_BE +es_PA +mt_MT +es_VE +bg +zh_TW +it +ko +uk +lv +da_DK +es_PR +vi_VN +en_US +sr_ME +sv_SE +es_BO +en_SG +ar_BH +pt +ar_SA +sk +ar_YE +hi_IN +ga +en_MT +fi_FI +et +sv +cs +sr_BA_#Latn +el +uk_UA +hu +fr_CH +in +es_AR +ar_EG +ja_JP_JP_#u-ca-japanese +es_SV +pt_BR +be +is_IS +cs_CZ +es +pl_PL +tr +ca_ES +sr_CS +ms_MY +hr +lt +es_ES +es_CO +bg_BG +sq +fr +ja +sr_BA +is +es_PY +de +es_EC +es_US +ar_SD +en +ro_RO +en_PH +ca +ar_TN +sr_ME_#Latn +es_GT +sl +ko_KR +el_CY +es_MX +ru_RU +es_HN +zh_HK +no_NO_NY +hu_HU +th_TH +ar_IQ +es_CL +fi +ar_MA +ga_IE +mk +tr_TR +et_EE +ar_QA +sr__#Latn +pt_PT +fr_LU +ar_OM +th +sq_AL +es_DO +es_CU +ar +ru +en_NZ +sr_RS +de_CH +es_UY +ms +el_GR +iw_IL +en_ZA +th_TH_TH_#u-nu-thai +hi +fr_FR +de_AT +nl +no_NO +en_AU +vi +nl_NL +fr_CA +lv_LV +de_LU +es_CR +ar_KW +sr +ar_LY +mt +it_CH +da +de_DE +ar_DZ +sk_SK +lt_LT +it_IT +en_IE +zh_SG +ro +en_CA +nl_BE +no +pl +zh_CN +ja_JP +de_GR +sr_RS_#Latn +iw +en_IN +ar_LB +es_NI +zh +mk_MK +be_BY +sl_SI +es_PE +in_ID +en_GB diff --git a/BasicJava_2018/DateDemo_util_after_before/DateDemo/.classpath b/BasicJava_2018/DateDemo_util_after_before/DateDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/DateDemo_util_after_before/DateDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/DateDemo_util_after_before/DateDemo/.project b/BasicJava_2018/DateDemo_util_after_before/DateDemo/.project new file mode 100644 index 000000000..a7e9109d7 --- /dev/null +++ b/BasicJava_2018/DateDemo_util_after_before/DateDemo/.project @@ -0,0 +1,17 @@ + + + DateDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/DateDemo_util_after_before/DateDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/DateDemo_util_after_before/DateDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/DateDemo_util_after_before/DateDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/DateDemo_util_after_before/DateDemo/bin/DateDemo.class b/BasicJava_2018/DateDemo_util_after_before/DateDemo/bin/DateDemo.class new file mode 100644 index 000000000..82e9b525b Binary files /dev/null and b/BasicJava_2018/DateDemo_util_after_before/DateDemo/bin/DateDemo.class differ diff --git a/BasicJava_2018/DateDemo_util_after_before/DateDemo/src/DateDemo.java b/BasicJava_2018/DateDemo_util_after_before/DateDemo/src/DateDemo.java new file mode 100644 index 000000000..2e2ab12ec --- /dev/null +++ b/BasicJava_2018/DateDemo_util_after_before/DateDemo/src/DateDemo.java @@ -0,0 +1,43 @@ +import java.util.Calendar; +import java.util.Date; + +public class DateDemo +{ + public static void main(String[] args) + { + Date date1 = Calendar.getInstance().getTime(); + System.out.println("date1 = " + date1); + + Calendar cal = Calendar.getInstance(); + cal.set(Calendar.YEAR, 2000); + Date date2 = cal.getTime(); + System.out.println("date2 = " + date2); + + /* + * Parameters: + * + * when - a date. + * + * Returns: + * + * true if and only if the instant represented by this Date + * object is strictly later than the instant represented by + * when; false otherwise. + */ + System.out.println("Is date1 after date2 ? : " + date1.after(date2)); + + /* + * Parameters: + * + * when - a date. + * + * Returns: + * + * true if and only if the instant of time represented by this + * Date object is strictly earlier than the instant + * represented by when; false otherwise. + */ + System.out.println("Is date1 before date2 ? : " + date1.before(date2)); + } + +} diff --git a/BasicJava_2018/DateDemo_util_after_before/Output.txt b/BasicJava_2018/DateDemo_util_after_before/Output.txt new file mode 100644 index 000000000..3c38f3f3a --- /dev/null +++ b/BasicJava_2018/DateDemo_util_after_before/Output.txt @@ -0,0 +1,4 @@ +date1 = Sat May 12 09:22:51 IST 2018 +date2 = Fri May 12 09:22:52 IST 2000 +Is date1 after date2 ? : true +Is date1 before date2 ? : false diff --git a/BasicJava_2018/DateDemo_util_clone/DateDemo/.classpath b/BasicJava_2018/DateDemo_util_clone/DateDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/DateDemo_util_clone/DateDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/DateDemo_util_clone/DateDemo/.project b/BasicJava_2018/DateDemo_util_clone/DateDemo/.project new file mode 100644 index 000000000..a7e9109d7 --- /dev/null +++ b/BasicJava_2018/DateDemo_util_clone/DateDemo/.project @@ -0,0 +1,17 @@ + + + DateDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/DateDemo_util_clone/DateDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/DateDemo_util_clone/DateDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/DateDemo_util_clone/DateDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/DateDemo_util_clone/DateDemo/bin/DateDemo.class b/BasicJava_2018/DateDemo_util_clone/DateDemo/bin/DateDemo.class new file mode 100644 index 000000000..96c7510f3 Binary files /dev/null and b/BasicJava_2018/DateDemo_util_clone/DateDemo/bin/DateDemo.class differ diff --git a/BasicJava_2018/DateDemo_util_clone/DateDemo/src/DateDemo.java b/BasicJava_2018/DateDemo_util_clone/DateDemo/src/DateDemo.java new file mode 100644 index 000000000..dbe3bb8c7 --- /dev/null +++ b/BasicJava_2018/DateDemo_util_clone/DateDemo/src/DateDemo.java @@ -0,0 +1,17 @@ +import java.util.Date; + +public class DateDemo +{ + public static void main(String[] args) + { + Date date1 = new Date(); + System.out.println("Original Date = " + date1); + + /* + * Return a copy of this object. + */ + Object date2 = date1.clone(); + System.out.println("Cloned date = " + date2); + } + +} diff --git a/BasicJava_2018/DateDemo_util_clone/Output.txt b/BasicJava_2018/DateDemo_util_clone/Output.txt new file mode 100644 index 000000000..f2694dbed --- /dev/null +++ b/BasicJava_2018/DateDemo_util_clone/Output.txt @@ -0,0 +1,2 @@ +Original Date = Sat May 12 09:40:54 IST 2018 +Cloned date = Sat May 12 09:40:54 IST 2018 diff --git a/BasicJava_2018/DateDemo_util_compareTo_equals/DateDemo/.classpath b/BasicJava_2018/DateDemo_util_compareTo_equals/DateDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/DateDemo_util_compareTo_equals/DateDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/DateDemo_util_compareTo_equals/DateDemo/.project b/BasicJava_2018/DateDemo_util_compareTo_equals/DateDemo/.project new file mode 100644 index 000000000..a7e9109d7 --- /dev/null +++ b/BasicJava_2018/DateDemo_util_compareTo_equals/DateDemo/.project @@ -0,0 +1,17 @@ + + + DateDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/DateDemo_util_compareTo_equals/DateDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/DateDemo_util_compareTo_equals/DateDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/DateDemo_util_compareTo_equals/DateDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/DateDemo_util_compareTo_equals/DateDemo/bin/DateDemo.class b/BasicJava_2018/DateDemo_util_compareTo_equals/DateDemo/bin/DateDemo.class new file mode 100644 index 000000000..cb94cacbe Binary files /dev/null and b/BasicJava_2018/DateDemo_util_compareTo_equals/DateDemo/bin/DateDemo.class differ diff --git a/BasicJava_2018/DateDemo_util_compareTo_equals/DateDemo/src/DateDemo.java b/BasicJava_2018/DateDemo_util_compareTo_equals/DateDemo/src/DateDemo.java new file mode 100644 index 000000000..d06dfc6fd --- /dev/null +++ b/BasicJava_2018/DateDemo_util_compareTo_equals/DateDemo/src/DateDemo.java @@ -0,0 +1,45 @@ +import java.util.Calendar; +import java.util.Date; + +public class DateDemo +{ + public static void main(String[] args) + { + Date date1 = Calendar.getInstance().getTime(); + System.out.println("date1 = " + date1); + + Calendar cal = Calendar.getInstance(); + cal.set(Calendar.YEAR, 2000); + Date date2 = cal.getTime(); + System.out.println("date2 = " + date2); + + /* + * Parameters: + * + * anotherDate - the Date to be compared. + * + * Returns: + * + * the value 0 if the argument Date is equal to this Date; a + * value less than 0 if this Date is before the Date argument; + * and a value greater than 0 if this Date is after the Date + * argument. + */ + int result = date1.compareTo(date2); + System.out.println(result); + + /* + * Parameters: + * + * obj - the object to compare with. + * + * Returns: + * + * true if the objects are the same; false otherwise. + */ + boolean isEqual = date1.equals(date2); + System.out.println(isEqual); + + } + +} diff --git a/BasicJava_2018/DateDemo_util_compareTo_equals/Output.txt b/BasicJava_2018/DateDemo_util_compareTo_equals/Output.txt new file mode 100644 index 000000000..43a08049f --- /dev/null +++ b/BasicJava_2018/DateDemo_util_compareTo_equals/Output.txt @@ -0,0 +1,4 @@ +date1 = Sun May 13 11:09:42 IST 2018 +date2 = Sat May 13 11:09:47 IST 2000 +1 +false diff --git a/BasicJava_2018/DateDemo_util_date_intro/DateDemo/.classpath b/BasicJava_2018/DateDemo_util_date_intro/DateDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/DateDemo_util_date_intro/DateDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/DateDemo_util_date_intro/DateDemo/.project b/BasicJava_2018/DateDemo_util_date_intro/DateDemo/.project new file mode 100644 index 000000000..a7e9109d7 --- /dev/null +++ b/BasicJava_2018/DateDemo_util_date_intro/DateDemo/.project @@ -0,0 +1,17 @@ + + + DateDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/DateDemo_util_date_intro/DateDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/DateDemo_util_date_intro/DateDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/DateDemo_util_date_intro/DateDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/DateDemo_util_date_intro/DateDemo/bin/DateDemo1.class b/BasicJava_2018/DateDemo_util_date_intro/DateDemo/bin/DateDemo1.class new file mode 100644 index 000000000..f4807f512 Binary files /dev/null and b/BasicJava_2018/DateDemo_util_date_intro/DateDemo/bin/DateDemo1.class differ diff --git a/BasicJava_2018/DateDemo_util_date_intro/DateDemo/bin/DateDemo2.class b/BasicJava_2018/DateDemo_util_date_intro/DateDemo/bin/DateDemo2.class new file mode 100644 index 000000000..fb8d5ff97 Binary files /dev/null and b/BasicJava_2018/DateDemo_util_date_intro/DateDemo/bin/DateDemo2.class differ diff --git a/BasicJava_2018/DateDemo_util_date_intro/DateDemo/src/DateDemo1.java b/BasicJava_2018/DateDemo_util_date_intro/DateDemo/src/DateDemo1.java new file mode 100644 index 000000000..226256bc9 --- /dev/null +++ b/BasicJava_2018/DateDemo_util_date_intro/DateDemo/src/DateDemo1.java @@ -0,0 +1,11 @@ +import java.util.Date; + +public class DateDemo1 +{ + public static void main(String[] args) + { + Date date = new Date(); + System.out.println(date); + } + +} diff --git a/BasicJava_2018/DateDemo_util_date_intro/DateDemo/src/DateDemo2.java b/BasicJava_2018/DateDemo_util_date_intro/DateDemo/src/DateDemo2.java new file mode 100644 index 000000000..71d7cfe59 --- /dev/null +++ b/BasicJava_2018/DateDemo_util_date_intro/DateDemo/src/DateDemo2.java @@ -0,0 +1,15 @@ +import java.util.Date; + +public class DateDemo2 +{ + public static void main(String[] args) + { + /* + * Returns the current time in milliseconds. + */ + long millis = System.currentTimeMillis(); + Date date = new Date(millis); + System.out.println(date); + } + +} diff --git a/BasicJava_2018/DateDemo_util_date_intro/DateDemo1_Output.txt b/BasicJava_2018/DateDemo_util_date_intro/DateDemo1_Output.txt new file mode 100644 index 000000000..cdda32a64 --- /dev/null +++ b/BasicJava_2018/DateDemo_util_date_intro/DateDemo1_Output.txt @@ -0,0 +1 @@ +Fri May 11 10:13:43 IST 2018 diff --git a/BasicJava_2018/DateDemo_util_date_intro/DateDemo2_Output.txt b/BasicJava_2018/DateDemo_util_date_intro/DateDemo2_Output.txt new file mode 100644 index 000000000..b013cee9d --- /dev/null +++ b/BasicJava_2018/DateDemo_util_date_intro/DateDemo2_Output.txt @@ -0,0 +1 @@ +Fri May 11 10:13:51 IST 2018 diff --git a/BasicJava_2018/DateDemo_util_getTime_setTime/DateDemo/.classpath b/BasicJava_2018/DateDemo_util_getTime_setTime/DateDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/DateDemo_util_getTime_setTime/DateDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/DateDemo_util_getTime_setTime/DateDemo/.project b/BasicJava_2018/DateDemo_util_getTime_setTime/DateDemo/.project new file mode 100644 index 000000000..a7e9109d7 --- /dev/null +++ b/BasicJava_2018/DateDemo_util_getTime_setTime/DateDemo/.project @@ -0,0 +1,17 @@ + + + DateDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/DateDemo_util_getTime_setTime/DateDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/DateDemo_util_getTime_setTime/DateDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/DateDemo_util_getTime_setTime/DateDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/DateDemo_util_getTime_setTime/DateDemo/bin/DateDemo1.class b/BasicJava_2018/DateDemo_util_getTime_setTime/DateDemo/bin/DateDemo1.class new file mode 100644 index 000000000..ef44578f9 Binary files /dev/null and b/BasicJava_2018/DateDemo_util_getTime_setTime/DateDemo/bin/DateDemo1.class differ diff --git a/BasicJava_2018/DateDemo_util_getTime_setTime/DateDemo/bin/DateDemo2.class b/BasicJava_2018/DateDemo_util_getTime_setTime/DateDemo/bin/DateDemo2.class new file mode 100644 index 000000000..ee16d98ef Binary files /dev/null and b/BasicJava_2018/DateDemo_util_getTime_setTime/DateDemo/bin/DateDemo2.class differ diff --git a/BasicJava_2018/DateDemo_util_getTime_setTime/DateDemo/src/DateDemo1.java b/BasicJava_2018/DateDemo_util_getTime_setTime/DateDemo/src/DateDemo1.java new file mode 100644 index 000000000..a7ee7c2d0 --- /dev/null +++ b/BasicJava_2018/DateDemo_util_getTime_setTime/DateDemo/src/DateDemo1.java @@ -0,0 +1,20 @@ +import java.util.Date; + +public class DateDemo1 +{ + public static void main(String[] args) + { + Date date = new Date(); + + /* + * Returns: + * + * the number of milliseconds since January 1, 1970, 00:00:00 + * GMT represented by this date. + */ + long milliSec = date.getTime(); + System.out.println(milliSec); + + } + +} diff --git a/BasicJava_2018/DateDemo_util_getTime_setTime/DateDemo/src/DateDemo2.java b/BasicJava_2018/DateDemo_util_getTime_setTime/DateDemo/src/DateDemo2.java new file mode 100644 index 000000000..e2561de42 --- /dev/null +++ b/BasicJava_2018/DateDemo_util_getTime_setTime/DateDemo/src/DateDemo2.java @@ -0,0 +1,24 @@ +import java.util.Date; + +public class DateDemo2 +{ + public static void main(String[] args) + { + Date date = new Date(); + System.out.println("Date before setting = " + date); + + /* + * Sets this Date object to represent a point in time that is + * time milliseconds after January 1, 1970 00:00:00 GMT. + * + * Parameters: + * + * time - the number of milliseconds. + */ + date.setTime(200000); + + System.out.println("Date after setting = " + date); + + } + +} diff --git a/BasicJava_2018/DateDemo_util_getTime_setTime/DateDemo1_Output.txt b/BasicJava_2018/DateDemo_util_getTime_setTime/DateDemo1_Output.txt new file mode 100644 index 000000000..339a22982 --- /dev/null +++ b/BasicJava_2018/DateDemo_util_getTime_setTime/DateDemo1_Output.txt @@ -0,0 +1 @@ +1526191183774 diff --git a/BasicJava_2018/DateDemo_util_getTime_setTime/DateDemo2_Output.txt b/BasicJava_2018/DateDemo_util_getTime_setTime/DateDemo2_Output.txt new file mode 100644 index 000000000..8e30b1cbc --- /dev/null +++ b/BasicJava_2018/DateDemo_util_getTime_setTime/DateDemo2_Output.txt @@ -0,0 +1,2 @@ +Date before setting = Sun May 13 11:29:50 IST 2018 +Date after setting = Thu Jan 01 05:33:20 IST 1970 diff --git a/BasicJava_2018/DayOfWeekDemo_Intro/DayOfWeekDemo/.classpath b/BasicJava_2018/DayOfWeekDemo_Intro/DayOfWeekDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_Intro/DayOfWeekDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/DayOfWeekDemo_Intro/DayOfWeekDemo/.project b/BasicJava_2018/DayOfWeekDemo_Intro/DayOfWeekDemo/.project new file mode 100644 index 000000000..e43474ed7 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_Intro/DayOfWeekDemo/.project @@ -0,0 +1,17 @@ + + + DayOfWeekDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/DayOfWeekDemo_Intro/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/DayOfWeekDemo_Intro/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_Intro/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/DayOfWeekDemo_Intro/DayOfWeekDemo/bin/DayOfWeekDemo.class b/BasicJava_2018/DayOfWeekDemo_Intro/DayOfWeekDemo/bin/DayOfWeekDemo.class new file mode 100644 index 000000000..985976dda Binary files /dev/null and b/BasicJava_2018/DayOfWeekDemo_Intro/DayOfWeekDemo/bin/DayOfWeekDemo.class differ diff --git a/BasicJava_2018/DayOfWeekDemo_Intro/DayOfWeekDemo/src/DayOfWeekDemo.java b/BasicJava_2018/DayOfWeekDemo_Intro/DayOfWeekDemo/src/DayOfWeekDemo.java new file mode 100644 index 000000000..10dc63dfb --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_Intro/DayOfWeekDemo/src/DayOfWeekDemo.java @@ -0,0 +1,25 @@ +import java.time.DayOfWeek; + +public class DayOfWeekDemo +{ + public static void main(String[] args) + { + + DayOfWeek dayOfWeek = DayOfWeek.MONDAY; + + /* + * Returns:the name of this enum constant + */ + System.out.println("Name = "+dayOfWeek.name()); + /* + * Returns:the day-of-week, from 1 (Monday) to 7 (Sunday) + */ + System.out.println("Value = "+dayOfWeek.getValue()); + /* + * Returns:the ordinal of this enumeration constant + */ + System.out.println("Ordinal = "+dayOfWeek.ordinal()); + + } + +} diff --git a/BasicJava_2018/DayOfWeekDemo_Intro/Output.txt b/BasicJava_2018/DayOfWeekDemo_Intro/Output.txt new file mode 100644 index 000000000..ecbe1671f --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_Intro/Output.txt @@ -0,0 +1,3 @@ +Name = MONDAY +Value = 1 +Ordinal = 0 diff --git a/BasicJava_2018/DayOfWeekDemo_from/DayOfWeekDemo/.classpath b/BasicJava_2018/DayOfWeekDemo_from/DayOfWeekDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_from/DayOfWeekDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/DayOfWeekDemo_from/DayOfWeekDemo/.project b/BasicJava_2018/DayOfWeekDemo_from/DayOfWeekDemo/.project new file mode 100644 index 000000000..e43474ed7 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_from/DayOfWeekDemo/.project @@ -0,0 +1,17 @@ + + + DayOfWeekDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/DayOfWeekDemo_from/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/DayOfWeekDemo_from/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_from/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/DayOfWeekDemo_from/DayOfWeekDemo/bin/DayOfWeekDemo.class b/BasicJava_2018/DayOfWeekDemo_from/DayOfWeekDemo/bin/DayOfWeekDemo.class new file mode 100644 index 000000000..358c8cc2e Binary files /dev/null and b/BasicJava_2018/DayOfWeekDemo_from/DayOfWeekDemo/bin/DayOfWeekDemo.class differ diff --git a/BasicJava_2018/DayOfWeekDemo_from/DayOfWeekDemo/src/DayOfWeekDemo.java b/BasicJava_2018/DayOfWeekDemo_from/DayOfWeekDemo/src/DayOfWeekDemo.java new file mode 100644 index 000000000..6eb2a16ba --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_from/DayOfWeekDemo/src/DayOfWeekDemo.java @@ -0,0 +1,25 @@ +import java.time.DayOfWeek; +import java.time.LocalDate; + +public class DayOfWeekDemo +{ + public static void main(String[] args) + { + + LocalDate localDate = LocalDate.now(); + System.out.println("localDate = "+localDate); + + /* + * Parameters: + * + * temporal - the temporal object to convert, not null + * + * Returns: + * + * the day-of-week, not null + */ + DayOfWeek dayOfWeek = DayOfWeek.from(localDate); + System.out.println("dayOfWeek = "+dayOfWeek); + } + +} diff --git a/BasicJava_2018/DayOfWeekDemo_from/Output.txt b/BasicJava_2018/DayOfWeekDemo_from/Output.txt new file mode 100644 index 000000000..2113f4b42 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_from/Output.txt @@ -0,0 +1,2 @@ +localDate = 2018-04-29 +dayOfWeek = SUNDAY diff --git a/BasicJava_2018/DayOfWeekDemo_get/DayOfWeekDemo/.classpath b/BasicJava_2018/DayOfWeekDemo_get/DayOfWeekDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_get/DayOfWeekDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/DayOfWeekDemo_get/DayOfWeekDemo/.project b/BasicJava_2018/DayOfWeekDemo_get/DayOfWeekDemo/.project new file mode 100644 index 000000000..e43474ed7 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_get/DayOfWeekDemo/.project @@ -0,0 +1,17 @@ + + + DayOfWeekDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/DayOfWeekDemo_get/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/DayOfWeekDemo_get/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_get/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/DayOfWeekDemo_get/DayOfWeekDemo/bin/DayOfWeekDemo1.class b/BasicJava_2018/DayOfWeekDemo_get/DayOfWeekDemo/bin/DayOfWeekDemo1.class new file mode 100644 index 000000000..7b4331094 Binary files /dev/null and b/BasicJava_2018/DayOfWeekDemo_get/DayOfWeekDemo/bin/DayOfWeekDemo1.class differ diff --git a/BasicJava_2018/DayOfWeekDemo_get/DayOfWeekDemo/bin/DayOfWeekDemo2.class b/BasicJava_2018/DayOfWeekDemo_get/DayOfWeekDemo/bin/DayOfWeekDemo2.class new file mode 100644 index 000000000..83db8bcfe Binary files /dev/null and b/BasicJava_2018/DayOfWeekDemo_get/DayOfWeekDemo/bin/DayOfWeekDemo2.class differ diff --git a/BasicJava_2018/DayOfWeekDemo_get/DayOfWeekDemo/src/DayOfWeekDemo1.java b/BasicJava_2018/DayOfWeekDemo_get/DayOfWeekDemo/src/DayOfWeekDemo1.java new file mode 100644 index 000000000..1c19831b3 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_get/DayOfWeekDemo/src/DayOfWeekDemo1.java @@ -0,0 +1,24 @@ +import java.time.DayOfWeek; +import java.time.temporal.ChronoField; + +public class DayOfWeekDemo1 +{ + public static void main(String[] args) + { + DayOfWeek dayOfWeek = DayOfWeek.TUESDAY; + System.out.println("dayOfWeek = "+dayOfWeek); + + /* + * Parameters: + * + * field - the field to get, not null + * + * Returns: + * + * the value for the field + */ + long value = dayOfWeek.getLong(ChronoField.DAY_OF_WEEK); + System.out.println(value); + } + +} diff --git a/BasicJava_2018/DayOfWeekDemo_get/DayOfWeekDemo/src/DayOfWeekDemo2.java b/BasicJava_2018/DayOfWeekDemo_get/DayOfWeekDemo/src/DayOfWeekDemo2.java new file mode 100644 index 000000000..b492d7650 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_get/DayOfWeekDemo/src/DayOfWeekDemo2.java @@ -0,0 +1,26 @@ +import java.time.DayOfWeek; +import java.time.temporal.ChronoField; + +public class DayOfWeekDemo2 +{ + public static void main(String[] args) + { + + DayOfWeek dayOfWeek = DayOfWeek.SUNDAY; + System.out.println("dayOfWeek = "+dayOfWeek); + + /* + * Parameters: + * + * field - the field to get, not null + * + * Returns: + * + * the value for the field, within the valid range of values + */ + int value = dayOfWeek.get(ChronoField.DAY_OF_WEEK); + System.out.println(value); + + } + +} diff --git a/BasicJava_2018/DayOfWeekDemo_get/DayOfWeekDemo1_Output.txt b/BasicJava_2018/DayOfWeekDemo_get/DayOfWeekDemo1_Output.txt new file mode 100644 index 000000000..0d4bd399d --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_get/DayOfWeekDemo1_Output.txt @@ -0,0 +1,2 @@ +dayOfWeek = TUESDAY +2 diff --git a/BasicJava_2018/DayOfWeekDemo_get/DayOfWeekDemo2_Output.txt b/BasicJava_2018/DayOfWeekDemo_get/DayOfWeekDemo2_Output.txt new file mode 100644 index 000000000..86ba94d84 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_get/DayOfWeekDemo2_Output.txt @@ -0,0 +1,2 @@ +dayOfWeek = SUNDAY +7 diff --git a/BasicJava_2018/DayOfWeekDemo_getDisplayName/DayOfWeekDemo/.classpath b/BasicJava_2018/DayOfWeekDemo_getDisplayName/DayOfWeekDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_getDisplayName/DayOfWeekDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/DayOfWeekDemo_getDisplayName/DayOfWeekDemo/.project b/BasicJava_2018/DayOfWeekDemo_getDisplayName/DayOfWeekDemo/.project new file mode 100644 index 000000000..e43474ed7 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_getDisplayName/DayOfWeekDemo/.project @@ -0,0 +1,17 @@ + + + DayOfWeekDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/DayOfWeekDemo_getDisplayName/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/DayOfWeekDemo_getDisplayName/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_getDisplayName/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/DayOfWeekDemo_getDisplayName/DayOfWeekDemo/bin/DayOfWeekDemo.class b/BasicJava_2018/DayOfWeekDemo_getDisplayName/DayOfWeekDemo/bin/DayOfWeekDemo.class new file mode 100644 index 000000000..5062862aa Binary files /dev/null and b/BasicJava_2018/DayOfWeekDemo_getDisplayName/DayOfWeekDemo/bin/DayOfWeekDemo.class differ diff --git a/BasicJava_2018/DayOfWeekDemo_getDisplayName/DayOfWeekDemo/src/DayOfWeekDemo.java b/BasicJava_2018/DayOfWeekDemo_getDisplayName/DayOfWeekDemo/src/DayOfWeekDemo.java new file mode 100644 index 000000000..7f92b3bc3 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_getDisplayName/DayOfWeekDemo/src/DayOfWeekDemo.java @@ -0,0 +1,31 @@ +import java.time.DayOfWeek; +import java.time.format.TextStyle; +import java.util.Locale; + +public class DayOfWeekDemo +{ + public static void main(String[] args) + { + DayOfWeek dayOfWeek = DayOfWeek.TUESDAY; + + /* + * Gets the textual representation, such as 'Mon' or 'Friday'. + * + * Parameters: + * + * style - the length of the text required, not null + * + * locale - the locale to use, not null + * + * Returns: + * + * the text value of the day-of-week, not null + */ + System.out.println("Full = "+dayOfWeek.getDisplayName(TextStyle.FULL, Locale.US)); + System.out + .println("Short = "+dayOfWeek.getDisplayName(TextStyle.SHORT, Locale.US)); + System.out + .println("Narrow = "+dayOfWeek.getDisplayName(TextStyle.NARROW, Locale.US)); + } + +} diff --git a/BasicJava_2018/DayOfWeekDemo_getDisplayName/Output.txt b/BasicJava_2018/DayOfWeekDemo_getDisplayName/Output.txt new file mode 100644 index 000000000..c80348c92 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_getDisplayName/Output.txt @@ -0,0 +1,3 @@ +Full = Tuesday +Short = Tue +Narrow = T diff --git a/BasicJava_2018/DayOfWeekDemo_isSupported/DayOfWeekDemo/.classpath b/BasicJava_2018/DayOfWeekDemo_isSupported/DayOfWeekDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_isSupported/DayOfWeekDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/DayOfWeekDemo_isSupported/DayOfWeekDemo/.project b/BasicJava_2018/DayOfWeekDemo_isSupported/DayOfWeekDemo/.project new file mode 100644 index 000000000..e43474ed7 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_isSupported/DayOfWeekDemo/.project @@ -0,0 +1,17 @@ + + + DayOfWeekDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/DayOfWeekDemo_isSupported/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/DayOfWeekDemo_isSupported/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_isSupported/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/DayOfWeekDemo_isSupported/DayOfWeekDemo/bin/DayOfWeekDemo.class b/BasicJava_2018/DayOfWeekDemo_isSupported/DayOfWeekDemo/bin/DayOfWeekDemo.class new file mode 100644 index 000000000..1f3975a19 Binary files /dev/null and b/BasicJava_2018/DayOfWeekDemo_isSupported/DayOfWeekDemo/bin/DayOfWeekDemo.class differ diff --git a/BasicJava_2018/DayOfWeekDemo_isSupported/DayOfWeekDemo/src/DayOfWeekDemo.java b/BasicJava_2018/DayOfWeekDemo_isSupported/DayOfWeekDemo/src/DayOfWeekDemo.java new file mode 100644 index 000000000..b1598d9c9 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_isSupported/DayOfWeekDemo/src/DayOfWeekDemo.java @@ -0,0 +1,27 @@ +import java.time.DayOfWeek; +import java.time.temporal.ChronoField; + +public class DayOfWeekDemo +{ + public static void main(String[] args) + { + DayOfWeek dayOfWeek = DayOfWeek.MONDAY; + + /* + * Parameters: + * + * field - the field to check, null returns false + * + * Returns: + * + * true if the field is supported on this day-of-week, false + * if not + */ + boolean isSupported= dayOfWeek.isSupported(ChronoField.DAY_OF_YEAR); + System.out.println(isSupported); + + isSupported= dayOfWeek.isSupported(ChronoField.DAY_OF_WEEK); + System.out.println(isSupported); + } + +} diff --git a/BasicJava_2018/DayOfWeekDemo_isSupported/Output.txt b/BasicJava_2018/DayOfWeekDemo_isSupported/Output.txt new file mode 100644 index 000000000..1d474d525 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_isSupported/Output.txt @@ -0,0 +1,2 @@ +false +true diff --git a/BasicJava_2018/DayOfWeekDemo_minus_plus/DayOfWeekDemo/.classpath b/BasicJava_2018/DayOfWeekDemo_minus_plus/DayOfWeekDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_minus_plus/DayOfWeekDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/DayOfWeekDemo_minus_plus/DayOfWeekDemo/.project b/BasicJava_2018/DayOfWeekDemo_minus_plus/DayOfWeekDemo/.project new file mode 100644 index 000000000..e43474ed7 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_minus_plus/DayOfWeekDemo/.project @@ -0,0 +1,17 @@ + + + DayOfWeekDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/DayOfWeekDemo_minus_plus/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/DayOfWeekDemo_minus_plus/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_minus_plus/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/DayOfWeekDemo_minus_plus/DayOfWeekDemo/bin/DayOfWeekDemo1.class b/BasicJava_2018/DayOfWeekDemo_minus_plus/DayOfWeekDemo/bin/DayOfWeekDemo1.class new file mode 100644 index 000000000..fbefe9655 Binary files /dev/null and b/BasicJava_2018/DayOfWeekDemo_minus_plus/DayOfWeekDemo/bin/DayOfWeekDemo1.class differ diff --git a/BasicJava_2018/DayOfWeekDemo_minus_plus/DayOfWeekDemo/bin/DayOfWeekDemo2.class b/BasicJava_2018/DayOfWeekDemo_minus_plus/DayOfWeekDemo/bin/DayOfWeekDemo2.class new file mode 100644 index 000000000..9705aee05 Binary files /dev/null and b/BasicJava_2018/DayOfWeekDemo_minus_plus/DayOfWeekDemo/bin/DayOfWeekDemo2.class differ diff --git a/BasicJava_2018/DayOfWeekDemo_minus_plus/DayOfWeekDemo/src/DayOfWeekDemo1.java b/BasicJava_2018/DayOfWeekDemo_minus_plus/DayOfWeekDemo/src/DayOfWeekDemo1.java new file mode 100644 index 000000000..f375b19bb --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_minus_plus/DayOfWeekDemo/src/DayOfWeekDemo1.java @@ -0,0 +1,23 @@ +import java.time.DayOfWeek; + +public class DayOfWeekDemo1 +{ + public static void main(String[] args) + { + DayOfWeek dayOfWeek = DayOfWeek.of(5); + System.out.println("dayOfWeek = " + dayOfWeek); + + /* + * Parameters: + * + * days - the days to subtract, positive or negative + * + * Returns: + * + * the resulting day-of-week, not null + */ + dayOfWeek = dayOfWeek.minus(2); + System.out.println("dayOfWeek = " + dayOfWeek); + } + +} diff --git a/BasicJava_2018/DayOfWeekDemo_minus_plus/DayOfWeekDemo/src/DayOfWeekDemo2.java b/BasicJava_2018/DayOfWeekDemo_minus_plus/DayOfWeekDemo/src/DayOfWeekDemo2.java new file mode 100644 index 000000000..2db77d9f8 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_minus_plus/DayOfWeekDemo/src/DayOfWeekDemo2.java @@ -0,0 +1,25 @@ +import java.time.DayOfWeek; + +public class DayOfWeekDemo2 +{ + public static void main(String[] args) + { + + DayOfWeek dayOfWeek = DayOfWeek.of(5); + System.out.println("dayOfWeek = " + dayOfWeek); + + /* + * Parameters: + * + * days - the days to add, positive or negative + * + * Returns: + * + * the resulting day-of-week, not null + */ + dayOfWeek = dayOfWeek.plus(1); + System.out.println("dayOfWeek = " + dayOfWeek); + + } + +} diff --git a/BasicJava_2018/DayOfWeekDemo_minus_plus/DayOfWeekDemo1_Output.txt b/BasicJava_2018/DayOfWeekDemo_minus_plus/DayOfWeekDemo1_Output.txt new file mode 100644 index 000000000..85d16a723 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_minus_plus/DayOfWeekDemo1_Output.txt @@ -0,0 +1,2 @@ +dayOfWeek = FRIDAY +dayOfWeek = WEDNESDAY diff --git a/BasicJava_2018/DayOfWeekDemo_minus_plus/DayOfWeekDemo2_Output.txt b/BasicJava_2018/DayOfWeekDemo_minus_plus/DayOfWeekDemo2_Output.txt new file mode 100644 index 000000000..2241c00e4 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_minus_plus/DayOfWeekDemo2_Output.txt @@ -0,0 +1,2 @@ +dayOfWeek = FRIDAY +dayOfWeek = SATURDAY diff --git a/BasicJava_2018/DayOfWeekDemo_of/DayOfWeekDemo/.classpath b/BasicJava_2018/DayOfWeekDemo_of/DayOfWeekDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_of/DayOfWeekDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/DayOfWeekDemo_of/DayOfWeekDemo/.project b/BasicJava_2018/DayOfWeekDemo_of/DayOfWeekDemo/.project new file mode 100644 index 000000000..e43474ed7 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_of/DayOfWeekDemo/.project @@ -0,0 +1,17 @@ + + + DayOfWeekDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/DayOfWeekDemo_of/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/DayOfWeekDemo_of/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_of/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/DayOfWeekDemo_of/DayOfWeekDemo/bin/DayOfWeekDemo.class b/BasicJava_2018/DayOfWeekDemo_of/DayOfWeekDemo/bin/DayOfWeekDemo.class new file mode 100644 index 000000000..ad079174a Binary files /dev/null and b/BasicJava_2018/DayOfWeekDemo_of/DayOfWeekDemo/bin/DayOfWeekDemo.class differ diff --git a/BasicJava_2018/DayOfWeekDemo_of/DayOfWeekDemo/src/DayOfWeekDemo.java b/BasicJava_2018/DayOfWeekDemo_of/DayOfWeekDemo/src/DayOfWeekDemo.java new file mode 100644 index 000000000..bbf064767 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_of/DayOfWeekDemo/src/DayOfWeekDemo.java @@ -0,0 +1,27 @@ +import java.time.DayOfWeek; + +public class DayOfWeekDemo +{ + public static void main(String[] args) + { + + /* + * Parameters: + * + * dayOfWeek - the day-of-week to represent, from 1 (Monday) + * to 7 (Sunday) + * + * Returns: + * + * the day-of-week singleton, not null + */ + DayOfWeek dayOfWeek = DayOfWeek.of(1); + System.out.println("dayOfWeek = "+dayOfWeek); + + System.out.println("Name = "+dayOfWeek.name()); + System.out.println("Value = "+dayOfWeek.getValue()); + System.out.println("Ordinal = "+dayOfWeek.ordinal()); + + } + +} diff --git a/BasicJava_2018/DayOfWeekDemo_of/Output.txt b/BasicJava_2018/DayOfWeekDemo_of/Output.txt new file mode 100644 index 000000000..ba5f7185d --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_of/Output.txt @@ -0,0 +1,4 @@ +dayOfWeek = MONDAY +Name = MONDAY +Value = 1 +Ordinal = 0 diff --git a/BasicJava_2018/DayOfWeekDemo_query/DayOfWeekDemo/.classpath b/BasicJava_2018/DayOfWeekDemo_query/DayOfWeekDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_query/DayOfWeekDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/DayOfWeekDemo_query/DayOfWeekDemo/.project b/BasicJava_2018/DayOfWeekDemo_query/DayOfWeekDemo/.project new file mode 100644 index 000000000..e43474ed7 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_query/DayOfWeekDemo/.project @@ -0,0 +1,17 @@ + + + DayOfWeekDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/DayOfWeekDemo_query/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/DayOfWeekDemo_query/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_query/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/DayOfWeekDemo_query/DayOfWeekDemo/bin/DayOfWeekDemo.class b/BasicJava_2018/DayOfWeekDemo_query/DayOfWeekDemo/bin/DayOfWeekDemo.class new file mode 100644 index 000000000..3422cefac Binary files /dev/null and b/BasicJava_2018/DayOfWeekDemo_query/DayOfWeekDemo/bin/DayOfWeekDemo.class differ diff --git a/BasicJava_2018/DayOfWeekDemo_query/DayOfWeekDemo/src/DayOfWeekDemo.java b/BasicJava_2018/DayOfWeekDemo_query/DayOfWeekDemo/src/DayOfWeekDemo.java new file mode 100644 index 000000000..0acd8e76a --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_query/DayOfWeekDemo/src/DayOfWeekDemo.java @@ -0,0 +1,28 @@ +import java.time.DayOfWeek; +import java.time.temporal.TemporalQueries; +import java.time.temporal.TemporalQuery; +import java.time.temporal.TemporalUnit; + +public class DayOfWeekDemo +{ + public static void main(String[] args) + { + DayOfWeek dayOfWeek = DayOfWeek.MONDAY; + TemporalQuery temporalQuery = TemporalQueries.precision(); + + /* + * Parameters: + * + * query - the query to invoke, not null + * + * Returns: + * + * the query result, null may be returned (defined by the + * query) + */ + + System.out.println(dayOfWeek.query(temporalQuery)); + + } + +} diff --git a/BasicJava_2018/DayOfWeekDemo_query/Output.txt b/BasicJava_2018/DayOfWeekDemo_query/Output.txt new file mode 100644 index 000000000..0344e0cd0 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_query/Output.txt @@ -0,0 +1 @@ +Days diff --git a/BasicJava_2018/DayOfWeekDemo_range/DayOfWeekDemo/.classpath b/BasicJava_2018/DayOfWeekDemo_range/DayOfWeekDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_range/DayOfWeekDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/DayOfWeekDemo_range/DayOfWeekDemo/.project b/BasicJava_2018/DayOfWeekDemo_range/DayOfWeekDemo/.project new file mode 100644 index 000000000..e43474ed7 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_range/DayOfWeekDemo/.project @@ -0,0 +1,17 @@ + + + DayOfWeekDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/DayOfWeekDemo_range/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/DayOfWeekDemo_range/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_range/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/DayOfWeekDemo_range/DayOfWeekDemo/bin/DayOfWeekDemo.class b/BasicJava_2018/DayOfWeekDemo_range/DayOfWeekDemo/bin/DayOfWeekDemo.class new file mode 100644 index 000000000..86ba66e00 Binary files /dev/null and b/BasicJava_2018/DayOfWeekDemo_range/DayOfWeekDemo/bin/DayOfWeekDemo.class differ diff --git a/BasicJava_2018/DayOfWeekDemo_range/DayOfWeekDemo/src/DayOfWeekDemo.java b/BasicJava_2018/DayOfWeekDemo_range/DayOfWeekDemo/src/DayOfWeekDemo.java new file mode 100644 index 000000000..1e29c20cb --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_range/DayOfWeekDemo/src/DayOfWeekDemo.java @@ -0,0 +1,29 @@ +import java.time.DayOfWeek; +import java.time.temporal.ChronoField; +import java.time.temporal.ValueRange; + +public class DayOfWeekDemo +{ + public static void main(String[] args) + { + + DayOfWeek dayOfWeek = DayOfWeek.of(1); + + /* + * Parameters: + * + * field - the field to query the range for, not null + * + * Returns: + * + * the range of valid values for the field, not null + */ + ValueRange valueRange = dayOfWeek.range(ChronoField.DAY_OF_WEEK); + + System.out.println(valueRange); + System.out.println("Min = " + valueRange.getMinimum()); + System.out.println("Max = " + valueRange.getMaximum()); + + } + +} diff --git a/BasicJava_2018/DayOfWeekDemo_range/Output.txt b/BasicJava_2018/DayOfWeekDemo_range/Output.txt new file mode 100644 index 000000000..9ecde7a83 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_range/Output.txt @@ -0,0 +1,3 @@ +1 - 7 +Min = 1 +Max = 7 diff --git a/BasicJava_2018/DayOfWeekDemo_valueOf/DayOfWeekDemo/.classpath b/BasicJava_2018/DayOfWeekDemo_valueOf/DayOfWeekDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_valueOf/DayOfWeekDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/DayOfWeekDemo_valueOf/DayOfWeekDemo/.project b/BasicJava_2018/DayOfWeekDemo_valueOf/DayOfWeekDemo/.project new file mode 100644 index 000000000..e43474ed7 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_valueOf/DayOfWeekDemo/.project @@ -0,0 +1,17 @@ + + + DayOfWeekDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/DayOfWeekDemo_valueOf/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/DayOfWeekDemo_valueOf/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_valueOf/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/DayOfWeekDemo_valueOf/DayOfWeekDemo/bin/DayOfWeekDemo.class b/BasicJava_2018/DayOfWeekDemo_valueOf/DayOfWeekDemo/bin/DayOfWeekDemo.class new file mode 100644 index 000000000..320538e92 Binary files /dev/null and b/BasicJava_2018/DayOfWeekDemo_valueOf/DayOfWeekDemo/bin/DayOfWeekDemo.class differ diff --git a/BasicJava_2018/DayOfWeekDemo_valueOf/DayOfWeekDemo/src/DayOfWeekDemo.java b/BasicJava_2018/DayOfWeekDemo_valueOf/DayOfWeekDemo/src/DayOfWeekDemo.java new file mode 100644 index 000000000..62f9e93d1 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_valueOf/DayOfWeekDemo/src/DayOfWeekDemo.java @@ -0,0 +1,20 @@ +import java.time.DayOfWeek; + +public class DayOfWeekDemo +{ + public static void main(String[] args) + { + /* + * Parameters: + * + * name - the name of the enum constant to be returned. + * + * Returns: + * + * the enum constant with the specified name + */ + DayOfWeek dayOfWeek = DayOfWeek.valueOf("FRIDAY"); + System.out.println("dayOfWeek = " + dayOfWeek); + } + +} diff --git a/BasicJava_2018/DayOfWeekDemo_valueOf/Output.txt b/BasicJava_2018/DayOfWeekDemo_valueOf/Output.txt new file mode 100644 index 000000000..5e12961b1 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_valueOf/Output.txt @@ -0,0 +1 @@ +dayOfWeek = FRIDAY diff --git a/BasicJava_2018/DayOfWeekDemo_values/DayOfWeekDemo/.classpath b/BasicJava_2018/DayOfWeekDemo_values/DayOfWeekDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_values/DayOfWeekDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/DayOfWeekDemo_values/DayOfWeekDemo/.project b/BasicJava_2018/DayOfWeekDemo_values/DayOfWeekDemo/.project new file mode 100644 index 000000000..e43474ed7 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_values/DayOfWeekDemo/.project @@ -0,0 +1,17 @@ + + + DayOfWeekDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/DayOfWeekDemo_values/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/DayOfWeekDemo_values/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_values/DayOfWeekDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/DayOfWeekDemo_values/DayOfWeekDemo/bin/DayOfWeekDemo.class b/BasicJava_2018/DayOfWeekDemo_values/DayOfWeekDemo/bin/DayOfWeekDemo.class new file mode 100644 index 000000000..6a8e0704f Binary files /dev/null and b/BasicJava_2018/DayOfWeekDemo_values/DayOfWeekDemo/bin/DayOfWeekDemo.class differ diff --git a/BasicJava_2018/DayOfWeekDemo_values/DayOfWeekDemo/src/DayOfWeekDemo.java b/BasicJava_2018/DayOfWeekDemo_values/DayOfWeekDemo/src/DayOfWeekDemo.java new file mode 100644 index 000000000..a290f0e49 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_values/DayOfWeekDemo/src/DayOfWeekDemo.java @@ -0,0 +1,23 @@ +import java.time.DayOfWeek; + +public class DayOfWeekDemo +{ + public static void main(String[] args) + { + + /* + * Returns: + * + * an array containing the constants of this enum + * type, in the order they are declared + */ + DayOfWeek[] dayOfWeekArray = DayOfWeek.values(); + + for (DayOfWeek dayOfWeek : dayOfWeekArray) + { + System.out.println(dayOfWeek); + } + + } + +} diff --git a/BasicJava_2018/DayOfWeekDemo_values/Output.txt b/BasicJava_2018/DayOfWeekDemo_values/Output.txt new file mode 100644 index 000000000..784c3f137 --- /dev/null +++ b/BasicJava_2018/DayOfWeekDemo_values/Output.txt @@ -0,0 +1,7 @@ +MONDAY +TUESDAY +WEDNESDAY +THURSDAY +FRIDAY +SATURDAY +SUNDAY diff --git a/BasicJava_2018/DurationDemo_Intro/DurationDemo/.classpath b/BasicJava_2018/DurationDemo_Intro/DurationDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/DurationDemo_Intro/DurationDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/DurationDemo_Intro/DurationDemo/.project b/BasicJava_2018/DurationDemo_Intro/DurationDemo/.project new file mode 100644 index 000000000..c9fc092e1 --- /dev/null +++ b/BasicJava_2018/DurationDemo_Intro/DurationDemo/.project @@ -0,0 +1,17 @@ + + + DurationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/DurationDemo_Intro/DurationDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/DurationDemo_Intro/DurationDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/DurationDemo_Intro/DurationDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/DurationDemo_Intro/DurationDemo/bin/DurationDemo.class b/BasicJava_2018/DurationDemo_Intro/DurationDemo/bin/DurationDemo.class new file mode 100644 index 000000000..4bbee065b Binary files /dev/null and b/BasicJava_2018/DurationDemo_Intro/DurationDemo/bin/DurationDemo.class differ diff --git a/BasicJava_2018/DurationDemo_Intro/DurationDemo/src/DurationDemo.java b/BasicJava_2018/DurationDemo_Intro/DurationDemo/src/DurationDemo.java new file mode 100644 index 000000000..10349a520 --- /dev/null +++ b/BasicJava_2018/DurationDemo_Intro/DurationDemo/src/DurationDemo.java @@ -0,0 +1,37 @@ +import java.time.Duration; +import java.time.LocalTime; + +public class DurationDemo +{ + + public static void main(String[] args) + { + + /* + * Parameters: + * + * startInclusive - the start instant, inclusive, not null + * + * endExclusive - the end instant, exclusive, not null + * + * Returns: a Duration, not null + * + */ + Duration duration = Duration.between(LocalTime.MIDNIGHT, + LocalTime.NOON); + System.out.println("duration = " + duration); + + /* + * Returns:the whole seconds part of the length of the + * duration, positive or negative + */ + System.out.println("seconds = " + duration.getSeconds()); + + /* + * Returns a copy of this duration with a positive length. + */ + System.out.println("abs = " + duration.abs()); + + } + +} diff --git a/BasicJava_2018/DurationDemo_Intro/Output.txt b/BasicJava_2018/DurationDemo_Intro/Output.txt new file mode 100644 index 000000000..ad966911f --- /dev/null +++ b/BasicJava_2018/DurationDemo_Intro/Output.txt @@ -0,0 +1,3 @@ +duration = PT12H +seconds = 43200 +abs = PT12H diff --git a/BasicJava_2018/DurationDemo_divide_multiply/DurationDemo/.classpath b/BasicJava_2018/DurationDemo_divide_multiply/DurationDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/DurationDemo_divide_multiply/DurationDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/DurationDemo_divide_multiply/DurationDemo/.project b/BasicJava_2018/DurationDemo_divide_multiply/DurationDemo/.project new file mode 100644 index 000000000..c9fc092e1 --- /dev/null +++ b/BasicJava_2018/DurationDemo_divide_multiply/DurationDemo/.project @@ -0,0 +1,17 @@ + + + DurationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/DurationDemo_divide_multiply/DurationDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/DurationDemo_divide_multiply/DurationDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/DurationDemo_divide_multiply/DurationDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/DurationDemo_divide_multiply/DurationDemo/bin/DurationDemo.class b/BasicJava_2018/DurationDemo_divide_multiply/DurationDemo/bin/DurationDemo.class new file mode 100644 index 000000000..efe35a8e1 Binary files /dev/null and b/BasicJava_2018/DurationDemo_divide_multiply/DurationDemo/bin/DurationDemo.class differ diff --git a/BasicJava_2018/DurationDemo_divide_multiply/DurationDemo/bin/DurationDemo1.class b/BasicJava_2018/DurationDemo_divide_multiply/DurationDemo/bin/DurationDemo1.class new file mode 100644 index 000000000..90ba7a800 Binary files /dev/null and b/BasicJava_2018/DurationDemo_divide_multiply/DurationDemo/bin/DurationDemo1.class differ diff --git a/BasicJava_2018/DurationDemo_divide_multiply/DurationDemo/bin/DurationDemo2.class b/BasicJava_2018/DurationDemo_divide_multiply/DurationDemo/bin/DurationDemo2.class new file mode 100644 index 000000000..f6106f04a Binary files /dev/null and b/BasicJava_2018/DurationDemo_divide_multiply/DurationDemo/bin/DurationDemo2.class differ diff --git a/BasicJava_2018/DurationDemo_divide_multiply/DurationDemo/src/DurationDemo.java b/BasicJava_2018/DurationDemo_divide_multiply/DurationDemo/src/DurationDemo.java new file mode 100644 index 000000000..caca64fb8 --- /dev/null +++ b/BasicJava_2018/DurationDemo_divide_multiply/DurationDemo/src/DurationDemo.java @@ -0,0 +1,34 @@ +import java.time.Duration; +import java.time.LocalTime; + +public class DurationDemo +{ + public static void main(String[] args) + { + Duration duration = Duration.between(LocalTime.MIDNIGHT, + LocalTime.NOON); + + System.out.println("Before dividedBy = " + duration); + + /* + * Parameters: + * + * divisor - the value to divide the duration by, positive or + * negative, not zero + * + * Returns: + * + * a Duration based on this duration divided by the specified + * divisor, not null + */ + duration = duration.dividedBy(2); + + System.out.println("After dividedBy 2 = " + duration); + + duration = duration.multipliedBy(3); + + System.out.println("After multipliedBy 3 = " + duration); + + } + +} diff --git a/BasicJava_2018/DurationDemo_divide_multiply/Output.txt b/BasicJava_2018/DurationDemo_divide_multiply/Output.txt new file mode 100644 index 000000000..38e3cac63 --- /dev/null +++ b/BasicJava_2018/DurationDemo_divide_multiply/Output.txt @@ -0,0 +1,3 @@ +Before dividedBy = PT12H +After dividedBy 2 = PT6H +After multipliedBy 3 = PT18H diff --git a/BasicJava_2018/DurationDemo_from/DurationDemo/.classpath b/BasicJava_2018/DurationDemo_from/DurationDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/DurationDemo_from/DurationDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/DurationDemo_from/DurationDemo/.project b/BasicJava_2018/DurationDemo_from/DurationDemo/.project new file mode 100644 index 000000000..c9fc092e1 --- /dev/null +++ b/BasicJava_2018/DurationDemo_from/DurationDemo/.project @@ -0,0 +1,17 @@ + + + DurationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/DurationDemo_from/DurationDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/DurationDemo_from/DurationDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/DurationDemo_from/DurationDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/DurationDemo_from/DurationDemo/bin/DurationDemo.class b/BasicJava_2018/DurationDemo_from/DurationDemo/bin/DurationDemo.class new file mode 100644 index 000000000..4f89e4392 Binary files /dev/null and b/BasicJava_2018/DurationDemo_from/DurationDemo/bin/DurationDemo.class differ diff --git a/BasicJava_2018/DurationDemo_from/DurationDemo/bin/DurationDemo1.class b/BasicJava_2018/DurationDemo_from/DurationDemo/bin/DurationDemo1.class new file mode 100644 index 000000000..90ba7a800 Binary files /dev/null and b/BasicJava_2018/DurationDemo_from/DurationDemo/bin/DurationDemo1.class differ diff --git a/BasicJava_2018/DurationDemo_from/DurationDemo/bin/DurationDemo2.class b/BasicJava_2018/DurationDemo_from/DurationDemo/bin/DurationDemo2.class new file mode 100644 index 000000000..f6106f04a Binary files /dev/null and b/BasicJava_2018/DurationDemo_from/DurationDemo/bin/DurationDemo2.class differ diff --git a/BasicJava_2018/DurationDemo_from/DurationDemo/src/DurationDemo.java b/BasicJava_2018/DurationDemo_from/DurationDemo/src/DurationDemo.java new file mode 100644 index 000000000..434dc6dfc --- /dev/null +++ b/BasicJava_2018/DurationDemo_from/DurationDemo/src/DurationDemo.java @@ -0,0 +1,23 @@ +import java.time.Duration; + +public class DurationDemo +{ + public static void main(String[] args) + { + /* + * Obtains an instance of Duration from a temporal amount. + * + * Parameters: + * + * amount - the temporal amount to convert, not null + * + * Returns: + * + * the equivalent duration, not null + */ + Duration duration = Duration.from(Duration.ZERO); + System.out.println(duration); + + } + +} diff --git a/BasicJava_2018/DurationDemo_from/Output.txt b/BasicJava_2018/DurationDemo_from/Output.txt new file mode 100644 index 000000000..ff3a8c155 --- /dev/null +++ b/BasicJava_2018/DurationDemo_from/Output.txt @@ -0,0 +1 @@ +PT0S diff --git a/BasicJava_2018/DurationDemo_get_temporalunit/DurationDemo/.classpath b/BasicJava_2018/DurationDemo_get_temporalunit/DurationDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/DurationDemo_get_temporalunit/DurationDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/DurationDemo_get_temporalunit/DurationDemo/.project b/BasicJava_2018/DurationDemo_get_temporalunit/DurationDemo/.project new file mode 100644 index 000000000..c9fc092e1 --- /dev/null +++ b/BasicJava_2018/DurationDemo_get_temporalunit/DurationDemo/.project @@ -0,0 +1,17 @@ + + + DurationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/DurationDemo_get_temporalunit/DurationDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/DurationDemo_get_temporalunit/DurationDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/DurationDemo_get_temporalunit/DurationDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/DurationDemo_get_temporalunit/DurationDemo/bin/DurationDemo.class b/BasicJava_2018/DurationDemo_get_temporalunit/DurationDemo/bin/DurationDemo.class new file mode 100644 index 000000000..ba269e47c Binary files /dev/null and b/BasicJava_2018/DurationDemo_get_temporalunit/DurationDemo/bin/DurationDemo.class differ diff --git a/BasicJava_2018/DurationDemo_get_temporalunit/DurationDemo/src/DurationDemo.java b/BasicJava_2018/DurationDemo_get_temporalunit/DurationDemo/src/DurationDemo.java new file mode 100644 index 000000000..fa24d3995 --- /dev/null +++ b/BasicJava_2018/DurationDemo_get_temporalunit/DurationDemo/src/DurationDemo.java @@ -0,0 +1,32 @@ +import java.time.Duration; +import java.time.LocalTime; +import java.time.temporal.ChronoUnit; + +public class DurationDemo +{ + public static void main(String[] args) + { + Duration duration = Duration.between(LocalTime.MIDNIGHT, + LocalTime.NOON); + System.out.println("duration = " + duration); + + /* + * Gets the value of the requested unit. + * + * Parameters: + * + * unit - the TemporalUnit for which to return the value + * + * Returns: + * + * the long value of the unit + * + */ + long secondsValue = duration.get(ChronoUnit.SECONDS); + System.out.println("secondsValue = " + secondsValue); + + long nanosValue = duration.get(ChronoUnit.NANOS); + System.out.println("nanosValue = " + nanosValue); + } + +} diff --git a/BasicJava_2018/DurationDemo_get_temporalunit/Output.txt b/BasicJava_2018/DurationDemo_get_temporalunit/Output.txt new file mode 100644 index 000000000..f8b2efee7 --- /dev/null +++ b/BasicJava_2018/DurationDemo_get_temporalunit/Output.txt @@ -0,0 +1,3 @@ +duration = PT12H +secondsValue = 43200 +nanosValue = 0 diff --git a/BasicJava_2018/DurationDemo_isNegative_zero/DurationDemo/.classpath b/BasicJava_2018/DurationDemo_isNegative_zero/DurationDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/DurationDemo_isNegative_zero/DurationDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/DurationDemo_isNegative_zero/DurationDemo/.project b/BasicJava_2018/DurationDemo_isNegative_zero/DurationDemo/.project new file mode 100644 index 000000000..c9fc092e1 --- /dev/null +++ b/BasicJava_2018/DurationDemo_isNegative_zero/DurationDemo/.project @@ -0,0 +1,17 @@ + + + DurationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/DurationDemo_isNegative_zero/DurationDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/DurationDemo_isNegative_zero/DurationDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/DurationDemo_isNegative_zero/DurationDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/DurationDemo_isNegative_zero/DurationDemo/bin/DurationDemo.class b/BasicJava_2018/DurationDemo_isNegative_zero/DurationDemo/bin/DurationDemo.class new file mode 100644 index 000000000..2e33c99eb Binary files /dev/null and b/BasicJava_2018/DurationDemo_isNegative_zero/DurationDemo/bin/DurationDemo.class differ diff --git a/BasicJava_2018/DurationDemo_isNegative_zero/DurationDemo/src/DurationDemo.java b/BasicJava_2018/DurationDemo_isNegative_zero/DurationDemo/src/DurationDemo.java new file mode 100644 index 000000000..e4620b784 --- /dev/null +++ b/BasicJava_2018/DurationDemo_isNegative_zero/DurationDemo/src/DurationDemo.java @@ -0,0 +1,25 @@ +import java.time.Duration; +import java.time.LocalTime; + +public class DurationDemo +{ + public static void main(String[] args) + { + + Duration duration = Duration.between(LocalTime.NOON, + LocalTime.MIDNIGHT); + System.out.println("duration = "+duration); + /* + * Returns:true if this duration has a total length less than + * zero + */ + System.out.println("is duration Negative? = "+duration.isNegative()); + + /* + * Returns:true if this duration has a total length equal to + * zero + */ + System.out.println("is duration zero? = "+duration.isZero()); + } + +} diff --git a/BasicJava_2018/DurationDemo_isNegative_zero/Output.txt b/BasicJava_2018/DurationDemo_isNegative_zero/Output.txt new file mode 100644 index 000000000..b989332cd --- /dev/null +++ b/BasicJava_2018/DurationDemo_isNegative_zero/Output.txt @@ -0,0 +1,3 @@ +duration = PT-12H +is duration Negative? = true +is duration zero? = false diff --git a/BasicJava_2018/DurationDemo_minus/DurationDemo/.classpath b/BasicJava_2018/DurationDemo_minus/DurationDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/DurationDemo_minus/DurationDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/DurationDemo_minus/DurationDemo/.project b/BasicJava_2018/DurationDemo_minus/DurationDemo/.project new file mode 100644 index 000000000..c9fc092e1 --- /dev/null +++ b/BasicJava_2018/DurationDemo_minus/DurationDemo/.project @@ -0,0 +1,17 @@ + + + DurationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/DurationDemo_minus/DurationDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/DurationDemo_minus/DurationDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/DurationDemo_minus/DurationDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/DurationDemo_minus/DurationDemo/bin/DurationDemo1.class b/BasicJava_2018/DurationDemo_minus/DurationDemo/bin/DurationDemo1.class new file mode 100644 index 000000000..06bcbce68 Binary files /dev/null and b/BasicJava_2018/DurationDemo_minus/DurationDemo/bin/DurationDemo1.class differ diff --git a/BasicJava_2018/DurationDemo_minus/DurationDemo/bin/DurationDemo2.class b/BasicJava_2018/DurationDemo_minus/DurationDemo/bin/DurationDemo2.class new file mode 100644 index 000000000..e2924ae5d Binary files /dev/null and b/BasicJava_2018/DurationDemo_minus/DurationDemo/bin/DurationDemo2.class differ diff --git a/BasicJava_2018/DurationDemo_minus/DurationDemo/src/DurationDemo1.java b/BasicJava_2018/DurationDemo_minus/DurationDemo/src/DurationDemo1.java new file mode 100644 index 000000000..b15ccee37 --- /dev/null +++ b/BasicJava_2018/DurationDemo_minus/DurationDemo/src/DurationDemo1.java @@ -0,0 +1,30 @@ +import java.time.Duration; + +public class DurationDemo1 +{ + public static void main(String[] args) + { + Duration duration = Duration.ofDays(2); + System.out.println("duration = "+duration); + + duration = duration.minusDays(1); + System.out.println("Minus 1 day = "+duration); + + duration = duration.minusHours(2); + System.out.println("Minus 2 hours = "+duration); + + duration = duration.minusMinutes(50); + System.out.println("Minus 50 mins = "+duration); + + duration = duration.minusSeconds(40); + System.out.println("Minus 40 secs = "+duration); + + duration = duration.minusMillis(10); + System.out.println("Minus 10 Millis = "+duration); + + duration = duration.minusNanos(70000); + System.out.println("Minus 70000 Nanos = "+duration); + + } + +} diff --git a/BasicJava_2018/DurationDemo_minus/DurationDemo/src/DurationDemo2.java b/BasicJava_2018/DurationDemo_minus/DurationDemo/src/DurationDemo2.java new file mode 100644 index 000000000..3d313d35e --- /dev/null +++ b/BasicJava_2018/DurationDemo_minus/DurationDemo/src/DurationDemo2.java @@ -0,0 +1,31 @@ +import java.time.Duration; +import java.time.temporal.ChronoUnit; + +public class DurationDemo2 +{ + public static void main(String[] args) + { + Duration duration = Duration.ofDays(2); + System.out.println("duration = " + duration); + + /* + * Parameters: + * + * amountToAdd - the amount to add, measured in terms of the + * unit, positive or negative unit - the unit that the amount + * is measured in, must have an exact duration, not null + * + * Returns: + * + * a Duration based on this duration with the specified + * duration added, not null + */ + duration = duration.minus(1, ChronoUnit.DAYS); + System.out.println("Minus 1 days = " + duration); + + duration = duration.minus(20, ChronoUnit.MINUTES); + System.out.println("Minus 20 minutes = " + duration); + + } + +} diff --git a/BasicJava_2018/DurationDemo_minus/DurationDemo1_Output.txt b/BasicJava_2018/DurationDemo_minus/DurationDemo1_Output.txt new file mode 100644 index 000000000..b1bd5f430 --- /dev/null +++ b/BasicJava_2018/DurationDemo_minus/DurationDemo1_Output.txt @@ -0,0 +1,7 @@ +duration = PT48H +Minus 1 day = PT24H +Minus 2 hours = PT22H +Minus 50 mins = PT21H10M +Minus 40 secs = PT21H9M20S +Minus 10 Millis = PT21H9M19.99S +Minus 70000 Nanos = PT21H9M19.98993S diff --git a/BasicJava_2018/DurationDemo_minus/DurationDemo2_Output.txt b/BasicJava_2018/DurationDemo_minus/DurationDemo2_Output.txt new file mode 100644 index 000000000..318dca2af --- /dev/null +++ b/BasicJava_2018/DurationDemo_minus/DurationDemo2_Output.txt @@ -0,0 +1,3 @@ +duration = PT48H +Minus 1 days = PT24H +Minus 20 minutes = PT23H40M diff --git a/BasicJava_2018/DurationDemo_negated/DurationDemo/.classpath b/BasicJava_2018/DurationDemo_negated/DurationDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/DurationDemo_negated/DurationDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/DurationDemo_negated/DurationDemo/.project b/BasicJava_2018/DurationDemo_negated/DurationDemo/.project new file mode 100644 index 000000000..c9fc092e1 --- /dev/null +++ b/BasicJava_2018/DurationDemo_negated/DurationDemo/.project @@ -0,0 +1,17 @@ + + + DurationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/DurationDemo_negated/DurationDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/DurationDemo_negated/DurationDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/DurationDemo_negated/DurationDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/DurationDemo_negated/DurationDemo/bin/DurationDemo.class b/BasicJava_2018/DurationDemo_negated/DurationDemo/bin/DurationDemo.class new file mode 100644 index 000000000..9383d50e9 Binary files /dev/null and b/BasicJava_2018/DurationDemo_negated/DurationDemo/bin/DurationDemo.class differ diff --git a/BasicJava_2018/DurationDemo_negated/DurationDemo/src/DurationDemo.java b/BasicJava_2018/DurationDemo_negated/DurationDemo/src/DurationDemo.java new file mode 100644 index 000000000..4257eb4c6 --- /dev/null +++ b/BasicJava_2018/DurationDemo_negated/DurationDemo/src/DurationDemo.java @@ -0,0 +1,20 @@ +import java.time.Duration; +import java.time.LocalTime; + +public class DurationDemo +{ + public static void main(String[] args) + { + Duration duration = Duration.between(LocalTime.MIDNIGHT, + LocalTime.NOON); + System.out.println("duration = " + duration); + + /* + * Returns:a Duration based on this duration with the amount + * negated, not null + */ + Duration negatedDuration = duration.negated(); + System.out.println("negatedDuration = " + negatedDuration); + } + +} diff --git a/BasicJava_2018/DurationDemo_negated/Output.txt b/BasicJava_2018/DurationDemo_negated/Output.txt new file mode 100644 index 000000000..6ce78f56e --- /dev/null +++ b/BasicJava_2018/DurationDemo_negated/Output.txt @@ -0,0 +1,2 @@ +duration = PT12H +negatedDuration = PT-12H diff --git a/BasicJava_2018/DurationDemo_of_methods/DurationDemo/.classpath b/BasicJava_2018/DurationDemo_of_methods/DurationDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/DurationDemo_of_methods/DurationDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/DurationDemo_of_methods/DurationDemo/.project b/BasicJava_2018/DurationDemo_of_methods/DurationDemo/.project new file mode 100644 index 000000000..c9fc092e1 --- /dev/null +++ b/BasicJava_2018/DurationDemo_of_methods/DurationDemo/.project @@ -0,0 +1,17 @@ + + + DurationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/DurationDemo_of_methods/DurationDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/DurationDemo_of_methods/DurationDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/DurationDemo_of_methods/DurationDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/DurationDemo_of_methods/DurationDemo/bin/DurationDemo1.class b/BasicJava_2018/DurationDemo_of_methods/DurationDemo/bin/DurationDemo1.class new file mode 100644 index 000000000..2e2263cf6 Binary files /dev/null and b/BasicJava_2018/DurationDemo_of_methods/DurationDemo/bin/DurationDemo1.class differ diff --git a/BasicJava_2018/DurationDemo_of_methods/DurationDemo/bin/DurationDemo2.class b/BasicJava_2018/DurationDemo_of_methods/DurationDemo/bin/DurationDemo2.class new file mode 100644 index 000000000..390237c93 Binary files /dev/null and b/BasicJava_2018/DurationDemo_of_methods/DurationDemo/bin/DurationDemo2.class differ diff --git a/BasicJava_2018/DurationDemo_of_methods/DurationDemo/src/DurationDemo1.java b/BasicJava_2018/DurationDemo_of_methods/DurationDemo/src/DurationDemo1.java new file mode 100644 index 000000000..4684177b5 --- /dev/null +++ b/BasicJava_2018/DurationDemo_of_methods/DurationDemo/src/DurationDemo1.java @@ -0,0 +1,32 @@ +import java.time.Duration; + +public class DurationDemo1 +{ + public static void main(String[] args) + { + /* + * Parameters: + * + * days - the number of days, positive or negative + * + * Returns: + * + * a Duration, not null + */ + Duration duration1 = Duration.ofDays(10); + System.out.println("duration1 = "+duration1); + + /* + * Parameters: + * + * hours - the number of hours, positive or negative + * + * Returns: + * + * a Duration, not null + */ + Duration duration2 = Duration.ofHours(10); + System.out.println("duration2 = "+duration2); + } + +} diff --git a/BasicJava_2018/DurationDemo_of_methods/DurationDemo/src/DurationDemo2.java b/BasicJava_2018/DurationDemo_of_methods/DurationDemo/src/DurationDemo2.java new file mode 100644 index 000000000..42beb0264 --- /dev/null +++ b/BasicJava_2018/DurationDemo_of_methods/DurationDemo/src/DurationDemo2.java @@ -0,0 +1,32 @@ +import java.time.Duration; + +public class DurationDemo2 +{ + public static void main(String[] args) + { + /* + * Parameters: + * + * millis - the number of milliseconds, positive or negative + * + * Returns: + * + * a Duration, not null + */ + Duration duration1 = Duration.ofMillis(1000); + System.out.println("duration1 = "+duration1); + + /* + * Parameters: + * + * minutes - the number of minutes, positive or negative + * + * Returns: + * + * a Duration, not null + */ + Duration duration2 = Duration.ofMinutes(20); + System.out.println("duration2 = "+duration2); + } + +} diff --git a/BasicJava_2018/DurationDemo_of_methods/DurationDemo1_Output.txt b/BasicJava_2018/DurationDemo_of_methods/DurationDemo1_Output.txt new file mode 100644 index 000000000..0a3ab4654 --- /dev/null +++ b/BasicJava_2018/DurationDemo_of_methods/DurationDemo1_Output.txt @@ -0,0 +1,2 @@ +duration1 = PT240H +duration2 = PT10H diff --git a/BasicJava_2018/DurationDemo_of_methods/DurationDemo2_Output.txt b/BasicJava_2018/DurationDemo_of_methods/DurationDemo2_Output.txt new file mode 100644 index 000000000..93c4110a5 --- /dev/null +++ b/BasicJava_2018/DurationDemo_of_methods/DurationDemo2_Output.txt @@ -0,0 +1,2 @@ +duration1 = PT1S +duration2 = PT20M diff --git a/BasicJava_2018/DurationDemo_of_nanos_sec/DurationDemo/.classpath b/BasicJava_2018/DurationDemo_of_nanos_sec/DurationDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/DurationDemo_of_nanos_sec/DurationDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/DurationDemo_of_nanos_sec/DurationDemo/.project b/BasicJava_2018/DurationDemo_of_nanos_sec/DurationDemo/.project new file mode 100644 index 000000000..c9fc092e1 --- /dev/null +++ b/BasicJava_2018/DurationDemo_of_nanos_sec/DurationDemo/.project @@ -0,0 +1,17 @@ + + + DurationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/DurationDemo_of_nanos_sec/DurationDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/DurationDemo_of_nanos_sec/DurationDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/DurationDemo_of_nanos_sec/DurationDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/DurationDemo_of_nanos_sec/DurationDemo/bin/DurationDemo1.class b/BasicJava_2018/DurationDemo_of_nanos_sec/DurationDemo/bin/DurationDemo1.class new file mode 100644 index 000000000..56fa5d0e9 Binary files /dev/null and b/BasicJava_2018/DurationDemo_of_nanos_sec/DurationDemo/bin/DurationDemo1.class differ diff --git a/BasicJava_2018/DurationDemo_of_nanos_sec/DurationDemo/bin/DurationDemo2.class b/BasicJava_2018/DurationDemo_of_nanos_sec/DurationDemo/bin/DurationDemo2.class new file mode 100644 index 000000000..1c6ab0c29 Binary files /dev/null and b/BasicJava_2018/DurationDemo_of_nanos_sec/DurationDemo/bin/DurationDemo2.class differ diff --git a/BasicJava_2018/DurationDemo_of_nanos_sec/DurationDemo/src/DurationDemo1.java b/BasicJava_2018/DurationDemo_of_nanos_sec/DurationDemo/src/DurationDemo1.java new file mode 100644 index 000000000..44fe8417f --- /dev/null +++ b/BasicJava_2018/DurationDemo_of_nanos_sec/DurationDemo/src/DurationDemo1.java @@ -0,0 +1,32 @@ +import java.time.Duration; + +public class DurationDemo1 +{ + public static void main(String[] args) + { + /* + * Parameters: + * + * nanos - the number of nanoseconds, positive or negative + * + * Returns: + * + * a Duration, not null + */ + Duration duration1 = Duration.ofNanos(2000000); + System.out.println("duration1 = "+duration1); + + /* + * Parameters: + * + * seconds - the number of seconds, positive or negative + * + * Returns: + * + * a Duration, not null + */ + Duration duration2 = Duration.ofSeconds(10); + System.out.println("duration2 = "+duration2); + } + +} diff --git a/BasicJava_2018/DurationDemo_of_nanos_sec/DurationDemo/src/DurationDemo2.java b/BasicJava_2018/DurationDemo_of_nanos_sec/DurationDemo/src/DurationDemo2.java new file mode 100644 index 000000000..6db2afd71 --- /dev/null +++ b/BasicJava_2018/DurationDemo_of_nanos_sec/DurationDemo/src/DurationDemo2.java @@ -0,0 +1,40 @@ +import java.time.Duration; +import java.time.temporal.ChronoUnit; + +public class DurationDemo2 +{ + public static void main(String[] args) + { + /* + * Parameters: + * + * seconds - the number of seconds, positive or negative + * + * nanoAdjustment - the nanosecond adjustment to the number of + * seconds, positive or negative + * + * Returns: + * + * a Duration, not null + */ + Duration duration1 = Duration.ofSeconds(10, 909090); + System.out.println("duration1 = " + duration1); + + /* + * Parameters: + * + * amount - the amount of the duration, measured in terms of + * the unit, positive or negative + * + * unit - the unit that the duration is measured in, must have + * an exact duration, not null + * + * Returns: + * + * a Duration, not null + */ + Duration duration2 = Duration.of(10, ChronoUnit.DAYS); + System.out.println("duration2 = " + duration2); + } + +} diff --git a/BasicJava_2018/DurationDemo_of_nanos_sec/DurationDemo1_Output.txt b/BasicJava_2018/DurationDemo_of_nanos_sec/DurationDemo1_Output.txt new file mode 100644 index 000000000..68313ee16 --- /dev/null +++ b/BasicJava_2018/DurationDemo_of_nanos_sec/DurationDemo1_Output.txt @@ -0,0 +1,2 @@ +duration1 = PT0.002S +duration2 = PT10S diff --git a/BasicJava_2018/DurationDemo_of_nanos_sec/DurationDemo2_Output.txt b/BasicJava_2018/DurationDemo_of_nanos_sec/DurationDemo2_Output.txt new file mode 100644 index 000000000..a39d607a3 --- /dev/null +++ b/BasicJava_2018/DurationDemo_of_nanos_sec/DurationDemo2_Output.txt @@ -0,0 +1,2 @@ +duration1 = PT10.00090909S +duration2 = PT240H diff --git a/BasicJava_2018/DurationDemo_parse/DurationDemo/.classpath b/BasicJava_2018/DurationDemo_parse/DurationDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/DurationDemo_parse/DurationDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/DurationDemo_parse/DurationDemo/.project b/BasicJava_2018/DurationDemo_parse/DurationDemo/.project new file mode 100644 index 000000000..c9fc092e1 --- /dev/null +++ b/BasicJava_2018/DurationDemo_parse/DurationDemo/.project @@ -0,0 +1,17 @@ + + + DurationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/DurationDemo_parse/DurationDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/DurationDemo_parse/DurationDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/DurationDemo_parse/DurationDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/DurationDemo_parse/DurationDemo/bin/DurationDemo.class b/BasicJava_2018/DurationDemo_parse/DurationDemo/bin/DurationDemo.class new file mode 100644 index 000000000..2c3a98e29 Binary files /dev/null and b/BasicJava_2018/DurationDemo_parse/DurationDemo/bin/DurationDemo.class differ diff --git a/BasicJava_2018/DurationDemo_parse/DurationDemo/src/DurationDemo.java b/BasicJava_2018/DurationDemo_parse/DurationDemo/src/DurationDemo.java new file mode 100644 index 000000000..8dcecbd18 --- /dev/null +++ b/BasicJava_2018/DurationDemo_parse/DurationDemo/src/DurationDemo.java @@ -0,0 +1,33 @@ +import java.time.Duration; + +public class DurationDemo +{ + public static void main(String[] args) + { + /* + * Parameters: + * + * text - the text to parse, not null + * + * Returns: + * + * the parsed duration, not null + */ + Duration duration = Duration.parse("PT15M"); + System.out.println(duration); + + duration = Duration.parse("PT10H"); + System.out.println(duration); + + duration = Duration.parse("P2D"); + System.out.println(duration); + + duration = Duration.parse("P2DT3H4M"); + System.out.println(duration); + + duration = Duration.parse("P2DT3H4M"); + System.out.println(duration); + + } + +} diff --git a/BasicJava_2018/DurationDemo_parse/Output.txt b/BasicJava_2018/DurationDemo_parse/Output.txt new file mode 100644 index 000000000..afcaf9e4b --- /dev/null +++ b/BasicJava_2018/DurationDemo_parse/Output.txt @@ -0,0 +1,5 @@ +PT15M +PT10H +PT48H +PT51H4M +PT51H4M diff --git a/BasicJava_2018/DurationDemo_plus/DurationDemo/.classpath b/BasicJava_2018/DurationDemo_plus/DurationDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/DurationDemo_plus/DurationDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/DurationDemo_plus/DurationDemo/.project b/BasicJava_2018/DurationDemo_plus/DurationDemo/.project new file mode 100644 index 000000000..c9fc092e1 --- /dev/null +++ b/BasicJava_2018/DurationDemo_plus/DurationDemo/.project @@ -0,0 +1,17 @@ + + + DurationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/DurationDemo_plus/DurationDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/DurationDemo_plus/DurationDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/DurationDemo_plus/DurationDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/DurationDemo_plus/DurationDemo/bin/DurationDemo1.class b/BasicJava_2018/DurationDemo_plus/DurationDemo/bin/DurationDemo1.class new file mode 100644 index 000000000..527a3aafc Binary files /dev/null and b/BasicJava_2018/DurationDemo_plus/DurationDemo/bin/DurationDemo1.class differ diff --git a/BasicJava_2018/DurationDemo_plus/DurationDemo/bin/DurationDemo2.class b/BasicJava_2018/DurationDemo_plus/DurationDemo/bin/DurationDemo2.class new file mode 100644 index 000000000..df11e722c Binary files /dev/null and b/BasicJava_2018/DurationDemo_plus/DurationDemo/bin/DurationDemo2.class differ diff --git a/BasicJava_2018/DurationDemo_plus/DurationDemo/src/DurationDemo1.java b/BasicJava_2018/DurationDemo_plus/DurationDemo/src/DurationDemo1.java new file mode 100644 index 000000000..f773194ae --- /dev/null +++ b/BasicJava_2018/DurationDemo_plus/DurationDemo/src/DurationDemo1.java @@ -0,0 +1,30 @@ +import java.time.Duration; + +public class DurationDemo1 +{ + public static void main(String[] args) + { + Duration duration = Duration.ofDays(1); + System.out.println("duration = "+duration); + + duration = duration.plusDays(1); + System.out.println("Plus 1 day = "+duration); + + duration = duration.plusHours(2); + System.out.println("Plus 2 hours = "+duration); + + duration = duration.plusMinutes(50); + System.out.println("Plus 50 mins = "+duration); + + duration = duration.plusSeconds(40); + System.out.println("Plus 40 secs = "+duration); + + duration = duration.plusMillis(10); + System.out.println("Plus 10 Millis = "+duration); + + duration = duration.plusNanos(70000); + System.out.println("Plus 70000 Nanos = "+duration); + + } + +} diff --git a/BasicJava_2018/DurationDemo_plus/DurationDemo/src/DurationDemo2.java b/BasicJava_2018/DurationDemo_plus/DurationDemo/src/DurationDemo2.java new file mode 100644 index 000000000..d68cbe82a --- /dev/null +++ b/BasicJava_2018/DurationDemo_plus/DurationDemo/src/DurationDemo2.java @@ -0,0 +1,33 @@ +import java.time.Duration; +import java.time.temporal.ChronoUnit; + +public class DurationDemo2 +{ + public static void main(String[] args) + { + Duration duration = Duration.ofDays(1); + System.out.println("duration = " + duration); + + /* + * Parameters: + * + * amountToAdd - the amount to add, measured in terms of the + * unit, positive or negative + * + * unit - the unit that the amount is measured in, must have + * an exact duration, not null + * + * Returns: + * + * a Duration based on this duration with the specified + * duration added, not null + */ + duration = duration.plus(1, ChronoUnit.DAYS); + System.out.println("Plus 1 days = " + duration); + + duration = duration.plus(20, ChronoUnit.MINUTES); + System.out.println("Plus 20 minutes = " + duration); + + } + +} diff --git a/BasicJava_2018/DurationDemo_plus/DurationDemo1_Output.txt b/BasicJava_2018/DurationDemo_plus/DurationDemo1_Output.txt new file mode 100644 index 000000000..969d2f497 --- /dev/null +++ b/BasicJava_2018/DurationDemo_plus/DurationDemo1_Output.txt @@ -0,0 +1,7 @@ +duration = PT24H +Plus 1 day = PT48H +Plus 2 hours = PT50H +Plus 50 mins = PT50H50M +Plus 40 secs = PT50H50M40S +Plus 10 Millis = PT50H50M40.01S +Plus 70000 Nanos = PT50H50M40.01007S diff --git a/BasicJava_2018/DurationDemo_plus/DurationDemo2_Output.txt b/BasicJava_2018/DurationDemo_plus/DurationDemo2_Output.txt new file mode 100644 index 000000000..d384264be --- /dev/null +++ b/BasicJava_2018/DurationDemo_plus/DurationDemo2_Output.txt @@ -0,0 +1,3 @@ +duration = PT24H +Plus 1 days = PT48H +Plus 20 minutes = PT48H20M diff --git a/BasicJava_2018/DurationDemo_subtractFrom/DurationDemo/.classpath b/BasicJava_2018/DurationDemo_subtractFrom/DurationDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/DurationDemo_subtractFrom/DurationDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/DurationDemo_subtractFrom/DurationDemo/.project b/BasicJava_2018/DurationDemo_subtractFrom/DurationDemo/.project new file mode 100644 index 000000000..c9fc092e1 --- /dev/null +++ b/BasicJava_2018/DurationDemo_subtractFrom/DurationDemo/.project @@ -0,0 +1,17 @@ + + + DurationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/DurationDemo_subtractFrom/DurationDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/DurationDemo_subtractFrom/DurationDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/DurationDemo_subtractFrom/DurationDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/DurationDemo_subtractFrom/DurationDemo/bin/DurationDemo.class b/BasicJava_2018/DurationDemo_subtractFrom/DurationDemo/bin/DurationDemo.class new file mode 100644 index 000000000..30f8d5d13 Binary files /dev/null and b/BasicJava_2018/DurationDemo_subtractFrom/DurationDemo/bin/DurationDemo.class differ diff --git a/BasicJava_2018/DurationDemo_subtractFrom/DurationDemo/src/DurationDemo.java b/BasicJava_2018/DurationDemo_subtractFrom/DurationDemo/src/DurationDemo.java new file mode 100644 index 000000000..bae1551ed --- /dev/null +++ b/BasicJava_2018/DurationDemo_subtractFrom/DurationDemo/src/DurationDemo.java @@ -0,0 +1,30 @@ +import java.time.Duration; +import java.time.LocalDateTime; +import java.time.temporal.Temporal; + +public class DurationDemo +{ + public static void main(String[] args) + { + Duration duration = Duration.ofDays(5); + System.out.println("duration = "+duration); + + LocalDateTime localDateTime = LocalDateTime.now(); + System.out.println("localDateTime = "+localDateTime); + + /* + * Parameters: + * + * temporal - the temporal object to adjust, not null + * + * Returns: + * + * an object of the same type with the adjustment made, not + * null + */ + Temporal temporal = duration.subtractFrom(localDateTime); + System.out.println("temporal = "+temporal); + + } + +} diff --git a/BasicJava_2018/DurationDemo_subtractFrom/Output.txt b/BasicJava_2018/DurationDemo_subtractFrom/Output.txt new file mode 100644 index 000000000..1fb0244e1 --- /dev/null +++ b/BasicJava_2018/DurationDemo_subtractFrom/Output.txt @@ -0,0 +1,3 @@ +duration = PT120H +localDateTime = 2018-03-23T09:10:38.480 +temporal = 2018-03-18T09:10:38.480 diff --git a/BasicJava_2018/DurationDemo_to/DurationDemo/.classpath b/BasicJava_2018/DurationDemo_to/DurationDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/DurationDemo_to/DurationDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/DurationDemo_to/DurationDemo/.project b/BasicJava_2018/DurationDemo_to/DurationDemo/.project new file mode 100644 index 000000000..c9fc092e1 --- /dev/null +++ b/BasicJava_2018/DurationDemo_to/DurationDemo/.project @@ -0,0 +1,17 @@ + + + DurationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/DurationDemo_to/DurationDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/DurationDemo_to/DurationDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/DurationDemo_to/DurationDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/DurationDemo_to/DurationDemo/bin/DurationDemo.class b/BasicJava_2018/DurationDemo_to/DurationDemo/bin/DurationDemo.class new file mode 100644 index 000000000..bc014c117 Binary files /dev/null and b/BasicJava_2018/DurationDemo_to/DurationDemo/bin/DurationDemo.class differ diff --git a/BasicJava_2018/DurationDemo_to/DurationDemo/src/DurationDemo.java b/BasicJava_2018/DurationDemo_to/DurationDemo/src/DurationDemo.java new file mode 100644 index 000000000..7f1eeefe9 --- /dev/null +++ b/BasicJava_2018/DurationDemo_to/DurationDemo/src/DurationDemo.java @@ -0,0 +1,41 @@ +import java.time.Duration; + +public class DurationDemo +{ + public static void main(String[] args) + { + Duration duration = Duration.ofHours(48); + + System.out.println("duration = " + duration); + + + /* + * Returns:the number of days in the duration, may be negative + */ + System.out.println("toDays = " + duration.toDays()); + + /* + * Returns:the number of hours in the duration, may be + * negative + */ + System.out.println("toHours = " + duration.toHours()); + + /* + * Returns:the number of minutes in the duration, may be + * negative + */ + System.out.println("toMinutes = " + duration.toMinutes()); + + /* + * Returns:the total length of the duration in milliseconds + */ + System.out.println("toMillis = " + duration.toMillis()); + + /* + * Returns:the total length of the duration in nanoseconds + */ + System.out.println("toNanos = " + duration.toNanos()); + + } + +} diff --git a/BasicJava_2018/DurationDemo_to/Output.txt b/BasicJava_2018/DurationDemo_to/Output.txt new file mode 100644 index 000000000..f1fede237 --- /dev/null +++ b/BasicJava_2018/DurationDemo_to/Output.txt @@ -0,0 +1,6 @@ +duration = PT48H +toDays = 2 +toHours = 48 +toMinutes = 2880 +toMillis = 172800000 +toNanos = 172800000000000 diff --git a/BasicJava_2018/DurationDemo_with/DurationDemo/.classpath b/BasicJava_2018/DurationDemo_with/DurationDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/DurationDemo_with/DurationDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/DurationDemo_with/DurationDemo/.project b/BasicJava_2018/DurationDemo_with/DurationDemo/.project new file mode 100644 index 000000000..c9fc092e1 --- /dev/null +++ b/BasicJava_2018/DurationDemo_with/DurationDemo/.project @@ -0,0 +1,17 @@ + + + DurationDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/DurationDemo_with/DurationDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/DurationDemo_with/DurationDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/DurationDemo_with/DurationDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/DurationDemo_with/DurationDemo/bin/DurationDemo.class b/BasicJava_2018/DurationDemo_with/DurationDemo/bin/DurationDemo.class new file mode 100644 index 000000000..e54a7afbb Binary files /dev/null and b/BasicJava_2018/DurationDemo_with/DurationDemo/bin/DurationDemo.class differ diff --git a/BasicJava_2018/DurationDemo_with/DurationDemo/bin/DurationDemo1.class b/BasicJava_2018/DurationDemo_with/DurationDemo/bin/DurationDemo1.class new file mode 100644 index 000000000..90ba7a800 Binary files /dev/null and b/BasicJava_2018/DurationDemo_with/DurationDemo/bin/DurationDemo1.class differ diff --git a/BasicJava_2018/DurationDemo_with/DurationDemo/bin/DurationDemo2.class b/BasicJava_2018/DurationDemo_with/DurationDemo/bin/DurationDemo2.class new file mode 100644 index 000000000..f6106f04a Binary files /dev/null and b/BasicJava_2018/DurationDemo_with/DurationDemo/bin/DurationDemo2.class differ diff --git a/BasicJava_2018/DurationDemo_with/DurationDemo/src/DurationDemo.java b/BasicJava_2018/DurationDemo_with/DurationDemo/src/DurationDemo.java new file mode 100644 index 000000000..552401288 --- /dev/null +++ b/BasicJava_2018/DurationDemo_with/DurationDemo/src/DurationDemo.java @@ -0,0 +1,43 @@ +import java.time.Duration; +import java.time.LocalTime; + +public class DurationDemo +{ + public static void main(String[] args) + { + Duration duration = Duration.between(LocalTime.MIDNIGHT, + LocalTime.NOON); + System.out.println("Before withNanos = " + duration.getNano()); + + /* + * Parameters: + * + * nanoOfSecond - the nano-of-second to represent, from 0 to + * 999,999,999 + * + * Returns: + * + * a Duration based on this period with the requested + * nano-of-second, not null + */ + duration = duration.withNanos(10000); + System.out.println("After withNanos = " + duration.getNano()); + + System.out.println("Before withSeconds = " + duration.getSeconds()); + + /* + * Parameters: + * + * seconds - the seconds to represent, may be negative + * + * Returns: + * + * a Duration based on this period with the requested seconds, + * not null + */ + duration = duration.withSeconds(3000); + System.out.println("After withSeconds = " + duration.getSeconds()); + + } + +} diff --git a/BasicJava_2018/DurationDemo_with/Output.txt b/BasicJava_2018/DurationDemo_with/Output.txt new file mode 100644 index 000000000..44660e0ae --- /dev/null +++ b/BasicJava_2018/DurationDemo_with/Output.txt @@ -0,0 +1,4 @@ +Before withNanos = 0 +After withNanos = 10000 +Before withSeconds = 43200 +After withSeconds = 3000 diff --git a/BasicJava_2018/GregorianCalendarDemo-equals/GregorianCalendarDemo/.classpath b/BasicJava_2018/GregorianCalendarDemo-equals/GregorianCalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo-equals/GregorianCalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/GregorianCalendarDemo-equals/GregorianCalendarDemo/.project b/BasicJava_2018/GregorianCalendarDemo-equals/GregorianCalendarDemo/.project new file mode 100644 index 000000000..e91c8879a --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo-equals/GregorianCalendarDemo/.project @@ -0,0 +1,17 @@ + + + GregorianCalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/GregorianCalendarDemo-equals/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/GregorianCalendarDemo-equals/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo-equals/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/GregorianCalendarDemo-equals/GregorianCalendarDemo/bin/GregorianCalendarDemo.class b/BasicJava_2018/GregorianCalendarDemo-equals/GregorianCalendarDemo/bin/GregorianCalendarDemo.class new file mode 100644 index 000000000..dce3de0f3 Binary files /dev/null and b/BasicJava_2018/GregorianCalendarDemo-equals/GregorianCalendarDemo/bin/GregorianCalendarDemo.class differ diff --git a/BasicJava_2018/GregorianCalendarDemo-equals/GregorianCalendarDemo/src/GregorianCalendarDemo.java b/BasicJava_2018/GregorianCalendarDemo-equals/GregorianCalendarDemo/src/GregorianCalendarDemo.java new file mode 100644 index 000000000..ea92482b0 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo-equals/GregorianCalendarDemo/src/GregorianCalendarDemo.java @@ -0,0 +1,26 @@ +import java.util.GregorianCalendar; + +public class GregorianCalendarDemo +{ + public static void main(String[] args) + { + GregorianCalendar cal1 = (GregorianCalendar) GregorianCalendar + .getInstance(); + System.out.println("cal1 = "+cal1.getTime()); + + GregorianCalendar cal2 = (GregorianCalendar) cal1.clone(); + System.out.println("cal2 = "+cal1.getTime()); + + /* + * Parameters: + * + * obj - the object to compare with. + * + * Returns:true if this object is equal to obj; false + * otherwise. + */ + // compare the two calendars + System.out.println("cal1 and cal2 are equal = " + cal1.equals(cal2)); + + } +} diff --git a/BasicJava_2018/GregorianCalendarDemo-equals/Output.txt b/BasicJava_2018/GregorianCalendarDemo-equals/Output.txt new file mode 100644 index 000000000..574512d86 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo-equals/Output.txt @@ -0,0 +1,3 @@ +cal1 = Thu Oct 11 09:02:24 IST 2018 +cal2 = Thu Oct 11 09:02:24 IST 2018 +cal1 and cal2 are equal = true diff --git a/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo/.classpath b/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo/.project b/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo/.project new file mode 100644 index 000000000..e91c8879a --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo/.project @@ -0,0 +1,17 @@ + + + GregorianCalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo/bin/GregorianCalendarDemo1.class b/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo/bin/GregorianCalendarDemo1.class new file mode 100644 index 000000000..8ff207de9 Binary files /dev/null and b/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo/bin/GregorianCalendarDemo1.class differ diff --git a/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo/bin/GregorianCalendarDemo2.class b/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo/bin/GregorianCalendarDemo2.class new file mode 100644 index 000000000..be1b43aeb Binary files /dev/null and b/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo/bin/GregorianCalendarDemo2.class differ diff --git a/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo/bin/GregorianCalendarDemo3.class b/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo/bin/GregorianCalendarDemo3.class new file mode 100644 index 000000000..ccedc6e99 Binary files /dev/null and b/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo/bin/GregorianCalendarDemo3.class differ diff --git a/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo/src/GregorianCalendarDemo1.java b/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo/src/GregorianCalendarDemo1.java new file mode 100644 index 000000000..248f69cc0 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo/src/GregorianCalendarDemo1.java @@ -0,0 +1,18 @@ +import java.util.GregorianCalendar; +import java.util.Locale; + +public class GregorianCalendarDemo1 +{ + public static void main(String[] args) + { + Locale locale = Locale.getDefault(); + System.out.println("locale = "+locale); + /* + * Parameters: + * + * aLocale - the given locale. + */ + GregorianCalendar cal = new GregorianCalendar(locale); + System.out.println(cal.getTime()); + } +} diff --git a/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo/src/GregorianCalendarDemo2.java b/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo/src/GregorianCalendarDemo2.java new file mode 100644 index 000000000..6555f6c24 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo/src/GregorianCalendarDemo2.java @@ -0,0 +1,19 @@ +import java.util.GregorianCalendar; +import java.util.TimeZone; + +public class GregorianCalendarDemo2 +{ + public static void main(String[] args) + { + TimeZone timeZone = TimeZone.getDefault(); + System.out.println("timeZone = "+timeZone); + + /* + * Parameters: + * + * zone - the given time zone. + */ + GregorianCalendar cal = new GregorianCalendar(timeZone); + System.out.println(cal.getTime()); + } +} diff --git a/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo/src/GregorianCalendarDemo3.java b/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo/src/GregorianCalendarDemo3.java new file mode 100644 index 000000000..132527f53 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo/src/GregorianCalendarDemo3.java @@ -0,0 +1,24 @@ +import java.util.GregorianCalendar; +import java.util.Locale; +import java.util.TimeZone; + +public class GregorianCalendarDemo3 +{ + public static void main(String[] args) + { + TimeZone timeZone = TimeZone.getDefault(); + System.out.println("timeZone = "+timeZone); + + Locale locale = Locale.getDefault(); + System.out.println("locale = "+locale); + + /* + * Parameters: + * + * zone - the given time zone. + * aLocale - the given locale. + */ + GregorianCalendar cal = new GregorianCalendar(timeZone,locale); + System.out.println(cal.getTime()); + } +} diff --git a/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo1_Output.txt b/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo1_Output.txt new file mode 100644 index 000000000..b9350781f --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo1_Output.txt @@ -0,0 +1,2 @@ +locale = en_US +Thu Aug 09 09:31:15 IST 2018 diff --git a/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo2_Output.txt b/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo2_Output.txt new file mode 100644 index 000000000..3140ce49c --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo2_Output.txt @@ -0,0 +1,2 @@ +timeZone = sun.util.calendar.ZoneInfo[id="Asia/Calcutta",offset=19800000,dstSavings=0,useDaylight=false,transitions=6,lastRule=null] +Thu Aug 09 09:31:23 IST 2018 diff --git a/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo3_Output.txt b/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo3_Output.txt new file mode 100644 index 000000000..2789ec4b6 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_Cons_locale_timezone/GregorianCalendarDemo3_Output.txt @@ -0,0 +1,3 @@ +timeZone = sun.util.calendar.ZoneInfo[id="Asia/Calcutta",offset=19800000,dstSavings=0,useDaylight=false,transitions=6,lastRule=null] +locale = en_US +Thu Aug 09 09:31:32 IST 2018 diff --git a/BasicJava_2018/GregorianCalendarDemo_Intro/GregorianCalendarDemo/.classpath b/BasicJava_2018/GregorianCalendarDemo_Intro/GregorianCalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_Intro/GregorianCalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/GregorianCalendarDemo_Intro/GregorianCalendarDemo/.project b/BasicJava_2018/GregorianCalendarDemo_Intro/GregorianCalendarDemo/.project new file mode 100644 index 000000000..e91c8879a --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_Intro/GregorianCalendarDemo/.project @@ -0,0 +1,17 @@ + + + GregorianCalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/GregorianCalendarDemo_Intro/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/GregorianCalendarDemo_Intro/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_Intro/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/GregorianCalendarDemo_Intro/GregorianCalendarDemo/bin/GregorianCalendarDemo.class b/BasicJava_2018/GregorianCalendarDemo_Intro/GregorianCalendarDemo/bin/GregorianCalendarDemo.class new file mode 100644 index 000000000..80982477b Binary files /dev/null and b/BasicJava_2018/GregorianCalendarDemo_Intro/GregorianCalendarDemo/bin/GregorianCalendarDemo.class differ diff --git a/BasicJava_2018/GregorianCalendarDemo_Intro/GregorianCalendarDemo/src/GregorianCalendarDemo.java b/BasicJava_2018/GregorianCalendarDemo_Intro/GregorianCalendarDemo/src/GregorianCalendarDemo.java new file mode 100644 index 000000000..000cf8a93 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_Intro/GregorianCalendarDemo/src/GregorianCalendarDemo.java @@ -0,0 +1,17 @@ +import java.util.Date; +import java.util.GregorianCalendar; + +public class GregorianCalendarDemo +{ + public static void main(String[] args) + { + GregorianCalendar cal = new GregorianCalendar(); + + /* + * Returns a Date object representing this Calendar's time + * value + */ + Date date = cal.getTime(); + System.out.println(date); + } +} diff --git a/BasicJava_2018/GregorianCalendarDemo_Intro/Output.txt b/BasicJava_2018/GregorianCalendarDemo_Intro/Output.txt new file mode 100644 index 000000000..d286be01f --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_Intro/Output.txt @@ -0,0 +1 @@ +Sat Jul 21 09:21:00 IST 2018 diff --git a/BasicJava_2018/GregorianCalendarDemo_add_amount/GregorianCalendarDemo/.classpath b/BasicJava_2018/GregorianCalendarDemo_add_amount/GregorianCalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_add_amount/GregorianCalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/GregorianCalendarDemo_add_amount/GregorianCalendarDemo/.project b/BasicJava_2018/GregorianCalendarDemo_add_amount/GregorianCalendarDemo/.project new file mode 100644 index 000000000..e91c8879a --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_add_amount/GregorianCalendarDemo/.project @@ -0,0 +1,17 @@ + + + GregorianCalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/GregorianCalendarDemo_add_amount/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/GregorianCalendarDemo_add_amount/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_add_amount/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/GregorianCalendarDemo_add_amount/GregorianCalendarDemo/bin/GregorianCalendarDemo.class b/BasicJava_2018/GregorianCalendarDemo_add_amount/GregorianCalendarDemo/bin/GregorianCalendarDemo.class new file mode 100644 index 000000000..a6efe6165 Binary files /dev/null and b/BasicJava_2018/GregorianCalendarDemo_add_amount/GregorianCalendarDemo/bin/GregorianCalendarDemo.class differ diff --git a/BasicJava_2018/GregorianCalendarDemo_add_amount/GregorianCalendarDemo/src/GregorianCalendarDemo.java b/BasicJava_2018/GregorianCalendarDemo_add_amount/GregorianCalendarDemo/src/GregorianCalendarDemo.java new file mode 100644 index 000000000..234103ca1 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_add_amount/GregorianCalendarDemo/src/GregorianCalendarDemo.java @@ -0,0 +1,29 @@ +import java.util.GregorianCalendar; + +public class GregorianCalendarDemo +{ + public static void main(String[] args) + { + GregorianCalendar cal = (GregorianCalendar) GregorianCalendar + .getInstance(); + + System.out.println(cal.getTime()); + + /* + * Parameters: + * + * field - the calendar field. + * + * amount - the amount of date or time to be added to the + * field. + */ + // add 2 months + cal.add(GregorianCalendar.MONTH, 2); + System.out.println(cal.getTime()); + + // add 2 years + cal.add(GregorianCalendar.YEAR, 2); + System.out.println(cal.getTime()); + + } +} diff --git a/BasicJava_2018/GregorianCalendarDemo_add_amount/Output.txt b/BasicJava_2018/GregorianCalendarDemo_add_amount/Output.txt new file mode 100644 index 000000000..33fc07fc1 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_add_amount/Output.txt @@ -0,0 +1,3 @@ +Thu Oct 11 08:50:55 IST 2018 +Tue Dec 11 08:50:55 IST 2018 +Fri Dec 11 08:50:55 IST 2020 diff --git a/BasicJava_2018/GregorianCalendarDemo_cons/GregorianCalendarDemo/.classpath b/BasicJava_2018/GregorianCalendarDemo_cons/GregorianCalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_cons/GregorianCalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/GregorianCalendarDemo_cons/GregorianCalendarDemo/.project b/BasicJava_2018/GregorianCalendarDemo_cons/GregorianCalendarDemo/.project new file mode 100644 index 000000000..e91c8879a --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_cons/GregorianCalendarDemo/.project @@ -0,0 +1,17 @@ + + + GregorianCalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/GregorianCalendarDemo_cons/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/GregorianCalendarDemo_cons/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_cons/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/GregorianCalendarDemo_cons/GregorianCalendarDemo/bin/GregorianCalendarDemo.class b/BasicJava_2018/GregorianCalendarDemo_cons/GregorianCalendarDemo/bin/GregorianCalendarDemo.class new file mode 100644 index 000000000..986420749 Binary files /dev/null and b/BasicJava_2018/GregorianCalendarDemo_cons/GregorianCalendarDemo/bin/GregorianCalendarDemo.class differ diff --git a/BasicJava_2018/GregorianCalendarDemo_cons/GregorianCalendarDemo/src/GregorianCalendarDemo.java b/BasicJava_2018/GregorianCalendarDemo_cons/GregorianCalendarDemo/src/GregorianCalendarDemo.java new file mode 100644 index 000000000..7018b2c18 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_cons/GregorianCalendarDemo/src/GregorianCalendarDemo.java @@ -0,0 +1,68 @@ +import java.util.GregorianCalendar; + +public class GregorianCalendarDemo +{ + public static void main(String[] args) + { + /* + * Parameters: + * + * year - the value used to set the YEAR calendar field in the + * calendar. + * + * month - the value used to set the MONTH calendar field in + * the calendar. Month value is 0-based. e.g., 0 for January. + * + * dayOfMonth - the value used to set the DAY_OF_MONTH + * calendar field in the calendar. + */ + GregorianCalendar cal1 = new GregorianCalendar(2017, 10, 21); + System.out.println(cal1.getTime()); + + + /* + * Parameters: + * + * year - the value used to set the YEAR calendar field in the + * calendar. + * + * month - the value used to set the MONTH calendar field in + * the calendar. Month value is 0-based. e.g., 0 for January. + * + * dayOfMonth - the value used to set the DAY_OF_MONTH + * calendar field in the calendar. + * + * hourOfDay - the value used to set the HOUR_OF_DAY calendar + * field in the calendar. + * + * minute - the value used to set the MINUTE calendar field in + * the calendar. + */ + GregorianCalendar cal2 = new GregorianCalendar(2017, 2, 9, 22, 23); + System.out.println(cal2.getTime()); + + /* + * Parameters: + * + * year - the value used to set the YEAR calendar field in the + * calendar. + * + * month - the value used to set the MONTH calendar field in + * the calendar. Month value is 0-based. e.g., 0 for January. + * + * dayOfMonth - the value used to set the DAY_OF_MONTH + * calendar field in the calendar. + * + * hourOfDay - the value used to set the HOUR_OF_DAY calendar + * field in the calendar. + * + * minute - the value used to set the MINUTE calendar field in + * the calendar. + * + * second - the value used to set the SECOND calendar field in + * the calendar. + */ + GregorianCalendar cal3 = new GregorianCalendar(2017,2,9,40,43,52); + System.out.println(cal3.getTime()); + } +} diff --git a/BasicJava_2018/GregorianCalendarDemo_cons/Output.txt b/BasicJava_2018/GregorianCalendarDemo_cons/Output.txt new file mode 100644 index 000000000..2d0c4cf86 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_cons/Output.txt @@ -0,0 +1,3 @@ +Tue Nov 21 00:00:00 IST 2017 +Thu Mar 09 22:23:00 IST 2017 +Fri Mar 10 16:43:52 IST 2017 diff --git a/BasicJava_2018/GregorianCalendarDemo_getActualMax_Min/GregorianCalendarDemo/.classpath b/BasicJava_2018/GregorianCalendarDemo_getActualMax_Min/GregorianCalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getActualMax_Min/GregorianCalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/GregorianCalendarDemo_getActualMax_Min/GregorianCalendarDemo/.project b/BasicJava_2018/GregorianCalendarDemo_getActualMax_Min/GregorianCalendarDemo/.project new file mode 100644 index 000000000..e91c8879a --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getActualMax_Min/GregorianCalendarDemo/.project @@ -0,0 +1,17 @@ + + + GregorianCalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/GregorianCalendarDemo_getActualMax_Min/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/GregorianCalendarDemo_getActualMax_Min/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getActualMax_Min/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/GregorianCalendarDemo_getActualMax_Min/GregorianCalendarDemo/bin/GregorianCalendarDemo.class b/BasicJava_2018/GregorianCalendarDemo_getActualMax_Min/GregorianCalendarDemo/bin/GregorianCalendarDemo.class new file mode 100644 index 000000000..9c8db3bbe Binary files /dev/null and b/BasicJava_2018/GregorianCalendarDemo_getActualMax_Min/GregorianCalendarDemo/bin/GregorianCalendarDemo.class differ diff --git a/BasicJava_2018/GregorianCalendarDemo_getActualMax_Min/GregorianCalendarDemo/src/GregorianCalendarDemo.java b/BasicJava_2018/GregorianCalendarDemo_getActualMax_Min/GregorianCalendarDemo/src/GregorianCalendarDemo.java new file mode 100644 index 000000000..91e7bb9b6 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getActualMax_Min/GregorianCalendarDemo/src/GregorianCalendarDemo.java @@ -0,0 +1,43 @@ +import java.util.GregorianCalendar; + +public class GregorianCalendarDemo +{ + public static void main(String[] args) + { + GregorianCalendar gCal = (GregorianCalendar) GregorianCalendar + .getInstance(); + + /* + * Parameters: + * + * field - the calendar field + * + * Returns: + * + * the maximum of the given field for the time value of this + * GregorianCalendar + */ + int max = gCal.getActualMaximum(GregorianCalendar.DAY_OF_MONTH); + System.out.println("Actual Maximum, DAY_OF_MONTH = " + max); + + max = gCal.getActualMaximum(GregorianCalendar.MONTH); + System.out.println("Actual Maximum, MONTH = " + max); + + /* + * Parameters: + * + * field - the calendar field + * + * Returns: + * + * the minimum of the given field for the time value of this + * GregorianCalendar + */ + int min = gCal.getActualMinimum(GregorianCalendar.DAY_OF_MONTH); + System.out.println("Actual Minimum, DAY_OF_MONTH = " + min); + + min = gCal.getActualMinimum(GregorianCalendar.MONTH); + System.out.println("Actual Minimum, MONTH = " + min); + + } +} diff --git a/BasicJava_2018/GregorianCalendarDemo_getActualMax_Min/Output.txt b/BasicJava_2018/GregorianCalendarDemo_getActualMax_Min/Output.txt new file mode 100644 index 000000000..795c39ba4 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getActualMax_Min/Output.txt @@ -0,0 +1,4 @@ +Actual Maximum, DAY_OF_MONTH = 30 +Actual Maximum, MONTH = 11 +Actual Minimum, DAY_OF_MONTH = 1 +Actual Minimum, MONTH = 0 diff --git a/BasicJava_2018/GregorianCalendarDemo_getGreatestMinimum/GregorianCalendarDemo/.classpath b/BasicJava_2018/GregorianCalendarDemo_getGreatestMinimum/GregorianCalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getGreatestMinimum/GregorianCalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/GregorianCalendarDemo_getGreatestMinimum/GregorianCalendarDemo/.project b/BasicJava_2018/GregorianCalendarDemo_getGreatestMinimum/GregorianCalendarDemo/.project new file mode 100644 index 000000000..e91c8879a --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getGreatestMinimum/GregorianCalendarDemo/.project @@ -0,0 +1,17 @@ + + + GregorianCalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/GregorianCalendarDemo_getGreatestMinimum/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/GregorianCalendarDemo_getGreatestMinimum/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getGreatestMinimum/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/GregorianCalendarDemo_getGreatestMinimum/GregorianCalendarDemo/bin/GregorianCalendarDemo.class b/BasicJava_2018/GregorianCalendarDemo_getGreatestMinimum/GregorianCalendarDemo/bin/GregorianCalendarDemo.class new file mode 100644 index 000000000..ff1f923ab Binary files /dev/null and b/BasicJava_2018/GregorianCalendarDemo_getGreatestMinimum/GregorianCalendarDemo/bin/GregorianCalendarDemo.class differ diff --git a/BasicJava_2018/GregorianCalendarDemo_getGreatestMinimum/GregorianCalendarDemo/src/GregorianCalendarDemo.java b/BasicJava_2018/GregorianCalendarDemo_getGreatestMinimum/GregorianCalendarDemo/src/GregorianCalendarDemo.java new file mode 100644 index 000000000..816bf01af --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getGreatestMinimum/GregorianCalendarDemo/src/GregorianCalendarDemo.java @@ -0,0 +1,41 @@ +import java.util.GregorianCalendar; + +public class GregorianCalendarDemo +{ + public static void main(String[] args) + { + GregorianCalendar cal = (GregorianCalendar) GregorianCalendar + .getInstance(); + + /* + * Parameters: + * + * field - the calendar field. + * + * Returns: + * + * the highest minimum value for the given calendar field. + */ + int min = cal.getGreatestMinimum(GregorianCalendar.DAY_OF_MONTH); + System.out.println("Greatest Minimum, DAY_OF_MONTH = " + min); + + min = cal.getGreatestMinimum(GregorianCalendar.MONTH); + System.out.println("Greatest Minimum, MONTH = " + min); + + /* + * Parameters: + * + * field - the calendar field + * + * Returns: + * + * the lowest maximum value for the given calendar field. + */ + int max = cal.getLeastMaximum(GregorianCalendar.DAY_OF_MONTH); + System.out.println("Least Maximum, DAY_OF_MONTH = " + max); + + max = cal.getLeastMaximum(GregorianCalendar.MONTH); + System.out.println("Least Maximum, MONTH = " + max); + + } +} diff --git a/BasicJava_2018/GregorianCalendarDemo_getGreatestMinimum/Output.txt b/BasicJava_2018/GregorianCalendarDemo_getGreatestMinimum/Output.txt new file mode 100644 index 000000000..ee96f6942 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getGreatestMinimum/Output.txt @@ -0,0 +1,4 @@ +Greatest Minimum, DAY_OF_MONTH = 1 +Greatest Minimum, MONTH = 0 +Least Maximum, DAY_OF_MONTH = 28 +Least Maximum, MONTH = 11 diff --git a/BasicJava_2018/GregorianCalendarDemo_getMaximum/GregorianCalendarDemo/.classpath b/BasicJava_2018/GregorianCalendarDemo_getMaximum/GregorianCalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getMaximum/GregorianCalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/GregorianCalendarDemo_getMaximum/GregorianCalendarDemo/.project b/BasicJava_2018/GregorianCalendarDemo_getMaximum/GregorianCalendarDemo/.project new file mode 100644 index 000000000..e91c8879a --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getMaximum/GregorianCalendarDemo/.project @@ -0,0 +1,17 @@ + + + GregorianCalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/GregorianCalendarDemo_getMaximum/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/GregorianCalendarDemo_getMaximum/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getMaximum/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/GregorianCalendarDemo_getMaximum/GregorianCalendarDemo/bin/GregorianCalendarDemo.class b/BasicJava_2018/GregorianCalendarDemo_getMaximum/GregorianCalendarDemo/bin/GregorianCalendarDemo.class new file mode 100644 index 000000000..62bd21506 Binary files /dev/null and b/BasicJava_2018/GregorianCalendarDemo_getMaximum/GregorianCalendarDemo/bin/GregorianCalendarDemo.class differ diff --git a/BasicJava_2018/GregorianCalendarDemo_getMaximum/GregorianCalendarDemo/src/GregorianCalendarDemo.java b/BasicJava_2018/GregorianCalendarDemo_getMaximum/GregorianCalendarDemo/src/GregorianCalendarDemo.java new file mode 100644 index 000000000..1ef3576cb --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getMaximum/GregorianCalendarDemo/src/GregorianCalendarDemo.java @@ -0,0 +1,29 @@ +import java.util.GregorianCalendar; + +public class GregorianCalendarDemo +{ + public static void main(String[] args) + { + GregorianCalendar cal = (GregorianCalendar) GregorianCalendar + .getInstance(); + + /* + * Parameters: + * + * field - the calendar field. + * + * Returns: + * + * the maximum value for the given calendar field. + */ + int max = cal.getMaximum(GregorianCalendar.DAY_OF_MONTH); + System.out.println("Maximum, DAY_OF_MONTH = " + max); + + max = cal.getMaximum(GregorianCalendar.MONTH); + System.out.println("Maximum, MONTH = " + max); + + max = cal.getMaximum(GregorianCalendar.YEAR); + System.out.println("Maximum, YEAR = " + max); + + } +} diff --git a/BasicJava_2018/GregorianCalendarDemo_getMaximum/Output.txt b/BasicJava_2018/GregorianCalendarDemo_getMaximum/Output.txt new file mode 100644 index 000000000..b2c3fadd6 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getMaximum/Output.txt @@ -0,0 +1,3 @@ +Maximum, DAY_OF_MONTH = 31 +Maximum, MONTH = 11 +Maximum, YEAR = 292278994 diff --git a/BasicJava_2018/GregorianCalendarDemo_getMinimum/GregorianCalendarDemo/.classpath b/BasicJava_2018/GregorianCalendarDemo_getMinimum/GregorianCalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getMinimum/GregorianCalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/GregorianCalendarDemo_getMinimum/GregorianCalendarDemo/.project b/BasicJava_2018/GregorianCalendarDemo_getMinimum/GregorianCalendarDemo/.project new file mode 100644 index 000000000..e91c8879a --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getMinimum/GregorianCalendarDemo/.project @@ -0,0 +1,17 @@ + + + GregorianCalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/GregorianCalendarDemo_getMinimum/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/GregorianCalendarDemo_getMinimum/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getMinimum/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/GregorianCalendarDemo_getMinimum/GregorianCalendarDemo/bin/GregorianCalendarDemo.class b/BasicJava_2018/GregorianCalendarDemo_getMinimum/GregorianCalendarDemo/bin/GregorianCalendarDemo.class new file mode 100644 index 000000000..e93364e9a Binary files /dev/null and b/BasicJava_2018/GregorianCalendarDemo_getMinimum/GregorianCalendarDemo/bin/GregorianCalendarDemo.class differ diff --git a/BasicJava_2018/GregorianCalendarDemo_getMinimum/GregorianCalendarDemo/src/GregorianCalendarDemo.java b/BasicJava_2018/GregorianCalendarDemo_getMinimum/GregorianCalendarDemo/src/GregorianCalendarDemo.java new file mode 100644 index 000000000..c28608d33 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getMinimum/GregorianCalendarDemo/src/GregorianCalendarDemo.java @@ -0,0 +1,29 @@ +import java.util.GregorianCalendar; + +public class GregorianCalendarDemo +{ + public static void main(String[] args) + { + GregorianCalendar cal = (GregorianCalendar) GregorianCalendar + .getInstance(); + + /* + * Parameters: + * + * field - the calendar field. + * + * Returns: + * + * the minimum value for the given calendar field. + */ + int min = cal.getMinimum(GregorianCalendar.DAY_OF_MONTH); + System.out.println("Minimum, DAY_OF_MONTH = " + min); + + min = cal.getMinimum(GregorianCalendar.MONTH); + System.out.println("Minimum, MONTH = " + min); + + min = cal.getMinimum(GregorianCalendar.YEAR); + System.out.println("Minimum, YEAR = " + min); + + } +} diff --git a/BasicJava_2018/GregorianCalendarDemo_getMinimum/Output.txt b/BasicJava_2018/GregorianCalendarDemo_getMinimum/Output.txt new file mode 100644 index 000000000..5f58e9ac1 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getMinimum/Output.txt @@ -0,0 +1,3 @@ +Minimum, DAY_OF_MONTH = 1 +Minimum, MONTH = 0 +Minimum, YEAR = 1 diff --git a/BasicJava_2018/GregorianCalendarDemo_getTimeZone/GregorianCalendarDemo/.classpath b/BasicJava_2018/GregorianCalendarDemo_getTimeZone/GregorianCalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getTimeZone/GregorianCalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/GregorianCalendarDemo_getTimeZone/GregorianCalendarDemo/.project b/BasicJava_2018/GregorianCalendarDemo_getTimeZone/GregorianCalendarDemo/.project new file mode 100644 index 000000000..e91c8879a --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getTimeZone/GregorianCalendarDemo/.project @@ -0,0 +1,17 @@ + + + GregorianCalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/GregorianCalendarDemo_getTimeZone/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/GregorianCalendarDemo_getTimeZone/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getTimeZone/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/GregorianCalendarDemo_getTimeZone/GregorianCalendarDemo/bin/GregorianCalendarDemo.class b/BasicJava_2018/GregorianCalendarDemo_getTimeZone/GregorianCalendarDemo/bin/GregorianCalendarDemo.class new file mode 100644 index 000000000..a877309b9 Binary files /dev/null and b/BasicJava_2018/GregorianCalendarDemo_getTimeZone/GregorianCalendarDemo/bin/GregorianCalendarDemo.class differ diff --git a/BasicJava_2018/GregorianCalendarDemo_getTimeZone/GregorianCalendarDemo/src/GregorianCalendarDemo.java b/BasicJava_2018/GregorianCalendarDemo_getTimeZone/GregorianCalendarDemo/src/GregorianCalendarDemo.java new file mode 100644 index 000000000..32d6163e0 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getTimeZone/GregorianCalendarDemo/src/GregorianCalendarDemo.java @@ -0,0 +1,18 @@ +import java.util.GregorianCalendar; +import java.util.TimeZone; + +public class GregorianCalendarDemo +{ + public static void main(String[] args) + { + GregorianCalendar cal = (GregorianCalendar) GregorianCalendar + .getInstance(); + + /* + * Returns:the time zone object associated with this calendar. + */ + TimeZone timeZone = cal.getTimeZone(); + System.out.println("Time Zone = " + timeZone.getDisplayName()); + + } +} diff --git a/BasicJava_2018/GregorianCalendarDemo_getTimeZone/Output.txt b/BasicJava_2018/GregorianCalendarDemo_getTimeZone/Output.txt new file mode 100644 index 000000000..76bec2666 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getTimeZone/Output.txt @@ -0,0 +1 @@ +Time Zone = India Standard Time diff --git a/BasicJava_2018/GregorianCalendarDemo_getWeekYear/GregorianCalendarDemo/.classpath b/BasicJava_2018/GregorianCalendarDemo_getWeekYear/GregorianCalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getWeekYear/GregorianCalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/GregorianCalendarDemo_getWeekYear/GregorianCalendarDemo/.project b/BasicJava_2018/GregorianCalendarDemo_getWeekYear/GregorianCalendarDemo/.project new file mode 100644 index 000000000..e91c8879a --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getWeekYear/GregorianCalendarDemo/.project @@ -0,0 +1,17 @@ + + + GregorianCalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/GregorianCalendarDemo_getWeekYear/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/GregorianCalendarDemo_getWeekYear/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getWeekYear/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/GregorianCalendarDemo_getWeekYear/GregorianCalendarDemo/bin/GregorianCalendarDemo.class b/BasicJava_2018/GregorianCalendarDemo_getWeekYear/GregorianCalendarDemo/bin/GregorianCalendarDemo.class new file mode 100644 index 000000000..ec0d7e31f Binary files /dev/null and b/BasicJava_2018/GregorianCalendarDemo_getWeekYear/GregorianCalendarDemo/bin/GregorianCalendarDemo.class differ diff --git a/BasicJava_2018/GregorianCalendarDemo_getWeekYear/GregorianCalendarDemo/src/GregorianCalendarDemo.java b/BasicJava_2018/GregorianCalendarDemo_getWeekYear/GregorianCalendarDemo/src/GregorianCalendarDemo.java new file mode 100644 index 000000000..fe6fb34c0 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getWeekYear/GregorianCalendarDemo/src/GregorianCalendarDemo.java @@ -0,0 +1,31 @@ +import java.util.Date; +import java.util.GregorianCalendar; + +public class GregorianCalendarDemo +{ + public static void main(String[] args) + { + GregorianCalendar cal = (GregorianCalendar) GregorianCalendar + .getInstance(); + + System.out.println(cal.getTime()); + + /* + * Returns: + * + * the week year represented by this GregorianCalendar. If the + * ERA value is BC, the year is represented by 0 or a negative + * number: BC 1 is 0, BC 2 is -1, BC 3 is -2, and so on. + */ + + int weekYear = cal.getWeekYear(); + System.out.println("weekYear = "+weekYear); + + /* + * Returns: the Gregorian cutover date for this + * GregorianCalendar object. + */ + Date date = cal.getGregorianChange(); + System.out.println(date); + } +} diff --git a/BasicJava_2018/GregorianCalendarDemo_getWeekYear/Output.txt b/BasicJava_2018/GregorianCalendarDemo_getWeekYear/Output.txt new file mode 100644 index 000000000..be15b2c7e --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getWeekYear/Output.txt @@ -0,0 +1,3 @@ +Fri Sep 21 09:59:22 IST 2018 +weekYear = 2018 +Fri Oct 15 05:30:00 IST 1582 diff --git a/BasicJava_2018/GregorianCalendarDemo_getWeeksInWeekYear/GregorianCalendarDemo/.classpath b/BasicJava_2018/GregorianCalendarDemo_getWeeksInWeekYear/GregorianCalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getWeeksInWeekYear/GregorianCalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/GregorianCalendarDemo_getWeeksInWeekYear/GregorianCalendarDemo/.project b/BasicJava_2018/GregorianCalendarDemo_getWeeksInWeekYear/GregorianCalendarDemo/.project new file mode 100644 index 000000000..e91c8879a --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getWeeksInWeekYear/GregorianCalendarDemo/.project @@ -0,0 +1,17 @@ + + + GregorianCalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/GregorianCalendarDemo_getWeeksInWeekYear/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/GregorianCalendarDemo_getWeeksInWeekYear/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getWeeksInWeekYear/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/GregorianCalendarDemo_getWeeksInWeekYear/GregorianCalendarDemo/bin/GregorianCalendarDemo.class b/BasicJava_2018/GregorianCalendarDemo_getWeeksInWeekYear/GregorianCalendarDemo/bin/GregorianCalendarDemo.class new file mode 100644 index 000000000..3da9b3c9f Binary files /dev/null and b/BasicJava_2018/GregorianCalendarDemo_getWeeksInWeekYear/GregorianCalendarDemo/bin/GregorianCalendarDemo.class differ diff --git a/BasicJava_2018/GregorianCalendarDemo_getWeeksInWeekYear/GregorianCalendarDemo/src/GregorianCalendarDemo.java b/BasicJava_2018/GregorianCalendarDemo_getWeeksInWeekYear/GregorianCalendarDemo/src/GregorianCalendarDemo.java new file mode 100644 index 000000000..31af9abb8 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getWeeksInWeekYear/GregorianCalendarDemo/src/GregorianCalendarDemo.java @@ -0,0 +1,19 @@ +import java.util.GregorianCalendar; + +public class GregorianCalendarDemo +{ + public static void main(String[] args) + { + GregorianCalendar cal = (GregorianCalendar) GregorianCalendar + .getInstance(); + + System.out.println(cal.getTime()); + + /* + * Returns:the number of weeks in the week year. + */ + int weeksInWeekYear = cal.getWeeksInWeekYear(); + System.out.println("weeksInWeekYear = " + weeksInWeekYear); + + } +} diff --git a/BasicJava_2018/GregorianCalendarDemo_getWeeksInWeekYear/Output.txt b/BasicJava_2018/GregorianCalendarDemo_getWeeksInWeekYear/Output.txt new file mode 100644 index 000000000..a28bc2e62 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_getWeeksInWeekYear/Output.txt @@ -0,0 +1,2 @@ +Tue Sep 18 10:09:57 IST 2018 +weeksInWeekYear = 52 diff --git a/BasicJava_2018/GregorianCalendarDemo_isLeapYear/GregorianCalendarDemo/.classpath b/BasicJava_2018/GregorianCalendarDemo_isLeapYear/GregorianCalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_isLeapYear/GregorianCalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/GregorianCalendarDemo_isLeapYear/GregorianCalendarDemo/.project b/BasicJava_2018/GregorianCalendarDemo_isLeapYear/GregorianCalendarDemo/.project new file mode 100644 index 000000000..e91c8879a --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_isLeapYear/GregorianCalendarDemo/.project @@ -0,0 +1,17 @@ + + + GregorianCalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/GregorianCalendarDemo_isLeapYear/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/GregorianCalendarDemo_isLeapYear/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_isLeapYear/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/GregorianCalendarDemo_isLeapYear/GregorianCalendarDemo/bin/GregorianCalendarDemo.class b/BasicJava_2018/GregorianCalendarDemo_isLeapYear/GregorianCalendarDemo/bin/GregorianCalendarDemo.class new file mode 100644 index 000000000..796471ff4 Binary files /dev/null and b/BasicJava_2018/GregorianCalendarDemo_isLeapYear/GregorianCalendarDemo/bin/GregorianCalendarDemo.class differ diff --git a/BasicJava_2018/GregorianCalendarDemo_isLeapYear/GregorianCalendarDemo/src/GregorianCalendarDemo.java b/BasicJava_2018/GregorianCalendarDemo_isLeapYear/GregorianCalendarDemo/src/GregorianCalendarDemo.java new file mode 100644 index 000000000..d96fbe850 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_isLeapYear/GregorianCalendarDemo/src/GregorianCalendarDemo.java @@ -0,0 +1,26 @@ +import java.util.GregorianCalendar; + +public class GregorianCalendarDemo +{ + public static void main(String[] args) + { + GregorianCalendar cal = (GregorianCalendar) GregorianCalendar + .getInstance(); + + /* + * Parameters: + * + * field - the given calendar field. + * + * Returns: + * + * the value for the given calendar field. + */ + int year = cal.get(GregorianCalendar.YEAR); + boolean isLeapYear = cal.isLeapYear(year); + System.out.println(year + " is leap year = " + isLeapYear); + + isLeapYear = cal.isLeapYear(2020); + System.out.println("2020 Is leap year = " + isLeapYear); + } +} diff --git a/BasicJava_2018/GregorianCalendarDemo_isLeapYear/Output.txt b/BasicJava_2018/GregorianCalendarDemo_isLeapYear/Output.txt new file mode 100644 index 000000000..eb48d255a --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_isLeapYear/Output.txt @@ -0,0 +1,2 @@ +2018 is leap year = false +2020 Is leap year = true diff --git a/BasicJava_2018/GregorianCalendarDemo_isWeekDateSupported/GregorianCalendarDemo/.classpath b/BasicJava_2018/GregorianCalendarDemo_isWeekDateSupported/GregorianCalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_isWeekDateSupported/GregorianCalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/GregorianCalendarDemo_isWeekDateSupported/GregorianCalendarDemo/.project b/BasicJava_2018/GregorianCalendarDemo_isWeekDateSupported/GregorianCalendarDemo/.project new file mode 100644 index 000000000..e91c8879a --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_isWeekDateSupported/GregorianCalendarDemo/.project @@ -0,0 +1,17 @@ + + + GregorianCalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/GregorianCalendarDemo_isWeekDateSupported/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/GregorianCalendarDemo_isWeekDateSupported/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_isWeekDateSupported/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/GregorianCalendarDemo_isWeekDateSupported/GregorianCalendarDemo/bin/GregorianCalendarDemo.class b/BasicJava_2018/GregorianCalendarDemo_isWeekDateSupported/GregorianCalendarDemo/bin/GregorianCalendarDemo.class new file mode 100644 index 000000000..1e55a2571 Binary files /dev/null and b/BasicJava_2018/GregorianCalendarDemo_isWeekDateSupported/GregorianCalendarDemo/bin/GregorianCalendarDemo.class differ diff --git a/BasicJava_2018/GregorianCalendarDemo_isWeekDateSupported/GregorianCalendarDemo/src/GregorianCalendarDemo.java b/BasicJava_2018/GregorianCalendarDemo_isWeekDateSupported/GregorianCalendarDemo/src/GregorianCalendarDemo.java new file mode 100644 index 000000000..bac002e35 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_isWeekDateSupported/GregorianCalendarDemo/src/GregorianCalendarDemo.java @@ -0,0 +1,18 @@ +import java.util.GregorianCalendar; + +public class GregorianCalendarDemo +{ + public static void main(String[] args) + { + GregorianCalendar cal = (GregorianCalendar) GregorianCalendar + .getInstance(); + + System.out.println(cal.getTime()); + + /* + * Returns:true (always) + */ + boolean isWeekDateSupported = cal.isWeekDateSupported(); + System.out.println(isWeekDateSupported); + } +} diff --git a/BasicJava_2018/GregorianCalendarDemo_isWeekDateSupported/Output.txt b/BasicJava_2018/GregorianCalendarDemo_isWeekDateSupported/Output.txt new file mode 100644 index 000000000..e7755ccee --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_isWeekDateSupported/Output.txt @@ -0,0 +1,2 @@ +Tue Oct 09 09:30:40 IST 2018 +true diff --git a/BasicJava_2018/GregorianCalendarDemo_roll_amount/GregorianCalendarDemo/.classpath b/BasicJava_2018/GregorianCalendarDemo_roll_amount/GregorianCalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_roll_amount/GregorianCalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/GregorianCalendarDemo_roll_amount/GregorianCalendarDemo/.project b/BasicJava_2018/GregorianCalendarDemo_roll_amount/GregorianCalendarDemo/.project new file mode 100644 index 000000000..e91c8879a --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_roll_amount/GregorianCalendarDemo/.project @@ -0,0 +1,17 @@ + + + GregorianCalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/GregorianCalendarDemo_roll_amount/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/GregorianCalendarDemo_roll_amount/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_roll_amount/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/GregorianCalendarDemo_roll_amount/GregorianCalendarDemo/bin/GregorianCalendarDemo.class b/BasicJava_2018/GregorianCalendarDemo_roll_amount/GregorianCalendarDemo/bin/GregorianCalendarDemo.class new file mode 100644 index 000000000..c7fa67f87 Binary files /dev/null and b/BasicJava_2018/GregorianCalendarDemo_roll_amount/GregorianCalendarDemo/bin/GregorianCalendarDemo.class differ diff --git a/BasicJava_2018/GregorianCalendarDemo_roll_amount/GregorianCalendarDemo/src/GregorianCalendarDemo.java b/BasicJava_2018/GregorianCalendarDemo_roll_amount/GregorianCalendarDemo/src/GregorianCalendarDemo.java new file mode 100644 index 000000000..70a95b08c --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_roll_amount/GregorianCalendarDemo/src/GregorianCalendarDemo.java @@ -0,0 +1,28 @@ +import java.util.GregorianCalendar; + +public class GregorianCalendarDemo +{ + public static void main(String[] args) + { + GregorianCalendar cal = (GregorianCalendar) GregorianCalendar + .getInstance(); + + System.out.println(cal.getTime()); + System.out.println("Date = " + cal.getTime()); + + /* + * Parameters: + * + * field - the calendar field. + * + * amount - the signed amount to add to field. + */ + // roll 3 months forward + cal.roll(GregorianCalendar.MONTH, 3); + System.out.println("Date = " + cal.getTime()); + + // roll 10 year backwards + cal.roll(GregorianCalendar.YEAR, -10); + System.out.println("Date = " + cal.getTime()); + } +} diff --git a/BasicJava_2018/GregorianCalendarDemo_roll_amount/Output.txt b/BasicJava_2018/GregorianCalendarDemo_roll_amount/Output.txt new file mode 100644 index 000000000..4e66837a2 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_roll_amount/Output.txt @@ -0,0 +1,4 @@ +Wed Oct 10 09:29:06 IST 2018 +Date = Wed Oct 10 09:29:06 IST 2018 +Date = Wed Jan 10 09:29:06 IST 2018 +Date = Thu Jan 10 09:29:06 IST 2008 diff --git a/BasicJava_2018/GregorianCalendarDemo_roll_up_indicator/GregorianCalendarDemo/.classpath b/BasicJava_2018/GregorianCalendarDemo_roll_up_indicator/GregorianCalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_roll_up_indicator/GregorianCalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/GregorianCalendarDemo_roll_up_indicator/GregorianCalendarDemo/.project b/BasicJava_2018/GregorianCalendarDemo_roll_up_indicator/GregorianCalendarDemo/.project new file mode 100644 index 000000000..e91c8879a --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_roll_up_indicator/GregorianCalendarDemo/.project @@ -0,0 +1,17 @@ + + + GregorianCalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/GregorianCalendarDemo_roll_up_indicator/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/GregorianCalendarDemo_roll_up_indicator/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_roll_up_indicator/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/GregorianCalendarDemo_roll_up_indicator/GregorianCalendarDemo/bin/GregorianCalendarDemo.class b/BasicJava_2018/GregorianCalendarDemo_roll_up_indicator/GregorianCalendarDemo/bin/GregorianCalendarDemo.class new file mode 100644 index 000000000..ff0e0d920 Binary files /dev/null and b/BasicJava_2018/GregorianCalendarDemo_roll_up_indicator/GregorianCalendarDemo/bin/GregorianCalendarDemo.class differ diff --git a/BasicJava_2018/GregorianCalendarDemo_roll_up_indicator/GregorianCalendarDemo/src/GregorianCalendarDemo.java b/BasicJava_2018/GregorianCalendarDemo_roll_up_indicator/GregorianCalendarDemo/src/GregorianCalendarDemo.java new file mode 100644 index 000000000..eca67b05f --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_roll_up_indicator/GregorianCalendarDemo/src/GregorianCalendarDemo.java @@ -0,0 +1,29 @@ +import java.util.GregorianCalendar; + +public class GregorianCalendarDemo +{ + public static void main(String[] args) + { + GregorianCalendar cal = (GregorianCalendar) GregorianCalendar + .getInstance(); + + System.out.println("Date = "+cal.getTime()); + + /* + * Parameters: + * + * field - the time field. + * + * up - indicates if the value of the specified calendar field + * is to be rolled up or rolled down. Use true if rolling up, + * false otherwise. + */ + // roll a month forward + cal.roll(GregorianCalendar.MONTH, true); + System.out.println("Date = " + cal.getTime()); + + // roll a year backwards + cal.roll(GregorianCalendar.YEAR, false); + System.out.println("Date = " + cal.getTime()); + } +} diff --git a/BasicJava_2018/GregorianCalendarDemo_roll_up_indicator/Output.txt b/BasicJava_2018/GregorianCalendarDemo_roll_up_indicator/Output.txt new file mode 100644 index 000000000..46701bb0d --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_roll_up_indicator/Output.txt @@ -0,0 +1,3 @@ +Date = Wed Oct 10 09:09:11 IST 2018 +Date = Sat Nov 10 09:09:11 IST 2018 +Date = Fri Nov 10 09:09:11 IST 2017 diff --git a/BasicJava_2018/GregorianCalendarDemo_setTimeZone/GregorianCalendarDemo/.classpath b/BasicJava_2018/GregorianCalendarDemo_setTimeZone/GregorianCalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_setTimeZone/GregorianCalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/GregorianCalendarDemo_setTimeZone/GregorianCalendarDemo/.project b/BasicJava_2018/GregorianCalendarDemo_setTimeZone/GregorianCalendarDemo/.project new file mode 100644 index 000000000..e91c8879a --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_setTimeZone/GregorianCalendarDemo/.project @@ -0,0 +1,17 @@ + + + GregorianCalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/GregorianCalendarDemo_setTimeZone/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/GregorianCalendarDemo_setTimeZone/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_setTimeZone/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/GregorianCalendarDemo_setTimeZone/GregorianCalendarDemo/bin/GregorianCalendarDemo.class b/BasicJava_2018/GregorianCalendarDemo_setTimeZone/GregorianCalendarDemo/bin/GregorianCalendarDemo.class new file mode 100644 index 000000000..dc7bb8e5a Binary files /dev/null and b/BasicJava_2018/GregorianCalendarDemo_setTimeZone/GregorianCalendarDemo/bin/GregorianCalendarDemo.class differ diff --git a/BasicJava_2018/GregorianCalendarDemo_setTimeZone/GregorianCalendarDemo/src/GregorianCalendarDemo.java b/BasicJava_2018/GregorianCalendarDemo_setTimeZone/GregorianCalendarDemo/src/GregorianCalendarDemo.java new file mode 100644 index 000000000..422728f49 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_setTimeZone/GregorianCalendarDemo/src/GregorianCalendarDemo.java @@ -0,0 +1,22 @@ +import java.util.GregorianCalendar; +import java.util.TimeZone; + +public class GregorianCalendarDemo +{ + public static void main(String[] args) + { + GregorianCalendar cal = (GregorianCalendar) GregorianCalendar + .getInstance(); + + System.out.println( + "Current Time Zone = " + cal.getTimeZone().getDisplayName()); + + /* + * Parameters:zone - the given time zone. + */ + cal.setTimeZone(TimeZone.getTimeZone("GMT")); + + System.out + .println("New Time Zone = " + cal.getTimeZone().getDisplayName()); + } +} diff --git a/BasicJava_2018/GregorianCalendarDemo_setTimeZone/Output.txt b/BasicJava_2018/GregorianCalendarDemo_setTimeZone/Output.txt new file mode 100644 index 000000000..a4438a64a --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_setTimeZone/Output.txt @@ -0,0 +1,2 @@ +Current Time Zone = India Standard Time +New Time Zone = Greenwich Mean Time diff --git a/BasicJava_2018/GregorianCalendarDemo_setWeekDate/GregorianCalendarDemo/.classpath b/BasicJava_2018/GregorianCalendarDemo_setWeekDate/GregorianCalendarDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_setWeekDate/GregorianCalendarDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/GregorianCalendarDemo_setWeekDate/GregorianCalendarDemo/.project b/BasicJava_2018/GregorianCalendarDemo_setWeekDate/GregorianCalendarDemo/.project new file mode 100644 index 000000000..e91c8879a --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_setWeekDate/GregorianCalendarDemo/.project @@ -0,0 +1,17 @@ + + + GregorianCalendarDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/GregorianCalendarDemo_setWeekDate/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/GregorianCalendarDemo_setWeekDate/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_setWeekDate/GregorianCalendarDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/GregorianCalendarDemo_setWeekDate/GregorianCalendarDemo/bin/GregorianCalendarDemo.class b/BasicJava_2018/GregorianCalendarDemo_setWeekDate/GregorianCalendarDemo/bin/GregorianCalendarDemo.class new file mode 100644 index 000000000..f24ff8890 Binary files /dev/null and b/BasicJava_2018/GregorianCalendarDemo_setWeekDate/GregorianCalendarDemo/bin/GregorianCalendarDemo.class differ diff --git a/BasicJava_2018/GregorianCalendarDemo_setWeekDate/GregorianCalendarDemo/src/GregorianCalendarDemo.java b/BasicJava_2018/GregorianCalendarDemo_setWeekDate/GregorianCalendarDemo/src/GregorianCalendarDemo.java new file mode 100644 index 000000000..0045bf074 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_setWeekDate/GregorianCalendarDemo/src/GregorianCalendarDemo.java @@ -0,0 +1,26 @@ +import java.util.GregorianCalendar; + +public class GregorianCalendarDemo +{ + public static void main(String[] args) + { + GregorianCalendar cal = (GregorianCalendar) GregorianCalendar + .getInstance(); + + System.out.println(cal.getTime()); + + /* + * Parameters: + * + * weekYear - the week year + * + * weekOfYear - the week number based on weekYear + * + * dayOfWeek - the day of week value: one of the constants for + * the DAY_OF_WEEK field: SUNDAY, ..., SATURDAY. + */ + cal.setWeekDate(2030, 11, 2); + + System.out.println(cal.getTime()); + } +} diff --git a/BasicJava_2018/GregorianCalendarDemo_setWeekDate/Output.txt b/BasicJava_2018/GregorianCalendarDemo_setWeekDate/Output.txt new file mode 100644 index 000000000..c00070b22 --- /dev/null +++ b/BasicJava_2018/GregorianCalendarDemo_setWeekDate/Output.txt @@ -0,0 +1,2 @@ +Mon Oct 08 08:53:54 IST 2018 +Mon Mar 11 08:53:54 IST 2030 diff --git a/BasicJava_2018/InstantDemo_adjustInto/InstantDemo/.classpath b/BasicJava_2018/InstantDemo_adjustInto/InstantDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/InstantDemo_adjustInto/InstantDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/InstantDemo_adjustInto/InstantDemo/.project b/BasicJava_2018/InstantDemo_adjustInto/InstantDemo/.project new file mode 100644 index 000000000..08fe4c5fa --- /dev/null +++ b/BasicJava_2018/InstantDemo_adjustInto/InstantDemo/.project @@ -0,0 +1,17 @@ + + + InstantDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/InstantDemo_adjustInto/InstantDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/InstantDemo_adjustInto/InstantDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/InstantDemo_adjustInto/InstantDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/InstantDemo_adjustInto/InstantDemo/bin/InstantDemo.class b/BasicJava_2018/InstantDemo_adjustInto/InstantDemo/bin/InstantDemo.class new file mode 100644 index 000000000..4c36f4c85 Binary files /dev/null and b/BasicJava_2018/InstantDemo_adjustInto/InstantDemo/bin/InstantDemo.class differ diff --git a/BasicJava_2018/InstantDemo_adjustInto/InstantDemo/src/InstantDemo.java b/BasicJava_2018/InstantDemo_adjustInto/InstantDemo/src/InstantDemo.java new file mode 100644 index 000000000..15a3586ff --- /dev/null +++ b/BasicJava_2018/InstantDemo_adjustInto/InstantDemo/src/InstantDemo.java @@ -0,0 +1,29 @@ +import java.time.Instant; +import java.time.ZonedDateTime; +import java.time.temporal.Temporal; + +public class InstantDemo +{ + public static void main(String[] args) + { + + Instant instant = Instant.parse("2017-12-03T10:15:30.00Z"); + System.out.println("instant = "+instant); + + ZonedDateTime zonedDateTime = ZonedDateTime.now(); + System.out.println("zonedDateTime = "+zonedDateTime); + /* + * Parameters: + * + * temporal - the target object to be adjusted, not null + * + * Returns: + * + * the adjusted object, not null + */ + Temporal temporal = instant.adjustInto(zonedDateTime); + System.out.println("temporal = "+temporal); + + } + +} diff --git a/BasicJava_2018/InstantDemo_adjustInto/Output.txt b/BasicJava_2018/InstantDemo_adjustInto/Output.txt new file mode 100644 index 000000000..88fdb23ec --- /dev/null +++ b/BasicJava_2018/InstantDemo_adjustInto/Output.txt @@ -0,0 +1,3 @@ +instant = 2017-12-03T10:15:30Z +zonedDateTime = 2018-03-31T11:02:53.706+05:30[Asia/Calcutta] +temporal = 2017-12-03T15:45:30+05:30[Asia/Calcutta] diff --git a/BasicJava_2018/InstantDemo_atOffset_zone/InstantDemo/.classpath b/BasicJava_2018/InstantDemo_atOffset_zone/InstantDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/InstantDemo_atOffset_zone/InstantDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/InstantDemo_atOffset_zone/InstantDemo/.project b/BasicJava_2018/InstantDemo_atOffset_zone/InstantDemo/.project new file mode 100644 index 000000000..08fe4c5fa --- /dev/null +++ b/BasicJava_2018/InstantDemo_atOffset_zone/InstantDemo/.project @@ -0,0 +1,17 @@ + + + InstantDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/InstantDemo_atOffset_zone/InstantDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/InstantDemo_atOffset_zone/InstantDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/InstantDemo_atOffset_zone/InstantDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/InstantDemo_atOffset_zone/InstantDemo/bin/InstantDemo1.class b/BasicJava_2018/InstantDemo_atOffset_zone/InstantDemo/bin/InstantDemo1.class new file mode 100644 index 000000000..cc13536ad Binary files /dev/null and b/BasicJava_2018/InstantDemo_atOffset_zone/InstantDemo/bin/InstantDemo1.class differ diff --git a/BasicJava_2018/InstantDemo_atOffset_zone/InstantDemo/bin/InstantDemo2.class b/BasicJava_2018/InstantDemo_atOffset_zone/InstantDemo/bin/InstantDemo2.class new file mode 100644 index 000000000..de63c73dd Binary files /dev/null and b/BasicJava_2018/InstantDemo_atOffset_zone/InstantDemo/bin/InstantDemo2.class differ diff --git a/BasicJava_2018/InstantDemo_atOffset_zone/InstantDemo/src/InstantDemo1.java b/BasicJava_2018/InstantDemo_atOffset_zone/InstantDemo/src/InstantDemo1.java new file mode 100644 index 000000000..3b6f163ff --- /dev/null +++ b/BasicJava_2018/InstantDemo_atOffset_zone/InstantDemo/src/InstantDemo1.java @@ -0,0 +1,28 @@ +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; + +public class InstantDemo1 +{ + public static void main(String[] args) + { + Instant instant = Instant.parse("2017-12-03T10:15:30.00Z"); + System.out.println("instant = " + instant); + /* + * Combines this instant with an offset to create an + * OffsetDateTime. + * + * Parameters: + * + * offset - the offset to combine with, not null + * + * Returns: + * + * the offset date-time formed from this instant and the + * specified offset, not null + */ + OffsetDateTime offsetDateTime = instant.atOffset(ZoneOffset.UTC); + System.out.println("offsetDateTime = " + offsetDateTime); + } + +} diff --git a/BasicJava_2018/InstantDemo_atOffset_zone/InstantDemo/src/InstantDemo2.java b/BasicJava_2018/InstantDemo_atOffset_zone/InstantDemo/src/InstantDemo2.java new file mode 100644 index 000000000..8ca52c680 --- /dev/null +++ b/BasicJava_2018/InstantDemo_atOffset_zone/InstantDemo/src/InstantDemo2.java @@ -0,0 +1,28 @@ +import java.time.Instant; +import java.time.ZoneId; +import java.time.ZonedDateTime; + +public class InstantDemo2 +{ + public static void main(String[] args) + { + Instant instant = Instant.parse("2017-12-03T10:15:30.00Z"); + System.out.println("instant = " + instant); + /* + * Combines this instant with a time-zone to create a + * ZonedDateTime. + * + * Parameters: + * + * zone - the zone to combine with, not null + * + * Returns: + * + * the zoned date-time formed from this instant and the + * specified zone, not null + */ + ZonedDateTime zonedDateTime = instant.atZone(ZoneId.systemDefault()); + System.out.println("zonedDateTime = " + zonedDateTime); + } + +} diff --git a/BasicJava_2018/InstantDemo_atOffset_zone/InstantDemo1_Output.txt b/BasicJava_2018/InstantDemo_atOffset_zone/InstantDemo1_Output.txt new file mode 100644 index 000000000..e4f222905 --- /dev/null +++ b/BasicJava_2018/InstantDemo_atOffset_zone/InstantDemo1_Output.txt @@ -0,0 +1,2 @@ +instant = 2017-12-03T10:15:30Z +offsetDateTime = 2017-12-03T10:15:30Z diff --git a/BasicJava_2018/InstantDemo_atOffset_zone/InstantDemo2_Output.txt b/BasicJava_2018/InstantDemo_atOffset_zone/InstantDemo2_Output.txt new file mode 100644 index 000000000..b5335201a --- /dev/null +++ b/BasicJava_2018/InstantDemo_atOffset_zone/InstantDemo2_Output.txt @@ -0,0 +1,2 @@ +instant = 2017-12-03T10:15:30Z +zonedDateTime = 2017-12-03T15:45:30+05:30[Asia/Calcutta] diff --git a/BasicJava_2018/InstantDemo_compareTo_equals/InstantDemo/.classpath b/BasicJava_2018/InstantDemo_compareTo_equals/InstantDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/InstantDemo_compareTo_equals/InstantDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/InstantDemo_compareTo_equals/InstantDemo/.project b/BasicJava_2018/InstantDemo_compareTo_equals/InstantDemo/.project new file mode 100644 index 000000000..08fe4c5fa --- /dev/null +++ b/BasicJava_2018/InstantDemo_compareTo_equals/InstantDemo/.project @@ -0,0 +1,17 @@ + + + InstantDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/InstantDemo_compareTo_equals/InstantDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/InstantDemo_compareTo_equals/InstantDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/InstantDemo_compareTo_equals/InstantDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/InstantDemo_compareTo_equals/InstantDemo/bin/InstantDemo.class b/BasicJava_2018/InstantDemo_compareTo_equals/InstantDemo/bin/InstantDemo.class new file mode 100644 index 000000000..6d9e8b908 Binary files /dev/null and b/BasicJava_2018/InstantDemo_compareTo_equals/InstantDemo/bin/InstantDemo.class differ diff --git a/BasicJava_2018/InstantDemo_compareTo_equals/InstantDemo/src/InstantDemo.java b/BasicJava_2018/InstantDemo_compareTo_equals/InstantDemo/src/InstantDemo.java new file mode 100644 index 000000000..0a486d758 --- /dev/null +++ b/BasicJava_2018/InstantDemo_compareTo_equals/InstantDemo/src/InstantDemo.java @@ -0,0 +1,41 @@ +import java.time.Instant; + +public class InstantDemo +{ + public static void main(String[] args) + { + + Instant instant1 = Instant.parse("2014-12-03T10:15:30.00Z"); + System.out.println("instant1 = "+instant1); + + Instant instant2 = Instant.parse("2017-12-03T10:15:30.00Z"); + System.out.println("instant2 = "+instant2); + + /* + * Parameters: + * + * otherInstant - the other instant to compare to, not null + * + * Returns: + * + * the comparator value, negative if less, positive if greater + */ + int value = instant1.compareTo(instant2); + System.out.println(value); + + /* + * Parameters: + * + * otherInstant - the other instant, null returns false + * + * Returns: + * + * true if the other instant is equal to this one + */ + boolean isEqual = instant1.equals(instant2); + System.out.println(isEqual); + + + } + +} diff --git a/BasicJava_2018/InstantDemo_compareTo_equals/Output.txt b/BasicJava_2018/InstantDemo_compareTo_equals/Output.txt new file mode 100644 index 000000000..98e895049 --- /dev/null +++ b/BasicJava_2018/InstantDemo_compareTo_equals/Output.txt @@ -0,0 +1,4 @@ +instant1 = 2014-12-03T10:15:30Z +instant2 = 2017-12-03T10:15:30Z +-1 +false diff --git a/BasicJava_2018/InstantDemo_get_methods/InstantDemo/.classpath b/BasicJava_2018/InstantDemo_get_methods/InstantDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/InstantDemo_get_methods/InstantDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/InstantDemo_get_methods/InstantDemo/.project b/BasicJava_2018/InstantDemo_get_methods/InstantDemo/.project new file mode 100644 index 000000000..08fe4c5fa --- /dev/null +++ b/BasicJava_2018/InstantDemo_get_methods/InstantDemo/.project @@ -0,0 +1,17 @@ + + + InstantDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/InstantDemo_get_methods/InstantDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/InstantDemo_get_methods/InstantDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/InstantDemo_get_methods/InstantDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/InstantDemo_get_methods/InstantDemo/bin/InstantDemo1.class b/BasicJava_2018/InstantDemo_get_methods/InstantDemo/bin/InstantDemo1.class new file mode 100644 index 000000000..5dd343dd0 Binary files /dev/null and b/BasicJava_2018/InstantDemo_get_methods/InstantDemo/bin/InstantDemo1.class differ diff --git a/BasicJava_2018/InstantDemo_get_methods/InstantDemo/bin/InstantDemo2.class b/BasicJava_2018/InstantDemo_get_methods/InstantDemo/bin/InstantDemo2.class new file mode 100644 index 000000000..d2aaa5be5 Binary files /dev/null and b/BasicJava_2018/InstantDemo_get_methods/InstantDemo/bin/InstantDemo2.class differ diff --git a/BasicJava_2018/InstantDemo_get_methods/InstantDemo/bin/InstantDemo3.class b/BasicJava_2018/InstantDemo_get_methods/InstantDemo/bin/InstantDemo3.class new file mode 100644 index 000000000..3eb514873 Binary files /dev/null and b/BasicJava_2018/InstantDemo_get_methods/InstantDemo/bin/InstantDemo3.class differ diff --git a/BasicJava_2018/InstantDemo_get_methods/InstantDemo/src/InstantDemo1.java b/BasicJava_2018/InstantDemo_get_methods/InstantDemo/src/InstantDemo1.java new file mode 100644 index 000000000..bf21764d5 --- /dev/null +++ b/BasicJava_2018/InstantDemo_get_methods/InstantDemo/src/InstantDemo1.java @@ -0,0 +1,26 @@ +import java.time.Instant; + +public class InstantDemo1 +{ + public static void main(String[] args) + { + + Instant instant = Instant.now(); + System.out.println("instant = "+instant); + + /* + * Returns:the seconds from the epoch of 1970-01-01T00:00:00Z + */ + long secondValue = instant.getEpochSecond(); + System.out.println("secondValue = "+secondValue); + + /* + * Returns:the nanoseconds within the second, always positive, + * never exceeds 999,999,999 + */ + long nanoValue = instant.getNano(); + System.out.println("nanoValue = "+nanoValue); + + } + +} diff --git a/BasicJava_2018/InstantDemo_get_methods/InstantDemo/src/InstantDemo2.java b/BasicJava_2018/InstantDemo_get_methods/InstantDemo/src/InstantDemo2.java new file mode 100644 index 000000000..21e8d0aa3 --- /dev/null +++ b/BasicJava_2018/InstantDemo_get_methods/InstantDemo/src/InstantDemo2.java @@ -0,0 +1,26 @@ +import java.time.Instant; +import java.time.temporal.ChronoField; + +public class InstantDemo2 +{ + public static void main(String[] args) + { + + Instant instant = Instant.now(); + System.out.println("instant = "+instant); + + /* + * Parameters: + * + * field - the field to get, not null + * + * Returns: + * + * the value for the field + */ + long nanoSecondValue = instant.getLong(ChronoField.NANO_OF_SECOND); + System.out.println("nanoSecondValue = "+nanoSecondValue); + + } + +} diff --git a/BasicJava_2018/InstantDemo_get_methods/InstantDemo/src/InstantDemo3.java b/BasicJava_2018/InstantDemo_get_methods/InstantDemo/src/InstantDemo3.java new file mode 100644 index 000000000..e0b901bd3 --- /dev/null +++ b/BasicJava_2018/InstantDemo_get_methods/InstantDemo/src/InstantDemo3.java @@ -0,0 +1,26 @@ +import java.time.Instant; +import java.time.temporal.ChronoField; + +public class InstantDemo3 +{ + public static void main(String[] args) + { + + Instant instant = Instant.now(); + System.out.println("instant = "+instant); + + /* + * Parameters: + * + * field - the field to get, not null + * + * Returns: + * + * the value for the field + */ + int nanoSecondValue = instant.get(ChronoField.NANO_OF_SECOND); + System.out.println("nanoSecondValue = "+nanoSecondValue); + + } + +} diff --git a/BasicJava_2018/InstantDemo_get_methods/InstantDemo1_Output.txt b/BasicJava_2018/InstantDemo_get_methods/InstantDemo1_Output.txt new file mode 100644 index 000000000..7d7f43452 --- /dev/null +++ b/BasicJava_2018/InstantDemo_get_methods/InstantDemo1_Output.txt @@ -0,0 +1,3 @@ +instant = 2018-03-24T04:12:53.409Z +secondValue = 1521864773 +nanoValue = 409000000 diff --git a/BasicJava_2018/InstantDemo_get_methods/InstantDemo2_Output.txt b/BasicJava_2018/InstantDemo_get_methods/InstantDemo2_Output.txt new file mode 100644 index 000000000..8b063f674 --- /dev/null +++ b/BasicJava_2018/InstantDemo_get_methods/InstantDemo2_Output.txt @@ -0,0 +1,2 @@ +instant = 2018-03-24T04:13:03.625Z +nanoSecondValue = 625000000 diff --git a/BasicJava_2018/InstantDemo_get_methods/InstantDemo3_Output.txt b/BasicJava_2018/InstantDemo_get_methods/InstantDemo3_Output.txt new file mode 100644 index 000000000..a59b1ad7e --- /dev/null +++ b/BasicJava_2018/InstantDemo_get_methods/InstantDemo3_Output.txt @@ -0,0 +1,2 @@ +instant = 2018-03-24T04:13:14.609Z +nanoSecondValue = 609000000 diff --git a/BasicJava_2018/InstantDemo_intro/InstantDemo/.classpath b/BasicJava_2018/InstantDemo_intro/InstantDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/InstantDemo_intro/InstantDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/InstantDemo_intro/InstantDemo/.project b/BasicJava_2018/InstantDemo_intro/InstantDemo/.project new file mode 100644 index 000000000..08fe4c5fa --- /dev/null +++ b/BasicJava_2018/InstantDemo_intro/InstantDemo/.project @@ -0,0 +1,17 @@ + + + InstantDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/InstantDemo_intro/InstantDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/InstantDemo_intro/InstantDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/InstantDemo_intro/InstantDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/InstantDemo_intro/InstantDemo/bin/InstantDemo1.class b/BasicJava_2018/InstantDemo_intro/InstantDemo/bin/InstantDemo1.class new file mode 100644 index 000000000..43bcfb47d Binary files /dev/null and b/BasicJava_2018/InstantDemo_intro/InstantDemo/bin/InstantDemo1.class differ diff --git a/BasicJava_2018/InstantDemo_intro/InstantDemo/bin/InstantDemo2.class b/BasicJava_2018/InstantDemo_intro/InstantDemo/bin/InstantDemo2.class new file mode 100644 index 000000000..04310a248 Binary files /dev/null and b/BasicJava_2018/InstantDemo_intro/InstantDemo/bin/InstantDemo2.class differ diff --git a/BasicJava_2018/InstantDemo_intro/InstantDemo/src/InstantDemo1.java b/BasicJava_2018/InstantDemo_intro/InstantDemo/src/InstantDemo1.java new file mode 100644 index 000000000..4dbe5d942 --- /dev/null +++ b/BasicJava_2018/InstantDemo_intro/InstantDemo/src/InstantDemo1.java @@ -0,0 +1,15 @@ +import java.time.Instant; + +public class InstantDemo1 +{ + public static void main(String[] args) + { + /* + * Returns:the current instant using the system clock, not + * null + */ + Instant instant = Instant.now(); + System.out.println(instant); + } + +} diff --git a/BasicJava_2018/InstantDemo_intro/InstantDemo/src/InstantDemo2.java b/BasicJava_2018/InstantDemo_intro/InstantDemo/src/InstantDemo2.java new file mode 100644 index 000000000..d21dd8eb5 --- /dev/null +++ b/BasicJava_2018/InstantDemo_intro/InstantDemo/src/InstantDemo2.java @@ -0,0 +1,28 @@ +import java.time.Clock; +import java.time.Instant; + +public class InstantDemo2 +{ + public static void main(String[] args) + { + + Clock clock = Clock.systemDefaultZone(); + System.out.println(clock); + + /* + * Obtains the current instant from the specified clock. + * + * Parameters: + * + * clock - the clock to use, not null + * + * Returns: + * + * the current instant, not null + */ + Instant instant = Instant.now(clock); + System.out.println(instant); + + } + +} diff --git a/BasicJava_2018/InstantDemo_intro/InstantDemo1_Output.txt b/BasicJava_2018/InstantDemo_intro/InstantDemo1_Output.txt new file mode 100644 index 000000000..f6ef915f6 --- /dev/null +++ b/BasicJava_2018/InstantDemo_intro/InstantDemo1_Output.txt @@ -0,0 +1 @@ +2018-03-23T04:38:53.443Z diff --git a/BasicJava_2018/InstantDemo_intro/InstantDemo2_Output.txt b/BasicJava_2018/InstantDemo_intro/InstantDemo2_Output.txt new file mode 100644 index 000000000..65ab1bf99 --- /dev/null +++ b/BasicJava_2018/InstantDemo_intro/InstantDemo2_Output.txt @@ -0,0 +1,2 @@ +SystemClock[Asia/Calcutta] +2018-03-23T04:34:48.679Z diff --git a/BasicJava_2018/InstantDemo_isAfter_before/InstantDemo/.classpath b/BasicJava_2018/InstantDemo_isAfter_before/InstantDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/InstantDemo_isAfter_before/InstantDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/InstantDemo_isAfter_before/InstantDemo/.project b/BasicJava_2018/InstantDemo_isAfter_before/InstantDemo/.project new file mode 100644 index 000000000..08fe4c5fa --- /dev/null +++ b/BasicJava_2018/InstantDemo_isAfter_before/InstantDemo/.project @@ -0,0 +1,17 @@ + + + InstantDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/InstantDemo_isAfter_before/InstantDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/InstantDemo_isAfter_before/InstantDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/InstantDemo_isAfter_before/InstantDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/InstantDemo_isAfter_before/InstantDemo/bin/InstantDemo.class b/BasicJava_2018/InstantDemo_isAfter_before/InstantDemo/bin/InstantDemo.class new file mode 100644 index 000000000..c1223e9dc Binary files /dev/null and b/BasicJava_2018/InstantDemo_isAfter_before/InstantDemo/bin/InstantDemo.class differ diff --git a/BasicJava_2018/InstantDemo_isAfter_before/InstantDemo/src/InstantDemo.java b/BasicJava_2018/InstantDemo_isAfter_before/InstantDemo/src/InstantDemo.java new file mode 100644 index 000000000..0ddeab61b --- /dev/null +++ b/BasicJava_2018/InstantDemo_isAfter_before/InstantDemo/src/InstantDemo.java @@ -0,0 +1,38 @@ +import java.time.Instant; + +public class InstantDemo +{ + public static void main(String[] args) + { + + Instant instant1 = Instant.parse("2016-12-03T10:15:30.00Z"); + System.out.println("instant1 = "+instant1); + + Instant instant2 = Instant.now(); + System.out.println("instant2 = "+instant2); + + /* + * Parameters: + * + * otherInstant - the other instant to compare to, not null + * + * Returns: + * + * true if this instant is after the specified instant + */ + System.out.println(instant1.isAfter(instant2)); + + /* + * Parameters: + * + * otherInstant - the other instant to compare to, not null + * + * Returns: + * + * true if this instant is before the specified instant + */ + System.out.println(instant1.isBefore(instant2)); + + } + +} diff --git a/BasicJava_2018/InstantDemo_isAfter_before/Output.txt b/BasicJava_2018/InstantDemo_isAfter_before/Output.txt new file mode 100644 index 000000000..709667e55 --- /dev/null +++ b/BasicJava_2018/InstantDemo_isAfter_before/Output.txt @@ -0,0 +1,4 @@ +instant1 = 2016-12-03T10:15:30Z +instant2 = 2018-03-28T03:40:39.091Z +false +true diff --git a/BasicJava_2018/InstantDemo_isSuported/InstantDemo/.classpath b/BasicJava_2018/InstantDemo_isSuported/InstantDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/InstantDemo_isSuported/InstantDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/InstantDemo_isSuported/InstantDemo/.project b/BasicJava_2018/InstantDemo_isSuported/InstantDemo/.project new file mode 100644 index 000000000..08fe4c5fa --- /dev/null +++ b/BasicJava_2018/InstantDemo_isSuported/InstantDemo/.project @@ -0,0 +1,17 @@ + + + InstantDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/InstantDemo_isSuported/InstantDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/InstantDemo_isSuported/InstantDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/InstantDemo_isSuported/InstantDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/InstantDemo_isSuported/InstantDemo/bin/InstantDemo1.class b/BasicJava_2018/InstantDemo_isSuported/InstantDemo/bin/InstantDemo1.class new file mode 100644 index 000000000..b0c242e05 Binary files /dev/null and b/BasicJava_2018/InstantDemo_isSuported/InstantDemo/bin/InstantDemo1.class differ diff --git a/BasicJava_2018/InstantDemo_isSuported/InstantDemo/bin/InstantDemo2.class b/BasicJava_2018/InstantDemo_isSuported/InstantDemo/bin/InstantDemo2.class new file mode 100644 index 000000000..9cd2f7cc1 Binary files /dev/null and b/BasicJava_2018/InstantDemo_isSuported/InstantDemo/bin/InstantDemo2.class differ diff --git a/BasicJava_2018/InstantDemo_isSuported/InstantDemo/src/InstantDemo1.java b/BasicJava_2018/InstantDemo_isSuported/InstantDemo/src/InstantDemo1.java new file mode 100644 index 000000000..8942ac541 --- /dev/null +++ b/BasicJava_2018/InstantDemo_isSuported/InstantDemo/src/InstantDemo1.java @@ -0,0 +1,24 @@ +import java.time.Instant; +import java.time.temporal.ChronoField; + +public class InstantDemo1 +{ + public static void main(String[] args) + { + Instant instant = Instant.parse("2014-12-03T10:15:30.00Z"); + + /* + * Parameters: + * + * field - the field to check, null returns false + * + * Returns: + * + * true if the field is supported on this instant, false if + * not + */ + System.out.println(instant.isSupported(ChronoField.NANO_OF_SECOND)); + System.out.println(instant.isSupported(ChronoField.DAY_OF_MONTH)); + } + +} diff --git a/BasicJava_2018/InstantDemo_isSuported/InstantDemo/src/InstantDemo2.java b/BasicJava_2018/InstantDemo_isSuported/InstantDemo/src/InstantDemo2.java new file mode 100644 index 000000000..9a165b335 --- /dev/null +++ b/BasicJava_2018/InstantDemo_isSuported/InstantDemo/src/InstantDemo2.java @@ -0,0 +1,23 @@ +import java.time.Instant; +import java.time.temporal.ChronoUnit; + +public class InstantDemo2 +{ + public static void main(String[] args) + { + Instant instant = Instant.parse("2014-12-03T10:15:30.00Z"); + + /* + * Parameters: + * + * unit - the unit to check, null returns false + * + * Returns: + * + * true if the unit can be added/subtracted, false if not + */ + System.out.println(instant.isSupported(ChronoUnit.DAYS)); + System.out.println(instant.isSupported(ChronoUnit.WEEKS)); + } + +} diff --git a/BasicJava_2018/InstantDemo_isSuported/InstantDemo1_Output.txt b/BasicJava_2018/InstantDemo_isSuported/InstantDemo1_Output.txt new file mode 100644 index 000000000..da29283aa --- /dev/null +++ b/BasicJava_2018/InstantDemo_isSuported/InstantDemo1_Output.txt @@ -0,0 +1,2 @@ +true +false diff --git a/BasicJava_2018/InstantDemo_isSuported/InstantDemo2_Output.txt b/BasicJava_2018/InstantDemo_isSuported/InstantDemo2_Output.txt new file mode 100644 index 000000000..da29283aa --- /dev/null +++ b/BasicJava_2018/InstantDemo_isSuported/InstantDemo2_Output.txt @@ -0,0 +1,2 @@ +true +false diff --git a/BasicJava_2018/InstantDemo_max_min/InstantDemo/.classpath b/BasicJava_2018/InstantDemo_max_min/InstantDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/InstantDemo_max_min/InstantDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/InstantDemo_max_min/InstantDemo/.project b/BasicJava_2018/InstantDemo_max_min/InstantDemo/.project new file mode 100644 index 000000000..08fe4c5fa --- /dev/null +++ b/BasicJava_2018/InstantDemo_max_min/InstantDemo/.project @@ -0,0 +1,17 @@ + + + InstantDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/InstantDemo_max_min/InstantDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/InstantDemo_max_min/InstantDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/InstantDemo_max_min/InstantDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/InstantDemo_max_min/InstantDemo/bin/InstantDemo.class b/BasicJava_2018/InstantDemo_max_min/InstantDemo/bin/InstantDemo.class new file mode 100644 index 000000000..7d4e14d07 Binary files /dev/null and b/BasicJava_2018/InstantDemo_max_min/InstantDemo/bin/InstantDemo.class differ diff --git a/BasicJava_2018/InstantDemo_max_min/InstantDemo/src/InstantDemo.java b/BasicJava_2018/InstantDemo_max_min/InstantDemo/src/InstantDemo.java new file mode 100644 index 000000000..34061f978 --- /dev/null +++ b/BasicJava_2018/InstantDemo_max_min/InstantDemo/src/InstantDemo.java @@ -0,0 +1,34 @@ +import java.time.Instant; + +public class InstantDemo +{ + public static void main(String[] args) + { + + /* + * Instant MAX defines the maximum supported Instant, + * '1000000000-12-31T23:59:59.999999999Z' is the value. + */ + Instant instant = Instant.MAX; + System.out.println("Max = "+instant); + System.out.println("Max EpochSecond = "+instant.getEpochSecond()); + + /* + * Instant MIN defines the minimum supported Instant, + * '-1000000000-01-01T00:00Z'. + */ + instant = Instant.MIN; + System.out.println("Min = "+instant); + System.out.println("Min EpochSecond = "+instant.getEpochSecond()); + + /* + * Instant EPOCH defines the constant for the + * 1970-01-01T00:00:00Z epoch instant. + */ + instant = Instant.EPOCH; + System.out.println("EPOCH = "+instant); + System.out.println("EPOCH EpochSecond = "+instant.getEpochSecond()); + + } + +} diff --git a/BasicJava_2018/InstantDemo_max_min/Output.txt b/BasicJava_2018/InstantDemo_max_min/Output.txt new file mode 100644 index 000000000..081b81675 --- /dev/null +++ b/BasicJava_2018/InstantDemo_max_min/Output.txt @@ -0,0 +1,6 @@ +Max = +1000000000-12-31T23:59:59.999999999Z +Max EpochSecond = 31556889864403199 +Min = -1000000000-01-01T00:00:00Z +Min EpochSecond = -31557014167219200 +EPOCH = 1970-01-01T00:00:00Z +EPOCH EpochSecond = 0 diff --git a/BasicJava_2018/InstantDemo_minus/InstantDemo/.classpath b/BasicJava_2018/InstantDemo_minus/InstantDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/InstantDemo_minus/InstantDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/InstantDemo_minus/InstantDemo/.project b/BasicJava_2018/InstantDemo_minus/InstantDemo/.project new file mode 100644 index 000000000..08fe4c5fa --- /dev/null +++ b/BasicJava_2018/InstantDemo_minus/InstantDemo/.project @@ -0,0 +1,17 @@ + + + InstantDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/InstantDemo_minus/InstantDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/InstantDemo_minus/InstantDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/InstantDemo_minus/InstantDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/InstantDemo_minus/InstantDemo/bin/InstantDemo1.class b/BasicJava_2018/InstantDemo_minus/InstantDemo/bin/InstantDemo1.class new file mode 100644 index 000000000..b34f4abde Binary files /dev/null and b/BasicJava_2018/InstantDemo_minus/InstantDemo/bin/InstantDemo1.class differ diff --git a/BasicJava_2018/InstantDemo_minus/InstantDemo/bin/InstantDemo2.class b/BasicJava_2018/InstantDemo_minus/InstantDemo/bin/InstantDemo2.class new file mode 100644 index 000000000..1d22eb693 Binary files /dev/null and b/BasicJava_2018/InstantDemo_minus/InstantDemo/bin/InstantDemo2.class differ diff --git a/BasicJava_2018/InstantDemo_minus/InstantDemo/bin/InstantDemo3.class b/BasicJava_2018/InstantDemo_minus/InstantDemo/bin/InstantDemo3.class new file mode 100644 index 000000000..766ad7604 Binary files /dev/null and b/BasicJava_2018/InstantDemo_minus/InstantDemo/bin/InstantDemo3.class differ diff --git a/BasicJava_2018/InstantDemo_minus/InstantDemo/src/InstantDemo1.java b/BasicJava_2018/InstantDemo_minus/InstantDemo/src/InstantDemo1.java new file mode 100644 index 000000000..2d76da623 --- /dev/null +++ b/BasicJava_2018/InstantDemo_minus/InstantDemo/src/InstantDemo1.java @@ -0,0 +1,52 @@ +import java.time.Instant; + +public class InstantDemo1 +{ + public static void main(String[] args) + { + + Instant instant = Instant.parse("2017-12-03T10:15:30.00Z"); + System.out.println("Before minus = "+instant); + + /* + * Parameters: + * + * secondsToAdd - the seconds to add, positive or negative + * + * Returns: + * + * an Instant based on this instant with the specified seconds + * added, not null + */ + instant = instant.minusSeconds(10000); + System.out.println("After minusSeconds = "+instant); + + /* + * Parameters: + * + * millisToAdd - the milliseconds to add, positive or negative + * + * Returns: + * + * an Instant based on this instant with the specified + * milliseconds added, not null + */ + instant = instant.minusMillis(20000); + System.out.println("After minusMillis = "+instant); + + /* + * Parameters: + * + * nanosToAdd - the nanoseconds to add, positive or negative + * + * Returns: + * + * an Instant based on this instant with the specified + * nanoseconds added, not null + */ + instant = instant.minusNanos(50000); + System.out.println("After minusNanos = "+instant); + + } + +} diff --git a/BasicJava_2018/InstantDemo_minus/InstantDemo/src/InstantDemo2.java b/BasicJava_2018/InstantDemo_minus/InstantDemo/src/InstantDemo2.java new file mode 100644 index 000000000..4a392653c --- /dev/null +++ b/BasicJava_2018/InstantDemo_minus/InstantDemo/src/InstantDemo2.java @@ -0,0 +1,28 @@ +import java.time.Instant; +import java.time.temporal.ChronoUnit; + +public class InstantDemo2 +{ + public static void main(String[] args) + { + Instant instant = Instant.parse("2017-12-23T10:15:30.00Z"); + System.out.println("Before minus = "+instant); + + /* + * Parameters: + * + * amountToAdd - the amount of the unit to add to the result, + * may be negative + * + * unit - the unit of the amount to add, not null + * + * Returns: + * + * an Instant based on this instant with the specified amount + * added, not null + */ + instant = instant.minus(10,ChronoUnit.DAYS); + System.out.println("After minus = "+instant); + } + +} diff --git a/BasicJava_2018/InstantDemo_minus/InstantDemo/src/InstantDemo3.java b/BasicJava_2018/InstantDemo_minus/InstantDemo/src/InstantDemo3.java new file mode 100644 index 000000000..e30a9c268 --- /dev/null +++ b/BasicJava_2018/InstantDemo_minus/InstantDemo/src/InstantDemo3.java @@ -0,0 +1,26 @@ +import java.time.Duration; +import java.time.Instant; + +public class InstantDemo3 +{ + public static void main(String[] args) + { + Instant instant = Instant.parse("2017-12-15T10:15:30.00Z"); + System.out.println("Before plus = "+instant); + + Duration duration = Duration.ofDays(5); + /* + * Parameters: + * + * amountToAdd - the amount to add, not null + * + * Returns: + * + * an Instant based on this instant with the addition made, + * not null + */ + instant = instant.minus(duration); + System.out.println("After minus = "+instant); + } + +} diff --git a/BasicJava_2018/InstantDemo_minus/InstantDemo1_Output.txt b/BasicJava_2018/InstantDemo_minus/InstantDemo1_Output.txt new file mode 100644 index 000000000..054b0925a --- /dev/null +++ b/BasicJava_2018/InstantDemo_minus/InstantDemo1_Output.txt @@ -0,0 +1,4 @@ +Before minus = 2017-12-03T10:15:30Z +After minusSeconds = 2017-12-03T07:28:50Z +After minusMillis = 2017-12-03T07:28:30Z +After minusNanos = 2017-12-03T07:28:29.999950Z diff --git a/BasicJava_2018/InstantDemo_minus/InstantDemo2_Output.txt b/BasicJava_2018/InstantDemo_minus/InstantDemo2_Output.txt new file mode 100644 index 000000000..75bfc8ed3 --- /dev/null +++ b/BasicJava_2018/InstantDemo_minus/InstantDemo2_Output.txt @@ -0,0 +1,2 @@ +Before minus = 2017-12-23T10:15:30Z +After minus = 2017-12-13T10:15:30Z diff --git a/BasicJava_2018/InstantDemo_minus/InstantDemo3_Output.txt b/BasicJava_2018/InstantDemo_minus/InstantDemo3_Output.txt new file mode 100644 index 000000000..fdf883ca3 --- /dev/null +++ b/BasicJava_2018/InstantDemo_minus/InstantDemo3_Output.txt @@ -0,0 +1,2 @@ +Before plus = 2017-12-15T10:15:30Z +After minus = 2017-12-10T10:15:30Z diff --git a/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo/.classpath b/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo/.project b/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo/.project new file mode 100644 index 000000000..08fe4c5fa --- /dev/null +++ b/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo/.project @@ -0,0 +1,17 @@ + + + InstantDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo/bin/InstantDemo1.class b/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo/bin/InstantDemo1.class new file mode 100644 index 000000000..3b81b4b61 Binary files /dev/null and b/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo/bin/InstantDemo1.class differ diff --git a/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo/bin/InstantDemo2.class b/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo/bin/InstantDemo2.class new file mode 100644 index 000000000..e0dc68f24 Binary files /dev/null and b/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo/bin/InstantDemo2.class differ diff --git a/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo/bin/InstantDemo3.class b/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo/bin/InstantDemo3.class new file mode 100644 index 000000000..acb8bcffd Binary files /dev/null and b/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo/bin/InstantDemo3.class differ diff --git a/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo/src/InstantDemo1.java b/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo/src/InstantDemo1.java new file mode 100644 index 000000000..97be43f80 --- /dev/null +++ b/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo/src/InstantDemo1.java @@ -0,0 +1,25 @@ +import java.time.Instant; + +public class InstantDemo1 +{ + public static void main(String[] args) + { + + /* + * Obtains an instance of Instant using milliseconds from the + * epoch of 1970-01-01T00:00:00Z. + * + * Parameters: + * + * epochMilli - the number of milliseconds from + * 1970-01-01T00:00:00Z + * + * Returns: + * + * an instant, not null + */ + Instant instant = Instant.ofEpochMilli(50000L); + System.out.println(instant); + } + +} diff --git a/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo/src/InstantDemo2.java b/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo/src/InstantDemo2.java new file mode 100644 index 000000000..17bb4165a --- /dev/null +++ b/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo/src/InstantDemo2.java @@ -0,0 +1,24 @@ +import java.time.Instant; + +public class InstantDemo2 +{ + public static void main(String[] args) + { + /* + * Obtains an instance of Instant using seconds from the epoch + * of 1970-01-01T00:00:00Z. + * + * Parameters: + * + * epochSecond - the number of seconds from + * 1970-01-01T00:00:00Z + * + * Returns: + * + * an instant, not null + */ + Instant instant = Instant.ofEpochSecond(100000L); + System.out.println(instant); + } + +} diff --git a/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo/src/InstantDemo3.java b/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo/src/InstantDemo3.java new file mode 100644 index 000000000..06092d4e5 --- /dev/null +++ b/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo/src/InstantDemo3.java @@ -0,0 +1,27 @@ +import java.time.Instant; + +public class InstantDemo3 +{ + public static void main(String[] args) + { + /* + * Obtains an instance of Instant using seconds from the epoch + * of 1970-01-01T00:00:00Z and nanosecond fraction of second. + * + * Parameters: + * + * epochSecond - the number of seconds from + * 1970-01-01T00:00:00Z + * + * nanoAdjustment - the nanosecond adjustment to the number of + * seconds, positive or negative + * + * Returns: + * + * an instant, not null + */ + Instant instant = Instant.ofEpochSecond(90900L, 8000); + System.out.println(instant); + } + +} diff --git a/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo1_Output.txt b/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo1_Output.txt new file mode 100644 index 000000000..94329fb62 --- /dev/null +++ b/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo1_Output.txt @@ -0,0 +1 @@ +1970-01-01T00:00:50Z diff --git a/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo2_Output.txt b/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo2_Output.txt new file mode 100644 index 000000000..008770c22 --- /dev/null +++ b/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo2_Output.txt @@ -0,0 +1 @@ +1970-01-02T03:46:40Z diff --git a/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo3_Output.txt b/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo3_Output.txt new file mode 100644 index 000000000..48d2954e1 --- /dev/null +++ b/BasicJava_2018/InstantDemo_ofEpoch/InstantDemo3_Output.txt @@ -0,0 +1 @@ +1970-01-02T01:15:00.000008Z diff --git a/BasicJava_2018/InstantDemo_parse/InstantDemo/.classpath b/BasicJava_2018/InstantDemo_parse/InstantDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/InstantDemo_parse/InstantDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/InstantDemo_parse/InstantDemo/.project b/BasicJava_2018/InstantDemo_parse/InstantDemo/.project new file mode 100644 index 000000000..08fe4c5fa --- /dev/null +++ b/BasicJava_2018/InstantDemo_parse/InstantDemo/.project @@ -0,0 +1,17 @@ + + + InstantDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/InstantDemo_parse/InstantDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/InstantDemo_parse/InstantDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/InstantDemo_parse/InstantDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/InstantDemo_parse/InstantDemo/bin/InstantDemo.class b/BasicJava_2018/InstantDemo_parse/InstantDemo/bin/InstantDemo.class new file mode 100644 index 000000000..028dd163f Binary files /dev/null and b/BasicJava_2018/InstantDemo_parse/InstantDemo/bin/InstantDemo.class differ diff --git a/BasicJava_2018/InstantDemo_parse/InstantDemo/src/InstantDemo.java b/BasicJava_2018/InstantDemo_parse/InstantDemo/src/InstantDemo.java new file mode 100644 index 000000000..0eec6f845 --- /dev/null +++ b/BasicJava_2018/InstantDemo_parse/InstantDemo/src/InstantDemo.java @@ -0,0 +1,22 @@ +import java.time.Instant; + +public class InstantDemo +{ + public static void main(String[] args) + { + + /* + * Parameters: + * + * text - the text to parse, not null + * + * Returns: + * + * the parsed instant, not null + */ + Instant instant = Instant.parse("2017-12-03T10:15:30.00Z"); + System.out.println(instant); + + } + +} diff --git a/BasicJava_2018/InstantDemo_parse/Output.txt b/BasicJava_2018/InstantDemo_parse/Output.txt new file mode 100644 index 000000000..165c74c67 --- /dev/null +++ b/BasicJava_2018/InstantDemo_parse/Output.txt @@ -0,0 +1 @@ +2017-12-03T10:15:30Z diff --git a/BasicJava_2018/InstantDemo_plus/InstantDemo/.classpath b/BasicJava_2018/InstantDemo_plus/InstantDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/InstantDemo_plus/InstantDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/InstantDemo_plus/InstantDemo/.project b/BasicJava_2018/InstantDemo_plus/InstantDemo/.project new file mode 100644 index 000000000..08fe4c5fa --- /dev/null +++ b/BasicJava_2018/InstantDemo_plus/InstantDemo/.project @@ -0,0 +1,17 @@ + + + InstantDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/InstantDemo_plus/InstantDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/InstantDemo_plus/InstantDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/InstantDemo_plus/InstantDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/InstantDemo_plus/InstantDemo/bin/InstantDemo1.class b/BasicJava_2018/InstantDemo_plus/InstantDemo/bin/InstantDemo1.class new file mode 100644 index 000000000..9f84d25a0 Binary files /dev/null and b/BasicJava_2018/InstantDemo_plus/InstantDemo/bin/InstantDemo1.class differ diff --git a/BasicJava_2018/InstantDemo_plus/InstantDemo/bin/InstantDemo2.class b/BasicJava_2018/InstantDemo_plus/InstantDemo/bin/InstantDemo2.class new file mode 100644 index 000000000..805fa349b Binary files /dev/null and b/BasicJava_2018/InstantDemo_plus/InstantDemo/bin/InstantDemo2.class differ diff --git a/BasicJava_2018/InstantDemo_plus/InstantDemo/bin/InstantDemo3.class b/BasicJava_2018/InstantDemo_plus/InstantDemo/bin/InstantDemo3.class new file mode 100644 index 000000000..80333e076 Binary files /dev/null and b/BasicJava_2018/InstantDemo_plus/InstantDemo/bin/InstantDemo3.class differ diff --git a/BasicJava_2018/InstantDemo_plus/InstantDemo/src/InstantDemo1.java b/BasicJava_2018/InstantDemo_plus/InstantDemo/src/InstantDemo1.java new file mode 100644 index 000000000..eb456560f --- /dev/null +++ b/BasicJava_2018/InstantDemo_plus/InstantDemo/src/InstantDemo1.java @@ -0,0 +1,52 @@ +import java.time.Instant; + +public class InstantDemo1 +{ + public static void main(String[] args) + { + + Instant instant = Instant.parse("2017-12-03T10:15:30.00Z"); + System.out.println("Before plus = "+instant); + + /* + * Parameters: + * + * secondsToAdd - the seconds to add, positive or negative + * + * Returns: + * + * an Instant based on this instant with the specified seconds + * added, not null + */ + instant = instant.plusSeconds(10000); + System.out.println("After plusSeconds = "+instant); + + /* + * Parameters: + * + * millisToAdd - the milliseconds to add, positive or negative + * + * Returns: + * + * an Instant based on this instant with the specified + * milliseconds added, not null + */ + instant = instant.plusMillis(20000); + System.out.println("After plusMillis = "+instant); + + /* + * Parameters: + * + * nanosToAdd - the nanoseconds to add, positive or negative + * + * Returns: + * + * an Instant based on this instant with the specified + * nanoseconds added, not null + */ + instant = instant.plusNanos(50000); + System.out.println("After plusNanos = "+instant); + + } + +} diff --git a/BasicJava_2018/InstantDemo_plus/InstantDemo/src/InstantDemo2.java b/BasicJava_2018/InstantDemo_plus/InstantDemo/src/InstantDemo2.java new file mode 100644 index 000000000..054accc44 --- /dev/null +++ b/BasicJava_2018/InstantDemo_plus/InstantDemo/src/InstantDemo2.java @@ -0,0 +1,28 @@ +import java.time.Instant; +import java.time.temporal.ChronoUnit; + +public class InstantDemo2 +{ + public static void main(String[] args) + { + Instant instant = Instant.parse("2017-12-03T10:15:30.00Z"); + System.out.println("Before plus = "+instant); + + /* + * Parameters: + * + * amountToAdd - the amount of the unit to add to the result, + * may be negative + * + * unit - the unit of the amount to add, not null + * + * Returns: + * + * an Instant based on this instant with the specified amount + * added, not null + */ + instant = instant.plus(10,ChronoUnit.DAYS); + System.out.println("After plus = "+instant); + } + +} diff --git a/BasicJava_2018/InstantDemo_plus/InstantDemo/src/InstantDemo3.java b/BasicJava_2018/InstantDemo_plus/InstantDemo/src/InstantDemo3.java new file mode 100644 index 000000000..2ca6d0bfc --- /dev/null +++ b/BasicJava_2018/InstantDemo_plus/InstantDemo/src/InstantDemo3.java @@ -0,0 +1,26 @@ +import java.time.Duration; +import java.time.Instant; + +public class InstantDemo3 +{ + public static void main(String[] args) + { + Instant instant = Instant.parse("2017-12-03T10:15:30.00Z"); + System.out.println("Before plus = "+instant); + + Duration duration = Duration.ofDays(5); + /* + * Parameters: + * + * amountToAdd - the amount to add, not null + * + * Returns: + * + * an Instant based on this instant with the addition made, + * not null + */ + instant = instant.plus(duration); + System.out.println("After plus = "+instant); + } + +} diff --git a/BasicJava_2018/InstantDemo_plus/InstantDemo1_Output.txt b/BasicJava_2018/InstantDemo_plus/InstantDemo1_Output.txt new file mode 100644 index 000000000..5e4be5a03 --- /dev/null +++ b/BasicJava_2018/InstantDemo_plus/InstantDemo1_Output.txt @@ -0,0 +1,4 @@ +Before plus = 2017-12-03T10:15:30Z +After plusSeconds = 2017-12-03T13:02:10Z +After plusMillis = 2017-12-03T13:02:30Z +After plusNanos = 2017-12-03T13:02:30.000050Z diff --git a/BasicJava_2018/InstantDemo_plus/InstantDemo2_Output.txt b/BasicJava_2018/InstantDemo_plus/InstantDemo2_Output.txt new file mode 100644 index 000000000..3c3a58986 --- /dev/null +++ b/BasicJava_2018/InstantDemo_plus/InstantDemo2_Output.txt @@ -0,0 +1,2 @@ +Before plus = 2017-12-03T10:15:30Z +After plus = 2017-12-13T10:15:30Z diff --git a/BasicJava_2018/InstantDemo_plus/InstantDemo3_Output.txt b/BasicJava_2018/InstantDemo_plus/InstantDemo3_Output.txt new file mode 100644 index 000000000..b0816b523 --- /dev/null +++ b/BasicJava_2018/InstantDemo_plus/InstantDemo3_Output.txt @@ -0,0 +1,2 @@ +Before plus = 2017-12-03T10:15:30Z +After plus = 2017-12-08T10:15:30Z diff --git a/BasicJava_2018/InstantDemo_query/InstantDemo/.classpath b/BasicJava_2018/InstantDemo_query/InstantDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/InstantDemo_query/InstantDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/InstantDemo_query/InstantDemo/.project b/BasicJava_2018/InstantDemo_query/InstantDemo/.project new file mode 100644 index 000000000..08fe4c5fa --- /dev/null +++ b/BasicJava_2018/InstantDemo_query/InstantDemo/.project @@ -0,0 +1,17 @@ + + + InstantDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/InstantDemo_query/InstantDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/InstantDemo_query/InstantDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/InstantDemo_query/InstantDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/InstantDemo_query/InstantDemo/bin/InstantDemo.class b/BasicJava_2018/InstantDemo_query/InstantDemo/bin/InstantDemo.class new file mode 100644 index 000000000..86c7b3418 Binary files /dev/null and b/BasicJava_2018/InstantDemo_query/InstantDemo/bin/InstantDemo.class differ diff --git a/BasicJava_2018/InstantDemo_query/InstantDemo/src/InstantDemo.java b/BasicJava_2018/InstantDemo_query/InstantDemo/src/InstantDemo.java new file mode 100644 index 000000000..4a49e1173 --- /dev/null +++ b/BasicJava_2018/InstantDemo_query/InstantDemo/src/InstantDemo.java @@ -0,0 +1,27 @@ +import java.time.Instant; +import java.time.temporal.TemporalQueries; +import java.time.temporal.TemporalUnit; + +public class InstantDemo +{ + public static void main(String[] args) + { + + Instant instant = Instant.parse("2017-12-03T10:15:30.00Z"); + + /* + * Parameters: + * + * query - the query to invoke, not null + * + * Returns: + * + * the query result, null may be returned (defined by the + * query) + */ + TemporalUnit temporalUnit = instant.query(TemporalQueries.precision()); + System.out.println(temporalUnit); + + } + +} diff --git a/BasicJava_2018/InstantDemo_query/Output.txt b/BasicJava_2018/InstantDemo_query/Output.txt new file mode 100644 index 000000000..7444ec743 --- /dev/null +++ b/BasicJava_2018/InstantDemo_query/Output.txt @@ -0,0 +1 @@ +Nanos diff --git a/BasicJava_2018/InstantDemo_range/InstantDemo/.classpath b/BasicJava_2018/InstantDemo_range/InstantDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/InstantDemo_range/InstantDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/InstantDemo_range/InstantDemo/.project b/BasicJava_2018/InstantDemo_range/InstantDemo/.project new file mode 100644 index 000000000..08fe4c5fa --- /dev/null +++ b/BasicJava_2018/InstantDemo_range/InstantDemo/.project @@ -0,0 +1,17 @@ + + + InstantDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/InstantDemo_range/InstantDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/InstantDemo_range/InstantDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/InstantDemo_range/InstantDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/InstantDemo_range/InstantDemo/bin/InstantDemo.class b/BasicJava_2018/InstantDemo_range/InstantDemo/bin/InstantDemo.class new file mode 100644 index 000000000..c45a776ca Binary files /dev/null and b/BasicJava_2018/InstantDemo_range/InstantDemo/bin/InstantDemo.class differ diff --git a/BasicJava_2018/InstantDemo_range/InstantDemo/src/InstantDemo.java b/BasicJava_2018/InstantDemo_range/InstantDemo/src/InstantDemo.java new file mode 100644 index 000000000..c145b199b --- /dev/null +++ b/BasicJava_2018/InstantDemo_range/InstantDemo/src/InstantDemo.java @@ -0,0 +1,28 @@ +import java.time.Instant; +import java.time.temporal.ChronoField; +import java.time.temporal.ValueRange; + +public class InstantDemo +{ + public static void main(String[] args) + { + + Instant instant = Instant.parse("2017-12-03T10:15:30.00Z"); + + /* + * Parameters: + * + * field - the field to query the range for, not null + * + * Returns: + * + * the range of valid values for the field, not null + */ + ValueRange range = instant.range(ChronoField.NANO_OF_SECOND); + System.out.println("range = "+range); + System.out.println("min = " + range.getMinimum()); + System.out.println("max = " + range.getMaximum()); + + } + +} diff --git a/BasicJava_2018/InstantDemo_range/Output.txt b/BasicJava_2018/InstantDemo_range/Output.txt new file mode 100644 index 000000000..dcad4481d --- /dev/null +++ b/BasicJava_2018/InstantDemo_range/Output.txt @@ -0,0 +1,3 @@ +range = 0 - 999999999 +min = 0 +max = 999999999 diff --git a/BasicJava_2018/InstantDemo_toEpochMilli/InstantDemo/.classpath b/BasicJava_2018/InstantDemo_toEpochMilli/InstantDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/InstantDemo_toEpochMilli/InstantDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/InstantDemo_toEpochMilli/InstantDemo/.project b/BasicJava_2018/InstantDemo_toEpochMilli/InstantDemo/.project new file mode 100644 index 000000000..08fe4c5fa --- /dev/null +++ b/BasicJava_2018/InstantDemo_toEpochMilli/InstantDemo/.project @@ -0,0 +1,17 @@ + + + InstantDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/InstantDemo_toEpochMilli/InstantDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/InstantDemo_toEpochMilli/InstantDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/InstantDemo_toEpochMilli/InstantDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/InstantDemo_toEpochMilli/InstantDemo/bin/InstantDemo.class b/BasicJava_2018/InstantDemo_toEpochMilli/InstantDemo/bin/InstantDemo.class new file mode 100644 index 000000000..f9dd1a645 Binary files /dev/null and b/BasicJava_2018/InstantDemo_toEpochMilli/InstantDemo/bin/InstantDemo.class differ diff --git a/BasicJava_2018/InstantDemo_toEpochMilli/InstantDemo/src/InstantDemo.java b/BasicJava_2018/InstantDemo_toEpochMilli/InstantDemo/src/InstantDemo.java new file mode 100644 index 000000000..5b77ca1d8 --- /dev/null +++ b/BasicJava_2018/InstantDemo_toEpochMilli/InstantDemo/src/InstantDemo.java @@ -0,0 +1,23 @@ +import java.time.Instant; + +public class InstantDemo +{ + public static void main(String[] args) + { + + Instant instant = Instant.parse("2014-12-03T10:15:30.00Z"); + System.out.println(instant); + + /* + * Converts this instant to the number of milliseconds from + * the epoch of 1970-01-01T00:00:00Z. + * + * Returns:the number of milliseconds since the epoch of + * 1970-01-01T00:00:00Z + */ + long ms = instant.toEpochMilli(); + System.out.println(ms); + + } + +} diff --git a/BasicJava_2018/InstantDemo_toEpochMilli/Output.txt b/BasicJava_2018/InstantDemo_toEpochMilli/Output.txt new file mode 100644 index 000000000..77f654b9e --- /dev/null +++ b/BasicJava_2018/InstantDemo_toEpochMilli/Output.txt @@ -0,0 +1,2 @@ +2014-12-03T10:15:30Z +1417601730000 diff --git a/BasicJava_2018/InstantDemo_truncatedTo/InstantDemo/.classpath b/BasicJava_2018/InstantDemo_truncatedTo/InstantDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/InstantDemo_truncatedTo/InstantDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/InstantDemo_truncatedTo/InstantDemo/.project b/BasicJava_2018/InstantDemo_truncatedTo/InstantDemo/.project new file mode 100644 index 000000000..08fe4c5fa --- /dev/null +++ b/BasicJava_2018/InstantDemo_truncatedTo/InstantDemo/.project @@ -0,0 +1,17 @@ + + + InstantDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/InstantDemo_truncatedTo/InstantDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/InstantDemo_truncatedTo/InstantDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/InstantDemo_truncatedTo/InstantDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/InstantDemo_truncatedTo/InstantDemo/bin/InstantDemo.class b/BasicJava_2018/InstantDemo_truncatedTo/InstantDemo/bin/InstantDemo.class new file mode 100644 index 000000000..f1009754c Binary files /dev/null and b/BasicJava_2018/InstantDemo_truncatedTo/InstantDemo/bin/InstantDemo.class differ diff --git a/BasicJava_2018/InstantDemo_truncatedTo/InstantDemo/src/InstantDemo.java b/BasicJava_2018/InstantDemo_truncatedTo/InstantDemo/src/InstantDemo.java new file mode 100644 index 000000000..ad1e62479 --- /dev/null +++ b/BasicJava_2018/InstantDemo_truncatedTo/InstantDemo/src/InstantDemo.java @@ -0,0 +1,27 @@ +import java.time.Instant; +import java.time.temporal.ChronoUnit; + +public class InstantDemo +{ + public static void main(String[] args) + { + + Instant instant = Instant.parse("2014-12-03T10:15:30.00Z"); + System.out.println(instant); + + /* + * Parameters: + * + * unit - the unit to truncate to, not null + * + * Returns: + * + * an Instant based on this instant with the time + * truncated, not null + */ + instant = instant.truncatedTo(ChronoUnit.DAYS); + System.out.println(instant); + + } + +} diff --git a/BasicJava_2018/InstantDemo_truncatedTo/Output.txt b/BasicJava_2018/InstantDemo_truncatedTo/Output.txt new file mode 100644 index 000000000..a5f8ae030 --- /dev/null +++ b/BasicJava_2018/InstantDemo_truncatedTo/Output.txt @@ -0,0 +1,2 @@ +2014-12-03T10:15:30Z +2014-12-03T00:00:00Z diff --git a/BasicJava_2018/InstantDemo_until/InstantDemo/.classpath b/BasicJava_2018/InstantDemo_until/InstantDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/InstantDemo_until/InstantDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/InstantDemo_until/InstantDemo/.project b/BasicJava_2018/InstantDemo_until/InstantDemo/.project new file mode 100644 index 000000000..08fe4c5fa --- /dev/null +++ b/BasicJava_2018/InstantDemo_until/InstantDemo/.project @@ -0,0 +1,17 @@ + + + InstantDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/InstantDemo_until/InstantDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/InstantDemo_until/InstantDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/InstantDemo_until/InstantDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/InstantDemo_until/InstantDemo/bin/InstantDemo.class b/BasicJava_2018/InstantDemo_until/InstantDemo/bin/InstantDemo.class new file mode 100644 index 000000000..6161306e6 Binary files /dev/null and b/BasicJava_2018/InstantDemo_until/InstantDemo/bin/InstantDemo.class differ diff --git a/BasicJava_2018/InstantDemo_until/InstantDemo/src/InstantDemo.java b/BasicJava_2018/InstantDemo_until/InstantDemo/src/InstantDemo.java new file mode 100644 index 000000000..c9285cf1e --- /dev/null +++ b/BasicJava_2018/InstantDemo_until/InstantDemo/src/InstantDemo.java @@ -0,0 +1,34 @@ +import java.time.Instant; +import java.time.ZonedDateTime; +import java.time.temporal.ChronoUnit; + +public class InstantDemo +{ + public static void main(String[] args) + { + + Instant instant = Instant.parse("2017-12-03T10:15:30.00Z"); + System.out.println("instant = "+instant); + + ZonedDateTime zoneDateTime = ZonedDateTime.now(); + System.out.println("zoneDateTime = "+zoneDateTime); + + /* + * Parameters: + * + * endExclusive - the end date, exclusive, which is converted + * to an Instant, not null + * + * unit - the unit to measure the amount in, not null + * + * Returns: + * + * the amount of time between this instant and the end instant + */ + + long value = instant.until(zoneDateTime, ChronoUnit.DAYS); + System.out.println(value); + + } + +} diff --git a/BasicJava_2018/InstantDemo_until/Output.txt b/BasicJava_2018/InstantDemo_until/Output.txt new file mode 100644 index 000000000..48a9649d8 --- /dev/null +++ b/BasicJava_2018/InstantDemo_until/Output.txt @@ -0,0 +1,3 @@ +instant = 2017-12-03T10:15:30Z +zoneDateTime = 2018-04-07T10:42:51.948+05:30[Asia/Calcutta] +124 diff --git a/BasicJava_2018/InstantDemo_with/InstantDemo/.classpath b/BasicJava_2018/InstantDemo_with/InstantDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/InstantDemo_with/InstantDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/InstantDemo_with/InstantDemo/.project b/BasicJava_2018/InstantDemo_with/InstantDemo/.project new file mode 100644 index 000000000..08fe4c5fa --- /dev/null +++ b/BasicJava_2018/InstantDemo_with/InstantDemo/.project @@ -0,0 +1,17 @@ + + + InstantDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/InstantDemo_with/InstantDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/InstantDemo_with/InstantDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/InstantDemo_with/InstantDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/InstantDemo_with/InstantDemo/bin/InstantDemo1.class b/BasicJava_2018/InstantDemo_with/InstantDemo/bin/InstantDemo1.class new file mode 100644 index 000000000..fdc498f72 Binary files /dev/null and b/BasicJava_2018/InstantDemo_with/InstantDemo/bin/InstantDemo1.class differ diff --git a/BasicJava_2018/InstantDemo_with/InstantDemo/bin/InstantDemo2.class b/BasicJava_2018/InstantDemo_with/InstantDemo/bin/InstantDemo2.class new file mode 100644 index 000000000..816eea978 Binary files /dev/null and b/BasicJava_2018/InstantDemo_with/InstantDemo/bin/InstantDemo2.class differ diff --git a/BasicJava_2018/InstantDemo_with/InstantDemo/src/InstantDemo1.java b/BasicJava_2018/InstantDemo_with/InstantDemo/src/InstantDemo1.java new file mode 100644 index 000000000..1198b987e --- /dev/null +++ b/BasicJava_2018/InstantDemo_with/InstantDemo/src/InstantDemo1.java @@ -0,0 +1,26 @@ +import java.time.Instant; + +public class InstantDemo1 +{ + public static void main(String[] args) + { + Instant instant1 = Instant.parse("2015-12-03T10:15:30.00Z"); + System.out.println("instant1 = "+instant1); + + Instant instant2 = Instant.now(); + System.out.println("instant2 = "+instant2); + + /* + * Parameters: + * + * adjuster - the adjuster to use, not null + * + * Returns: + * + * an Instant based on this with the adjustment made, not null + */ + Instant instant3 = instant1.with(instant2); + System.out.println("instant3 = "+instant3); + } + +} diff --git a/BasicJava_2018/InstantDemo_with/InstantDemo/src/InstantDemo2.java b/BasicJava_2018/InstantDemo_with/InstantDemo/src/InstantDemo2.java new file mode 100644 index 000000000..7274614f6 --- /dev/null +++ b/BasicJava_2018/InstantDemo_with/InstantDemo/src/InstantDemo2.java @@ -0,0 +1,27 @@ +import java.time.Instant; +import java.time.temporal.ChronoField; + +public class InstantDemo2 +{ + public static void main(String[] args) + { + Instant instant1 = Instant.parse("2017-12-03T10:15:30.00Z"); + System.out.println("instant1 = "+instant1); + + /* + * Parameters: + * + * field - the field to set in the result, not null + * + * newValue - the new value of the field in the result + * + * Returns: + * + * an Instant based on this with the specified field set, not + * null + */ + Instant instant2 = instant1.with(ChronoField.NANO_OF_SECOND, 800); + System.out.println("instant2 = "+instant2); + } + +} diff --git a/BasicJava_2018/InstantDemo_with/InstantDemo1_Output.txt b/BasicJava_2018/InstantDemo_with/InstantDemo1_Output.txt new file mode 100644 index 000000000..2aaf8c2ee --- /dev/null +++ b/BasicJava_2018/InstantDemo_with/InstantDemo1_Output.txt @@ -0,0 +1,3 @@ +instant1 = 2015-12-03T10:15:30Z +instant2 = 2018-04-08T04:36:01.776Z +instant3 = 2018-04-08T04:36:01.776Z diff --git a/BasicJava_2018/InstantDemo_with/InstantDemo2_Output.txt b/BasicJava_2018/InstantDemo_with/InstantDemo2_Output.txt new file mode 100644 index 000000000..9d4d6542b --- /dev/null +++ b/BasicJava_2018/InstantDemo_with/InstantDemo2_Output.txt @@ -0,0 +1,2 @@ +instant1 = 2017-12-03T10:15:30Z +instant2 = 2017-12-03T10:15:30.000000800Z diff --git a/BasicJava_2018/MonthDemo_adjustInto/MonthDemo/.classpath b/BasicJava_2018/MonthDemo_adjustInto/MonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/MonthDemo_adjustInto/MonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/MonthDemo_adjustInto/MonthDemo/.project b/BasicJava_2018/MonthDemo_adjustInto/MonthDemo/.project new file mode 100644 index 000000000..701943470 --- /dev/null +++ b/BasicJava_2018/MonthDemo_adjustInto/MonthDemo/.project @@ -0,0 +1,17 @@ + + + MonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/MonthDemo_adjustInto/MonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/MonthDemo_adjustInto/MonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/MonthDemo_adjustInto/MonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/MonthDemo_adjustInto/MonthDemo/bin/MonthDemo.class b/BasicJava_2018/MonthDemo_adjustInto/MonthDemo/bin/MonthDemo.class new file mode 100644 index 000000000..3be137404 Binary files /dev/null and b/BasicJava_2018/MonthDemo_adjustInto/MonthDemo/bin/MonthDemo.class differ diff --git a/BasicJava_2018/MonthDemo_adjustInto/MonthDemo/src/MonthDemo.java b/BasicJava_2018/MonthDemo_adjustInto/MonthDemo/src/MonthDemo.java new file mode 100644 index 000000000..538b14aaa --- /dev/null +++ b/BasicJava_2018/MonthDemo_adjustInto/MonthDemo/src/MonthDemo.java @@ -0,0 +1,32 @@ +import java.time.Month; +import java.time.ZonedDateTime; + +/** + * Temporal java.time.Month.adjustInto(Temporal temporal) + * + * Adjusts the specified temporal object to have this month-of-year. + * + * Parameters: + * + * temporal - the target object to be adjusted, not null + * + * Returns: + * + * the adjusted object, not null + * + */ +public class MonthDemo +{ + public static void main(String[] args) + { + ZonedDateTime zonedDateTime = ZonedDateTime.now(); + System.out.println("zonedDateTime = " + zonedDateTime); + + Month month = Month.of(2); + System.out.println("month = " + month); + + zonedDateTime = (ZonedDateTime) month.adjustInto(zonedDateTime); + System.out.println(zonedDateTime); + } + +} diff --git a/BasicJava_2018/MonthDemo_adjustInto/Output.txt b/BasicJava_2018/MonthDemo_adjustInto/Output.txt new file mode 100644 index 000000000..d933a034c --- /dev/null +++ b/BasicJava_2018/MonthDemo_adjustInto/Output.txt @@ -0,0 +1,3 @@ +zonedDateTime = 2018-04-18T10:11:54.598+05:30[Asia/Calcutta] +month = FEBRUARY +2018-02-18T10:11:54.598+05:30[Asia/Calcutta] diff --git a/BasicJava_2018/MonthDemo_firstDayOfYear/MonthDemo/.classpath b/BasicJava_2018/MonthDemo_firstDayOfYear/MonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/MonthDemo_firstDayOfYear/MonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/MonthDemo_firstDayOfYear/MonthDemo/.project b/BasicJava_2018/MonthDemo_firstDayOfYear/MonthDemo/.project new file mode 100644 index 000000000..701943470 --- /dev/null +++ b/BasicJava_2018/MonthDemo_firstDayOfYear/MonthDemo/.project @@ -0,0 +1,17 @@ + + + MonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/MonthDemo_firstDayOfYear/MonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/MonthDemo_firstDayOfYear/MonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/MonthDemo_firstDayOfYear/MonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/MonthDemo_firstDayOfYear/MonthDemo/bin/MonthDemo.class b/BasicJava_2018/MonthDemo_firstDayOfYear/MonthDemo/bin/MonthDemo.class new file mode 100644 index 000000000..514792ffd Binary files /dev/null and b/BasicJava_2018/MonthDemo_firstDayOfYear/MonthDemo/bin/MonthDemo.class differ diff --git a/BasicJava_2018/MonthDemo_firstDayOfYear/MonthDemo/src/MonthDemo.java b/BasicJava_2018/MonthDemo_firstDayOfYear/MonthDemo/src/MonthDemo.java new file mode 100644 index 000000000..433bafc84 --- /dev/null +++ b/BasicJava_2018/MonthDemo_firstDayOfYear/MonthDemo/src/MonthDemo.java @@ -0,0 +1,24 @@ +import java.time.Month; + +public class MonthDemo +{ + public static void main(String[] args) + { + Month month = Month.of(2); + System.out.println("month = "+month); + + /* + * Parameters: + * + * leapYear - true if the length is required for a leap year + * + * Returns: + * + * the day of year corresponding to the first day of this + * month, from 1 to 336 + */ + int firstDayOfYear = month.firstDayOfYear(false); + System.out.println("firstDayOfYear = "+firstDayOfYear); + } + +} diff --git a/BasicJava_2018/MonthDemo_firstDayOfYear/Output.txt b/BasicJava_2018/MonthDemo_firstDayOfYear/Output.txt new file mode 100644 index 000000000..eedfc57ba --- /dev/null +++ b/BasicJava_2018/MonthDemo_firstDayOfYear/Output.txt @@ -0,0 +1,2 @@ +month = FEBRUARY +firstDayOfYear = 32 diff --git a/BasicJava_2018/MonthDemo_firstMonthOfQuarter/MonthDemo/.classpath b/BasicJava_2018/MonthDemo_firstMonthOfQuarter/MonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/MonthDemo_firstMonthOfQuarter/MonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/MonthDemo_firstMonthOfQuarter/MonthDemo/.project b/BasicJava_2018/MonthDemo_firstMonthOfQuarter/MonthDemo/.project new file mode 100644 index 000000000..701943470 --- /dev/null +++ b/BasicJava_2018/MonthDemo_firstMonthOfQuarter/MonthDemo/.project @@ -0,0 +1,17 @@ + + + MonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/MonthDemo_firstMonthOfQuarter/MonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/MonthDemo_firstMonthOfQuarter/MonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/MonthDemo_firstMonthOfQuarter/MonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/MonthDemo_firstMonthOfQuarter/MonthDemo/bin/MonthDemo.class b/BasicJava_2018/MonthDemo_firstMonthOfQuarter/MonthDemo/bin/MonthDemo.class new file mode 100644 index 000000000..70b9f7706 Binary files /dev/null and b/BasicJava_2018/MonthDemo_firstMonthOfQuarter/MonthDemo/bin/MonthDemo.class differ diff --git a/BasicJava_2018/MonthDemo_firstMonthOfQuarter/MonthDemo/src/MonthDemo.java b/BasicJava_2018/MonthDemo_firstMonthOfQuarter/MonthDemo/src/MonthDemo.java new file mode 100644 index 000000000..48d8fb670 --- /dev/null +++ b/BasicJava_2018/MonthDemo_firstMonthOfQuarter/MonthDemo/src/MonthDemo.java @@ -0,0 +1,20 @@ +import java.time.Month; + +public class MonthDemo +{ + public static void main(String[] args) + { + Month month = Month.of(6); + System.out.println("month = "+month); + + /* + * Returns: + * + * the first month of the quarter corresponding to this month, + * not null + */ + Month firstMonthOfQuarter = month.firstMonthOfQuarter(); + System.out.println("firstMonthOfQuarter = "+firstMonthOfQuarter); + } + +} diff --git a/BasicJava_2018/MonthDemo_firstMonthOfQuarter/Output.txt b/BasicJava_2018/MonthDemo_firstMonthOfQuarter/Output.txt new file mode 100644 index 000000000..163112985 --- /dev/null +++ b/BasicJava_2018/MonthDemo_firstMonthOfQuarter/Output.txt @@ -0,0 +1,2 @@ +month = JUNE +firstMonthOfQuarter = APRIL diff --git a/BasicJava_2018/MonthDemo_getDisplayName/MonthDemo/.classpath b/BasicJava_2018/MonthDemo_getDisplayName/MonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/MonthDemo_getDisplayName/MonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/MonthDemo_getDisplayName/MonthDemo/.project b/BasicJava_2018/MonthDemo_getDisplayName/MonthDemo/.project new file mode 100644 index 000000000..701943470 --- /dev/null +++ b/BasicJava_2018/MonthDemo_getDisplayName/MonthDemo/.project @@ -0,0 +1,17 @@ + + + MonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/MonthDemo_getDisplayName/MonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/MonthDemo_getDisplayName/MonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/MonthDemo_getDisplayName/MonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/MonthDemo_getDisplayName/MonthDemo/bin/MonthDemo.class b/BasicJava_2018/MonthDemo_getDisplayName/MonthDemo/bin/MonthDemo.class new file mode 100644 index 000000000..876cca755 Binary files /dev/null and b/BasicJava_2018/MonthDemo_getDisplayName/MonthDemo/bin/MonthDemo.class differ diff --git a/BasicJava_2018/MonthDemo_getDisplayName/MonthDemo/src/MonthDemo.java b/BasicJava_2018/MonthDemo_getDisplayName/MonthDemo/src/MonthDemo.java new file mode 100644 index 000000000..18f625b2b --- /dev/null +++ b/BasicJava_2018/MonthDemo_getDisplayName/MonthDemo/src/MonthDemo.java @@ -0,0 +1,33 @@ +import java.time.Month; +import java.time.format.TextStyle; +import java.util.Locale; + +public class MonthDemo +{ + public static void main(String[] args) + { + Month month = Month.of(3); + + /* + * Gets the textual representation, such as 'Jan' or + * 'December'. + * + * Parameters: + * + * style - the length of the text required, not null + * + * locale - the locale to use, not null + * + * Returns: + * + * the text value of the month-of-year, not null + */ + System.out + .println(month.getDisplayName(TextStyle.FULL, Locale.ENGLISH)); + System.out + .println(month.getDisplayName(TextStyle.SHORT, Locale.ENGLISH)); + System.out.println( + month.getDisplayName(TextStyle.NARROW, Locale.ENGLISH)); + } + +} diff --git a/BasicJava_2018/MonthDemo_getDisplayName/Output.txt b/BasicJava_2018/MonthDemo_getDisplayName/Output.txt new file mode 100644 index 000000000..9b8b95ca9 --- /dev/null +++ b/BasicJava_2018/MonthDemo_getDisplayName/Output.txt @@ -0,0 +1,3 @@ +March +Mar +M diff --git a/BasicJava_2018/MonthDemo_get_methods/MonthDemo/.classpath b/BasicJava_2018/MonthDemo_get_methods/MonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/MonthDemo_get_methods/MonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/MonthDemo_get_methods/MonthDemo/.project b/BasicJava_2018/MonthDemo_get_methods/MonthDemo/.project new file mode 100644 index 000000000..701943470 --- /dev/null +++ b/BasicJava_2018/MonthDemo_get_methods/MonthDemo/.project @@ -0,0 +1,17 @@ + + + MonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/MonthDemo_get_methods/MonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/MonthDemo_get_methods/MonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/MonthDemo_get_methods/MonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/MonthDemo_get_methods/MonthDemo/bin/MonthDemo1.class b/BasicJava_2018/MonthDemo_get_methods/MonthDemo/bin/MonthDemo1.class new file mode 100644 index 000000000..7b92d195d Binary files /dev/null and b/BasicJava_2018/MonthDemo_get_methods/MonthDemo/bin/MonthDemo1.class differ diff --git a/BasicJava_2018/MonthDemo_get_methods/MonthDemo/bin/MonthDemo2.class b/BasicJava_2018/MonthDemo_get_methods/MonthDemo/bin/MonthDemo2.class new file mode 100644 index 000000000..4868ce4f3 Binary files /dev/null and b/BasicJava_2018/MonthDemo_get_methods/MonthDemo/bin/MonthDemo2.class differ diff --git a/BasicJava_2018/MonthDemo_get_methods/MonthDemo/src/MonthDemo1.java b/BasicJava_2018/MonthDemo_get_methods/MonthDemo/src/MonthDemo1.java new file mode 100644 index 000000000..5e1f148e4 --- /dev/null +++ b/BasicJava_2018/MonthDemo_get_methods/MonthDemo/src/MonthDemo1.java @@ -0,0 +1,27 @@ +import java.time.Month; +import java.time.temporal.ChronoField; + +public class MonthDemo1 +{ + public static void main(String[] args) + { + Month month = Month.NOVEMBER; + System.out.println("month = " + month); + + /* + * Gets the value of the specified field from this + * month-of-year as an int. + * + * Parameters: + * + * field - the field to get, not null + * + * Returns: + * + * the value for the field, within the valid range of values + */ + int monthOfYear = month.get(ChronoField.MONTH_OF_YEAR); + System.out.println("monthOfYear = " + monthOfYear); + } + +} diff --git a/BasicJava_2018/MonthDemo_get_methods/MonthDemo/src/MonthDemo2.java b/BasicJava_2018/MonthDemo_get_methods/MonthDemo/src/MonthDemo2.java new file mode 100644 index 000000000..72c0bb81d --- /dev/null +++ b/BasicJava_2018/MonthDemo_get_methods/MonthDemo/src/MonthDemo2.java @@ -0,0 +1,27 @@ +import java.time.Month; +import java.time.temporal.ChronoField; + +public class MonthDemo2 +{ + public static void main(String[] args) + { + Month month = Month.MARCH; + System.out.println("month = " + month); + + /* + * Gets the value of the specified field from this + * month-of-year as a long. + * + * Parameters: + * + * field - the field to get, not null + * + * Returns: + * + * the value for the field, within the valid range of values + */ + long monthOfYear = month.getLong(ChronoField.MONTH_OF_YEAR); + System.out.println("monthOfYear = " + monthOfYear); + } + +} diff --git a/BasicJava_2018/MonthDemo_get_methods/MonthDemo1_Output.txt b/BasicJava_2018/MonthDemo_get_methods/MonthDemo1_Output.txt new file mode 100644 index 000000000..370c970dd --- /dev/null +++ b/BasicJava_2018/MonthDemo_get_methods/MonthDemo1_Output.txt @@ -0,0 +1,2 @@ +month = NOVEMBER +monthOfYear = 11 diff --git a/BasicJava_2018/MonthDemo_get_methods/MonthDemo2_Output.txt b/BasicJava_2018/MonthDemo_get_methods/MonthDemo2_Output.txt new file mode 100644 index 000000000..5337b2124 --- /dev/null +++ b/BasicJava_2018/MonthDemo_get_methods/MonthDemo2_Output.txt @@ -0,0 +1,2 @@ +month = MARCH +monthOfYear = 3 diff --git a/BasicJava_2018/MonthDemo_intro/MonthDemo/.classpath b/BasicJava_2018/MonthDemo_intro/MonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/MonthDemo_intro/MonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/MonthDemo_intro/MonthDemo/.project b/BasicJava_2018/MonthDemo_intro/MonthDemo/.project new file mode 100644 index 000000000..701943470 --- /dev/null +++ b/BasicJava_2018/MonthDemo_intro/MonthDemo/.project @@ -0,0 +1,17 @@ + + + MonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/MonthDemo_intro/MonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/MonthDemo_intro/MonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/MonthDemo_intro/MonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/MonthDemo_intro/MonthDemo/bin/MonthDemo1.class b/BasicJava_2018/MonthDemo_intro/MonthDemo/bin/MonthDemo1.class new file mode 100644 index 000000000..9e98869b6 Binary files /dev/null and b/BasicJava_2018/MonthDemo_intro/MonthDemo/bin/MonthDemo1.class differ diff --git a/BasicJava_2018/MonthDemo_intro/MonthDemo/bin/MonthDemo2.class b/BasicJava_2018/MonthDemo_intro/MonthDemo/bin/MonthDemo2.class new file mode 100644 index 000000000..36d97b365 Binary files /dev/null and b/BasicJava_2018/MonthDemo_intro/MonthDemo/bin/MonthDemo2.class differ diff --git a/BasicJava_2018/MonthDemo_intro/MonthDemo/src/MonthDemo1.java b/BasicJava_2018/MonthDemo_intro/MonthDemo/src/MonthDemo1.java new file mode 100644 index 000000000..b63a4a684 --- /dev/null +++ b/BasicJava_2018/MonthDemo_intro/MonthDemo/src/MonthDemo1.java @@ -0,0 +1,19 @@ +import java.time.Month; + +public class MonthDemo1 +{ + public static void main(String[] args) + { + Month month = Month.JULY; + + /* + * Returns the name of this enum constant + */ + System.out.println("Name = " + month.name()); + /* + * Gets the month-of-year int value. + */ + System.out.println("Value = " + month.getValue()); + } + +} diff --git a/BasicJava_2018/MonthDemo_intro/MonthDemo/src/MonthDemo2.java b/BasicJava_2018/MonthDemo_intro/MonthDemo/src/MonthDemo2.java new file mode 100644 index 000000000..611d40d4f --- /dev/null +++ b/BasicJava_2018/MonthDemo_intro/MonthDemo/src/MonthDemo2.java @@ -0,0 +1,28 @@ +import java.time.LocalDate; +import java.time.Month; + +public class MonthDemo2 +{ + public static void main(String[] args) + { + + LocalDate localDate = LocalDate.now(); + System.out.println("localDate = " + localDate); + + /* + * Obtains an instance of Month from a temporal object. + * + * Parameters: + * + * temporal - the temporal object to convert, not null + * + * Returns: + * + * the month-of-year, not null + */ + Month month = Month.from(localDate); + System.out.println("Name = " + month.name()); + System.out.println("Value = " + month.getValue()); + } + +} diff --git a/BasicJava_2018/MonthDemo_intro/MonthDemo1_Output.txt b/BasicJava_2018/MonthDemo_intro/MonthDemo1_Output.txt new file mode 100644 index 000000000..7129f859a --- /dev/null +++ b/BasicJava_2018/MonthDemo_intro/MonthDemo1_Output.txt @@ -0,0 +1,2 @@ +Name = JULY +Value = 7 diff --git a/BasicJava_2018/MonthDemo_intro/MonthDemo2_Output.txt b/BasicJava_2018/MonthDemo_intro/MonthDemo2_Output.txt new file mode 100644 index 000000000..aa270a98d --- /dev/null +++ b/BasicJava_2018/MonthDemo_intro/MonthDemo2_Output.txt @@ -0,0 +1,3 @@ +localDate = 2018-04-10 +Name = APRIL +Value = 4 diff --git a/BasicJava_2018/MonthDemo_isSupported/MonthDemo/.classpath b/BasicJava_2018/MonthDemo_isSupported/MonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/MonthDemo_isSupported/MonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/MonthDemo_isSupported/MonthDemo/.project b/BasicJava_2018/MonthDemo_isSupported/MonthDemo/.project new file mode 100644 index 000000000..701943470 --- /dev/null +++ b/BasicJava_2018/MonthDemo_isSupported/MonthDemo/.project @@ -0,0 +1,17 @@ + + + MonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/MonthDemo_isSupported/MonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/MonthDemo_isSupported/MonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/MonthDemo_isSupported/MonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/MonthDemo_isSupported/MonthDemo/bin/MonthDemo.class b/BasicJava_2018/MonthDemo_isSupported/MonthDemo/bin/MonthDemo.class new file mode 100644 index 000000000..ed9cb1918 Binary files /dev/null and b/BasicJava_2018/MonthDemo_isSupported/MonthDemo/bin/MonthDemo.class differ diff --git a/BasicJava_2018/MonthDemo_isSupported/MonthDemo/src/MonthDemo.java b/BasicJava_2018/MonthDemo_isSupported/MonthDemo/src/MonthDemo.java new file mode 100644 index 000000000..63fd3f68f --- /dev/null +++ b/BasicJava_2018/MonthDemo_isSupported/MonthDemo/src/MonthDemo.java @@ -0,0 +1,25 @@ +import java.time.Month; +import java.time.temporal.ChronoField; + +public class MonthDemo +{ + public static void main(String[] args) + { + + Month month = Month.of(3); + + /* + * Parameters: + * + * field - the field to check, null returns false + * + * Returns: + * + * true if the field is supported on this month-of-year, false + * if not + */ + boolean isSupported = month.isSupported(ChronoField.MONTH_OF_YEAR); + System.out.println(isSupported); + } + +} diff --git a/BasicJava_2018/MonthDemo_isSupported/Output.txt b/BasicJava_2018/MonthDemo_isSupported/Output.txt new file mode 100644 index 000000000..27ba77dda --- /dev/null +++ b/BasicJava_2018/MonthDemo_isSupported/Output.txt @@ -0,0 +1 @@ +true diff --git a/BasicJava_2018/MonthDemo_min_max/MonthDemo/.classpath b/BasicJava_2018/MonthDemo_min_max/MonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/MonthDemo_min_max/MonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/MonthDemo_min_max/MonthDemo/.project b/BasicJava_2018/MonthDemo_min_max/MonthDemo/.project new file mode 100644 index 000000000..701943470 --- /dev/null +++ b/BasicJava_2018/MonthDemo_min_max/MonthDemo/.project @@ -0,0 +1,17 @@ + + + MonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/MonthDemo_min_max/MonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/MonthDemo_min_max/MonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/MonthDemo_min_max/MonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/MonthDemo_min_max/MonthDemo/bin/MonthDemo.class b/BasicJava_2018/MonthDemo_min_max/MonthDemo/bin/MonthDemo.class new file mode 100644 index 000000000..ac05a0337 Binary files /dev/null and b/BasicJava_2018/MonthDemo_min_max/MonthDemo/bin/MonthDemo.class differ diff --git a/BasicJava_2018/MonthDemo_min_max/MonthDemo/src/MonthDemo.java b/BasicJava_2018/MonthDemo_min_max/MonthDemo/src/MonthDemo.java new file mode 100644 index 000000000..cd5c680f8 --- /dev/null +++ b/BasicJava_2018/MonthDemo_min_max/MonthDemo/src/MonthDemo.java @@ -0,0 +1,23 @@ +import java.time.Month; + +public class MonthDemo +{ + public static void main(String[] args) + { + Month month = Month.FEBRUARY; + System.out.println("month = " + month); + + /* + * Returns:the minimum length of this month in days, from 28 + * to 31 + */ + System.out.println("min length = " + month.minLength()); + + /* + * Returns:the maximum length of this month in days, from 29 + * to 31 + */ + System.out.println("max length = " + month.maxLength()); + } + +} diff --git a/BasicJava_2018/MonthDemo_min_max/Output.txt b/BasicJava_2018/MonthDemo_min_max/Output.txt new file mode 100644 index 000000000..940f3d10a --- /dev/null +++ b/BasicJava_2018/MonthDemo_min_max/Output.txt @@ -0,0 +1,3 @@ +month = FEBRUARY +min length = 28 +max length = 29 diff --git a/BasicJava_2018/MonthDemo_minus_plus/MonthDemo/.classpath b/BasicJava_2018/MonthDemo_minus_plus/MonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/MonthDemo_minus_plus/MonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/MonthDemo_minus_plus/MonthDemo/.project b/BasicJava_2018/MonthDemo_minus_plus/MonthDemo/.project new file mode 100644 index 000000000..701943470 --- /dev/null +++ b/BasicJava_2018/MonthDemo_minus_plus/MonthDemo/.project @@ -0,0 +1,17 @@ + + + MonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/MonthDemo_minus_plus/MonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/MonthDemo_minus_plus/MonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/MonthDemo_minus_plus/MonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/MonthDemo_minus_plus/MonthDemo/bin/MonthDemo1.class b/BasicJava_2018/MonthDemo_minus_plus/MonthDemo/bin/MonthDemo1.class new file mode 100644 index 000000000..a431cabbd Binary files /dev/null and b/BasicJava_2018/MonthDemo_minus_plus/MonthDemo/bin/MonthDemo1.class differ diff --git a/BasicJava_2018/MonthDemo_minus_plus/MonthDemo/bin/MonthDemo2.class b/BasicJava_2018/MonthDemo_minus_plus/MonthDemo/bin/MonthDemo2.class new file mode 100644 index 000000000..f8f8b33fe Binary files /dev/null and b/BasicJava_2018/MonthDemo_minus_plus/MonthDemo/bin/MonthDemo2.class differ diff --git a/BasicJava_2018/MonthDemo_minus_plus/MonthDemo/src/MonthDemo1.java b/BasicJava_2018/MonthDemo_minus_plus/MonthDemo/src/MonthDemo1.java new file mode 100644 index 000000000..996c59172 --- /dev/null +++ b/BasicJava_2018/MonthDemo_minus_plus/MonthDemo/src/MonthDemo1.java @@ -0,0 +1,23 @@ +import java.time.Month; + +public class MonthDemo1 +{ + public static void main(String[] args) + { + Month month = Month.of(2); + System.out.println("Before minus, Month = "+month); + + /* + * Parameters: + * + * months - the months to subtract, positive or negative + * + * Returns: + * + * the resulting month, not null + */ + month = month.minus(1); + System.out.println("After minus, Month = "+month); + } + +} diff --git a/BasicJava_2018/MonthDemo_minus_plus/MonthDemo/src/MonthDemo2.java b/BasicJava_2018/MonthDemo_minus_plus/MonthDemo/src/MonthDemo2.java new file mode 100644 index 000000000..3815a7cfb --- /dev/null +++ b/BasicJava_2018/MonthDemo_minus_plus/MonthDemo/src/MonthDemo2.java @@ -0,0 +1,23 @@ +import java.time.Month; + +public class MonthDemo2 +{ + public static void main(String[] args) + { + Month month = Month.of(2); + System.out.println("Before plus, Month = "+month); + + /* + * Parameters: + * + * months - the months to add, positive or negative + * + * Returns: + * + * the resulting month, not null + */ + month = month.plus(1); + System.out.println("Before plus, Month = "+month); + } + +} diff --git a/BasicJava_2018/MonthDemo_minus_plus/MonthDemo1_Output.txt b/BasicJava_2018/MonthDemo_minus_plus/MonthDemo1_Output.txt new file mode 100644 index 000000000..d0e90615c --- /dev/null +++ b/BasicJava_2018/MonthDemo_minus_plus/MonthDemo1_Output.txt @@ -0,0 +1,2 @@ +Before minus, Month = FEBRUARY +After minus, Month = JANUARY diff --git a/BasicJava_2018/MonthDemo_minus_plus/MonthDemo2_Output.txt b/BasicJava_2018/MonthDemo_minus_plus/MonthDemo2_Output.txt new file mode 100644 index 000000000..80ebec89b --- /dev/null +++ b/BasicJava_2018/MonthDemo_minus_plus/MonthDemo2_Output.txt @@ -0,0 +1,2 @@ +Before plus, Month = FEBRUARY +Before plus, Month = MARCH diff --git a/BasicJava_2018/MonthDemo_query/MonthDemo/.classpath b/BasicJava_2018/MonthDemo_query/MonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/MonthDemo_query/MonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/MonthDemo_query/MonthDemo/.project b/BasicJava_2018/MonthDemo_query/MonthDemo/.project new file mode 100644 index 000000000..701943470 --- /dev/null +++ b/BasicJava_2018/MonthDemo_query/MonthDemo/.project @@ -0,0 +1,17 @@ + + + MonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/MonthDemo_query/MonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/MonthDemo_query/MonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/MonthDemo_query/MonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/MonthDemo_query/MonthDemo/bin/MonthDemo.class b/BasicJava_2018/MonthDemo_query/MonthDemo/bin/MonthDemo.class new file mode 100644 index 000000000..ef6d41950 Binary files /dev/null and b/BasicJava_2018/MonthDemo_query/MonthDemo/bin/MonthDemo.class differ diff --git a/BasicJava_2018/MonthDemo_query/MonthDemo/src/MonthDemo.java b/BasicJava_2018/MonthDemo_query/MonthDemo/src/MonthDemo.java new file mode 100644 index 000000000..9f3ddd684 --- /dev/null +++ b/BasicJava_2018/MonthDemo_query/MonthDemo/src/MonthDemo.java @@ -0,0 +1,25 @@ +import java.time.Month; +import java.time.temporal.TemporalQueries; +import java.time.temporal.TemporalUnit; + +public class MonthDemo +{ + public static void main(String[] args) + { + Month month = Month.of(2); + + /* + * Parameters: + * + * query - the query to invoke, not null + * + * Returns: + * + * the query result, null may be returned (defined by the + * query) + */ + TemporalUnit temporalUnit = month.query(TemporalQueries.precision()); + System.out.println(temporalUnit); + } + +} diff --git a/BasicJava_2018/MonthDemo_query/Output.txt b/BasicJava_2018/MonthDemo_query/Output.txt new file mode 100644 index 000000000..c5b098a75 --- /dev/null +++ b/BasicJava_2018/MonthDemo_query/Output.txt @@ -0,0 +1 @@ +Months diff --git a/BasicJava_2018/MonthDemo_range/MonthDemo/.classpath b/BasicJava_2018/MonthDemo_range/MonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/MonthDemo_range/MonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/MonthDemo_range/MonthDemo/.project b/BasicJava_2018/MonthDemo_range/MonthDemo/.project new file mode 100644 index 000000000..701943470 --- /dev/null +++ b/BasicJava_2018/MonthDemo_range/MonthDemo/.project @@ -0,0 +1,17 @@ + + + MonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/MonthDemo_range/MonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/MonthDemo_range/MonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/MonthDemo_range/MonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/MonthDemo_range/MonthDemo/bin/MonthDemo.class b/BasicJava_2018/MonthDemo_range/MonthDemo/bin/MonthDemo.class new file mode 100644 index 000000000..6ed21599f Binary files /dev/null and b/BasicJava_2018/MonthDemo_range/MonthDemo/bin/MonthDemo.class differ diff --git a/BasicJava_2018/MonthDemo_range/MonthDemo/src/MonthDemo.java b/BasicJava_2018/MonthDemo_range/MonthDemo/src/MonthDemo.java new file mode 100644 index 000000000..d262216b5 --- /dev/null +++ b/BasicJava_2018/MonthDemo_range/MonthDemo/src/MonthDemo.java @@ -0,0 +1,26 @@ +import java.time.Month; +import java.time.temporal.ChronoField; +import java.time.temporal.ValueRange; + +public class MonthDemo +{ + public static void main(String[] args) + { + Month month = Month.of(2); + + /* + * Parameters: + * + * field - the field to query the range for, not null + * + * Returns: + * + * the range of valid values for the field, not null + */ + ValueRange valueRange = month.range(ChronoField.MONTH_OF_YEAR); + System.out.println("Range = " + valueRange); + System.out.println("Min = " + valueRange.getMinimum()); + System.out.println("Max = " + valueRange.getMaximum()); + } + +} diff --git a/BasicJava_2018/MonthDemo_range/Output.txt b/BasicJava_2018/MonthDemo_range/Output.txt new file mode 100644 index 000000000..6ff33185e --- /dev/null +++ b/BasicJava_2018/MonthDemo_range/Output.txt @@ -0,0 +1,3 @@ +Range = 1 - 12 +Min = 1 +Max = 12 diff --git a/BasicJava_2018/MonthDemo_valueOf/MonthDemo/.classpath b/BasicJava_2018/MonthDemo_valueOf/MonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/MonthDemo_valueOf/MonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/MonthDemo_valueOf/MonthDemo/.project b/BasicJava_2018/MonthDemo_valueOf/MonthDemo/.project new file mode 100644 index 000000000..701943470 --- /dev/null +++ b/BasicJava_2018/MonthDemo_valueOf/MonthDemo/.project @@ -0,0 +1,17 @@ + + + MonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/MonthDemo_valueOf/MonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/MonthDemo_valueOf/MonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/MonthDemo_valueOf/MonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/MonthDemo_valueOf/MonthDemo/bin/MonthDemo.class b/BasicJava_2018/MonthDemo_valueOf/MonthDemo/bin/MonthDemo.class new file mode 100644 index 000000000..953383198 Binary files /dev/null and b/BasicJava_2018/MonthDemo_valueOf/MonthDemo/bin/MonthDemo.class differ diff --git a/BasicJava_2018/MonthDemo_valueOf/MonthDemo/src/MonthDemo.java b/BasicJava_2018/MonthDemo_valueOf/MonthDemo/src/MonthDemo.java new file mode 100644 index 000000000..a86ada1d0 --- /dev/null +++ b/BasicJava_2018/MonthDemo_valueOf/MonthDemo/src/MonthDemo.java @@ -0,0 +1,22 @@ +import java.time.Month; + +public class MonthDemo +{ + public static void main(String[] args) + { + /* + * Parameters: + * + * name - the name of the enum constant to be returned. + * + * Returns: + * + * the enum constant with the specified name + */ + Month month = Month.valueOf("JUNE"); + + System.out.println("Name = " + month.name()); + System.out.println("Value = " + month.getValue()); + } + +} diff --git a/BasicJava_2018/MonthDemo_valueOf/Output.txt b/BasicJava_2018/MonthDemo_valueOf/Output.txt new file mode 100644 index 000000000..960076f31 --- /dev/null +++ b/BasicJava_2018/MonthDemo_valueOf/Output.txt @@ -0,0 +1,2 @@ +Name = JUNE +Value = 6 diff --git a/BasicJava_2018/MonthDemo_values/MonthDemo/.classpath b/BasicJava_2018/MonthDemo_values/MonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/MonthDemo_values/MonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/MonthDemo_values/MonthDemo/.project b/BasicJava_2018/MonthDemo_values/MonthDemo/.project new file mode 100644 index 000000000..701943470 --- /dev/null +++ b/BasicJava_2018/MonthDemo_values/MonthDemo/.project @@ -0,0 +1,17 @@ + + + MonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/MonthDemo_values/MonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/MonthDemo_values/MonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/MonthDemo_values/MonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/MonthDemo_values/MonthDemo/bin/MonthDemo.class b/BasicJava_2018/MonthDemo_values/MonthDemo/bin/MonthDemo.class new file mode 100644 index 000000000..c3d1fa9a3 Binary files /dev/null and b/BasicJava_2018/MonthDemo_values/MonthDemo/bin/MonthDemo.class differ diff --git a/BasicJava_2018/MonthDemo_values/MonthDemo/src/MonthDemo.java b/BasicJava_2018/MonthDemo_values/MonthDemo/src/MonthDemo.java new file mode 100644 index 000000000..559f171e4 --- /dev/null +++ b/BasicJava_2018/MonthDemo_values/MonthDemo/src/MonthDemo.java @@ -0,0 +1,20 @@ +import java.time.Month; + +public class MonthDemo +{ + public static void main(String[] args) + { + /* + * Returns: + * + * an array containing the constants of this enum type, in the + * order they are declared + */ + Month[] monthArray = Month.values(); + for (Month month : monthArray) + { + System.out.println(month); + } + } + +} diff --git a/BasicJava_2018/MonthDemo_values/Output.txt b/BasicJava_2018/MonthDemo_values/Output.txt new file mode 100644 index 000000000..3fa69a99d --- /dev/null +++ b/BasicJava_2018/MonthDemo_values/Output.txt @@ -0,0 +1,12 @@ +JANUARY +FEBRUARY +MARCH +APRIL +MAY +JUNE +JULY +AUGUST +SEPTEMBER +OCTOBER +NOVEMBER +DECEMBER diff --git a/BasicJava_2018/PeriodDemo-normalized/Output.txt b/BasicJava_2018/PeriodDemo-normalized/Output.txt new file mode 100644 index 000000000..fa250ba63 --- /dev/null +++ b/BasicJava_2018/PeriodDemo-normalized/Output.txt @@ -0,0 +1,2 @@ +period1 = P14M +period2 = P1Y2M diff --git a/BasicJava_2018/PeriodDemo-normalized/PeriodDemo/.classpath b/BasicJava_2018/PeriodDemo-normalized/PeriodDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/PeriodDemo-normalized/PeriodDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/PeriodDemo-normalized/PeriodDemo/.project b/BasicJava_2018/PeriodDemo-normalized/PeriodDemo/.project new file mode 100644 index 000000000..1459e07e5 --- /dev/null +++ b/BasicJava_2018/PeriodDemo-normalized/PeriodDemo/.project @@ -0,0 +1,17 @@ + + + PeriodDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/PeriodDemo-normalized/PeriodDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/PeriodDemo-normalized/PeriodDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/PeriodDemo-normalized/PeriodDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/PeriodDemo-normalized/PeriodDemo/bin/PeriodDemo.class b/BasicJava_2018/PeriodDemo-normalized/PeriodDemo/bin/PeriodDemo.class new file mode 100644 index 000000000..485a83691 Binary files /dev/null and b/BasicJava_2018/PeriodDemo-normalized/PeriodDemo/bin/PeriodDemo.class differ diff --git a/BasicJava_2018/PeriodDemo-normalized/PeriodDemo/src/PeriodDemo.java b/BasicJava_2018/PeriodDemo-normalized/PeriodDemo/src/PeriodDemo.java new file mode 100644 index 000000000..eb86cf359 --- /dev/null +++ b/BasicJava_2018/PeriodDemo-normalized/PeriodDemo/src/PeriodDemo.java @@ -0,0 +1,26 @@ +import java.time.Period; + +public class PeriodDemo +{ + + public static void main(String[] args) + { + + Period period1 = Period.ofMonths(14); + System.out.println("period1 = " + period1); + + /* + * Returns a copy of this period with the years and months + * normalized. + * + * Returns: + * + * a Period based on this period with excess months normalized + * to years, not null + */ + Period period2 = period1.normalized(); + System.out.println("period2 = " + period2); + + } + +} diff --git a/BasicJava_2018/PeriodDemo_addTo/Output.txt b/BasicJava_2018/PeriodDemo_addTo/Output.txt new file mode 100644 index 000000000..9ef8a0faa --- /dev/null +++ b/BasicJava_2018/PeriodDemo_addTo/Output.txt @@ -0,0 +1,3 @@ +period = P2D +localDate = 2018-03-07 +temporal = 2018-03-09 diff --git a/BasicJava_2018/PeriodDemo_addTo/PeriodDemo/.classpath b/BasicJava_2018/PeriodDemo_addTo/PeriodDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/PeriodDemo_addTo/PeriodDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/PeriodDemo_addTo/PeriodDemo/.project b/BasicJava_2018/PeriodDemo_addTo/PeriodDemo/.project new file mode 100644 index 000000000..1459e07e5 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_addTo/PeriodDemo/.project @@ -0,0 +1,17 @@ + + + PeriodDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/PeriodDemo_addTo/PeriodDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/PeriodDemo_addTo/PeriodDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_addTo/PeriodDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/PeriodDemo_addTo/PeriodDemo/bin/PeriodDemo.class b/BasicJava_2018/PeriodDemo_addTo/PeriodDemo/bin/PeriodDemo.class new file mode 100644 index 000000000..34c7b716b Binary files /dev/null and b/BasicJava_2018/PeriodDemo_addTo/PeriodDemo/bin/PeriodDemo.class differ diff --git a/BasicJava_2018/PeriodDemo_addTo/PeriodDemo/src/PeriodDemo.java b/BasicJava_2018/PeriodDemo_addTo/PeriodDemo/src/PeriodDemo.java new file mode 100644 index 000000000..37b658c29 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_addTo/PeriodDemo/src/PeriodDemo.java @@ -0,0 +1,31 @@ +import java.time.LocalDate; +import java.time.Period; +import java.time.temporal.Temporal; + +public class PeriodDemo +{ + + public static void main(String[] args) + { + + Period period = Period.ofDays(2); + System.out.println("period = " + period); + + LocalDate localDate = LocalDate.now(); + System.out.println("localDate = " + localDate); + + /* + * Parameters: + * + * temporal - the temporal object to adjust, not null + * + * Returns: + * + * an object of the same type with the adjustment made, not + * null + */ + Temporal temporal = period.addTo(localDate); + System.out.println("temporal = "+temporal); + } + +} diff --git a/BasicJava_2018/PeriodDemo_between/Output.txt b/BasicJava_2018/PeriodDemo_between/Output.txt new file mode 100644 index 000000000..4b576c45b --- /dev/null +++ b/BasicJava_2018/PeriodDemo_between/Output.txt @@ -0,0 +1,3 @@ +startDate = 2010-01-21 +endDate = 2025-01-21 +period = P15Y diff --git a/BasicJava_2018/PeriodDemo_between/PeriodDemo/.classpath b/BasicJava_2018/PeriodDemo_between/PeriodDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/PeriodDemo_between/PeriodDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/PeriodDemo_between/PeriodDemo/.project b/BasicJava_2018/PeriodDemo_between/PeriodDemo/.project new file mode 100644 index 000000000..1459e07e5 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_between/PeriodDemo/.project @@ -0,0 +1,17 @@ + + + PeriodDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/PeriodDemo_between/PeriodDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/PeriodDemo_between/PeriodDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_between/PeriodDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/PeriodDemo_between/PeriodDemo/bin/PeriodDemo.class b/BasicJava_2018/PeriodDemo_between/PeriodDemo/bin/PeriodDemo.class new file mode 100644 index 000000000..c7ab110e4 Binary files /dev/null and b/BasicJava_2018/PeriodDemo_between/PeriodDemo/bin/PeriodDemo.class differ diff --git a/BasicJava_2018/PeriodDemo_between/PeriodDemo/src/PeriodDemo.java b/BasicJava_2018/PeriodDemo_between/PeriodDemo/src/PeriodDemo.java new file mode 100644 index 000000000..70bbe56d3 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_between/PeriodDemo/src/PeriodDemo.java @@ -0,0 +1,31 @@ +import java.time.LocalDate; +import java.time.Month; +import java.time.Period; + +public class PeriodDemo +{ + + public static void main(String[] args) + { + + LocalDate startDate = LocalDate.of(2010, Month.JANUARY, 21); + System.out.println("startDate = " + startDate); + + LocalDate endDate = LocalDate.of(2025, Month.JANUARY, 21); + System.out.println("endDate = " + endDate); + + /* + * Parameters: + * + * startDateInclusive - the start date, inclusive, not null + * endDateExclusive - the end date, exclusive, not null + * + * Returns: + * + * the period between this date and the end date, not null + */ + Period period = Period.between(startDate, endDate); + System.out.println("period = " + period); + } + +} diff --git a/BasicJava_2018/PeriodDemo_equals/Output.txt b/BasicJava_2018/PeriodDemo_equals/Output.txt new file mode 100644 index 000000000..9fc455590 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_equals/Output.txt @@ -0,0 +1,3 @@ +period1 = P12D +period2 = P12D +isEqual = true diff --git a/BasicJava_2018/PeriodDemo_equals/PeriodDemo/.classpath b/BasicJava_2018/PeriodDemo_equals/PeriodDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/PeriodDemo_equals/PeriodDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/PeriodDemo_equals/PeriodDemo/.project b/BasicJava_2018/PeriodDemo_equals/PeriodDemo/.project new file mode 100644 index 000000000..1459e07e5 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_equals/PeriodDemo/.project @@ -0,0 +1,17 @@ + + + PeriodDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/PeriodDemo_equals/PeriodDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/PeriodDemo_equals/PeriodDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_equals/PeriodDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/PeriodDemo_equals/PeriodDemo/bin/PeriodDemo.class b/BasicJava_2018/PeriodDemo_equals/PeriodDemo/bin/PeriodDemo.class new file mode 100644 index 000000000..d31170475 Binary files /dev/null and b/BasicJava_2018/PeriodDemo_equals/PeriodDemo/bin/PeriodDemo.class differ diff --git a/BasicJava_2018/PeriodDemo_equals/PeriodDemo/src/PeriodDemo.java b/BasicJava_2018/PeriodDemo_equals/PeriodDemo/src/PeriodDemo.java new file mode 100644 index 000000000..05b3fc486 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_equals/PeriodDemo/src/PeriodDemo.java @@ -0,0 +1,28 @@ +import java.time.Period; + +public class PeriodDemo +{ + + public static void main(String[] args) + { + + Period period1 = Period.ofDays(12); + System.out.println("period1 = " + period1); + + Period period2 = Period.ofDays(12); + System.out.println("period2 = " + period2); + /* + * Parameters: + * + * obj - the object to check, null returns false + * + * Returns: + * + * true if this is equal to the other period + */ + boolean isEqual = period1.equals(period2); + System.out.println("isEqual = " + isEqual); + + } + +} diff --git a/BasicJava_2018/PeriodDemo_from/Output.txt b/BasicJava_2018/PeriodDemo_from/Output.txt new file mode 100644 index 000000000..90b9d28c7 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_from/Output.txt @@ -0,0 +1 @@ +P12M diff --git a/BasicJava_2018/PeriodDemo_from/PeriodDemo/.classpath b/BasicJava_2018/PeriodDemo_from/PeriodDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/PeriodDemo_from/PeriodDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/PeriodDemo_from/PeriodDemo/.project b/BasicJava_2018/PeriodDemo_from/PeriodDemo/.project new file mode 100644 index 000000000..1459e07e5 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_from/PeriodDemo/.project @@ -0,0 +1,17 @@ + + + PeriodDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/PeriodDemo_from/PeriodDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/PeriodDemo_from/PeriodDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_from/PeriodDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/PeriodDemo_from/PeriodDemo/bin/PeriodDemo.class b/BasicJava_2018/PeriodDemo_from/PeriodDemo/bin/PeriodDemo.class new file mode 100644 index 000000000..ce58205f8 Binary files /dev/null and b/BasicJava_2018/PeriodDemo_from/PeriodDemo/bin/PeriodDemo.class differ diff --git a/BasicJava_2018/PeriodDemo_from/PeriodDemo/src/PeriodDemo.java b/BasicJava_2018/PeriodDemo_from/PeriodDemo/src/PeriodDemo.java new file mode 100644 index 000000000..80c9c7ebd --- /dev/null +++ b/BasicJava_2018/PeriodDemo_from/PeriodDemo/src/PeriodDemo.java @@ -0,0 +1,29 @@ +import java.time.Period; +import java.time.temporal.TemporalAmount; + +public class PeriodDemo +{ + + public static void main(String[] args) + { + + TemporalAmount temporalAmount = Period.ofMonths(12); + + /* + * Obtains an instance of Period from a temporal amount. + * + * Parameters: + * + * amount - the temporal amount to convert, not null + * + * Returns: + * + * the equivalent period, not null + */ + Period period = Period.from(temporalAmount); + + System.out.println(period); + + } + +} diff --git a/BasicJava_2018/PeriodDemo_getChronology/Output.txt b/BasicJava_2018/PeriodDemo_getChronology/Output.txt new file mode 100644 index 000000000..a647daad5 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_getChronology/Output.txt @@ -0,0 +1 @@ +ISO diff --git a/BasicJava_2018/PeriodDemo_getChronology/PeriodDemo/.classpath b/BasicJava_2018/PeriodDemo_getChronology/PeriodDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/PeriodDemo_getChronology/PeriodDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/PeriodDemo_getChronology/PeriodDemo/.project b/BasicJava_2018/PeriodDemo_getChronology/PeriodDemo/.project new file mode 100644 index 000000000..1459e07e5 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_getChronology/PeriodDemo/.project @@ -0,0 +1,17 @@ + + + PeriodDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/PeriodDemo_getChronology/PeriodDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/PeriodDemo_getChronology/PeriodDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_getChronology/PeriodDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/PeriodDemo_getChronology/PeriodDemo/bin/PeriodDemo.class b/BasicJava_2018/PeriodDemo_getChronology/PeriodDemo/bin/PeriodDemo.class new file mode 100644 index 000000000..f4d289704 Binary files /dev/null and b/BasicJava_2018/PeriodDemo_getChronology/PeriodDemo/bin/PeriodDemo.class differ diff --git a/BasicJava_2018/PeriodDemo_getChronology/PeriodDemo/src/PeriodDemo.java b/BasicJava_2018/PeriodDemo_getChronology/PeriodDemo/src/PeriodDemo.java new file mode 100644 index 000000000..c5d615fb3 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_getChronology/PeriodDemo/src/PeriodDemo.java @@ -0,0 +1,21 @@ +import java.time.Period; +import java.time.chrono.IsoChronology; + +public class PeriodDemo +{ + + public static void main(String[] args) + { + + Period period = Period.ofMonths(12); + /* + * Returns: + * + * the ISO chronology, not null + */ + IsoChronology isoChronology = period.getChronology(); + System.out.println(isoChronology.getId()); + + } + +} diff --git a/BasicJava_2018/PeriodDemo_get_unit/Output.txt b/BasicJava_2018/PeriodDemo_get_unit/Output.txt new file mode 100644 index 000000000..c6f56448f --- /dev/null +++ b/BasicJava_2018/PeriodDemo_get_unit/Output.txt @@ -0,0 +1,2 @@ +period = P12M +monthValue = 12 diff --git a/BasicJava_2018/PeriodDemo_get_unit/PeriodDemo/.classpath b/BasicJava_2018/PeriodDemo_get_unit/PeriodDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/PeriodDemo_get_unit/PeriodDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/PeriodDemo_get_unit/PeriodDemo/.project b/BasicJava_2018/PeriodDemo_get_unit/PeriodDemo/.project new file mode 100644 index 000000000..1459e07e5 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_get_unit/PeriodDemo/.project @@ -0,0 +1,17 @@ + + + PeriodDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/PeriodDemo_get_unit/PeriodDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/PeriodDemo_get_unit/PeriodDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_get_unit/PeriodDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/PeriodDemo_get_unit/PeriodDemo/bin/PeriodDemo.class b/BasicJava_2018/PeriodDemo_get_unit/PeriodDemo/bin/PeriodDemo.class new file mode 100644 index 000000000..954cc5b2b Binary files /dev/null and b/BasicJava_2018/PeriodDemo_get_unit/PeriodDemo/bin/PeriodDemo.class differ diff --git a/BasicJava_2018/PeriodDemo_get_unit/PeriodDemo/src/PeriodDemo.java b/BasicJava_2018/PeriodDemo_get_unit/PeriodDemo/src/PeriodDemo.java new file mode 100644 index 000000000..fe611c656 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_get_unit/PeriodDemo/src/PeriodDemo.java @@ -0,0 +1,28 @@ +import java.time.Period; +import java.time.temporal.ChronoUnit; + +public class PeriodDemo +{ + + public static void main(String[] args) + { + + Period period = Period.ofMonths(12); + System.out.println("period = "+period); + + /* + * Parameters: + * + * unit - the TemporalUnit for which to return the value + * + * Returns: + * + * the long value of the unit + */ + long monthValue = period.get(ChronoUnit.MONTHS); + + System.out.println("monthValue = "+monthValue); + + } + +} diff --git a/BasicJava_2018/PeriodDemo_intro/PeriodDemo/.classpath b/BasicJava_2018/PeriodDemo_intro/PeriodDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/PeriodDemo_intro/PeriodDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/PeriodDemo_intro/PeriodDemo/.project b/BasicJava_2018/PeriodDemo_intro/PeriodDemo/.project new file mode 100644 index 000000000..1459e07e5 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_intro/PeriodDemo/.project @@ -0,0 +1,17 @@ + + + PeriodDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/PeriodDemo_intro/PeriodDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/PeriodDemo_intro/PeriodDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_intro/PeriodDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/PeriodDemo_intro/PeriodDemo/bin/PeriodDemo1.class b/BasicJava_2018/PeriodDemo_intro/PeriodDemo/bin/PeriodDemo1.class new file mode 100644 index 000000000..c13e128a1 Binary files /dev/null and b/BasicJava_2018/PeriodDemo_intro/PeriodDemo/bin/PeriodDemo1.class differ diff --git a/BasicJava_2018/PeriodDemo_intro/PeriodDemo/bin/PeriodDemo2.class b/BasicJava_2018/PeriodDemo_intro/PeriodDemo/bin/PeriodDemo2.class new file mode 100644 index 000000000..4720f6364 Binary files /dev/null and b/BasicJava_2018/PeriodDemo_intro/PeriodDemo/bin/PeriodDemo2.class differ diff --git a/BasicJava_2018/PeriodDemo_intro/PeriodDemo/src/PeriodDemo1.java b/BasicJava_2018/PeriodDemo_intro/PeriodDemo/src/PeriodDemo1.java new file mode 100644 index 000000000..5da17672d --- /dev/null +++ b/BasicJava_2018/PeriodDemo_intro/PeriodDemo/src/PeriodDemo1.java @@ -0,0 +1,42 @@ +import java.time.Period; + +public class PeriodDemo1 +{ + + public static void main(String[] args) + { + /* + * Parameters: + * + * years - the amount of years, may be negative + * + * months - the amount of months, may be negative + * + * days - the amount of days, may be negative + * + * Returns: + * + * the period of years, months and days, not null + */ + Period period = Period.of(2017, 02, 16); + System.out.println("period = " + period); + + /* + * Returns: the amount of years of this period, may be + * negative + */ + System.out.println("Years = " + period.getYears()); + + /* + * Returns: the amount of months of this period, may be + * negative + */ + System.out.println("Months = " + period.getMonths()); + + /* + * Returns: the amount of days of this period, may be negative + */ + System.out.println("Days = " + period.getDays()); + } + +} diff --git a/BasicJava_2018/PeriodDemo_intro/PeriodDemo/src/PeriodDemo2.java b/BasicJava_2018/PeriodDemo_intro/PeriodDemo/src/PeriodDemo2.java new file mode 100644 index 000000000..1eda5289f --- /dev/null +++ b/BasicJava_2018/PeriodDemo_intro/PeriodDemo/src/PeriodDemo2.java @@ -0,0 +1,15 @@ +import java.time.Period; + +public class PeriodDemo2 +{ + public static void main(String[] args) + { + /* + * A constant for a period of zero. + */ + Period period = Period.ZERO; + + System.out.println("period = "+period); + } + +} diff --git a/BasicJava_2018/PeriodDemo_intro/PeriodDemo1_Output.txt b/BasicJava_2018/PeriodDemo_intro/PeriodDemo1_Output.txt new file mode 100644 index 000000000..0273b5c38 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_intro/PeriodDemo1_Output.txt @@ -0,0 +1,4 @@ +period = P2017Y2M16D +Years = 2017 +Months = 2 +Days = 16 diff --git a/BasicJava_2018/PeriodDemo_intro/PeriodDemo2_Output.txt b/BasicJava_2018/PeriodDemo_intro/PeriodDemo2_Output.txt new file mode 100644 index 000000000..6809329d2 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_intro/PeriodDemo2_Output.txt @@ -0,0 +1 @@ +period = P0D diff --git a/BasicJava_2018/PeriodDemo_isNegative_zero/Output.txt b/BasicJava_2018/PeriodDemo_isNegative_zero/Output.txt new file mode 100644 index 000000000..71c10f212 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_isNegative_zero/Output.txt @@ -0,0 +1,3 @@ +period = P12M +isNegative = false +isZero = false diff --git a/BasicJava_2018/PeriodDemo_isNegative_zero/PeriodDemo/.classpath b/BasicJava_2018/PeriodDemo_isNegative_zero/PeriodDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/PeriodDemo_isNegative_zero/PeriodDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/PeriodDemo_isNegative_zero/PeriodDemo/.project b/BasicJava_2018/PeriodDemo_isNegative_zero/PeriodDemo/.project new file mode 100644 index 000000000..1459e07e5 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_isNegative_zero/PeriodDemo/.project @@ -0,0 +1,17 @@ + + + PeriodDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/PeriodDemo_isNegative_zero/PeriodDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/PeriodDemo_isNegative_zero/PeriodDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_isNegative_zero/PeriodDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/PeriodDemo_isNegative_zero/PeriodDemo/bin/PeriodDemo.class b/BasicJava_2018/PeriodDemo_isNegative_zero/PeriodDemo/bin/PeriodDemo.class new file mode 100644 index 000000000..67a3cc154 Binary files /dev/null and b/BasicJava_2018/PeriodDemo_isNegative_zero/PeriodDemo/bin/PeriodDemo.class differ diff --git a/BasicJava_2018/PeriodDemo_isNegative_zero/PeriodDemo/src/PeriodDemo.java b/BasicJava_2018/PeriodDemo_isNegative_zero/PeriodDemo/src/PeriodDemo.java new file mode 100644 index 000000000..6d279b649 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_isNegative_zero/PeriodDemo/src/PeriodDemo.java @@ -0,0 +1,33 @@ +import java.time.Period; + +public class PeriodDemo +{ + + public static void main(String[] args) + { + + Period period = Period.ofMonths(12); + System.out.println("period = "+period); + + /* + * Returns: + * + * true if any unit of this period is negative + */ + boolean isNegative = period.isNegative(); + System.out.println("isNegative = "+isNegative); + + + /* + * Checks if all three units of this period are zero. + * + * A zero period has the value zero for the years, months and + * days units + * + */ + boolean isZero = period.isZero(); + System.out.println("isZero = "+isZero); + + } + +} diff --git a/BasicJava_2018/PeriodDemo_minus/PeriodDemo/.classpath b/BasicJava_2018/PeriodDemo_minus/PeriodDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/PeriodDemo_minus/PeriodDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/PeriodDemo_minus/PeriodDemo/.project b/BasicJava_2018/PeriodDemo_minus/PeriodDemo/.project new file mode 100644 index 000000000..1459e07e5 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_minus/PeriodDemo/.project @@ -0,0 +1,17 @@ + + + PeriodDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/PeriodDemo_minus/PeriodDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/PeriodDemo_minus/PeriodDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_minus/PeriodDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/PeriodDemo_minus/PeriodDemo/bin/PeriodDemo1.class b/BasicJava_2018/PeriodDemo_minus/PeriodDemo/bin/PeriodDemo1.class new file mode 100644 index 000000000..99620d839 Binary files /dev/null and b/BasicJava_2018/PeriodDemo_minus/PeriodDemo/bin/PeriodDemo1.class differ diff --git a/BasicJava_2018/PeriodDemo_minus/PeriodDemo/bin/PeriodDemo2.class b/BasicJava_2018/PeriodDemo_minus/PeriodDemo/bin/PeriodDemo2.class new file mode 100644 index 000000000..c56df9588 Binary files /dev/null and b/BasicJava_2018/PeriodDemo_minus/PeriodDemo/bin/PeriodDemo2.class differ diff --git a/BasicJava_2018/PeriodDemo_minus/PeriodDemo/src/PeriodDemo1.java b/BasicJava_2018/PeriodDemo_minus/PeriodDemo/src/PeriodDemo1.java new file mode 100644 index 000000000..781c1448d --- /dev/null +++ b/BasicJava_2018/PeriodDemo_minus/PeriodDemo/src/PeriodDemo1.java @@ -0,0 +1,45 @@ +import java.time.Period; + +public class PeriodDemo1 +{ + + public static void main(String[] args) + { + + Period periodOfDays = Period.ofDays(12); + System.out.println("Before Minus, periodOfDays = " + periodOfDays); + + /* + * Parameters: + * + * daysToSubtract - the months to subtract, positive or + * negative + * + * Returns: + * + * a Period based on this period with the specified days + * subtracted, not null + */ + periodOfDays = periodOfDays.minusDays(5); + System.out.println("After Minus, periodOfDays = " + periodOfDays); + + + Period periodOfMonths = Period.ofMonths(12); + System.out.println("Before Minus, periodOfMonths = " + periodOfMonths); + + /* + * Parameters: + * + * monthsToSubtract - the years to subtract, positive or + * negative + * + * Returns: + * + * a Period based on this period with the specified months + * subtracted, not null + */ + periodOfMonths = periodOfMonths.minusMonths(5); + System.out.println("After Minus, periodOfMonths = " + periodOfMonths); + } + +} diff --git a/BasicJava_2018/PeriodDemo_minus/PeriodDemo/src/PeriodDemo2.java b/BasicJava_2018/PeriodDemo_minus/PeriodDemo/src/PeriodDemo2.java new file mode 100644 index 000000000..b835fd5f3 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_minus/PeriodDemo/src/PeriodDemo2.java @@ -0,0 +1,42 @@ +import java.time.Period; + +public class PeriodDemo2 +{ + public static void main(String[] args) + { + Period periodOfYears = Period.ofYears(2017); + System.out.println("Before Minus, periodOfYears = " + periodOfYears); + + /* + * Parameters: + * + * yearsToSubtract - the years to subtract, positive or + * negative + * + * Returns: + * + * a Period based on this period with the specified years + * subtracted, not null + */ + periodOfYears = periodOfYears.minusYears(13); + System.out.println("After Minus, periodOfYears = " + periodOfYears); + + + Period periodOfMonths = Period.ofMonths(12); + System.out.println("Before Minus, periodOfMonths = " + periodOfMonths); + + /* + * Parameters: + * + * amountToSubtract - the amount to subtract, not null + * + * Returns: + * + * a Period based on this period with the requested period + * subtracted, not null + */ + periodOfMonths = periodOfMonths.minus(Period.ofMonths(10)); + System.out.println("After Minus, periodOfMonths = " + periodOfMonths); + } + +} diff --git a/BasicJava_2018/PeriodDemo_minus/PeriodDemo1_Output.txt b/BasicJava_2018/PeriodDemo_minus/PeriodDemo1_Output.txt new file mode 100644 index 000000000..3d8c1deec --- /dev/null +++ b/BasicJava_2018/PeriodDemo_minus/PeriodDemo1_Output.txt @@ -0,0 +1,4 @@ +Before Minus, periodOfDays = P12D +After Minus, periodOfDays = P7D +Before Minus, periodOfMonths = P12M +After Minus, periodOfMonths = P7M diff --git a/BasicJava_2018/PeriodDemo_minus/PeriodDemo2_Output.txt b/BasicJava_2018/PeriodDemo_minus/PeriodDemo2_Output.txt new file mode 100644 index 000000000..bf6925229 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_minus/PeriodDemo2_Output.txt @@ -0,0 +1,4 @@ +Before Minus, periodOfYears = P2017Y +After Minus, periodOfYears = P2004Y +Before Minus, periodOfMonths = P12M +After Minus, periodOfMonths = P2M diff --git a/BasicJava_2018/PeriodDemo_multipliedBy/Output.txt b/BasicJava_2018/PeriodDemo_multipliedBy/Output.txt new file mode 100644 index 000000000..9709621e6 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_multipliedBy/Output.txt @@ -0,0 +1,2 @@ +period1 = P12D +period2 = P120D diff --git a/BasicJava_2018/PeriodDemo_multipliedBy/PeriodDemo/.classpath b/BasicJava_2018/PeriodDemo_multipliedBy/PeriodDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/PeriodDemo_multipliedBy/PeriodDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/PeriodDemo_multipliedBy/PeriodDemo/.project b/BasicJava_2018/PeriodDemo_multipliedBy/PeriodDemo/.project new file mode 100644 index 000000000..1459e07e5 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_multipliedBy/PeriodDemo/.project @@ -0,0 +1,17 @@ + + + PeriodDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/PeriodDemo_multipliedBy/PeriodDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/PeriodDemo_multipliedBy/PeriodDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_multipliedBy/PeriodDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/PeriodDemo_multipliedBy/PeriodDemo/bin/PeriodDemo.class b/BasicJava_2018/PeriodDemo_multipliedBy/PeriodDemo/bin/PeriodDemo.class new file mode 100644 index 000000000..9ee50e1bd Binary files /dev/null and b/BasicJava_2018/PeriodDemo_multipliedBy/PeriodDemo/bin/PeriodDemo.class differ diff --git a/BasicJava_2018/PeriodDemo_multipliedBy/PeriodDemo/src/PeriodDemo.java b/BasicJava_2018/PeriodDemo_multipliedBy/PeriodDemo/src/PeriodDemo.java new file mode 100644 index 000000000..1633dd7c5 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_multipliedBy/PeriodDemo/src/PeriodDemo.java @@ -0,0 +1,28 @@ +import java.time.Period; + +public class PeriodDemo +{ + + public static void main(String[] args) + { + + Period period1 = Period.ofDays(12); + System.out.println("period1 = "+period1); + + /* + * Parameters: + * + * scalar - the scalar to multiply by, not null + * + * Returns: + * + * a Period based on this period with the amounts multiplied + * by the scalar, not null + */ + + Period period2 = period1.multipliedBy(10); + System.out.println("period2 = "+period2); + + } + +} diff --git a/BasicJava_2018/PeriodDemo_negated/Output.txt b/BasicJava_2018/PeriodDemo_negated/Output.txt new file mode 100644 index 000000000..de2fa5ac2 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_negated/Output.txt @@ -0,0 +1,2 @@ +period1 = P12M +period2 = P-12M diff --git a/BasicJava_2018/PeriodDemo_negated/PeriodDemo/.classpath b/BasicJava_2018/PeriodDemo_negated/PeriodDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/PeriodDemo_negated/PeriodDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/PeriodDemo_negated/PeriodDemo/.project b/BasicJava_2018/PeriodDemo_negated/PeriodDemo/.project new file mode 100644 index 000000000..1459e07e5 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_negated/PeriodDemo/.project @@ -0,0 +1,17 @@ + + + PeriodDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/PeriodDemo_negated/PeriodDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/PeriodDemo_negated/PeriodDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_negated/PeriodDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/PeriodDemo_negated/PeriodDemo/bin/PeriodDemo.class b/BasicJava_2018/PeriodDemo_negated/PeriodDemo/bin/PeriodDemo.class new file mode 100644 index 000000000..c84a37093 Binary files /dev/null and b/BasicJava_2018/PeriodDemo_negated/PeriodDemo/bin/PeriodDemo.class differ diff --git a/BasicJava_2018/PeriodDemo_negated/PeriodDemo/src/PeriodDemo.java b/BasicJava_2018/PeriodDemo_negated/PeriodDemo/src/PeriodDemo.java new file mode 100644 index 000000000..2ac63bf32 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_negated/PeriodDemo/src/PeriodDemo.java @@ -0,0 +1,30 @@ +import java.time.Period; + +public class PeriodDemo +{ + + public static void main(String[] args) + { + + Period period1 = Period.ofMonths(12); + System.out.println("period1 = " + period1); + /* + * Returns a new instance with each amount in this period + * negated. + * + * This returns a period with each of the years, months and + * days units individually negated. For example, a period of + * "2 years, -3 months and 4 days" will be negated to + * "-2 years, 3 months and -4 days". + * + * Returns: + * + * a Period based on this period with the amounts negated, not + * null + */ + Period period2 = period1.negated(); + System.out.println("period2 = " + period2); + + } + +} diff --git a/BasicJava_2018/PeriodDemo_of_methods/Output.txt b/BasicJava_2018/PeriodDemo_of_methods/Output.txt new file mode 100644 index 000000000..bfbf64950 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_of_methods/Output.txt @@ -0,0 +1,4 @@ +periodOfDays = P12D +periodOfMonth = P12M +periodOfYears = P2017Y +periodWeekToDays = P14D diff --git a/BasicJava_2018/PeriodDemo_of_methods/PeriodDemo/.classpath b/BasicJava_2018/PeriodDemo_of_methods/PeriodDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/PeriodDemo_of_methods/PeriodDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/PeriodDemo_of_methods/PeriodDemo/.project b/BasicJava_2018/PeriodDemo_of_methods/PeriodDemo/.project new file mode 100644 index 000000000..1459e07e5 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_of_methods/PeriodDemo/.project @@ -0,0 +1,17 @@ + + + PeriodDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/PeriodDemo_of_methods/PeriodDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/PeriodDemo_of_methods/PeriodDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_of_methods/PeriodDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/PeriodDemo_of_methods/PeriodDemo/bin/PeriodDemo.class b/BasicJava_2018/PeriodDemo_of_methods/PeriodDemo/bin/PeriodDemo.class new file mode 100644 index 000000000..88c57b139 Binary files /dev/null and b/BasicJava_2018/PeriodDemo_of_methods/PeriodDemo/bin/PeriodDemo.class differ diff --git a/BasicJava_2018/PeriodDemo_of_methods/PeriodDemo/src/PeriodDemo.java b/BasicJava_2018/PeriodDemo_of_methods/PeriodDemo/src/PeriodDemo.java new file mode 100644 index 000000000..77a5f9d72 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_of_methods/PeriodDemo/src/PeriodDemo.java @@ -0,0 +1,59 @@ +import java.time.Period; + +public class PeriodDemo +{ + + public static void main(String[] args) + { + /* + * Parameters: + * + * days - the number of days, positive or negative + * + * Returns: + * + * the period of days, not null + */ + Period periodOfDays = Period.ofDays(12); + System.out.println("periodOfDays = " + periodOfDays); + + /* + * Parameters: + * + * months - the number of months, positive or negative + * + * Returns: + * + * the period of months, not null + */ + Period periodOfMonth = Period.ofMonths(12); + System.out.println("periodOfMonth = " + periodOfMonth); + + /* + * Parameters: + * + * years - the number of years, positive or negative + * + * Returns: + * + * the period of years, not null + */ + Period periodOfYears = Period.ofYears(2017); + System.out.println("periodOfYears = " + periodOfYears); + + /* + * Parameters: + * + * weeks - the number of weeks, positive or negative + * + * Returns: + * + * the period, with the input weeks converted to days, not + * null + */ + Period periodWeekToDays = Period.ofWeeks(2); + System.out.println("periodWeekToDays = " + periodWeekToDays); + + } + +} diff --git a/BasicJava_2018/PeriodDemo_parse/Output.txt b/BasicJava_2018/PeriodDemo_parse/Output.txt new file mode 100644 index 000000000..0bf605cb3 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_parse/Output.txt @@ -0,0 +1 @@ +period = P5D diff --git a/BasicJava_2018/PeriodDemo_parse/PeriodDemo/.classpath b/BasicJava_2018/PeriodDemo_parse/PeriodDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/PeriodDemo_parse/PeriodDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/PeriodDemo_parse/PeriodDemo/.project b/BasicJava_2018/PeriodDemo_parse/PeriodDemo/.project new file mode 100644 index 000000000..1459e07e5 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_parse/PeriodDemo/.project @@ -0,0 +1,17 @@ + + + PeriodDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/PeriodDemo_parse/PeriodDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/PeriodDemo_parse/PeriodDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_parse/PeriodDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/PeriodDemo_parse/PeriodDemo/bin/PeriodDemo.class b/BasicJava_2018/PeriodDemo_parse/PeriodDemo/bin/PeriodDemo.class new file mode 100644 index 000000000..0750d3f3f Binary files /dev/null and b/BasicJava_2018/PeriodDemo_parse/PeriodDemo/bin/PeriodDemo.class differ diff --git a/BasicJava_2018/PeriodDemo_parse/PeriodDemo/src/PeriodDemo.java b/BasicJava_2018/PeriodDemo_parse/PeriodDemo/src/PeriodDemo.java new file mode 100644 index 000000000..ec45c24d4 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_parse/PeriodDemo/src/PeriodDemo.java @@ -0,0 +1,35 @@ +import java.time.Period; + +public class PeriodDemo +{ + + public static void main(String[] args) + { + /* + * Parameters: + * + * text - the text to parse, not null + * + * Examples of valid input: + * + * "P2Y" -- Period.ofYears(2) + * "P3M" -- Period.ofMonths(3) + * "P4W" -- Period.ofWeeks(4) + * "P5D" -- Period.ofDays(5) + * "P2Y2M3D" -- Period.of(2, 2, 3) + * "P2Y2M3W4D" -- Period.of(2, 2, 25) + * "P-2Y2M" -- Period.of(-2, 2, 0) + * "-P2Y2M" -- Period.of(-2, -2, 0) + * + * Returns: + * + * the parsed period, not null + * + */ + Period period = Period.parse("P5D"); + + System.out.println("period = " + period); + + } + +} diff --git a/BasicJava_2018/PeriodDemo_plus/PeriodDemo/.classpath b/BasicJava_2018/PeriodDemo_plus/PeriodDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/PeriodDemo_plus/PeriodDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/PeriodDemo_plus/PeriodDemo/.project b/BasicJava_2018/PeriodDemo_plus/PeriodDemo/.project new file mode 100644 index 000000000..1459e07e5 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_plus/PeriodDemo/.project @@ -0,0 +1,17 @@ + + + PeriodDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/PeriodDemo_plus/PeriodDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/PeriodDemo_plus/PeriodDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_plus/PeriodDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/PeriodDemo_plus/PeriodDemo/bin/PeriodDemo1.class b/BasicJava_2018/PeriodDemo_plus/PeriodDemo/bin/PeriodDemo1.class new file mode 100644 index 000000000..ac1985749 Binary files /dev/null and b/BasicJava_2018/PeriodDemo_plus/PeriodDemo/bin/PeriodDemo1.class differ diff --git a/BasicJava_2018/PeriodDemo_plus/PeriodDemo/bin/PeriodDemo2.class b/BasicJava_2018/PeriodDemo_plus/PeriodDemo/bin/PeriodDemo2.class new file mode 100644 index 000000000..e180db1fb Binary files /dev/null and b/BasicJava_2018/PeriodDemo_plus/PeriodDemo/bin/PeriodDemo2.class differ diff --git a/BasicJava_2018/PeriodDemo_plus/PeriodDemo/src/PeriodDemo1.java b/BasicJava_2018/PeriodDemo_plus/PeriodDemo/src/PeriodDemo1.java new file mode 100644 index 000000000..1710da12a --- /dev/null +++ b/BasicJava_2018/PeriodDemo_plus/PeriodDemo/src/PeriodDemo1.java @@ -0,0 +1,42 @@ +import java.time.Period; + +public class PeriodDemo1 +{ + + public static void main(String[] args) + { + + Period periodOfDays = Period.ofDays(12); + System.out.println("Before Plus, periodOfDays = " + periodOfDays); + + /* + * Parameters: + * + * daysToAdd - the days to add, positive or negative + * + * Returns: + * + * a Period based on this period with the specified days + * added, not null + */ + periodOfDays = periodOfDays.plusDays(15); + System.out.println("After Plus, periodOfDays = " + periodOfDays); + + + Period periodOfMonths = Period.ofMonths(2); + System.out.println("Before Plus, periodOfMonths = " + periodOfMonths); + + /* + * Parameters: + * + * monthsToAdd - the months to add, positive or negative + * + * Returns: + * + * a Period based on this period with the specified months added, not null + */ + periodOfMonths = periodOfMonths.plusMonths(5); + System.out.println("After Plus, periodOfMonths = " + periodOfMonths); + } + +} diff --git a/BasicJava_2018/PeriodDemo_plus/PeriodDemo/src/PeriodDemo2.java b/BasicJava_2018/PeriodDemo_plus/PeriodDemo/src/PeriodDemo2.java new file mode 100644 index 000000000..233afa0de --- /dev/null +++ b/BasicJava_2018/PeriodDemo_plus/PeriodDemo/src/PeriodDemo2.java @@ -0,0 +1,41 @@ +import java.time.Period; + +public class PeriodDemo2 +{ + public static void main(String[] args) + { + Period periodOfYears = Period.ofYears(2017); + System.out.println("Before Plus, periodOfYears = " + periodOfYears); + + /* + * Parameters: + * + * yearsToAdd - the years to add, positive or negative + * + * Returns: + * + * a Period based on this period with the specified years + * added, not null + */ + periodOfYears = periodOfYears.plusYears(13); + System.out.println("After Plus, periodOfYears = " + periodOfYears); + + + Period periodOfMonths = Period.ofMonths(2); + System.out.println("Before Plus, periodOfMonths = " + periodOfMonths); + + /* + * Parameters: + * + * amountToAdd - the amount to add, not null + * + * Returns: + * + * a Period based on this period with the requested period + * added, not null + */ + periodOfMonths = periodOfMonths.plus(Period.ofMonths(10)); + System.out.println("After Plus, periodOfMonths = " + periodOfMonths); + } + +} diff --git a/BasicJava_2018/PeriodDemo_plus/PeriodDemo1_Output.txt b/BasicJava_2018/PeriodDemo_plus/PeriodDemo1_Output.txt new file mode 100644 index 000000000..e20372ea3 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_plus/PeriodDemo1_Output.txt @@ -0,0 +1,4 @@ +Before Plus, periodOfDays = P12D +After Plus, periodOfDays = P27D +Before Plus, periodOfMonths = P2M +After Plus, periodOfMonths = P7M diff --git a/BasicJava_2018/PeriodDemo_plus/PeriodDemo2_Output.txt b/BasicJava_2018/PeriodDemo_plus/PeriodDemo2_Output.txt new file mode 100644 index 000000000..575630b39 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_plus/PeriodDemo2_Output.txt @@ -0,0 +1,4 @@ +Before Plus, periodOfYears = P2017Y +After Plus, periodOfYears = P2030Y +Before Plus, periodOfMonths = P2M +After Plus, periodOfMonths = P12M diff --git a/BasicJava_2018/PeriodDemo_subtractFrom/Output.txt b/BasicJava_2018/PeriodDemo_subtractFrom/Output.txt new file mode 100644 index 000000000..d25e8ff89 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_subtractFrom/Output.txt @@ -0,0 +1,3 @@ +period = P2D +localDate = 2018-03-11 +temporal = 2018-03-09 diff --git a/BasicJava_2018/PeriodDemo_subtractFrom/PeriodDemo/.classpath b/BasicJava_2018/PeriodDemo_subtractFrom/PeriodDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/PeriodDemo_subtractFrom/PeriodDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/PeriodDemo_subtractFrom/PeriodDemo/.project b/BasicJava_2018/PeriodDemo_subtractFrom/PeriodDemo/.project new file mode 100644 index 000000000..1459e07e5 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_subtractFrom/PeriodDemo/.project @@ -0,0 +1,17 @@ + + + PeriodDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/PeriodDemo_subtractFrom/PeriodDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/PeriodDemo_subtractFrom/PeriodDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_subtractFrom/PeriodDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/PeriodDemo_subtractFrom/PeriodDemo/bin/PeriodDemo.class b/BasicJava_2018/PeriodDemo_subtractFrom/PeriodDemo/bin/PeriodDemo.class new file mode 100644 index 000000000..086ffd277 Binary files /dev/null and b/BasicJava_2018/PeriodDemo_subtractFrom/PeriodDemo/bin/PeriodDemo.class differ diff --git a/BasicJava_2018/PeriodDemo_subtractFrom/PeriodDemo/src/PeriodDemo.java b/BasicJava_2018/PeriodDemo_subtractFrom/PeriodDemo/src/PeriodDemo.java new file mode 100644 index 000000000..8fa8a6a10 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_subtractFrom/PeriodDemo/src/PeriodDemo.java @@ -0,0 +1,33 @@ +import java.time.LocalDate; +import java.time.Period; +import java.time.temporal.Temporal; + +public class PeriodDemo +{ + + public static void main(String[] args) + { + + Period period = Period.ofDays(2); + System.out.println("period = "+period); + + LocalDate localDate = LocalDate.now(); + System.out.println("localDate = "+localDate); + + /* + * Parameters: + * + * temporal - the temporal object to adjust, not null + * + * Returns: + * + * an object of the same type with the adjustment made, not + * null + */ + + Temporal temporal = period.subtractFrom(localDate); + System.out.println("temporal = "+temporal); + + } + +} diff --git a/BasicJava_2018/PeriodDemo_toTotalMonths/Output.txt b/BasicJava_2018/PeriodDemo_toTotalMonths/Output.txt new file mode 100644 index 000000000..d1e6de310 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_toTotalMonths/Output.txt @@ -0,0 +1,2 @@ +period = P11M +totalMonths = 11 diff --git a/BasicJava_2018/PeriodDemo_toTotalMonths/PeriodDemo/.classpath b/BasicJava_2018/PeriodDemo_toTotalMonths/PeriodDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/PeriodDemo_toTotalMonths/PeriodDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/PeriodDemo_toTotalMonths/PeriodDemo/.project b/BasicJava_2018/PeriodDemo_toTotalMonths/PeriodDemo/.project new file mode 100644 index 000000000..1459e07e5 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_toTotalMonths/PeriodDemo/.project @@ -0,0 +1,17 @@ + + + PeriodDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/PeriodDemo_toTotalMonths/PeriodDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/PeriodDemo_toTotalMonths/PeriodDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_toTotalMonths/PeriodDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/PeriodDemo_toTotalMonths/PeriodDemo/bin/PeriodDemo.class b/BasicJava_2018/PeriodDemo_toTotalMonths/PeriodDemo/bin/PeriodDemo.class new file mode 100644 index 000000000..b5f0a8ee8 Binary files /dev/null and b/BasicJava_2018/PeriodDemo_toTotalMonths/PeriodDemo/bin/PeriodDemo.class differ diff --git a/BasicJava_2018/PeriodDemo_toTotalMonths/PeriodDemo/src/PeriodDemo.java b/BasicJava_2018/PeriodDemo_toTotalMonths/PeriodDemo/src/PeriodDemo.java new file mode 100644 index 000000000..9fe31129d --- /dev/null +++ b/BasicJava_2018/PeriodDemo_toTotalMonths/PeriodDemo/src/PeriodDemo.java @@ -0,0 +1,21 @@ +import java.time.Period; + +public class PeriodDemo +{ + + public static void main(String[] args) + { + + Period period = Period.ofMonths(11); + System.out.println("period = " + period); + /* + * Returns: + * + * the total number of months in the period, may be negative + */ + long totalMonths = period.toTotalMonths(); + System.out.println("totalMonths = " + totalMonths); + + } + +} diff --git a/BasicJava_2018/PeriodDemo_with_methods/Output.txt b/BasicJava_2018/PeriodDemo_with_methods/Output.txt new file mode 100644 index 000000000..9730d5b16 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_with_methods/Output.txt @@ -0,0 +1,4 @@ +period1 = P12M +period2[withDays] = P12M20D +period3[withYears] = P2017Y12M20D +period4[withMonths]= P2017Y1M20D diff --git a/BasicJava_2018/PeriodDemo_with_methods/PeriodDemo/.classpath b/BasicJava_2018/PeriodDemo_with_methods/PeriodDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/PeriodDemo_with_methods/PeriodDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/PeriodDemo_with_methods/PeriodDemo/.project b/BasicJava_2018/PeriodDemo_with_methods/PeriodDemo/.project new file mode 100644 index 000000000..1459e07e5 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_with_methods/PeriodDemo/.project @@ -0,0 +1,17 @@ + + + PeriodDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/PeriodDemo_with_methods/PeriodDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/PeriodDemo_with_methods/PeriodDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/PeriodDemo_with_methods/PeriodDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/PeriodDemo_with_methods/PeriodDemo/bin/PeriodDemo.class b/BasicJava_2018/PeriodDemo_with_methods/PeriodDemo/bin/PeriodDemo.class new file mode 100644 index 000000000..6626ddf0b Binary files /dev/null and b/BasicJava_2018/PeriodDemo_with_methods/PeriodDemo/bin/PeriodDemo.class differ diff --git a/BasicJava_2018/PeriodDemo_with_methods/PeriodDemo/bin/PeriodDemo1.class b/BasicJava_2018/PeriodDemo_with_methods/PeriodDemo/bin/PeriodDemo1.class new file mode 100644 index 000000000..0e2b9a8ef Binary files /dev/null and b/BasicJava_2018/PeriodDemo_with_methods/PeriodDemo/bin/PeriodDemo1.class differ diff --git a/BasicJava_2018/PeriodDemo_with_methods/PeriodDemo/bin/PeriodDemo2.class b/BasicJava_2018/PeriodDemo_with_methods/PeriodDemo/bin/PeriodDemo2.class new file mode 100644 index 000000000..fcd1433f7 Binary files /dev/null and b/BasicJava_2018/PeriodDemo_with_methods/PeriodDemo/bin/PeriodDemo2.class differ diff --git a/BasicJava_2018/PeriodDemo_with_methods/PeriodDemo/src/PeriodDemo.java b/BasicJava_2018/PeriodDemo_with_methods/PeriodDemo/src/PeriodDemo.java new file mode 100644 index 000000000..e92a9bd3c --- /dev/null +++ b/BasicJava_2018/PeriodDemo_with_methods/PeriodDemo/src/PeriodDemo.java @@ -0,0 +1,54 @@ +import java.time.Period; + +public class PeriodDemo +{ + + public static void main(String[] args) + { + + Period period1 = Period.ofMonths(12); + System.out.println("period1 = " + period1); + + /* + * Parameters: + * + * days - the days to represent, may be negative + * + * Returns: + * + * a Period based on this period with the requested days, not + * null + */ + + Period period2 = period1.withDays(20); + System.out.println("period2[withDays] = " + period2); + + /* + * Parameters: + * + * years - the years to represent, may be negative + * + * Returns: + * + * a Period based on this period with the requested years, not + * null + */ + Period period3 = period2.withYears(2017); + System.out.println("period3[withYears] = " + period3); + + /* + * Parameters: + * + * months - the months to represent, may be negative + * + * Returns: + * + * a Period based on this period with the requested months, + * not null + */ + Period period4 = period3.withMonths(1); + System.out.println("period4[withMonths]= " + period4); + + } + +} diff --git a/BasicJava_2018/SqlDateDemo_Intro/Output.txt b/BasicJava_2018/SqlDateDemo_Intro/Output.txt new file mode 100644 index 000000000..f2f83217a --- /dev/null +++ b/BasicJava_2018/SqlDateDemo_Intro/Output.txt @@ -0,0 +1 @@ +2018-10-12 diff --git a/BasicJava_2018/SqlDateDemo_Intro/SqlDateDemo/.classpath b/BasicJava_2018/SqlDateDemo_Intro/SqlDateDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/SqlDateDemo_Intro/SqlDateDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/SqlDateDemo_Intro/SqlDateDemo/.project b/BasicJava_2018/SqlDateDemo_Intro/SqlDateDemo/.project new file mode 100644 index 000000000..f3328a3e1 --- /dev/null +++ b/BasicJava_2018/SqlDateDemo_Intro/SqlDateDemo/.project @@ -0,0 +1,17 @@ + + + SqlDateDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/SqlDateDemo_Intro/SqlDateDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/SqlDateDemo_Intro/SqlDateDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/SqlDateDemo_Intro/SqlDateDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/SqlDateDemo_Intro/SqlDateDemo/bin/SqlDateDemo.class b/BasicJava_2018/SqlDateDemo_Intro/SqlDateDemo/bin/SqlDateDemo.class new file mode 100644 index 000000000..a5ea2e57e Binary files /dev/null and b/BasicJava_2018/SqlDateDemo_Intro/SqlDateDemo/bin/SqlDateDemo.class differ diff --git a/BasicJava_2018/SqlDateDemo_Intro/SqlDateDemo/src/SqlDateDemo.java b/BasicJava_2018/SqlDateDemo_Intro/SqlDateDemo/src/SqlDateDemo.java new file mode 100644 index 000000000..af75df796 --- /dev/null +++ b/BasicJava_2018/SqlDateDemo_Intro/SqlDateDemo/src/SqlDateDemo.java @@ -0,0 +1,12 @@ +import java.sql.Date; + +public class SqlDateDemo +{ + public static void main(String[] args) + { + long millis = System.currentTimeMillis(); + Date date = new Date(millis); + System.out.println(date); + } + +} diff --git a/BasicJava_2018/SqlDateDemo_toInstant/Output.txt b/BasicJava_2018/SqlDateDemo_toInstant/Output.txt new file mode 100644 index 000000000..64cd3ecdd --- /dev/null +++ b/BasicJava_2018/SqlDateDemo_toInstant/Output.txt @@ -0,0 +1,4 @@ +2018-10-15 +Exception in thread "main" java.lang.UnsupportedOperationException + at java.sql.Date.toInstant(Date.java:304) + at SqlDateDemo.main(SqlDateDemo.java:17) diff --git a/BasicJava_2018/SqlDateDemo_toInstant/SqlDateDemo/.classpath b/BasicJava_2018/SqlDateDemo_toInstant/SqlDateDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/SqlDateDemo_toInstant/SqlDateDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/SqlDateDemo_toInstant/SqlDateDemo/.project b/BasicJava_2018/SqlDateDemo_toInstant/SqlDateDemo/.project new file mode 100644 index 000000000..f3328a3e1 --- /dev/null +++ b/BasicJava_2018/SqlDateDemo_toInstant/SqlDateDemo/.project @@ -0,0 +1,17 @@ + + + SqlDateDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/SqlDateDemo_toInstant/SqlDateDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/SqlDateDemo_toInstant/SqlDateDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/SqlDateDemo_toInstant/SqlDateDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/SqlDateDemo_toInstant/SqlDateDemo/bin/SqlDateDemo.class b/BasicJava_2018/SqlDateDemo_toInstant/SqlDateDemo/bin/SqlDateDemo.class new file mode 100644 index 000000000..49db1750a Binary files /dev/null and b/BasicJava_2018/SqlDateDemo_toInstant/SqlDateDemo/bin/SqlDateDemo.class differ diff --git a/BasicJava_2018/SqlDateDemo_toInstant/SqlDateDemo/src/SqlDateDemo.java b/BasicJava_2018/SqlDateDemo_toInstant/SqlDateDemo/src/SqlDateDemo.java new file mode 100644 index 000000000..e324e1012 --- /dev/null +++ b/BasicJava_2018/SqlDateDemo_toInstant/SqlDateDemo/src/SqlDateDemo.java @@ -0,0 +1,21 @@ +import java.sql.Date; +import java.time.Instant; + +public class SqlDateDemo +{ + public static void main(String[] args) + { + long millis = System.currentTimeMillis(); + java.sql.Date date = new Date(millis); + System.out.println(date); + + /* + * This method always throws an UnsupportedOperationException + * and should not be used because SQL Date values do not have + * a time component. + */ + Instant instant = date.toInstant(); + System.out.println(instant); + } + +} diff --git a/BasicJava_2018/SqlDateDemo_toLocalDate/Output.txt b/BasicJava_2018/SqlDateDemo_toLocalDate/Output.txt new file mode 100644 index 000000000..321eb07b5 --- /dev/null +++ b/BasicJava_2018/SqlDateDemo_toLocalDate/Output.txt @@ -0,0 +1,2 @@ +2018-10-22 +2018-10-22 diff --git a/BasicJava_2018/SqlDateDemo_toLocalDate/SqlDateDemo/.classpath b/BasicJava_2018/SqlDateDemo_toLocalDate/SqlDateDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/SqlDateDemo_toLocalDate/SqlDateDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/SqlDateDemo_toLocalDate/SqlDateDemo/.project b/BasicJava_2018/SqlDateDemo_toLocalDate/SqlDateDemo/.project new file mode 100644 index 000000000..f3328a3e1 --- /dev/null +++ b/BasicJava_2018/SqlDateDemo_toLocalDate/SqlDateDemo/.project @@ -0,0 +1,17 @@ + + + SqlDateDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/SqlDateDemo_toLocalDate/SqlDateDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/SqlDateDemo_toLocalDate/SqlDateDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/SqlDateDemo_toLocalDate/SqlDateDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/SqlDateDemo_toLocalDate/SqlDateDemo/bin/SqlDateDemo.class b/BasicJava_2018/SqlDateDemo_toLocalDate/SqlDateDemo/bin/SqlDateDemo.class new file mode 100644 index 000000000..ec93e0692 Binary files /dev/null and b/BasicJava_2018/SqlDateDemo_toLocalDate/SqlDateDemo/bin/SqlDateDemo.class differ diff --git a/BasicJava_2018/SqlDateDemo_toLocalDate/SqlDateDemo/src/SqlDateDemo.java b/BasicJava_2018/SqlDateDemo_toLocalDate/SqlDateDemo/src/SqlDateDemo.java new file mode 100644 index 000000000..e0572eacb --- /dev/null +++ b/BasicJava_2018/SqlDateDemo_toLocalDate/SqlDateDemo/src/SqlDateDemo.java @@ -0,0 +1,21 @@ +import java.sql.Date; +import java.time.LocalDate; + +public class SqlDateDemo +{ + public static void main(String[] args) + { + long millis = System.currentTimeMillis(); + java.sql.Date date = new Date(millis); + System.out.println(date); + + /* + * Returns: + * + * a LocalDate object representing the same date value + */ + LocalDate localDate = date.toLocalDate(); + System.out.println(localDate); + } + +} diff --git a/BasicJava_2018/SqlDateDemo_valueOf/Output.txt b/BasicJava_2018/SqlDateDemo_valueOf/Output.txt new file mode 100644 index 000000000..184552b99 --- /dev/null +++ b/BasicJava_2018/SqlDateDemo_valueOf/Output.txt @@ -0,0 +1 @@ +2018-05-25 diff --git a/BasicJava_2018/SqlDateDemo_valueOf/SqlDateDemo/.classpath b/BasicJava_2018/SqlDateDemo_valueOf/SqlDateDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/SqlDateDemo_valueOf/SqlDateDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/SqlDateDemo_valueOf/SqlDateDemo/.project b/BasicJava_2018/SqlDateDemo_valueOf/SqlDateDemo/.project new file mode 100644 index 000000000..f3328a3e1 --- /dev/null +++ b/BasicJava_2018/SqlDateDemo_valueOf/SqlDateDemo/.project @@ -0,0 +1,17 @@ + + + SqlDateDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/SqlDateDemo_valueOf/SqlDateDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/SqlDateDemo_valueOf/SqlDateDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/SqlDateDemo_valueOf/SqlDateDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/SqlDateDemo_valueOf/SqlDateDemo/bin/SqlDateDemo.class b/BasicJava_2018/SqlDateDemo_valueOf/SqlDateDemo/bin/SqlDateDemo.class new file mode 100644 index 000000000..01ba7a48b Binary files /dev/null and b/BasicJava_2018/SqlDateDemo_valueOf/SqlDateDemo/bin/SqlDateDemo.class differ diff --git a/BasicJava_2018/SqlDateDemo_valueOf/SqlDateDemo/src/SqlDateDemo.java b/BasicJava_2018/SqlDateDemo_valueOf/SqlDateDemo/src/SqlDateDemo.java new file mode 100644 index 000000000..2a120dc89 --- /dev/null +++ b/BasicJava_2018/SqlDateDemo_valueOf/SqlDateDemo/src/SqlDateDemo.java @@ -0,0 +1,24 @@ +import java.sql.Date; + +public class SqlDateDemo +{ + public static void main(String[] args) + { + String strDate = "2018-05-25"; + + /* + * Parameters:s - + * + * a String object representing a date in in the format + * "yyyy-[m]m-[d]d". The leading zero for mm and dd may also + * be omitted. + * + * Returns: + * + * a java.sql.Date object representing the given date + */ + Date date = Date.valueOf(strDate); + System.out.println(date); + } + +} diff --git a/BasicJava_2018/SqlDateDemo_valueOf_localDate/Output.txt b/BasicJava_2018/SqlDateDemo_valueOf_localDate/Output.txt new file mode 100644 index 000000000..321eb07b5 --- /dev/null +++ b/BasicJava_2018/SqlDateDemo_valueOf_localDate/Output.txt @@ -0,0 +1,2 @@ +2018-10-22 +2018-10-22 diff --git a/BasicJava_2018/SqlDateDemo_valueOf_localDate/SqlDateDemo/.classpath b/BasicJava_2018/SqlDateDemo_valueOf_localDate/SqlDateDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/SqlDateDemo_valueOf_localDate/SqlDateDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/SqlDateDemo_valueOf_localDate/SqlDateDemo/.project b/BasicJava_2018/SqlDateDemo_valueOf_localDate/SqlDateDemo/.project new file mode 100644 index 000000000..f3328a3e1 --- /dev/null +++ b/BasicJava_2018/SqlDateDemo_valueOf_localDate/SqlDateDemo/.project @@ -0,0 +1,17 @@ + + + SqlDateDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/SqlDateDemo_valueOf_localDate/SqlDateDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/SqlDateDemo_valueOf_localDate/SqlDateDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/SqlDateDemo_valueOf_localDate/SqlDateDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/SqlDateDemo_valueOf_localDate/SqlDateDemo/bin/SqlDateDemo.class b/BasicJava_2018/SqlDateDemo_valueOf_localDate/SqlDateDemo/bin/SqlDateDemo.class new file mode 100644 index 000000000..77ee51f4d Binary files /dev/null and b/BasicJava_2018/SqlDateDemo_valueOf_localDate/SqlDateDemo/bin/SqlDateDemo.class differ diff --git a/BasicJava_2018/SqlDateDemo_valueOf_localDate/SqlDateDemo/src/SqlDateDemo.java b/BasicJava_2018/SqlDateDemo_valueOf_localDate/SqlDateDemo/src/SqlDateDemo.java new file mode 100644 index 000000000..ce2891ca6 --- /dev/null +++ b/BasicJava_2018/SqlDateDemo_valueOf_localDate/SqlDateDemo/src/SqlDateDemo.java @@ -0,0 +1,24 @@ +import java.sql.Date; +import java.time.LocalDate; + +public class SqlDateDemo +{ + public static void main(String[] args) + { + LocalDate localDate = LocalDate.now(); + System.out.println(localDate); + + /* + * Parameters: + * + * date - a LocalDate to convert + * + * Returns: + * + * a Date object + */ + Date date = Date.valueOf(localDate); + System.out.println(date); + } + +} diff --git a/BasicJava_2018/TimeDemo_Intro/Output.txt b/BasicJava_2018/TimeDemo_Intro/Output.txt new file mode 100644 index 000000000..f0902463b --- /dev/null +++ b/BasicJava_2018/TimeDemo_Intro/Output.txt @@ -0,0 +1 @@ +09:38:34 \ No newline at end of file diff --git a/BasicJava_2018/TimeDemo_Intro/TimeDemo/.classpath b/BasicJava_2018/TimeDemo_Intro/TimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/TimeDemo_Intro/TimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/TimeDemo_Intro/TimeDemo/.project b/BasicJava_2018/TimeDemo_Intro/TimeDemo/.project new file mode 100644 index 000000000..d48557649 --- /dev/null +++ b/BasicJava_2018/TimeDemo_Intro/TimeDemo/.project @@ -0,0 +1,17 @@ + + + TimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/TimeDemo_Intro/TimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/TimeDemo_Intro/TimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/TimeDemo_Intro/TimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/TimeDemo_Intro/TimeDemo/bin/TimeDemo.class b/BasicJava_2018/TimeDemo_Intro/TimeDemo/bin/TimeDemo.class new file mode 100644 index 000000000..be2275ef9 Binary files /dev/null and b/BasicJava_2018/TimeDemo_Intro/TimeDemo/bin/TimeDemo.class differ diff --git a/BasicJava_2018/TimeDemo_Intro/TimeDemo/src/TimeDemo.java b/BasicJava_2018/TimeDemo_Intro/TimeDemo/src/TimeDemo.java new file mode 100644 index 000000000..1ab50b166 --- /dev/null +++ b/BasicJava_2018/TimeDemo_Intro/TimeDemo/src/TimeDemo.java @@ -0,0 +1,18 @@ +import java.sql.Time; + +public class TimeDemo +{ + + public static void main(String[] args) + { + + long millis = System.currentTimeMillis(); + + /* + * Constructs a Time object using a milliseconds time value. + */ + Time time = new Time(millis); + System.out.println(time); + } + +} diff --git a/BasicJava_2018/TimeDemo_ValueOf_Str/Output.txt b/BasicJava_2018/TimeDemo_ValueOf_Str/Output.txt new file mode 100644 index 000000000..e6dfad261 --- /dev/null +++ b/BasicJava_2018/TimeDemo_ValueOf_Str/Output.txt @@ -0,0 +1 @@ +15:06:00 diff --git a/BasicJava_2018/TimeDemo_ValueOf_Str/TimeDemo/.classpath b/BasicJava_2018/TimeDemo_ValueOf_Str/TimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/TimeDemo_ValueOf_Str/TimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/TimeDemo_ValueOf_Str/TimeDemo/.project b/BasicJava_2018/TimeDemo_ValueOf_Str/TimeDemo/.project new file mode 100644 index 000000000..d48557649 --- /dev/null +++ b/BasicJava_2018/TimeDemo_ValueOf_Str/TimeDemo/.project @@ -0,0 +1,17 @@ + + + TimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/TimeDemo_ValueOf_Str/TimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/TimeDemo_ValueOf_Str/TimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/TimeDemo_ValueOf_Str/TimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/TimeDemo_ValueOf_Str/TimeDemo/bin/TimeDemo.class b/BasicJava_2018/TimeDemo_ValueOf_Str/TimeDemo/bin/TimeDemo.class new file mode 100644 index 000000000..98f617c8a Binary files /dev/null and b/BasicJava_2018/TimeDemo_ValueOf_Str/TimeDemo/bin/TimeDemo.class differ diff --git a/BasicJava_2018/TimeDemo_ValueOf_Str/TimeDemo/src/TimeDemo.java b/BasicJava_2018/TimeDemo_ValueOf_Str/TimeDemo/src/TimeDemo.java new file mode 100644 index 000000000..0321fc4a0 --- /dev/null +++ b/BasicJava_2018/TimeDemo_ValueOf_Str/TimeDemo/src/TimeDemo.java @@ -0,0 +1,26 @@ +import java.sql.Time; + +public class TimeDemo +{ + + public static void main(String[] args) + { + + /* + * Converts a string in JDBC time escape format to a Time + * value. + * + * Parameters: + * + * s - time in format "hh:mm:ss" + * + * Returns: + * + * a corresponding Time object + */ + Time time = Time.valueOf("15:06:00"); + System.out.println(time); + + } + +} diff --git a/BasicJava_2018/TimeDemo_setTime/Output.txt b/BasicJava_2018/TimeDemo_setTime/Output.txt new file mode 100644 index 000000000..bfe757e3f --- /dev/null +++ b/BasicJava_2018/TimeDemo_setTime/Output.txt @@ -0,0 +1,2 @@ +Before setTime = 15:06:00 +After setTime = 09:51:09 diff --git a/BasicJava_2018/TimeDemo_setTime/TimeDemo/.classpath b/BasicJava_2018/TimeDemo_setTime/TimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/TimeDemo_setTime/TimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/TimeDemo_setTime/TimeDemo/.project b/BasicJava_2018/TimeDemo_setTime/TimeDemo/.project new file mode 100644 index 000000000..d48557649 --- /dev/null +++ b/BasicJava_2018/TimeDemo_setTime/TimeDemo/.project @@ -0,0 +1,17 @@ + + + TimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/TimeDemo_setTime/TimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/TimeDemo_setTime/TimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/TimeDemo_setTime/TimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/TimeDemo_setTime/TimeDemo/bin/TimeDemo.class b/BasicJava_2018/TimeDemo_setTime/TimeDemo/bin/TimeDemo.class new file mode 100644 index 000000000..4ac732e9f Binary files /dev/null and b/BasicJava_2018/TimeDemo_setTime/TimeDemo/bin/TimeDemo.class differ diff --git a/BasicJava_2018/TimeDemo_setTime/TimeDemo/src/TimeDemo.java b/BasicJava_2018/TimeDemo_setTime/TimeDemo/src/TimeDemo.java new file mode 100644 index 000000000..be1e94c76 --- /dev/null +++ b/BasicJava_2018/TimeDemo_setTime/TimeDemo/src/TimeDemo.java @@ -0,0 +1,20 @@ +import java.sql.Time; + +public class TimeDemo +{ + + public static void main(String[] args) + { + + Time time = Time.valueOf("15:06:00"); + System.out.println("Before setTime = " + time); + + /* + * Sets a Time object using a milliseconds time value. + */ + time.setTime(System.currentTimeMillis()); + System.out.println("After setTime = " + time); + + } + +} diff --git a/BasicJava_2018/TimeDemo_toInstant/Output.txt b/BasicJava_2018/TimeDemo_toInstant/Output.txt new file mode 100644 index 000000000..ad278cbee --- /dev/null +++ b/BasicJava_2018/TimeDemo_toInstant/Output.txt @@ -0,0 +1,3 @@ +Exception in thread "main" java.lang.UnsupportedOperationException + at java.sql.Time.toInstant(Time.java:291) + at TimeDemo.main(TimeDemo.java:17) diff --git a/BasicJava_2018/TimeDemo_toInstant/TimeDemo/.classpath b/BasicJava_2018/TimeDemo_toInstant/TimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/TimeDemo_toInstant/TimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/TimeDemo_toInstant/TimeDemo/.project b/BasicJava_2018/TimeDemo_toInstant/TimeDemo/.project new file mode 100644 index 000000000..d48557649 --- /dev/null +++ b/BasicJava_2018/TimeDemo_toInstant/TimeDemo/.project @@ -0,0 +1,17 @@ + + + TimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/TimeDemo_toInstant/TimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/TimeDemo_toInstant/TimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/TimeDemo_toInstant/TimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/TimeDemo_toInstant/TimeDemo/bin/TimeDemo.class b/BasicJava_2018/TimeDemo_toInstant/TimeDemo/bin/TimeDemo.class new file mode 100644 index 000000000..0657291d4 Binary files /dev/null and b/BasicJava_2018/TimeDemo_toInstant/TimeDemo/bin/TimeDemo.class differ diff --git a/BasicJava_2018/TimeDemo_toInstant/TimeDemo/src/TimeDemo.java b/BasicJava_2018/TimeDemo_toInstant/TimeDemo/src/TimeDemo.java new file mode 100644 index 000000000..a03d119ea --- /dev/null +++ b/BasicJava_2018/TimeDemo_toInstant/TimeDemo/src/TimeDemo.java @@ -0,0 +1,22 @@ +import java.sql.Time; +import java.time.Instant; + +public class TimeDemo +{ + + public static void main(String[] args) + { + + Time time = Time.valueOf("15:06:00"); + + /* + * This method always throws an UnsupportedOperationException + * and should not be used because SQL Time values do not have + * a date component. + */ + Instant instant = time.toInstant(); + System.out.println(instant); + + } + +} diff --git a/BasicJava_2018/TimeDemo_toLocalTime/Output.txt b/BasicJava_2018/TimeDemo_toLocalTime/Output.txt new file mode 100644 index 000000000..99ded0f3b --- /dev/null +++ b/BasicJava_2018/TimeDemo_toLocalTime/Output.txt @@ -0,0 +1,2 @@ +time = 15:06:20 +localTime = 15:06:20 diff --git a/BasicJava_2018/TimeDemo_toLocalTime/TimeDemo/.classpath b/BasicJava_2018/TimeDemo_toLocalTime/TimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/TimeDemo_toLocalTime/TimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/TimeDemo_toLocalTime/TimeDemo/.project b/BasicJava_2018/TimeDemo_toLocalTime/TimeDemo/.project new file mode 100644 index 000000000..d48557649 --- /dev/null +++ b/BasicJava_2018/TimeDemo_toLocalTime/TimeDemo/.project @@ -0,0 +1,17 @@ + + + TimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/TimeDemo_toLocalTime/TimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/TimeDemo_toLocalTime/TimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/TimeDemo_toLocalTime/TimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/TimeDemo_toLocalTime/TimeDemo/bin/TimeDemo.class b/BasicJava_2018/TimeDemo_toLocalTime/TimeDemo/bin/TimeDemo.class new file mode 100644 index 000000000..863b20987 Binary files /dev/null and b/BasicJava_2018/TimeDemo_toLocalTime/TimeDemo/bin/TimeDemo.class differ diff --git a/BasicJava_2018/TimeDemo_toLocalTime/TimeDemo/src/TimeDemo.java b/BasicJava_2018/TimeDemo_toLocalTime/TimeDemo/src/TimeDemo.java new file mode 100644 index 000000000..cf4defb6a --- /dev/null +++ b/BasicJava_2018/TimeDemo_toLocalTime/TimeDemo/src/TimeDemo.java @@ -0,0 +1,27 @@ +import java.sql.Time; +import java.time.LocalTime; + +public class TimeDemo +{ + + public static void main(String[] args) + { + + Time time = Time.valueOf("15:06:20"); + System.out.println("time = "+time); + + /* + * + * The conversion creates a LocalTime that represents the same + * hour, minute, and second time value as this Time. + * + * Returns: + * + * a LocalTime object representing the same time value + */ + LocalTime localTime = time.toLocalTime(); + System.out.println("localTime = "+localTime); + + } + +} diff --git a/BasicJava_2018/TimeDemo_valueOf_localTime/Output.txt b/BasicJava_2018/TimeDemo_valueOf_localTime/Output.txt new file mode 100644 index 000000000..0aa1432be --- /dev/null +++ b/BasicJava_2018/TimeDemo_valueOf_localTime/Output.txt @@ -0,0 +1,2 @@ +localTime = 09:58:01.935 +time = 09:58:01 diff --git a/BasicJava_2018/TimeDemo_valueOf_localTime/TimeDemo/.classpath b/BasicJava_2018/TimeDemo_valueOf_localTime/TimeDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/TimeDemo_valueOf_localTime/TimeDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/TimeDemo_valueOf_localTime/TimeDemo/.project b/BasicJava_2018/TimeDemo_valueOf_localTime/TimeDemo/.project new file mode 100644 index 000000000..d48557649 --- /dev/null +++ b/BasicJava_2018/TimeDemo_valueOf_localTime/TimeDemo/.project @@ -0,0 +1,17 @@ + + + TimeDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/TimeDemo_valueOf_localTime/TimeDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/TimeDemo_valueOf_localTime/TimeDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/TimeDemo_valueOf_localTime/TimeDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/TimeDemo_valueOf_localTime/TimeDemo/bin/TimeDemo.class b/BasicJava_2018/TimeDemo_valueOf_localTime/TimeDemo/bin/TimeDemo.class new file mode 100644 index 000000000..3624eb052 Binary files /dev/null and b/BasicJava_2018/TimeDemo_valueOf_localTime/TimeDemo/bin/TimeDemo.class differ diff --git a/BasicJava_2018/TimeDemo_valueOf_localTime/TimeDemo/src/TimeDemo.java b/BasicJava_2018/TimeDemo_valueOf_localTime/TimeDemo/src/TimeDemo.java new file mode 100644 index 000000000..a97cb1347 --- /dev/null +++ b/BasicJava_2018/TimeDemo_valueOf_localTime/TimeDemo/src/TimeDemo.java @@ -0,0 +1,31 @@ +import java.sql.Time; +import java.time.LocalTime; + +public class TimeDemo +{ + + public static void main(String[] args) + { + + LocalTime localTime = LocalTime.now(); + System.out.println("localTime = " + localTime); + + /* + * Obtains an instance of Time from a LocalTime object with + * the same hour, minute and second time value as the given + * LocalTime. + * + * Parameters: + * + * time - a LocalTime to convert + * + * Returns: + * + * a Time object + */ + Time time = Time.valueOf(localTime); + System.out.println("time = " + time); + + } + +} diff --git a/BasicJava_2018/TimeZoneDemo_Intro/Output.txt b/BasicJava_2018/TimeZoneDemo_Intro/Output.txt new file mode 100644 index 000000000..555cd6511 --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_Intro/Output.txt @@ -0,0 +1,2 @@ +timeZone = sun.util.calendar.ZoneInfo[id="Asia/Calcutta",offset=19800000,dstSavings=0,useDaylight=false,transitions=6,lastRule=null] +displayName = India Standard Time diff --git a/BasicJava_2018/TimeZoneDemo_Intro/TimeZoneDemo/.classpath b/BasicJava_2018/TimeZoneDemo_Intro/TimeZoneDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_Intro/TimeZoneDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/TimeZoneDemo_Intro/TimeZoneDemo/.project b/BasicJava_2018/TimeZoneDemo_Intro/TimeZoneDemo/.project new file mode 100644 index 000000000..99ffb945b --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_Intro/TimeZoneDemo/.project @@ -0,0 +1,17 @@ + + + TimeZoneDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/TimeZoneDemo_Intro/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/TimeZoneDemo_Intro/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_Intro/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/TimeZoneDemo_Intro/TimeZoneDemo/bin/TimeZoneDemo.class b/BasicJava_2018/TimeZoneDemo_Intro/TimeZoneDemo/bin/TimeZoneDemo.class new file mode 100644 index 000000000..0193a91a6 Binary files /dev/null and b/BasicJava_2018/TimeZoneDemo_Intro/TimeZoneDemo/bin/TimeZoneDemo.class differ diff --git a/BasicJava_2018/TimeZoneDemo_Intro/TimeZoneDemo/src/TimeZoneDemo.java b/BasicJava_2018/TimeZoneDemo_Intro/TimeZoneDemo/src/TimeZoneDemo.java new file mode 100644 index 000000000..482770860 --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_Intro/TimeZoneDemo/src/TimeZoneDemo.java @@ -0,0 +1,16 @@ +import java.util.TimeZone; + +public class TimeZoneDemo +{ + public static void main(String[] args) + { + /* + * Returns: the default TimeZone + */ + TimeZone timeZone = TimeZone.getDefault(); + System.out.println("timeZone = " + timeZone); + + String displayName = timeZone.getDisplayName(); + System.out.println("displayName = " + displayName); + } +} diff --git a/BasicJava_2018/TimeZoneDemo_getAvailableIDs/TimeZoneDemo/.classpath b/BasicJava_2018/TimeZoneDemo_getAvailableIDs/TimeZoneDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getAvailableIDs/TimeZoneDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/TimeZoneDemo_getAvailableIDs/TimeZoneDemo/.project b/BasicJava_2018/TimeZoneDemo_getAvailableIDs/TimeZoneDemo/.project new file mode 100644 index 000000000..99ffb945b --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getAvailableIDs/TimeZoneDemo/.project @@ -0,0 +1,17 @@ + + + TimeZoneDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/TimeZoneDemo_getAvailableIDs/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/TimeZoneDemo_getAvailableIDs/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getAvailableIDs/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/TimeZoneDemo_getAvailableIDs/TimeZoneDemo/bin/TimeZoneDemo1.class b/BasicJava_2018/TimeZoneDemo_getAvailableIDs/TimeZoneDemo/bin/TimeZoneDemo1.class new file mode 100644 index 000000000..927d8cc4e Binary files /dev/null and b/BasicJava_2018/TimeZoneDemo_getAvailableIDs/TimeZoneDemo/bin/TimeZoneDemo1.class differ diff --git a/BasicJava_2018/TimeZoneDemo_getAvailableIDs/TimeZoneDemo/bin/TimeZoneDemo2.class b/BasicJava_2018/TimeZoneDemo_getAvailableIDs/TimeZoneDemo/bin/TimeZoneDemo2.class new file mode 100644 index 000000000..3717b8eca Binary files /dev/null and b/BasicJava_2018/TimeZoneDemo_getAvailableIDs/TimeZoneDemo/bin/TimeZoneDemo2.class differ diff --git a/BasicJava_2018/TimeZoneDemo_getAvailableIDs/TimeZoneDemo/src/TimeZoneDemo1.java b/BasicJava_2018/TimeZoneDemo_getAvailableIDs/TimeZoneDemo/src/TimeZoneDemo1.java new file mode 100644 index 000000000..8cda1137a --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getAvailableIDs/TimeZoneDemo/src/TimeZoneDemo1.java @@ -0,0 +1,16 @@ +import java.util.TimeZone; + +public class TimeZoneDemo1 +{ + public static void main(String[] args) + { + /* + * Returns:an array of IDs. + */ + String[] idArray = TimeZone.getAvailableIDs(); + for (String id : idArray) + { + System.out.println(id); + } + } +} diff --git a/BasicJava_2018/TimeZoneDemo_getAvailableIDs/TimeZoneDemo/src/TimeZoneDemo2.java b/BasicJava_2018/TimeZoneDemo_getAvailableIDs/TimeZoneDemo/src/TimeZoneDemo2.java new file mode 100644 index 000000000..1515689db --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getAvailableIDs/TimeZoneDemo/src/TimeZoneDemo2.java @@ -0,0 +1,25 @@ +import java.util.TimeZone; + +public class TimeZoneDemo2 +{ + public static void main(String[] args) + { + /* + * Parameters: + * + * rawOffset - the given time zone GMT offset in milliseconds. + * + * Returns:an array of IDs, where the time zone for that ID + * has the specified GMT offset. For example, + * "America/Phoenix" and "America/Denver" both have GMT-07:00, + * but differ in daylight saving behavior. + */ + String[] availableIDArray = TimeZone.getAvailableIDs(3600000); + + System.out.println("Available Ids for offset are: "); + for (String availableID : availableIDArray) + { + System.out.println(availableID); + } + } +} diff --git a/BasicJava_2018/TimeZoneDemo_getAvailableIDs/TimeZoneDemo1_Output.txt b/BasicJava_2018/TimeZoneDemo_getAvailableIDs/TimeZoneDemo1_Output.txt new file mode 100644 index 000000000..ac331ef6c --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getAvailableIDs/TimeZoneDemo1_Output.txt @@ -0,0 +1,31 @@ +Africa/Abidjan +Africa/Accra +Africa/Addis_Ababa +Africa/Algiers +Africa/Asmara +Africa/Asmera +Africa/Bamako +Africa/Bangui +Africa/Banjul +Africa/Bissau +Africa/Blantyre +Africa/Brazzaville +Africa/Bujumbura +Africa/Cairo + +--- +--- +--- + +IET +IST +JST +MIT +NET +NST +PLT +PNT +PRT +PST +SST +VST diff --git a/BasicJava_2018/TimeZoneDemo_getAvailableIDs/TimeZoneDemo2_Output.txt b/BasicJava_2018/TimeZoneDemo_getAvailableIDs/TimeZoneDemo2_Output.txt new file mode 100644 index 000000000..753b5023a --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getAvailableIDs/TimeZoneDemo2_Output.txt @@ -0,0 +1,23 @@ +Available Ids for offset are: +Africa/Algiers +Africa/Bangui +Africa/Brazzaville +Africa/Ceuta +Africa/Douala +Africa/Kinshasa +Africa/Lagos +Africa/Libreville + +--- +--- + +Europe/Stockholm +Europe/Tirane +Europe/Vaduz +Europe/Vatican +Europe/Vienna +Europe/Warsaw +Europe/Zagreb +Europe/Zurich +MET +Poland diff --git a/BasicJava_2018/TimeZoneDemo_getDSTSavings/Output.txt b/BasicJava_2018/TimeZoneDemo_getDSTSavings/Output.txt new file mode 100644 index 000000000..57cb226f3 --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getDSTSavings/Output.txt @@ -0,0 +1,2 @@ +ID value is = Europe/Paris +DST saving is = 3600000 diff --git a/BasicJava_2018/TimeZoneDemo_getDSTSavings/TimeZoneDemo/.classpath b/BasicJava_2018/TimeZoneDemo_getDSTSavings/TimeZoneDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getDSTSavings/TimeZoneDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/TimeZoneDemo_getDSTSavings/TimeZoneDemo/.project b/BasicJava_2018/TimeZoneDemo_getDSTSavings/TimeZoneDemo/.project new file mode 100644 index 000000000..99ffb945b --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getDSTSavings/TimeZoneDemo/.project @@ -0,0 +1,17 @@ + + + TimeZoneDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/TimeZoneDemo_getDSTSavings/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/TimeZoneDemo_getDSTSavings/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getDSTSavings/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/TimeZoneDemo_getDSTSavings/TimeZoneDemo/bin/TimeZoneDemo.class b/BasicJava_2018/TimeZoneDemo_getDSTSavings/TimeZoneDemo/bin/TimeZoneDemo.class new file mode 100644 index 000000000..b354b4da0 Binary files /dev/null and b/BasicJava_2018/TimeZoneDemo_getDSTSavings/TimeZoneDemo/bin/TimeZoneDemo.class differ diff --git a/BasicJava_2018/TimeZoneDemo_getDSTSavings/TimeZoneDemo/src/TimeZoneDemo.java b/BasicJava_2018/TimeZoneDemo_getDSTSavings/TimeZoneDemo/src/TimeZoneDemo.java new file mode 100644 index 000000000..bf9b2eca3 --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getDSTSavings/TimeZoneDemo/src/TimeZoneDemo.java @@ -0,0 +1,22 @@ +import java.util.TimeZone; + +public class TimeZoneDemo +{ + public static void main(String[] args) + { + TimeZone timezone = TimeZone.getTimeZone("Europe/Paris"); + + + /* + * Returns:the ID of this time zone. + */ + System.out.println("ID value is = " + timezone.getID()); + + /* + * Returns: + * + * the amount of saving time in milliseconds + */ + System.out.println("DST saving is = " + timezone.getDSTSavings()); + } +} diff --git a/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style/Output.txt b/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style/Output.txt new file mode 100644 index 000000000..f9bd990da --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style/Output.txt @@ -0,0 +1,2 @@ +displayName LONG = India Daylight Time +displayName SHORT = IDT diff --git a/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style/TimeZoneDemo/.classpath b/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style/TimeZoneDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style/TimeZoneDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style/TimeZoneDemo/.project b/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style/TimeZoneDemo/.project new file mode 100644 index 000000000..99ffb945b --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style/TimeZoneDemo/.project @@ -0,0 +1,17 @@ + + + TimeZoneDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style/TimeZoneDemo/bin/TimeZoneDemo.class b/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style/TimeZoneDemo/bin/TimeZoneDemo.class new file mode 100644 index 000000000..cc574586c Binary files /dev/null and b/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style/TimeZoneDemo/bin/TimeZoneDemo.class differ diff --git a/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style/TimeZoneDemo/src/TimeZoneDemo.java b/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style/TimeZoneDemo/src/TimeZoneDemo.java new file mode 100644 index 000000000..7559c90df --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style/TimeZoneDemo/src/TimeZoneDemo.java @@ -0,0 +1,30 @@ +import java.util.TimeZone; + +public class TimeZoneDemo +{ + public static void main(String[] args) + { + TimeZone timezonedefault = TimeZone.getDefault(); + + /* + * Parameters: + * + * daylight - true specifying a Daylight Saving Time name, or + * false specifying a Standard Time + * + * namestyle - either LONG or SHORTReturns:the human-readable + * name of this time zone in the default locale. + * + * Returns: + * + * the human-readable name of this time zone in the default + * locale. + */ + String displayName = timezonedefault.getDisplayName(true, + TimeZone.LONG); + System.out.println("displayName LONG = " + displayName); + + displayName = timezonedefault.getDisplayName(true, TimeZone.SHORT); + System.out.println("displayName SHORT = " + displayName); + } +} diff --git a/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style_locale/Output.txt b/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style_locale/Output.txt new file mode 100644 index 000000000..50ec93a49 --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style_locale/Output.txt @@ -0,0 +1,2 @@ +displayName = India Daylight Time +displayName = IDT diff --git a/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style_locale/TimeZoneDemo/.classpath b/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style_locale/TimeZoneDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style_locale/TimeZoneDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style_locale/TimeZoneDemo/.project b/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style_locale/TimeZoneDemo/.project new file mode 100644 index 000000000..99ffb945b --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style_locale/TimeZoneDemo/.project @@ -0,0 +1,17 @@ + + + TimeZoneDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style_locale/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style_locale/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style_locale/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style_locale/TimeZoneDemo/bin/TimeZoneDemo.class b/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style_locale/TimeZoneDemo/bin/TimeZoneDemo.class new file mode 100644 index 000000000..ef63fb7b5 Binary files /dev/null and b/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style_locale/TimeZoneDemo/bin/TimeZoneDemo.class differ diff --git a/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style_locale/TimeZoneDemo/src/TimeZoneDemo.java b/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style_locale/TimeZoneDemo/src/TimeZoneDemo.java new file mode 100644 index 000000000..44054dbee --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style_locale/TimeZoneDemo/src/TimeZoneDemo.java @@ -0,0 +1,34 @@ +import java.util.Locale; +import java.util.TimeZone; + +public class TimeZoneDemo +{ + public static void main(String[] args) + { + TimeZone timezonedefault = TimeZone.getDefault(); + + /* + * Parameters: + * + * daylight - true specifying a Daylight Saving Time name, or + * false specifying a Standard Time + * + * namestyle - either LONG or SHORTReturns:the human-readable + * name of this time zone in the default locale. + * + * locale - the locale in which to supply the display name. + * + * Returns: + * + * the human-readable name of this time zone in the given + * locale. + */ + String displayName = timezonedefault.getDisplayName(true, TimeZone.LONG, + new Locale("EN", "US")); + System.out.println("displayName = " + displayName); + + displayName = timezonedefault.getDisplayName(true, TimeZone.SHORT, + new Locale("EN", "US")); + System.out.println("displayName = " + displayName); + } +} diff --git a/BasicJava_2018/TimeZoneDemo_getDisplayName_locale/Output.txt b/BasicJava_2018/TimeZoneDemo_getDisplayName_locale/Output.txt new file mode 100644 index 000000000..123214c35 --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getDisplayName_locale/Output.txt @@ -0,0 +1 @@ +displayName = India Standard Time diff --git a/BasicJava_2018/TimeZoneDemo_getDisplayName_locale/TimeZoneDemo/.classpath b/BasicJava_2018/TimeZoneDemo_getDisplayName_locale/TimeZoneDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getDisplayName_locale/TimeZoneDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/TimeZoneDemo_getDisplayName_locale/TimeZoneDemo/.project b/BasicJava_2018/TimeZoneDemo_getDisplayName_locale/TimeZoneDemo/.project new file mode 100644 index 000000000..99ffb945b --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getDisplayName_locale/TimeZoneDemo/.project @@ -0,0 +1,17 @@ + + + TimeZoneDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/TimeZoneDemo_getDisplayName_locale/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/TimeZoneDemo_getDisplayName_locale/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getDisplayName_locale/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/TimeZoneDemo_getDisplayName_locale/TimeZoneDemo/bin/TimeZoneDemo.class b/BasicJava_2018/TimeZoneDemo_getDisplayName_locale/TimeZoneDemo/bin/TimeZoneDemo.class new file mode 100644 index 000000000..dce7dba7d Binary files /dev/null and b/BasicJava_2018/TimeZoneDemo_getDisplayName_locale/TimeZoneDemo/bin/TimeZoneDemo.class differ diff --git a/BasicJava_2018/TimeZoneDemo_getDisplayName_locale/TimeZoneDemo/src/TimeZoneDemo.java b/BasicJava_2018/TimeZoneDemo_getDisplayName_locale/TimeZoneDemo/src/TimeZoneDemo.java new file mode 100644 index 000000000..e99a3c7b1 --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getDisplayName_locale/TimeZoneDemo/src/TimeZoneDemo.java @@ -0,0 +1,26 @@ +import java.util.Locale; +import java.util.TimeZone; + +public class TimeZoneDemo +{ + public static void main(String[] args) + { + TimeZone timeZone = TimeZone.getDefault(); + + Locale locale = new Locale("EN", "US"); + + /* + * Parameters: + * + * locale - the locale in which to supply the display name. + * + * Returns: + * + * the human-readable name of this time zone in the given + * locale. + */ + String displayName = timeZone.getDisplayName(locale); + + System.out.println("displayName = " + displayName); + } +} diff --git a/BasicJava_2018/TimeZoneDemo_getOffset/TimeZoneDemo/.classpath b/BasicJava_2018/TimeZoneDemo_getOffset/TimeZoneDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getOffset/TimeZoneDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/TimeZoneDemo_getOffset/TimeZoneDemo/.project b/BasicJava_2018/TimeZoneDemo_getOffset/TimeZoneDemo/.project new file mode 100644 index 000000000..99ffb945b --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getOffset/TimeZoneDemo/.project @@ -0,0 +1,17 @@ + + + TimeZoneDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/TimeZoneDemo_getOffset/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/TimeZoneDemo_getOffset/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getOffset/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/TimeZoneDemo_getOffset/TimeZoneDemo/bin/TimeZoneDemo1.class b/BasicJava_2018/TimeZoneDemo_getOffset/TimeZoneDemo/bin/TimeZoneDemo1.class new file mode 100644 index 000000000..a1e0271e3 Binary files /dev/null and b/BasicJava_2018/TimeZoneDemo_getOffset/TimeZoneDemo/bin/TimeZoneDemo1.class differ diff --git a/BasicJava_2018/TimeZoneDemo_getOffset/TimeZoneDemo/bin/TimeZoneDemo2.class b/BasicJava_2018/TimeZoneDemo_getOffset/TimeZoneDemo/bin/TimeZoneDemo2.class new file mode 100644 index 000000000..69fe05326 Binary files /dev/null and b/BasicJava_2018/TimeZoneDemo_getOffset/TimeZoneDemo/bin/TimeZoneDemo2.class differ diff --git a/BasicJava_2018/TimeZoneDemo_getOffset/TimeZoneDemo/src/TimeZoneDemo1.java b/BasicJava_2018/TimeZoneDemo_getOffset/TimeZoneDemo/src/TimeZoneDemo1.java new file mode 100644 index 000000000..8e2cc9332 --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getOffset/TimeZoneDemo/src/TimeZoneDemo1.java @@ -0,0 +1,26 @@ +import java.util.TimeZone; + +public class TimeZoneDemo1 +{ + public static void main(String[] args) + { + TimeZone timezone = TimeZone.getTimeZone("Europe/Paris"); + + /* + * Parameters: + * + * era - the era of the given date. + * year - the year in the given date. + * month - the month in the given date. Month is 0-based. e.g., 0 for January. + * day - the day-in-month of the given date. + * dayOfWeek - the day-of-week of the given date. + * milliseconds - the milliseconds in day in standard local time. + * + * Returns: + * + * the offset in milliseconds to add to GMT to get local time. + */ + int offset = timezone.getOffset(1, 2017, 3, 4, 5, 300); + System.out.println("offset = " + offset); + } +} diff --git a/BasicJava_2018/TimeZoneDemo_getOffset/TimeZoneDemo/src/TimeZoneDemo2.java b/BasicJava_2018/TimeZoneDemo_getOffset/TimeZoneDemo/src/TimeZoneDemo2.java new file mode 100644 index 000000000..b24a74b53 --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getOffset/TimeZoneDemo/src/TimeZoneDemo2.java @@ -0,0 +1,24 @@ +import java.util.Calendar; +import java.util.TimeZone; + +public class TimeZoneDemo2 +{ + public static void main(String[] args) + { + TimeZone timezone = TimeZone.getTimeZone("Europe/Paris"); + + /* + * Parameters: + * + * date - the date represented in milliseconds since January + * 1, 1970 00:00:00 GMT + * + * Returns: + * + * the amount of time in milliseconds to add to UTC to get + * local time. + */ + int offset = timezone.getOffset(Calendar.ZONE_OFFSET); + System.out.println("offset = " + offset); + } +} diff --git a/BasicJava_2018/TimeZoneDemo_getOffset/TimeZoneDemo1_Output.txt b/BasicJava_2018/TimeZoneDemo_getOffset/TimeZoneDemo1_Output.txt new file mode 100644 index 000000000..aa962d49d --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getOffset/TimeZoneDemo1_Output.txt @@ -0,0 +1 @@ +offset = 7200000 diff --git a/BasicJava_2018/TimeZoneDemo_getOffset/TimeZoneDemo2_Output.txt b/BasicJava_2018/TimeZoneDemo_getOffset/TimeZoneDemo2_Output.txt new file mode 100644 index 000000000..f892df158 --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getOffset/TimeZoneDemo2_Output.txt @@ -0,0 +1 @@ +offset = 3600000 diff --git a/BasicJava_2018/TimeZoneDemo_getRawOffset/Output.txt b/BasicJava_2018/TimeZoneDemo_getRawOffset/Output.txt new file mode 100644 index 000000000..76edf58ab --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getRawOffset/Output.txt @@ -0,0 +1 @@ +rawOffset = 19800000 diff --git a/BasicJava_2018/TimeZoneDemo_getRawOffset/TimeZoneDemo/.classpath b/BasicJava_2018/TimeZoneDemo_getRawOffset/TimeZoneDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getRawOffset/TimeZoneDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/TimeZoneDemo_getRawOffset/TimeZoneDemo/.project b/BasicJava_2018/TimeZoneDemo_getRawOffset/TimeZoneDemo/.project new file mode 100644 index 000000000..99ffb945b --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getRawOffset/TimeZoneDemo/.project @@ -0,0 +1,17 @@ + + + TimeZoneDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/TimeZoneDemo_getRawOffset/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/TimeZoneDemo_getRawOffset/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getRawOffset/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/TimeZoneDemo_getRawOffset/TimeZoneDemo/bin/TimeZoneDemo.class b/BasicJava_2018/TimeZoneDemo_getRawOffset/TimeZoneDemo/bin/TimeZoneDemo.class new file mode 100644 index 000000000..8ddce1863 Binary files /dev/null and b/BasicJava_2018/TimeZoneDemo_getRawOffset/TimeZoneDemo/bin/TimeZoneDemo.class differ diff --git a/BasicJava_2018/TimeZoneDemo_getRawOffset/TimeZoneDemo/src/TimeZoneDemo.java b/BasicJava_2018/TimeZoneDemo_getRawOffset/TimeZoneDemo/src/TimeZoneDemo.java new file mode 100644 index 000000000..e7328cb5f --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getRawOffset/TimeZoneDemo/src/TimeZoneDemo.java @@ -0,0 +1,18 @@ +import java.util.TimeZone; + +public class TimeZoneDemo +{ + public static void main(String[] args) + { + TimeZone timezone = TimeZone.getDefault(); + + /* + * Returns the amount of time in milliseconds to add to UTC to + * get standard time in this time zone. Because this value is + * not affected by daylight saving time, it is called raw + * offset. + */ + int rawOffset = timezone.getRawOffset(); + System.out.println("rawOffset = " + rawOffset); + } +} diff --git a/BasicJava_2018/TimeZoneDemo_getTimeZone_id/Output.txt b/BasicJava_2018/TimeZoneDemo_getTimeZone_id/Output.txt new file mode 100644 index 000000000..f0c859f20 --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getTimeZone_id/Output.txt @@ -0,0 +1,2 @@ +sun.util.calendar.ZoneInfo[id="America/New_York",offset=-18000000,dstSavings=3600000,useDaylight=true,transitions=235,lastRule=java.util.SimpleTimeZone[id=America/New_York,offset=-18000000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]] +Eastern Standard Time diff --git a/BasicJava_2018/TimeZoneDemo_getTimeZone_id/TimeZoneDemo/.classpath b/BasicJava_2018/TimeZoneDemo_getTimeZone_id/TimeZoneDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getTimeZone_id/TimeZoneDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/TimeZoneDemo_getTimeZone_id/TimeZoneDemo/.project b/BasicJava_2018/TimeZoneDemo_getTimeZone_id/TimeZoneDemo/.project new file mode 100644 index 000000000..99ffb945b --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getTimeZone_id/TimeZoneDemo/.project @@ -0,0 +1,17 @@ + + + TimeZoneDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/TimeZoneDemo_getTimeZone_id/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/TimeZoneDemo_getTimeZone_id/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getTimeZone_id/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/TimeZoneDemo_getTimeZone_id/TimeZoneDemo/bin/TimeZoneDemo.class b/BasicJava_2018/TimeZoneDemo_getTimeZone_id/TimeZoneDemo/bin/TimeZoneDemo.class new file mode 100644 index 000000000..b3fcb4e49 Binary files /dev/null and b/BasicJava_2018/TimeZoneDemo_getTimeZone_id/TimeZoneDemo/bin/TimeZoneDemo.class differ diff --git a/BasicJava_2018/TimeZoneDemo_getTimeZone_id/TimeZoneDemo/src/TimeZoneDemo.java b/BasicJava_2018/TimeZoneDemo_getTimeZone_id/TimeZoneDemo/src/TimeZoneDemo.java new file mode 100644 index 000000000..af2e14296 --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_getTimeZone_id/TimeZoneDemo/src/TimeZoneDemo.java @@ -0,0 +1,23 @@ +import java.util.TimeZone; + +public class TimeZoneDemo +{ + public static void main(String[] args) + { + /* + * Parameters: + * + * ID - the ID for a TimeZone, either an abbreviation such as + * "PST", a full name such as "America/Los_Angeles", or a + * custom ID such as "GMT-8:00". Note that the support of + * abbreviations is for JDK 1.1.x compatibility only and full + * names should be used. + * + * Returns:the specified TimeZone, or the GMT zone if the + * given ID cannot be understood. + */ + TimeZone timeZone = TimeZone.getTimeZone("America/New_York"); + System.out.println(timeZone); + System.out.println(timeZone.getDisplayName()); + } +} diff --git a/BasicJava_2018/TimeZoneDemo_hasSameRules/Output.txt b/BasicJava_2018/TimeZoneDemo_hasSameRules/Output.txt new file mode 100644 index 000000000..1d474d525 --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_hasSameRules/Output.txt @@ -0,0 +1,2 @@ +false +true diff --git a/BasicJava_2018/TimeZoneDemo_hasSameRules/TimeZoneDemo/.classpath b/BasicJava_2018/TimeZoneDemo_hasSameRules/TimeZoneDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_hasSameRules/TimeZoneDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/TimeZoneDemo_hasSameRules/TimeZoneDemo/.project b/BasicJava_2018/TimeZoneDemo_hasSameRules/TimeZoneDemo/.project new file mode 100644 index 000000000..99ffb945b --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_hasSameRules/TimeZoneDemo/.project @@ -0,0 +1,17 @@ + + + TimeZoneDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/TimeZoneDemo_hasSameRules/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/TimeZoneDemo_hasSameRules/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_hasSameRules/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/TimeZoneDemo_hasSameRules/TimeZoneDemo/bin/TimeZoneDemo.class b/BasicJava_2018/TimeZoneDemo_hasSameRules/TimeZoneDemo/bin/TimeZoneDemo.class new file mode 100644 index 000000000..142694e5f Binary files /dev/null and b/BasicJava_2018/TimeZoneDemo_hasSameRules/TimeZoneDemo/bin/TimeZoneDemo.class differ diff --git a/BasicJava_2018/TimeZoneDemo_hasSameRules/TimeZoneDemo/src/TimeZoneDemo.java b/BasicJava_2018/TimeZoneDemo_hasSameRules/TimeZoneDemo/src/TimeZoneDemo.java new file mode 100644 index 000000000..6c2e63726 --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_hasSameRules/TimeZoneDemo/src/TimeZoneDemo.java @@ -0,0 +1,27 @@ +import java.util.TimeZone; + +public class TimeZoneDemo +{ + public static void main(String[] args) + { + TimeZone timeZone1 = TimeZone.getDefault(); + TimeZone timeZone2 = TimeZone.getTimeZone("America/Los_Angeles"); + TimeZone timeZone3 = TimeZone.getTimeZone("America/Los_Angeles"); + + /* + * Parameters: + * + * other - the TimeZone object to be compared with + * + * Returns: + * + * true if the other zone is not null and is the same as this + * one, with the possible exception of the ID + */ + boolean hasSameRules = timeZone1.hasSameRules(timeZone2); + System.out.println(hasSameRules); + + hasSameRules = timeZone2.hasSameRules(timeZone3); + System.out.println(hasSameRules); + } +} diff --git a/BasicJava_2018/TimeZoneDemo_inDaylightTime/Output.txt b/BasicJava_2018/TimeZoneDemo_inDaylightTime/Output.txt new file mode 100644 index 000000000..c508d5366 --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_inDaylightTime/Output.txt @@ -0,0 +1 @@ +false diff --git a/BasicJava_2018/TimeZoneDemo_inDaylightTime/TimeZoneDemo/.classpath b/BasicJava_2018/TimeZoneDemo_inDaylightTime/TimeZoneDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_inDaylightTime/TimeZoneDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/TimeZoneDemo_inDaylightTime/TimeZoneDemo/.project b/BasicJava_2018/TimeZoneDemo_inDaylightTime/TimeZoneDemo/.project new file mode 100644 index 000000000..99ffb945b --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_inDaylightTime/TimeZoneDemo/.project @@ -0,0 +1,17 @@ + + + TimeZoneDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/TimeZoneDemo_inDaylightTime/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/TimeZoneDemo_inDaylightTime/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_inDaylightTime/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/TimeZoneDemo_inDaylightTime/TimeZoneDemo/bin/TimeZoneDemo.class b/BasicJava_2018/TimeZoneDemo_inDaylightTime/TimeZoneDemo/bin/TimeZoneDemo.class new file mode 100644 index 000000000..6bc821e0a Binary files /dev/null and b/BasicJava_2018/TimeZoneDemo_inDaylightTime/TimeZoneDemo/bin/TimeZoneDemo.class differ diff --git a/BasicJava_2018/TimeZoneDemo_inDaylightTime/TimeZoneDemo/src/TimeZoneDemo.java b/BasicJava_2018/TimeZoneDemo_inDaylightTime/TimeZoneDemo/src/TimeZoneDemo.java new file mode 100644 index 000000000..fab37b1ef --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_inDaylightTime/TimeZoneDemo/src/TimeZoneDemo.java @@ -0,0 +1,25 @@ +import java.util.Date; +import java.util.TimeZone; + +public class TimeZoneDemo +{ + public static void main(String[] args) + { + TimeZone timezone = TimeZone.getDefault(); + + Date date = new Date(); + + /* + * Parameters: + * + * date - the given Date. + * + * Returns: + * + * true if the given date is in Daylight Saving Time, false, + * otherwise. + */ + boolean result = timezone.inDaylightTime(date); + System.out.println(result); + } +} diff --git a/BasicJava_2018/TimeZoneDemo_observesDaylightTime/Output.txt b/BasicJava_2018/TimeZoneDemo_observesDaylightTime/Output.txt new file mode 100644 index 000000000..b403d5f68 --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_observesDaylightTime/Output.txt @@ -0,0 +1,2 @@ +sun.util.calendar.ZoneInfo[id="America/Los_Angeles",offset=-28800000,dstSavings=3600000,useDaylight=true,transitions=185,lastRule=java.util.SimpleTimeZone[id=America/Los_Angeles,offset=-28800000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]] +true diff --git a/BasicJava_2018/TimeZoneDemo_observesDaylightTime/TimeZoneDemo/.classpath b/BasicJava_2018/TimeZoneDemo_observesDaylightTime/TimeZoneDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_observesDaylightTime/TimeZoneDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/TimeZoneDemo_observesDaylightTime/TimeZoneDemo/.project b/BasicJava_2018/TimeZoneDemo_observesDaylightTime/TimeZoneDemo/.project new file mode 100644 index 000000000..99ffb945b --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_observesDaylightTime/TimeZoneDemo/.project @@ -0,0 +1,17 @@ + + + TimeZoneDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/TimeZoneDemo_observesDaylightTime/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/TimeZoneDemo_observesDaylightTime/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_observesDaylightTime/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/TimeZoneDemo_observesDaylightTime/TimeZoneDemo/bin/TimeZoneDemo.class b/BasicJava_2018/TimeZoneDemo_observesDaylightTime/TimeZoneDemo/bin/TimeZoneDemo.class new file mode 100644 index 000000000..eb4543ac7 Binary files /dev/null and b/BasicJava_2018/TimeZoneDemo_observesDaylightTime/TimeZoneDemo/bin/TimeZoneDemo.class differ diff --git a/BasicJava_2018/TimeZoneDemo_observesDaylightTime/TimeZoneDemo/src/TimeZoneDemo.java b/BasicJava_2018/TimeZoneDemo_observesDaylightTime/TimeZoneDemo/src/TimeZoneDemo.java new file mode 100644 index 000000000..8bd3d15f9 --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_observesDaylightTime/TimeZoneDemo/src/TimeZoneDemo.java @@ -0,0 +1,21 @@ +import java.util.TimeZone; + +public class TimeZoneDemo +{ + public static void main(String[] args) + { + TimeZone timeZone = TimeZone.getTimeZone("America/Los_Angeles"); + System.out.println(timeZone); + + + /* + * Returns: + * + * true if this TimeZone is currently in Daylight Saving Time, + * or if a transition from Standard Time to Daylight Saving + * Time occurs at any future time; false otherwise. + */ + boolean result = timeZone.observesDaylightTime(); + System.out.println(result); + } +} diff --git a/BasicJava_2018/TimeZoneDemo_useDaylightTime/Output.txt b/BasicJava_2018/TimeZoneDemo_useDaylightTime/Output.txt new file mode 100644 index 000000000..b403d5f68 --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_useDaylightTime/Output.txt @@ -0,0 +1,2 @@ +sun.util.calendar.ZoneInfo[id="America/Los_Angeles",offset=-28800000,dstSavings=3600000,useDaylight=true,transitions=185,lastRule=java.util.SimpleTimeZone[id=America/Los_Angeles,offset=-28800000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]] +true diff --git a/BasicJava_2018/TimeZoneDemo_useDaylightTime/TimeZoneDemo/.classpath b/BasicJava_2018/TimeZoneDemo_useDaylightTime/TimeZoneDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_useDaylightTime/TimeZoneDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/TimeZoneDemo_useDaylightTime/TimeZoneDemo/.project b/BasicJava_2018/TimeZoneDemo_useDaylightTime/TimeZoneDemo/.project new file mode 100644 index 000000000..99ffb945b --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_useDaylightTime/TimeZoneDemo/.project @@ -0,0 +1,17 @@ + + + TimeZoneDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/TimeZoneDemo_useDaylightTime/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/TimeZoneDemo_useDaylightTime/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_useDaylightTime/TimeZoneDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/TimeZoneDemo_useDaylightTime/TimeZoneDemo/bin/TimeZoneDemo.class b/BasicJava_2018/TimeZoneDemo_useDaylightTime/TimeZoneDemo/bin/TimeZoneDemo.class new file mode 100644 index 000000000..ec8a87819 Binary files /dev/null and b/BasicJava_2018/TimeZoneDemo_useDaylightTime/TimeZoneDemo/bin/TimeZoneDemo.class differ diff --git a/BasicJava_2018/TimeZoneDemo_useDaylightTime/TimeZoneDemo/src/TimeZoneDemo.java b/BasicJava_2018/TimeZoneDemo_useDaylightTime/TimeZoneDemo/src/TimeZoneDemo.java new file mode 100644 index 000000000..c0a1ed31f --- /dev/null +++ b/BasicJava_2018/TimeZoneDemo_useDaylightTime/TimeZoneDemo/src/TimeZoneDemo.java @@ -0,0 +1,19 @@ +import java.util.TimeZone; + +public class TimeZoneDemo +{ + public static void main(String[] args) + { + TimeZone timeZone = TimeZone.getTimeZone("America/Los_Angeles"); + System.out.println(timeZone); + + /* + * Returns: + * + * true if this TimeZone uses Daylight Saving Time, false, + * otherwise. + */ + boolean result = timeZone.useDaylightTime(); + System.out.println(result); + } +} diff --git a/BasicJava_2018/TimestampDemo_Create/Output.txt b/BasicJava_2018/TimestampDemo_Create/Output.txt new file mode 100644 index 000000000..54a19a620 --- /dev/null +++ b/BasicJava_2018/TimestampDemo_Create/Output.txt @@ -0,0 +1,2 @@ +2018-11-07 09:26:20.266 +2018-11-07 09:26:39.52 diff --git a/BasicJava_2018/TimestampDemo_Create/TimestampDemo/.classpath b/BasicJava_2018/TimestampDemo_Create/TimestampDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/TimestampDemo_Create/TimestampDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/TimestampDemo_Create/TimestampDemo/.project b/BasicJava_2018/TimestampDemo_Create/TimestampDemo/.project new file mode 100644 index 000000000..765985f43 --- /dev/null +++ b/BasicJava_2018/TimestampDemo_Create/TimestampDemo/.project @@ -0,0 +1,17 @@ + + + TimestampDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/TimestampDemo_Create/TimestampDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/TimestampDemo_Create/TimestampDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/TimestampDemo_Create/TimestampDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/TimestampDemo_Create/TimestampDemo/bin/TimestampDemo.class b/BasicJava_2018/TimestampDemo_Create/TimestampDemo/bin/TimestampDemo.class new file mode 100644 index 000000000..a186bd976 Binary files /dev/null and b/BasicJava_2018/TimestampDemo_Create/TimestampDemo/bin/TimestampDemo.class differ diff --git a/BasicJava_2018/TimestampDemo_Create/TimestampDemo/src/TimestampDemo.java b/BasicJava_2018/TimestampDemo_Create/TimestampDemo/src/TimestampDemo.java new file mode 100644 index 000000000..41bb29941 --- /dev/null +++ b/BasicJava_2018/TimestampDemo_Create/TimestampDemo/src/TimestampDemo.java @@ -0,0 +1,23 @@ +import java.sql.Timestamp; +import java.util.Date; + +public class TimestampDemo +{ + + public static void main(String[] args) + { + + // method 1 + long millis = System.currentTimeMillis(); + Timestamp timestamp = new Timestamp(millis); + System.out.println(timestamp); + + // method 2 - via Date + Date date = new Date(); + millis = date.getTime(); + timestamp = new Timestamp(millis); + System.out.println(timestamp); + + } + +} diff --git a/BasicJava_2018/TimestampDemo_Intro/Output.txt b/BasicJava_2018/TimestampDemo_Intro/Output.txt new file mode 100644 index 000000000..ed2b20045 --- /dev/null +++ b/BasicJava_2018/TimestampDemo_Intro/Output.txt @@ -0,0 +1 @@ +2018-11-03 11:04:10.96 diff --git a/BasicJava_2018/TimestampDemo_Intro/TimestampDemo/.classpath b/BasicJava_2018/TimestampDemo_Intro/TimestampDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/TimestampDemo_Intro/TimestampDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/TimestampDemo_Intro/TimestampDemo/.project b/BasicJava_2018/TimestampDemo_Intro/TimestampDemo/.project new file mode 100644 index 000000000..765985f43 --- /dev/null +++ b/BasicJava_2018/TimestampDemo_Intro/TimestampDemo/.project @@ -0,0 +1,17 @@ + + + TimestampDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/TimestampDemo_Intro/TimestampDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/TimestampDemo_Intro/TimestampDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/TimestampDemo_Intro/TimestampDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/TimestampDemo_Intro/TimestampDemo/bin/TimestampDemo.class b/BasicJava_2018/TimestampDemo_Intro/TimestampDemo/bin/TimestampDemo.class new file mode 100644 index 000000000..935e07dd7 Binary files /dev/null and b/BasicJava_2018/TimestampDemo_Intro/TimestampDemo/bin/TimestampDemo.class differ diff --git a/BasicJava_2018/TimestampDemo_Intro/TimestampDemo/src/TimestampDemo.java b/BasicJava_2018/TimestampDemo_Intro/TimestampDemo/src/TimestampDemo.java new file mode 100644 index 000000000..c56da529f --- /dev/null +++ b/BasicJava_2018/TimestampDemo_Intro/TimestampDemo/src/TimestampDemo.java @@ -0,0 +1,25 @@ +import java.sql.Timestamp; + +public class TimestampDemo +{ + public static void main(String[] args) + { + long millisecond = System.currentTimeMillis(); + + /* + * Constructs a Timestamp object using a milliseconds time + * value. The integral seconds are stored in the underlying + * date value; the fractional seconds are stored in the nanos + * field of the Timestamp object. + * + * Parameters: + * + * time - milliseconds since January 1, 1970, 00:00:00 GMT. A + * negative number is the number of milliseconds before + * January 1, 1970, 00:00:00 GMT. + */ + Timestamp timestamp = new Timestamp(millisecond); + System.out.println(timestamp); + } + +} diff --git a/BasicJava_2018/TimestampDemo_format/Output.txt b/BasicJava_2018/TimestampDemo_format/Output.txt new file mode 100644 index 000000000..0c32277c1 --- /dev/null +++ b/BasicJava_2018/TimestampDemo_format/Output.txt @@ -0,0 +1,2 @@ +2018-11-07 09:38:42.398 +07/11/2018 09.38.42 diff --git a/BasicJava_2018/TimestampDemo_format/TimestampDemo/.classpath b/BasicJava_2018/TimestampDemo_format/TimestampDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/TimestampDemo_format/TimestampDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/TimestampDemo_format/TimestampDemo/.project b/BasicJava_2018/TimestampDemo_format/TimestampDemo/.project new file mode 100644 index 000000000..765985f43 --- /dev/null +++ b/BasicJava_2018/TimestampDemo_format/TimestampDemo/.project @@ -0,0 +1,17 @@ + + + TimestampDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/TimestampDemo_format/TimestampDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/TimestampDemo_format/TimestampDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/TimestampDemo_format/TimestampDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/TimestampDemo_format/TimestampDemo/bin/TimestampDemo.class b/BasicJava_2018/TimestampDemo_format/TimestampDemo/bin/TimestampDemo.class new file mode 100644 index 000000000..3593cfba1 Binary files /dev/null and b/BasicJava_2018/TimestampDemo_format/TimestampDemo/bin/TimestampDemo.class differ diff --git a/BasicJava_2018/TimestampDemo_format/TimestampDemo/src/TimestampDemo.java b/BasicJava_2018/TimestampDemo_format/TimestampDemo/src/TimestampDemo.java new file mode 100644 index 000000000..74517220d --- /dev/null +++ b/BasicJava_2018/TimestampDemo_format/TimestampDemo/src/TimestampDemo.java @@ -0,0 +1,30 @@ +import java.sql.Timestamp; +import java.text.SimpleDateFormat; + +public class TimestampDemo +{ + + public static void main(String[] args) + { + + long millis = System.currentTimeMillis(); + Timestamp timestamp = new Timestamp(millis); + System.out.println(timestamp); + + SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH.mm.ss"); + + /* + * Parameters: + * + * date - the time value to be formatted into a time string. + * + * Returns: + * + * the formatted time string. + */ + String formatedStrDate = sdf.format(timestamp); + System.out.println(formatedStrDate); + + } + +} diff --git a/BasicJava_2018/TimestampDemo_from/Output.txt b/BasicJava_2018/TimestampDemo_from/Output.txt new file mode 100644 index 000000000..7070f1396 --- /dev/null +++ b/BasicJava_2018/TimestampDemo_from/Output.txt @@ -0,0 +1,2 @@ +instant = 2018-11-25T02:54:24.089Z +timestamp = 2018-11-25 08:24:24.089 diff --git a/BasicJava_2018/TimestampDemo_from/TimestampDemo/.classpath b/BasicJava_2018/TimestampDemo_from/TimestampDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/TimestampDemo_from/TimestampDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/TimestampDemo_from/TimestampDemo/.project b/BasicJava_2018/TimestampDemo_from/TimestampDemo/.project new file mode 100644 index 000000000..765985f43 --- /dev/null +++ b/BasicJava_2018/TimestampDemo_from/TimestampDemo/.project @@ -0,0 +1,17 @@ + + + TimestampDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/TimestampDemo_from/TimestampDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/TimestampDemo_from/TimestampDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/TimestampDemo_from/TimestampDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/TimestampDemo_from/TimestampDemo/bin/TimestampDemo.class b/BasicJava_2018/TimestampDemo_from/TimestampDemo/bin/TimestampDemo.class new file mode 100644 index 000000000..6ba3f053e Binary files /dev/null and b/BasicJava_2018/TimestampDemo_from/TimestampDemo/bin/TimestampDemo.class differ diff --git a/BasicJava_2018/TimestampDemo_from/TimestampDemo/src/TimestampDemo.java b/BasicJava_2018/TimestampDemo_from/TimestampDemo/src/TimestampDemo.java new file mode 100644 index 000000000..63d19575b --- /dev/null +++ b/BasicJava_2018/TimestampDemo_from/TimestampDemo/src/TimestampDemo.java @@ -0,0 +1,27 @@ +import java.sql.Timestamp; +import java.time.Instant; + +public class TimestampDemo +{ + + public static void main(String[] args) + { + + Instant instant = Instant.now(); + System.out.println("instant = "+ instant); + + /* + * Parameters: + * + * instant - the instant to convert + * + * Returns: + * + * an Timestamp representing the same point on the time-line + * as the provided instant + */ + Timestamp timestamp = Timestamp.from(instant); + System.out.println("timestamp = "+timestamp); + } + +} diff --git a/BasicJava_2018/TimestampDemo_getTime_nanos/Output.txt b/BasicJava_2018/TimestampDemo_getTime_nanos/Output.txt new file mode 100644 index 000000000..39419efb7 --- /dev/null +++ b/BasicJava_2018/TimestampDemo_getTime_nanos/Output.txt @@ -0,0 +1,3 @@ +2018-11-09 09:51:20.999 +milliseconds = 1541737280999 +nanoseconds = 999000000 diff --git a/BasicJava_2018/TimestampDemo_getTime_nanos/TimestampDemo/.classpath b/BasicJava_2018/TimestampDemo_getTime_nanos/TimestampDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/TimestampDemo_getTime_nanos/TimestampDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/TimestampDemo_getTime_nanos/TimestampDemo/.project b/BasicJava_2018/TimestampDemo_getTime_nanos/TimestampDemo/.project new file mode 100644 index 000000000..765985f43 --- /dev/null +++ b/BasicJava_2018/TimestampDemo_getTime_nanos/TimestampDemo/.project @@ -0,0 +1,17 @@ + + + TimestampDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/TimestampDemo_getTime_nanos/TimestampDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/TimestampDemo_getTime_nanos/TimestampDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/TimestampDemo_getTime_nanos/TimestampDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/TimestampDemo_getTime_nanos/TimestampDemo/bin/TimestampDemo.class b/BasicJava_2018/TimestampDemo_getTime_nanos/TimestampDemo/bin/TimestampDemo.class new file mode 100644 index 000000000..5f8d9c88a Binary files /dev/null and b/BasicJava_2018/TimestampDemo_getTime_nanos/TimestampDemo/bin/TimestampDemo.class differ diff --git a/BasicJava_2018/TimestampDemo_getTime_nanos/TimestampDemo/src/TimestampDemo.java b/BasicJava_2018/TimestampDemo_getTime_nanos/TimestampDemo/src/TimestampDemo.java new file mode 100644 index 000000000..29714a966 --- /dev/null +++ b/BasicJava_2018/TimestampDemo_getTime_nanos/TimestampDemo/src/TimestampDemo.java @@ -0,0 +1,26 @@ +import java.sql.Timestamp; + +public class TimestampDemo +{ + + public static void main(String[] args) + { + long millis = System.currentTimeMillis(); + Timestamp timestamp = new Timestamp(millis); + System.out.println(timestamp); + + /* + * Returns:the number of milliseconds since January 1, 1970, + * 00:00:00 GMT represented by this date. + */ + long milliseconds = timestamp.getTime(); + System.out.println("milliseconds = " + milliseconds); + + /* + * Gets this Timestamp object's nanos value. + */ + long nanoseconds = timestamp.getNanos(); + System.out.println("nanoseconds = " + nanoseconds); + } + +} diff --git a/BasicJava_2018/TimestampDemo_settime_nanos/Output.txt b/BasicJava_2018/TimestampDemo_settime_nanos/Output.txt new file mode 100644 index 000000000..30dfb3d6c --- /dev/null +++ b/BasicJava_2018/TimestampDemo_settime_nanos/Output.txt @@ -0,0 +1,3 @@ +2018-01-23 19:09:58.743 +2018-11-25 08:33:21.444 +2018-11-25 08:33:21.000000003 diff --git a/BasicJava_2018/TimestampDemo_settime_nanos/TimestampDemo/.classpath b/BasicJava_2018/TimestampDemo_settime_nanos/TimestampDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/TimestampDemo_settime_nanos/TimestampDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/TimestampDemo_settime_nanos/TimestampDemo/.project b/BasicJava_2018/TimestampDemo_settime_nanos/TimestampDemo/.project new file mode 100644 index 000000000..765985f43 --- /dev/null +++ b/BasicJava_2018/TimestampDemo_settime_nanos/TimestampDemo/.project @@ -0,0 +1,17 @@ + + + TimestampDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/TimestampDemo_settime_nanos/TimestampDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/TimestampDemo_settime_nanos/TimestampDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/TimestampDemo_settime_nanos/TimestampDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/TimestampDemo_settime_nanos/TimestampDemo/bin/TimestampDemo.class b/BasicJava_2018/TimestampDemo_settime_nanos/TimestampDemo/bin/TimestampDemo.class new file mode 100644 index 000000000..8089f29f9 Binary files /dev/null and b/BasicJava_2018/TimestampDemo_settime_nanos/TimestampDemo/bin/TimestampDemo.class differ diff --git a/BasicJava_2018/TimestampDemo_settime_nanos/TimestampDemo/src/TimestampDemo.java b/BasicJava_2018/TimestampDemo_settime_nanos/TimestampDemo/src/TimestampDemo.java new file mode 100644 index 000000000..e35372981 --- /dev/null +++ b/BasicJava_2018/TimestampDemo_settime_nanos/TimestampDemo/src/TimestampDemo.java @@ -0,0 +1,31 @@ +import java.sql.Timestamp; + +public class TimestampDemo +{ + + public static void main(String[] args) + { + + Timestamp timestamp = Timestamp.valueOf("2018-01-23 19:09:58.743"); + System.out.println(timestamp); + + long time = System.currentTimeMillis(); + + /* + * Parameters: + * + * time - the number of milliseconds. + */ + timestamp.setTime(time); + System.out.println(timestamp); + + /* + * Parameters: + * + * n - the new fractional seconds component + */ + timestamp.setNanos(3); + System.out.println(timestamp); + } + +} diff --git a/BasicJava_2018/TimestampDemo_toInstant/Output.txt b/BasicJava_2018/TimestampDemo_toInstant/Output.txt new file mode 100644 index 000000000..95b290bca --- /dev/null +++ b/BasicJava_2018/TimestampDemo_toInstant/Output.txt @@ -0,0 +1,3 @@ +timestamp = 2018-11-12 10:14:13.501 +instant = 2018-11-12T04:44:13.501Z +localDateTime = 2018-11-12T10:14:13.501 diff --git a/BasicJava_2018/TimestampDemo_toInstant/TimestampDemo/.classpath b/BasicJava_2018/TimestampDemo_toInstant/TimestampDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/TimestampDemo_toInstant/TimestampDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/TimestampDemo_toInstant/TimestampDemo/.project b/BasicJava_2018/TimestampDemo_toInstant/TimestampDemo/.project new file mode 100644 index 000000000..765985f43 --- /dev/null +++ b/BasicJava_2018/TimestampDemo_toInstant/TimestampDemo/.project @@ -0,0 +1,17 @@ + + + TimestampDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/TimestampDemo_toInstant/TimestampDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/TimestampDemo_toInstant/TimestampDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/TimestampDemo_toInstant/TimestampDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/TimestampDemo_toInstant/TimestampDemo/bin/TimestampDemo.class b/BasicJava_2018/TimestampDemo_toInstant/TimestampDemo/bin/TimestampDemo.class new file mode 100644 index 000000000..8d6e5e324 Binary files /dev/null and b/BasicJava_2018/TimestampDemo_toInstant/TimestampDemo/bin/TimestampDemo.class differ diff --git a/BasicJava_2018/TimestampDemo_toInstant/TimestampDemo/src/TimestampDemo.java b/BasicJava_2018/TimestampDemo_toInstant/TimestampDemo/src/TimestampDemo.java new file mode 100644 index 000000000..e121f3eda --- /dev/null +++ b/BasicJava_2018/TimestampDemo_toInstant/TimestampDemo/src/TimestampDemo.java @@ -0,0 +1,29 @@ +import java.sql.Timestamp; +import java.time.Instant; +import java.time.LocalDateTime; + +public class TimestampDemo +{ + + public static void main(String[] args) + { + + long millis = System.currentTimeMillis(); + Timestamp timestamp = new Timestamp(millis); + System.out.println("timestamp = "+timestamp); + + /* + * Converts this Timestamp object to an Instant. + */ + Instant instant = timestamp.toInstant(); + System.out.println("instant = "+instant); + + /* + * Converts this Timestamp object to a LocalDateTime. + */ + LocalDateTime localDateTime = timestamp.toLocalDateTime(); + System.out.println("localDateTime = "+localDateTime); + + } + +} diff --git a/BasicJava_2018/TimestampDemo_valueOf_methods/Output.txt b/BasicJava_2018/TimestampDemo_valueOf_methods/Output.txt new file mode 100644 index 000000000..9586340fa --- /dev/null +++ b/BasicJava_2018/TimestampDemo_valueOf_methods/Output.txt @@ -0,0 +1,3 @@ +localDateTime = 2018-11-13T09:59:07.900 +2018-11-13 09:59:07.9 +2013-01-23 19:09:58.743 diff --git a/BasicJava_2018/TimestampDemo_valueOf_methods/TimestampDemo/.classpath b/BasicJava_2018/TimestampDemo_valueOf_methods/TimestampDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/TimestampDemo_valueOf_methods/TimestampDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/TimestampDemo_valueOf_methods/TimestampDemo/.project b/BasicJava_2018/TimestampDemo_valueOf_methods/TimestampDemo/.project new file mode 100644 index 000000000..765985f43 --- /dev/null +++ b/BasicJava_2018/TimestampDemo_valueOf_methods/TimestampDemo/.project @@ -0,0 +1,17 @@ + + + TimestampDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/TimestampDemo_valueOf_methods/TimestampDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/TimestampDemo_valueOf_methods/TimestampDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/TimestampDemo_valueOf_methods/TimestampDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/TimestampDemo_valueOf_methods/TimestampDemo/bin/TimestampDemo.class b/BasicJava_2018/TimestampDemo_valueOf_methods/TimestampDemo/bin/TimestampDemo.class new file mode 100644 index 000000000..335914e04 Binary files /dev/null and b/BasicJava_2018/TimestampDemo_valueOf_methods/TimestampDemo/bin/TimestampDemo.class differ diff --git a/BasicJava_2018/TimestampDemo_valueOf_methods/TimestampDemo/src/TimestampDemo.java b/BasicJava_2018/TimestampDemo_valueOf_methods/TimestampDemo/src/TimestampDemo.java new file mode 100644 index 000000000..80c20fc72 --- /dev/null +++ b/BasicJava_2018/TimestampDemo_valueOf_methods/TimestampDemo/src/TimestampDemo.java @@ -0,0 +1,37 @@ +import java.sql.Timestamp; +import java.time.LocalDateTime; + +public class TimestampDemo +{ + + public static void main(String[] args) + { + + LocalDateTime localDateTime = LocalDateTime.now(); + System.out.println("localDateTime = " + localDateTime); + + /* + * Obtains an instance of Timestamp from a LocalDateTime + * object, with the same year, month, day of month, hours, + * minutes, seconds and nanos date-time value as the provided + * LocalDateTime + */ + Timestamp timestamp = Timestamp.valueOf(localDateTime); + System.out.println(timestamp); + + /* + * Parameters: + * + * s - timestamp in format yyyy-[m]m-[d]d hh:mm:ss[.f...]. The + * fractional seconds may be omitted. The leading zero for mm + * and dd may also be omitted. + * + * Returns: + * + * corresponding Timestamp value + */ + timestamp = Timestamp.valueOf("2013-01-23 19:09:58.743"); + System.out.println(timestamp); + } + +} diff --git a/BasicJava_2018/YearDemo_at_methods/YearDemo/.classpath b/BasicJava_2018/YearDemo_at_methods/YearDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearDemo_at_methods/YearDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearDemo_at_methods/YearDemo/.project b/BasicJava_2018/YearDemo_at_methods/YearDemo/.project new file mode 100644 index 000000000..1da24220d --- /dev/null +++ b/BasicJava_2018/YearDemo_at_methods/YearDemo/.project @@ -0,0 +1,17 @@ + + + YearDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearDemo_at_methods/YearDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearDemo_at_methods/YearDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearDemo_at_methods/YearDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearDemo_at_methods/YearDemo/bin/YearDemo1.class b/BasicJava_2018/YearDemo_at_methods/YearDemo/bin/YearDemo1.class new file mode 100644 index 000000000..52cfc5aae Binary files /dev/null and b/BasicJava_2018/YearDemo_at_methods/YearDemo/bin/YearDemo1.class differ diff --git a/BasicJava_2018/YearDemo_at_methods/YearDemo/bin/YearDemo2.class b/BasicJava_2018/YearDemo_at_methods/YearDemo/bin/YearDemo2.class new file mode 100644 index 000000000..114100c42 Binary files /dev/null and b/BasicJava_2018/YearDemo_at_methods/YearDemo/bin/YearDemo2.class differ diff --git a/BasicJava_2018/YearDemo_at_methods/YearDemo/bin/YearDemo3.class b/BasicJava_2018/YearDemo_at_methods/YearDemo/bin/YearDemo3.class new file mode 100644 index 000000000..74ff5376f Binary files /dev/null and b/BasicJava_2018/YearDemo_at_methods/YearDemo/bin/YearDemo3.class differ diff --git a/BasicJava_2018/YearDemo_at_methods/YearDemo/src/YearDemo1.java b/BasicJava_2018/YearDemo_at_methods/YearDemo/src/YearDemo1.java new file mode 100644 index 000000000..6bda12f4e --- /dev/null +++ b/BasicJava_2018/YearDemo_at_methods/YearDemo/src/YearDemo1.java @@ -0,0 +1,41 @@ +import java.time.LocalDate; +import java.time.Year; +import java.time.YearMonth; + +public class YearDemo1 +{ + + public static void main(String[] args) + { + + Year year = Year.of(2017); + /* + * Parameters: + * + * dayOfYear - the day-of-year to use, from 1 to 365-366 + * + * Returns: + * + * the local date formed from this year and the specified date + * of year, not null + */ + LocalDate localDate = year.atDay(300); + System.out.println(localDate); + + /* + * Parameters: + * + * month - the month-of-year to use, from 1 (January) to 12 + * (December) + * + * Returns: + * + * the year-month formed from this year and the specified + * month, not null + */ + YearMonth yearMonth = year.atMonth(2); + System.out.println(yearMonth); + + } + +} diff --git a/BasicJava_2018/YearDemo_at_methods/YearDemo/src/YearDemo2.java b/BasicJava_2018/YearDemo_at_methods/YearDemo/src/YearDemo2.java new file mode 100644 index 000000000..5958d11dc --- /dev/null +++ b/BasicJava_2018/YearDemo_at_methods/YearDemo/src/YearDemo2.java @@ -0,0 +1,31 @@ +import java.time.LocalDate; +import java.time.Month; +import java.time.MonthDay; +import java.time.Year; + +public class YearDemo2 +{ + + public static void main(String[] args) + { + Year year = Year.of(2017); + System.out.println("year = "+year); + + MonthDay monthDay = MonthDay.of(Month.MARCH, 29); + System.out.println("monthDay = "+monthDay); + + /* + * Parameters: + * + * monthDay - the month-day to use, not null + * + * Returns: + * + * the local date formed from this year and the specified + * month-day, not null + */ + LocalDate localDate = year.atMonthDay(monthDay); + System.out.println(localDate); + } + +} diff --git a/BasicJava_2018/YearDemo_at_methods/YearDemo/src/YearDemo3.java b/BasicJava_2018/YearDemo_at_methods/YearDemo/src/YearDemo3.java new file mode 100644 index 000000000..b958b6877 --- /dev/null +++ b/BasicJava_2018/YearDemo_at_methods/YearDemo/src/YearDemo3.java @@ -0,0 +1,28 @@ +import java.time.Month; +import java.time.Year; +import java.time.YearMonth; + +public class YearDemo3 +{ + + public static void main(String[] args) + { + Year year = Year.of(2017); + + /* + * Parameters: + * + * month - the month-of-year to use, not null + * + * Returns: + * + * the year-month formed from this year and the specified + * month, not null + */ + + YearMonth yearMonth = year.atMonth(Month.JANUARY); + System.out.println(yearMonth); + + } + +} diff --git a/BasicJava_2018/YearDemo_at_methods/YearDemo1_Output.txt b/BasicJava_2018/YearDemo_at_methods/YearDemo1_Output.txt new file mode 100644 index 000000000..dcb9409b5 --- /dev/null +++ b/BasicJava_2018/YearDemo_at_methods/YearDemo1_Output.txt @@ -0,0 +1,2 @@ +2017-10-27 +2017-02 diff --git a/BasicJava_2018/YearDemo_at_methods/YearDemo2_Output.txt b/BasicJava_2018/YearDemo_at_methods/YearDemo2_Output.txt new file mode 100644 index 000000000..0632db8ca --- /dev/null +++ b/BasicJava_2018/YearDemo_at_methods/YearDemo2_Output.txt @@ -0,0 +1,3 @@ +year = 2017 +monthDay = --03-29 +2017-03-29 diff --git a/BasicJava_2018/YearDemo_at_methods/YearDemo3_Output.txt b/BasicJava_2018/YearDemo_at_methods/YearDemo3_Output.txt new file mode 100644 index 000000000..f36f8393c --- /dev/null +++ b/BasicJava_2018/YearDemo_at_methods/YearDemo3_Output.txt @@ -0,0 +1 @@ +2017-01 diff --git a/BasicJava_2018/YearDemo_equals_compareto/Output.txt b/BasicJava_2018/YearDemo_equals_compareto/Output.txt new file mode 100644 index 000000000..d6f7800e0 --- /dev/null +++ b/BasicJava_2018/YearDemo_equals_compareto/Output.txt @@ -0,0 +1,4 @@ +year1 = 2014 +year2 = 2018 +2014 is equal to 2018 = false +2014 compare to 2018 = -4 diff --git a/BasicJava_2018/YearDemo_equals_compareto/YearDemo/.classpath b/BasicJava_2018/YearDemo_equals_compareto/YearDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearDemo_equals_compareto/YearDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearDemo_equals_compareto/YearDemo/.project b/BasicJava_2018/YearDemo_equals_compareto/YearDemo/.project new file mode 100644 index 000000000..1da24220d --- /dev/null +++ b/BasicJava_2018/YearDemo_equals_compareto/YearDemo/.project @@ -0,0 +1,17 @@ + + + YearDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearDemo_equals_compareto/YearDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearDemo_equals_compareto/YearDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearDemo_equals_compareto/YearDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearDemo_equals_compareto/YearDemo/bin/YearDemo.class b/BasicJava_2018/YearDemo_equals_compareto/YearDemo/bin/YearDemo.class new file mode 100644 index 000000000..46a94e157 Binary files /dev/null and b/BasicJava_2018/YearDemo_equals_compareto/YearDemo/bin/YearDemo.class differ diff --git a/BasicJava_2018/YearDemo_equals_compareto/YearDemo/src/YearDemo.java b/BasicJava_2018/YearDemo_equals_compareto/YearDemo/src/YearDemo.java new file mode 100644 index 000000000..9c0566f3b --- /dev/null +++ b/BasicJava_2018/YearDemo_equals_compareto/YearDemo/src/YearDemo.java @@ -0,0 +1,40 @@ +import java.time.Year; + +public class YearDemo +{ + + public static void main(String[] args) + { + Year year1 = Year.of(2014); + System.out.println("year1 = "+year1); + + Year year2 = Year.of(2018); + System.out.println("year2 = "+year2); + + /* + * Parameters: + * + * obj - the object to check, null returns false + * + * Returns: + * + * true if this is equal to the other year + */ + boolean isEqual = year1.equals(year2); + System.out.println(year1+" is equal to "+year2+" = "+isEqual); + + /* + * Parameters: + * + * other - the other year to compare to, not null + * + * Returns: + * + * the comparator value, negative if less, positive if greater + */ + + int result = year1.compareTo(year2); + System.out.println(year1+" compare to "+year2+" = "+result); + } + +} diff --git a/BasicJava_2018/YearDemo_from/Output.txt b/BasicJava_2018/YearDemo_from/Output.txt new file mode 100644 index 000000000..949ff47d4 --- /dev/null +++ b/BasicJava_2018/YearDemo_from/Output.txt @@ -0,0 +1,2 @@ +2018-02-25 +2018 diff --git a/BasicJava_2018/YearDemo_from/YearDemo/.classpath b/BasicJava_2018/YearDemo_from/YearDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearDemo_from/YearDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearDemo_from/YearDemo/.project b/BasicJava_2018/YearDemo_from/YearDemo/.project new file mode 100644 index 000000000..1da24220d --- /dev/null +++ b/BasicJava_2018/YearDemo_from/YearDemo/.project @@ -0,0 +1,17 @@ + + + YearDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearDemo_from/YearDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearDemo_from/YearDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearDemo_from/YearDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearDemo_from/YearDemo/bin/YearDemo.class b/BasicJava_2018/YearDemo_from/YearDemo/bin/YearDemo.class new file mode 100644 index 000000000..13f46b489 Binary files /dev/null and b/BasicJava_2018/YearDemo_from/YearDemo/bin/YearDemo.class differ diff --git a/BasicJava_2018/YearDemo_from/YearDemo/src/YearDemo.java b/BasicJava_2018/YearDemo_from/YearDemo/src/YearDemo.java new file mode 100644 index 000000000..2b44842d8 --- /dev/null +++ b/BasicJava_2018/YearDemo_from/YearDemo/src/YearDemo.java @@ -0,0 +1,27 @@ +import java.time.LocalDate; +import java.time.Year; + +public class YearDemo +{ + + public static void main(String[] args) + { + + LocalDate localDate = LocalDate.now(); + System.out.println(localDate); + + /* + * Parameters: + * + * temporal - the temporal object to convert, not null + * + * Returns: + * + * the year, not null + */ + Year year = Year.from(localDate); + System.out.println(year); + + } + +} diff --git a/BasicJava_2018/YearDemo_get_field/Output.txt b/BasicJava_2018/YearDemo_get_field/Output.txt new file mode 100644 index 000000000..9e738ea31 --- /dev/null +++ b/BasicJava_2018/YearDemo_get_field/Output.txt @@ -0,0 +1,2 @@ +2017 +2017 diff --git a/BasicJava_2018/YearDemo_get_field/YearDemo/.classpath b/BasicJava_2018/YearDemo_get_field/YearDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearDemo_get_field/YearDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearDemo_get_field/YearDemo/.project b/BasicJava_2018/YearDemo_get_field/YearDemo/.project new file mode 100644 index 000000000..1da24220d --- /dev/null +++ b/BasicJava_2018/YearDemo_get_field/YearDemo/.project @@ -0,0 +1,17 @@ + + + YearDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearDemo_get_field/YearDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearDemo_get_field/YearDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearDemo_get_field/YearDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearDemo_get_field/YearDemo/bin/YearDemo.class b/BasicJava_2018/YearDemo_get_field/YearDemo/bin/YearDemo.class new file mode 100644 index 000000000..ff3f0ca1a Binary files /dev/null and b/BasicJava_2018/YearDemo_get_field/YearDemo/bin/YearDemo.class differ diff --git a/BasicJava_2018/YearDemo_get_field/YearDemo/src/YearDemo.java b/BasicJava_2018/YearDemo_get_field/YearDemo/src/YearDemo.java new file mode 100644 index 000000000..3748991a6 --- /dev/null +++ b/BasicJava_2018/YearDemo_get_field/YearDemo/src/YearDemo.java @@ -0,0 +1,39 @@ +import java.time.Year; +import java.time.temporal.ChronoField; + +public class YearDemo +{ + + public static void main(String[] args) + { + + Year year = Year.of(2017); + + /* + * Parameters: + * + * field - the field to get, not null + * + * Returns: + * + * the value for the field + */ + + int yearValue1 = year.get(ChronoField.YEAR); + System.out.println(yearValue1); + + /* + * Parameters: + * + * field - the field to get, not null + * + * Returns: + * + * the value for the field + */ + long yearValue2 = year.getLong(ChronoField.YEAR); + System.out.println(yearValue2); + + } + +} diff --git a/BasicJava_2018/YearDemo_intro/YearDemo/.classpath b/BasicJava_2018/YearDemo_intro/YearDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearDemo_intro/YearDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearDemo_intro/YearDemo/.project b/BasicJava_2018/YearDemo_intro/YearDemo/.project new file mode 100644 index 000000000..1da24220d --- /dev/null +++ b/BasicJava_2018/YearDemo_intro/YearDemo/.project @@ -0,0 +1,17 @@ + + + YearDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearDemo_intro/YearDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearDemo_intro/YearDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearDemo_intro/YearDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearDemo_intro/YearDemo/bin/YearDemo1.class b/BasicJava_2018/YearDemo_intro/YearDemo/bin/YearDemo1.class new file mode 100644 index 000000000..edc787550 Binary files /dev/null and b/BasicJava_2018/YearDemo_intro/YearDemo/bin/YearDemo1.class differ diff --git a/BasicJava_2018/YearDemo_intro/YearDemo/bin/YearDemo2.class b/BasicJava_2018/YearDemo_intro/YearDemo/bin/YearDemo2.class new file mode 100644 index 000000000..6b1b8e2c5 Binary files /dev/null and b/BasicJava_2018/YearDemo_intro/YearDemo/bin/YearDemo2.class differ diff --git a/BasicJava_2018/YearDemo_intro/YearDemo/src/YearDemo1.java b/BasicJava_2018/YearDemo_intro/YearDemo/src/YearDemo1.java new file mode 100644 index 000000000..537bbda55 --- /dev/null +++ b/BasicJava_2018/YearDemo_intro/YearDemo/src/YearDemo1.java @@ -0,0 +1,18 @@ +import java.time.Year; + +public class YearDemo1 +{ + + public static void main(String[] args) + { + /* + * Returns: + * + * the current year using the system clock and default + * time-zone, not null + */ + Year year = Year.now(); + System.out.println(year); + } + +} diff --git a/BasicJava_2018/YearDemo_intro/YearDemo/src/YearDemo2.java b/BasicJava_2018/YearDemo_intro/YearDemo/src/YearDemo2.java new file mode 100644 index 000000000..f6e244afb --- /dev/null +++ b/BasicJava_2018/YearDemo_intro/YearDemo/src/YearDemo2.java @@ -0,0 +1,21 @@ +import java.time.Year; + +public class YearDemo2 +{ + + public static void main(String[] args) + { + /* + * The minimum supported year + */ + int minYear = Year.MIN_VALUE; + System.out.println("Minimum supported year = "+minYear); + + /* + * The maximum supported year + */ + int maxYear = Year.MAX_VALUE; + System.out.println("Maximum supported year = "+maxYear); + } + +} diff --git a/BasicJava_2018/YearDemo_intro/YearDemo1_Output.txt b/BasicJava_2018/YearDemo_intro/YearDemo1_Output.txt new file mode 100644 index 000000000..b39a36a7c --- /dev/null +++ b/BasicJava_2018/YearDemo_intro/YearDemo1_Output.txt @@ -0,0 +1 @@ +2018 diff --git a/BasicJava_2018/YearDemo_intro/YearDemo2_Output.txt b/BasicJava_2018/YearDemo_intro/YearDemo2_Output.txt new file mode 100644 index 000000000..740213a58 --- /dev/null +++ b/BasicJava_2018/YearDemo_intro/YearDemo2_Output.txt @@ -0,0 +1,2 @@ +Minimum supported year = -999999999 +Maximum supported year = 999999999 diff --git a/BasicJava_2018/YearDemo_isAfter_before_getValue/YearDemo/.classpath b/BasicJava_2018/YearDemo_isAfter_before_getValue/YearDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearDemo_isAfter_before_getValue/YearDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearDemo_isAfter_before_getValue/YearDemo/.project b/BasicJava_2018/YearDemo_isAfter_before_getValue/YearDemo/.project new file mode 100644 index 000000000..1da24220d --- /dev/null +++ b/BasicJava_2018/YearDemo_isAfter_before_getValue/YearDemo/.project @@ -0,0 +1,17 @@ + + + YearDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearDemo_isAfter_before_getValue/YearDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearDemo_isAfter_before_getValue/YearDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearDemo_isAfter_before_getValue/YearDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearDemo_isAfter_before_getValue/YearDemo/bin/YearDemo1.class b/BasicJava_2018/YearDemo_isAfter_before_getValue/YearDemo/bin/YearDemo1.class new file mode 100644 index 000000000..75e435b4b Binary files /dev/null and b/BasicJava_2018/YearDemo_isAfter_before_getValue/YearDemo/bin/YearDemo1.class differ diff --git a/BasicJava_2018/YearDemo_isAfter_before_getValue/YearDemo/bin/YearDemo2.class b/BasicJava_2018/YearDemo_isAfter_before_getValue/YearDemo/bin/YearDemo2.class new file mode 100644 index 000000000..ecea00ce4 Binary files /dev/null and b/BasicJava_2018/YearDemo_isAfter_before_getValue/YearDemo/bin/YearDemo2.class differ diff --git a/BasicJava_2018/YearDemo_isAfter_before_getValue/YearDemo/src/YearDemo1.java b/BasicJava_2018/YearDemo_isAfter_before_getValue/YearDemo/src/YearDemo1.java new file mode 100644 index 000000000..d0e2318f1 --- /dev/null +++ b/BasicJava_2018/YearDemo_isAfter_before_getValue/YearDemo/src/YearDemo1.java @@ -0,0 +1,40 @@ +import java.time.Year; + +public class YearDemo1 +{ + + public static void main(String[] args) + { + Year year1 = Year.of(2017); + System.out.println("year1 = "+year1); + + Year year2 = Year.of(2014); + System.out.println("year2 = "+year2); + + /* + * Parameters: + * + * other - the other year to compare to, not null + * + * Returns: + * + * true if this is after the specified year + */ + boolean result = year1.isAfter(year2); + System.out.println(year1+" is after "+year2+" = "+result); + + /* + * Parameters: + * + * other - the other year to compare to, not null + * + * Returns: + * + * true if this point is before the specified year + */ + + result = year1.isBefore(year2); + System.out.println(year1+" is before "+year2+" = "+result); + } + +} diff --git a/BasicJava_2018/YearDemo_isAfter_before_getValue/YearDemo/src/YearDemo2.java b/BasicJava_2018/YearDemo_isAfter_before_getValue/YearDemo/src/YearDemo2.java new file mode 100644 index 000000000..d043c4d72 --- /dev/null +++ b/BasicJava_2018/YearDemo_isAfter_before_getValue/YearDemo/src/YearDemo2.java @@ -0,0 +1,21 @@ +import java.time.Year; + +public class YearDemo2 +{ + + public static void main(String[] args) + { + Year year = Year.of(2017); + + /* + * Returns: + * + * the year, MIN_VALUE to MAX_VALUE + */ + + int yearValue = year.getValue(); + System.out.println(yearValue); + } + + +} diff --git a/BasicJava_2018/YearDemo_isAfter_before_getValue/YearDemo1_Output.txt b/BasicJava_2018/YearDemo_isAfter_before_getValue/YearDemo1_Output.txt new file mode 100644 index 000000000..2cec8f141 --- /dev/null +++ b/BasicJava_2018/YearDemo_isAfter_before_getValue/YearDemo1_Output.txt @@ -0,0 +1,4 @@ +year1 = 2017 +year2 = 2014 +2017 is after 2014 = true +2017 is before 2014 = false diff --git a/BasicJava_2018/YearDemo_isAfter_before_getValue/YearDemo2_Output.txt b/BasicJava_2018/YearDemo_isAfter_before_getValue/YearDemo2_Output.txt new file mode 100644 index 000000000..deaf8236e --- /dev/null +++ b/BasicJava_2018/YearDemo_isAfter_before_getValue/YearDemo2_Output.txt @@ -0,0 +1 @@ +2017 diff --git a/BasicJava_2018/YearDemo_isSupported_field/Output.txt b/BasicJava_2018/YearDemo_isSupported_field/Output.txt new file mode 100644 index 000000000..216ccec64 --- /dev/null +++ b/BasicJava_2018/YearDemo_isSupported_field/Output.txt @@ -0,0 +1,2 @@ +isYearSupported = true +isMonthYearSupported = false diff --git a/BasicJava_2018/YearDemo_isSupported_field/YearDemo/.classpath b/BasicJava_2018/YearDemo_isSupported_field/YearDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearDemo_isSupported_field/YearDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearDemo_isSupported_field/YearDemo/.project b/BasicJava_2018/YearDemo_isSupported_field/YearDemo/.project new file mode 100644 index 000000000..1da24220d --- /dev/null +++ b/BasicJava_2018/YearDemo_isSupported_field/YearDemo/.project @@ -0,0 +1,17 @@ + + + YearDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearDemo_isSupported_field/YearDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearDemo_isSupported_field/YearDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearDemo_isSupported_field/YearDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearDemo_isSupported_field/YearDemo/bin/YearDemo.class b/BasicJava_2018/YearDemo_isSupported_field/YearDemo/bin/YearDemo.class new file mode 100644 index 000000000..3dced0895 Binary files /dev/null and b/BasicJava_2018/YearDemo_isSupported_field/YearDemo/bin/YearDemo.class differ diff --git a/BasicJava_2018/YearDemo_isSupported_field/YearDemo/src/YearDemo.java b/BasicJava_2018/YearDemo_isSupported_field/YearDemo/src/YearDemo.java new file mode 100644 index 000000000..ccd30ee6b --- /dev/null +++ b/BasicJava_2018/YearDemo_isSupported_field/YearDemo/src/YearDemo.java @@ -0,0 +1,29 @@ +import java.time.Year; +import java.time.temporal.ChronoField; + +public class YearDemo +{ + + public static void main(String[] args) + { + + Year year = Year.of(2017); + + /* + * Parameters: + * + * field - the field to check, null returns false + * + * Returns: + * + * true if the field is supported on this year, false if not + */ + boolean isYearSupported = year.isSupported(ChronoField.YEAR); + System.out.println("isYearSupported = "+isYearSupported); + + boolean isMonthYearSupported = year.isSupported(ChronoField.MONTH_OF_YEAR); + System.out.println("isMonthYearSupported = "+isMonthYearSupported); + + } + +} diff --git a/BasicJava_2018/YearDemo_isSupported_unit/Output.txt b/BasicJava_2018/YearDemo_isSupported_unit/Output.txt new file mode 100644 index 000000000..51cc1f90b --- /dev/null +++ b/BasicJava_2018/YearDemo_isSupported_unit/Output.txt @@ -0,0 +1,2 @@ +isYearSupported = true +isDaysSupported = false diff --git a/BasicJava_2018/YearDemo_isSupported_unit/YearDemo/.classpath b/BasicJava_2018/YearDemo_isSupported_unit/YearDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearDemo_isSupported_unit/YearDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearDemo_isSupported_unit/YearDemo/.project b/BasicJava_2018/YearDemo_isSupported_unit/YearDemo/.project new file mode 100644 index 000000000..1da24220d --- /dev/null +++ b/BasicJava_2018/YearDemo_isSupported_unit/YearDemo/.project @@ -0,0 +1,17 @@ + + + YearDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearDemo_isSupported_unit/YearDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearDemo_isSupported_unit/YearDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearDemo_isSupported_unit/YearDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearDemo_isSupported_unit/YearDemo/bin/YearDemo.class b/BasicJava_2018/YearDemo_isSupported_unit/YearDemo/bin/YearDemo.class new file mode 100644 index 000000000..81cc097ba Binary files /dev/null and b/BasicJava_2018/YearDemo_isSupported_unit/YearDemo/bin/YearDemo.class differ diff --git a/BasicJava_2018/YearDemo_isSupported_unit/YearDemo/src/YearDemo.java b/BasicJava_2018/YearDemo_isSupported_unit/YearDemo/src/YearDemo.java new file mode 100644 index 000000000..6abee37ae --- /dev/null +++ b/BasicJava_2018/YearDemo_isSupported_unit/YearDemo/src/YearDemo.java @@ -0,0 +1,29 @@ +import java.time.Year; +import java.time.temporal.ChronoUnit; + +public class YearDemo +{ + + public static void main(String[] args) + { + + Year year = Year.of(2017); + + /* + * Parameters: + * + * unit - the unit to check, null returns false + * + * Returns: + * + * true if the unit can be added/subtracted, false if not + */ + boolean isYearSupported = year.isSupported(ChronoUnit.YEARS); + System.out.println("isYearSupported = " + isYearSupported); + + boolean isDaysSupported = year.isSupported(ChronoUnit.DAYS); + System.out.println("isDaysSupported = " + isDaysSupported); + + } + +} diff --git a/BasicJava_2018/YearDemo_isValidMonthDay/Output.txt b/BasicJava_2018/YearDemo_isValidMonthDay/Output.txt new file mode 100644 index 000000000..e5043fda4 --- /dev/null +++ b/BasicJava_2018/YearDemo_isValidMonthDay/Output.txt @@ -0,0 +1,4 @@ +isValidMonthDay = true +Exception in thread "main" java.time.DateTimeException: Illegal value for DayOfMonth field, value 30 is not valid for month FEBRUARY + at java.time.MonthDay.of(Unknown Source) + at YearDemo.main(YearDemo.java:26) diff --git a/BasicJava_2018/YearDemo_isValidMonthDay/YearDemo/.classpath b/BasicJava_2018/YearDemo_isValidMonthDay/YearDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearDemo_isValidMonthDay/YearDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearDemo_isValidMonthDay/YearDemo/.project b/BasicJava_2018/YearDemo_isValidMonthDay/YearDemo/.project new file mode 100644 index 000000000..1da24220d --- /dev/null +++ b/BasicJava_2018/YearDemo_isValidMonthDay/YearDemo/.project @@ -0,0 +1,17 @@ + + + YearDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearDemo_isValidMonthDay/YearDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearDemo_isValidMonthDay/YearDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearDemo_isValidMonthDay/YearDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearDemo_isValidMonthDay/YearDemo/bin/YearDemo.class b/BasicJava_2018/YearDemo_isValidMonthDay/YearDemo/bin/YearDemo.class new file mode 100644 index 000000000..1829a5e85 Binary files /dev/null and b/BasicJava_2018/YearDemo_isValidMonthDay/YearDemo/bin/YearDemo.class differ diff --git a/BasicJava_2018/YearDemo_isValidMonthDay/YearDemo/src/YearDemo.java b/BasicJava_2018/YearDemo_isValidMonthDay/YearDemo/src/YearDemo.java new file mode 100644 index 000000000..da5a0d43b --- /dev/null +++ b/BasicJava_2018/YearDemo_isValidMonthDay/YearDemo/src/YearDemo.java @@ -0,0 +1,31 @@ +import java.time.Month; +import java.time.MonthDay; +import java.time.Year; + +public class YearDemo +{ + + public static void main(String[] args) + { + + Year year = Year.of(2017); + + /* + * Parameters: + * + * monthDay - the month-day to validate, null returns false + * + * Returns: + * + * true if the month and day are valid for this year + */ + boolean isValidMonthDay = year + .isValidMonthDay(MonthDay.of(Month.FEBRUARY, 1)); + System.out.println("isValidMonthDay = " + isValidMonthDay); + + isValidMonthDay = year.isValidMonthDay(MonthDay.of(Month.FEBRUARY, 30)); + System.out.println("isValidMonthDay = " + isValidMonthDay); + + } + +} diff --git a/BasicJava_2018/YearDemo_leap_length/YearDemo/.classpath b/BasicJava_2018/YearDemo_leap_length/YearDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearDemo_leap_length/YearDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearDemo_leap_length/YearDemo/.project b/BasicJava_2018/YearDemo_leap_length/YearDemo/.project new file mode 100644 index 000000000..1da24220d --- /dev/null +++ b/BasicJava_2018/YearDemo_leap_length/YearDemo/.project @@ -0,0 +1,17 @@ + + + YearDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearDemo_leap_length/YearDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearDemo_leap_length/YearDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearDemo_leap_length/YearDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearDemo_leap_length/YearDemo/bin/YearDemo1.class b/BasicJava_2018/YearDemo_leap_length/YearDemo/bin/YearDemo1.class new file mode 100644 index 000000000..9f43d55ca Binary files /dev/null and b/BasicJava_2018/YearDemo_leap_length/YearDemo/bin/YearDemo1.class differ diff --git a/BasicJava_2018/YearDemo_leap_length/YearDemo/bin/YearDemo2.class b/BasicJava_2018/YearDemo_leap_length/YearDemo/bin/YearDemo2.class new file mode 100644 index 000000000..17612aba1 Binary files /dev/null and b/BasicJava_2018/YearDemo_leap_length/YearDemo/bin/YearDemo2.class differ diff --git a/BasicJava_2018/YearDemo_leap_length/YearDemo/bin/YearDemo3.class b/BasicJava_2018/YearDemo_leap_length/YearDemo/bin/YearDemo3.class new file mode 100644 index 000000000..8be2c5cf1 Binary files /dev/null and b/BasicJava_2018/YearDemo_leap_length/YearDemo/bin/YearDemo3.class differ diff --git a/BasicJava_2018/YearDemo_leap_length/YearDemo/src/YearDemo1.java b/BasicJava_2018/YearDemo_leap_length/YearDemo/src/YearDemo1.java new file mode 100644 index 000000000..50080613c --- /dev/null +++ b/BasicJava_2018/YearDemo_leap_length/YearDemo/src/YearDemo1.java @@ -0,0 +1,20 @@ +import java.time.Year; + +public class YearDemo1 +{ + + public static void main(String[] args) + { + Year year = Year.of(2017); + System.out.println(year); + + /* + * Returns: + * + * true if the year is leap, false otherwise + */ + boolean isLeap = year.isLeap(); + System.out.println(year+ " is a leap year? = " + isLeap); + } + +} diff --git a/BasicJava_2018/YearDemo_leap_length/YearDemo/src/YearDemo2.java b/BasicJava_2018/YearDemo_leap_length/YearDemo/src/YearDemo2.java new file mode 100644 index 000000000..d1ba61672 --- /dev/null +++ b/BasicJava_2018/YearDemo_leap_length/YearDemo/src/YearDemo2.java @@ -0,0 +1,25 @@ +import java.time.Year; + +public class YearDemo2 +{ + + public static void main(String[] args) + { + /* + * Parameters: + * + * year - the year to check + * + * Returns: + * + * true if the year is leap, false otherwise + */ + boolean isLeap = Year.isLeap(2012); + System.out.println("2012 is a Leap year? = " + isLeap); + + isLeap = Year.isLeap(2014); + System.out.println("2014 is a Leap year? = " + isLeap); + } + + +} diff --git a/BasicJava_2018/YearDemo_leap_length/YearDemo/src/YearDemo3.java b/BasicJava_2018/YearDemo_leap_length/YearDemo/src/YearDemo3.java new file mode 100644 index 000000000..4e6908cb0 --- /dev/null +++ b/BasicJava_2018/YearDemo_leap_length/YearDemo/src/YearDemo3.java @@ -0,0 +1,22 @@ +import java.time.Year; + +public class YearDemo3 +{ + + public static void main(String[] args) + { + Year year = Year.of(2017); + System.out.println(year); + + /* + * Returns: + * + * the length of this year in days, 365 or 366 + */ + int length = year.length(); + + System.out.println("length = " + length); + + } + +} diff --git a/BasicJava_2018/YearDemo_leap_length/YearDemo1_Output.txt b/BasicJava_2018/YearDemo_leap_length/YearDemo1_Output.txt new file mode 100644 index 000000000..cc1d2458b --- /dev/null +++ b/BasicJava_2018/YearDemo_leap_length/YearDemo1_Output.txt @@ -0,0 +1,2 @@ +2017 +2017 is a leap year? = false diff --git a/BasicJava_2018/YearDemo_leap_length/YearDemo2_Output.txt b/BasicJava_2018/YearDemo_leap_length/YearDemo2_Output.txt new file mode 100644 index 000000000..6d43c5f23 --- /dev/null +++ b/BasicJava_2018/YearDemo_leap_length/YearDemo2_Output.txt @@ -0,0 +1,2 @@ +2012 is a Leap year? = true +2014 is a Leap year? = false diff --git a/BasicJava_2018/YearDemo_leap_length/YearDemo3_Output.txt b/BasicJava_2018/YearDemo_leap_length/YearDemo3_Output.txt new file mode 100644 index 000000000..a00e9773a --- /dev/null +++ b/BasicJava_2018/YearDemo_leap_length/YearDemo3_Output.txt @@ -0,0 +1,2 @@ +2017 +length = 365 diff --git a/BasicJava_2018/YearDemo_minus/YearDemo/.classpath b/BasicJava_2018/YearDemo_minus/YearDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearDemo_minus/YearDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearDemo_minus/YearDemo/.project b/BasicJava_2018/YearDemo_minus/YearDemo/.project new file mode 100644 index 000000000..1da24220d --- /dev/null +++ b/BasicJava_2018/YearDemo_minus/YearDemo/.project @@ -0,0 +1,17 @@ + + + YearDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearDemo_minus/YearDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearDemo_minus/YearDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearDemo_minus/YearDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearDemo_minus/YearDemo/bin/YearDemo1.class b/BasicJava_2018/YearDemo_minus/YearDemo/bin/YearDemo1.class new file mode 100644 index 000000000..fdce29c54 Binary files /dev/null and b/BasicJava_2018/YearDemo_minus/YearDemo/bin/YearDemo1.class differ diff --git a/BasicJava_2018/YearDemo_minus/YearDemo/bin/YearDemo2.class b/BasicJava_2018/YearDemo_minus/YearDemo/bin/YearDemo2.class new file mode 100644 index 000000000..1cc67c4a6 Binary files /dev/null and b/BasicJava_2018/YearDemo_minus/YearDemo/bin/YearDemo2.class differ diff --git a/BasicJava_2018/YearDemo_minus/YearDemo/bin/YearDemo3.class b/BasicJava_2018/YearDemo_minus/YearDemo/bin/YearDemo3.class new file mode 100644 index 000000000..55a8a3e2c Binary files /dev/null and b/BasicJava_2018/YearDemo_minus/YearDemo/bin/YearDemo3.class differ diff --git a/BasicJava_2018/YearDemo_minus/YearDemo/src/YearDemo1.java b/BasicJava_2018/YearDemo_minus/YearDemo/src/YearDemo1.java new file mode 100644 index 000000000..c76b23020 --- /dev/null +++ b/BasicJava_2018/YearDemo_minus/YearDemo/src/YearDemo1.java @@ -0,0 +1,24 @@ +import java.time.Year; + +public class YearDemo1 +{ + + public static void main(String[] args) + { + Year year1 = Year.of(2017); + System.out.println("year1 = " + year1); + + /* + * Parameters: + * + * yearsToSubtract - the years to subtract, may be negative + * + * Returns: + * + * a Year based on this year with the year subtracted, not null + */ + Year year2 = year1.minusYears(2); + System.out.println("year2 = " + year2); + } + +} diff --git a/BasicJava_2018/YearDemo_minus/YearDemo/src/YearDemo2.java b/BasicJava_2018/YearDemo_minus/YearDemo/src/YearDemo2.java new file mode 100644 index 000000000..f6ca2ba6e --- /dev/null +++ b/BasicJava_2018/YearDemo_minus/YearDemo/src/YearDemo2.java @@ -0,0 +1,29 @@ +import java.time.Year; +import java.time.temporal.ChronoUnit; + +public class YearDemo2 +{ + + public static void main(String[] args) + { + Year year1 = Year.of(2017); + System.out.println("year1 = " + year1); + + /* + * Parameters: + * + * amountToSubtract - the amount of the unit to subtract from + * the result, may be negative + * + * unit - the unit of the amount to subtract, not null + * + * Returns: + * + * a Year based on this year with the specified amount + * subtracted, not null + */ + Year year2 = year1.minus(5, ChronoUnit.YEARS); + System.out.println("year2 = " + year2); + } + +} diff --git a/BasicJava_2018/YearDemo_minus/YearDemo/src/YearDemo3.java b/BasicJava_2018/YearDemo_minus/YearDemo/src/YearDemo3.java new file mode 100644 index 000000000..3ae872628 --- /dev/null +++ b/BasicJava_2018/YearDemo_minus/YearDemo/src/YearDemo3.java @@ -0,0 +1,29 @@ +import java.time.Period; +import java.time.Year; + +public class YearDemo3 +{ + + public static void main(String[] args) + { + Year year1 = Year.of(2017); + System.out.println("year1 = " + year1); + + Period period = Period.ofYears(9); + System.out.println("period = " + period); + + /* + * Parameters: + * + * amountToSubtract - the amount to subtract, not null + * + * Returns: + * + * a Year based on this year with the subtraction made, not + * null + */ + Year year2 = year1.minus(period); + System.out.println("year2 = " + year2); + } + +} diff --git a/BasicJava_2018/YearDemo_minus/YearDemo1_Output.txt b/BasicJava_2018/YearDemo_minus/YearDemo1_Output.txt new file mode 100644 index 000000000..420e9aa33 --- /dev/null +++ b/BasicJava_2018/YearDemo_minus/YearDemo1_Output.txt @@ -0,0 +1,2 @@ +year1 = 2017 +year2 = 2015 diff --git a/BasicJava_2018/YearDemo_minus/YearDemo2_Output.txt b/BasicJava_2018/YearDemo_minus/YearDemo2_Output.txt new file mode 100644 index 000000000..a95b50726 --- /dev/null +++ b/BasicJava_2018/YearDemo_minus/YearDemo2_Output.txt @@ -0,0 +1,2 @@ +year1 = 2017 +year2 = 2012 diff --git a/BasicJava_2018/YearDemo_minus/YearDemo3_Output.txt b/BasicJava_2018/YearDemo_minus/YearDemo3_Output.txt new file mode 100644 index 000000000..a838157a4 --- /dev/null +++ b/BasicJava_2018/YearDemo_minus/YearDemo3_Output.txt @@ -0,0 +1,3 @@ +year1 = 2017 +period = P9Y +year2 = 2008 diff --git a/BasicJava_2018/YearDemo_now_methods/YearDemo/.classpath b/BasicJava_2018/YearDemo_now_methods/YearDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearDemo_now_methods/YearDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearDemo_now_methods/YearDemo/.project b/BasicJava_2018/YearDemo_now_methods/YearDemo/.project new file mode 100644 index 000000000..1da24220d --- /dev/null +++ b/BasicJava_2018/YearDemo_now_methods/YearDemo/.project @@ -0,0 +1,17 @@ + + + YearDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearDemo_now_methods/YearDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearDemo_now_methods/YearDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearDemo_now_methods/YearDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearDemo_now_methods/YearDemo/bin/YearDemo1.class b/BasicJava_2018/YearDemo_now_methods/YearDemo/bin/YearDemo1.class new file mode 100644 index 000000000..1791f36fd Binary files /dev/null and b/BasicJava_2018/YearDemo_now_methods/YearDemo/bin/YearDemo1.class differ diff --git a/BasicJava_2018/YearDemo_now_methods/YearDemo/bin/YearDemo2.class b/BasicJava_2018/YearDemo_now_methods/YearDemo/bin/YearDemo2.class new file mode 100644 index 000000000..acbd4a1a5 Binary files /dev/null and b/BasicJava_2018/YearDemo_now_methods/YearDemo/bin/YearDemo2.class differ diff --git a/BasicJava_2018/YearDemo_now_methods/YearDemo/src/YearDemo1.java b/BasicJava_2018/YearDemo_now_methods/YearDemo/src/YearDemo1.java new file mode 100644 index 000000000..97ad1cca2 --- /dev/null +++ b/BasicJava_2018/YearDemo_now_methods/YearDemo/src/YearDemo1.java @@ -0,0 +1,22 @@ +import java.time.Clock; +import java.time.Year; + +public class YearDemo1 +{ + + public static void main(String[] args) + { + Clock clock = Clock.systemDefaultZone(); + System.out.println(clock); + /* + * Parameters: + * + * clock - the clock to use, not null + * + * Returns:the current year, not null + */ + Year year = Year.now(clock); + System.out.println(year); + } + +} diff --git a/BasicJava_2018/YearDemo_now_methods/YearDemo/src/YearDemo2.java b/BasicJava_2018/YearDemo_now_methods/YearDemo/src/YearDemo2.java new file mode 100644 index 000000000..5fade7b72 --- /dev/null +++ b/BasicJava_2018/YearDemo_now_methods/YearDemo/src/YearDemo2.java @@ -0,0 +1,24 @@ +import java.time.Year; +import java.time.ZoneId; + +public class YearDemo2 +{ + + public static void main(String[] args) + { + ZoneId zoneId = ZoneId.systemDefault(); + System.out.println(zoneId); + /* + * Parameters: + * + * zone - the zone ID to use, not null + * + * Returns: + * + * the current year using the system clock, not null + */ + Year year = Year.now(zoneId); + System.out.println(year); + } + +} diff --git a/BasicJava_2018/YearDemo_now_methods/YearDemo1_Output.txt b/BasicJava_2018/YearDemo_now_methods/YearDemo1_Output.txt new file mode 100644 index 000000000..ff19bd458 --- /dev/null +++ b/BasicJava_2018/YearDemo_now_methods/YearDemo1_Output.txt @@ -0,0 +1,2 @@ +SystemClock[Asia/Calcutta] +2018 diff --git a/BasicJava_2018/YearDemo_now_methods/YearDemo2_Output.txt b/BasicJava_2018/YearDemo_now_methods/YearDemo2_Output.txt new file mode 100644 index 000000000..12e04a5da --- /dev/null +++ b/BasicJava_2018/YearDemo_now_methods/YearDemo2_Output.txt @@ -0,0 +1,2 @@ +Asia/Calcutta +2018 diff --git a/BasicJava_2018/YearDemo_parse_of/YearDemo/.classpath b/BasicJava_2018/YearDemo_parse_of/YearDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearDemo_parse_of/YearDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearDemo_parse_of/YearDemo/.project b/BasicJava_2018/YearDemo_parse_of/YearDemo/.project new file mode 100644 index 000000000..1da24220d --- /dev/null +++ b/BasicJava_2018/YearDemo_parse_of/YearDemo/.project @@ -0,0 +1,17 @@ + + + YearDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearDemo_parse_of/YearDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearDemo_parse_of/YearDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearDemo_parse_of/YearDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearDemo_parse_of/YearDemo/bin/YearDemo1.class b/BasicJava_2018/YearDemo_parse_of/YearDemo/bin/YearDemo1.class new file mode 100644 index 000000000..450f923e7 Binary files /dev/null and b/BasicJava_2018/YearDemo_parse_of/YearDemo/bin/YearDemo1.class differ diff --git a/BasicJava_2018/YearDemo_parse_of/YearDemo/bin/YearDemo2.class b/BasicJava_2018/YearDemo_parse_of/YearDemo/bin/YearDemo2.class new file mode 100644 index 000000000..3a8ab282e Binary files /dev/null and b/BasicJava_2018/YearDemo_parse_of/YearDemo/bin/YearDemo2.class differ diff --git a/BasicJava_2018/YearDemo_parse_of/YearDemo/bin/YearDemo3.class b/BasicJava_2018/YearDemo_parse_of/YearDemo/bin/YearDemo3.class new file mode 100644 index 000000000..23da11fb3 Binary files /dev/null and b/BasicJava_2018/YearDemo_parse_of/YearDemo/bin/YearDemo3.class differ diff --git a/BasicJava_2018/YearDemo_parse_of/YearDemo/src/YearDemo1.java b/BasicJava_2018/YearDemo_parse_of/YearDemo/src/YearDemo1.java new file mode 100644 index 000000000..52b55bc4d --- /dev/null +++ b/BasicJava_2018/YearDemo_parse_of/YearDemo/src/YearDemo1.java @@ -0,0 +1,21 @@ +import java.time.Year; + +public class YearDemo1 +{ + + public static void main(String[] args) + { + /* + * Parameters: + * + * text - the text to parse such as "2007", not null + * + * Returns: + * + * the parsed year, not null + */ + Year year = Year.parse("2017"); + System.out.println(year); + } + +} diff --git a/BasicJava_2018/YearDemo_parse_of/YearDemo/src/YearDemo2.java b/BasicJava_2018/YearDemo_parse_of/YearDemo/src/YearDemo2.java new file mode 100644 index 000000000..ab4522f6d --- /dev/null +++ b/BasicJava_2018/YearDemo_parse_of/YearDemo/src/YearDemo2.java @@ -0,0 +1,24 @@ +import java.time.Year; +import java.time.format.DateTimeFormatter; + +public class YearDemo2 +{ + + public static void main(String[] args) + { + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy"); + /* + * Parameters: + * + * text - the text to parse, not null + * formatter - the formatter to use, not null + * + * Returns: + * + * the parsed year, not null + */ + Year year = Year.parse("2017",dateTimeFormatter); + System.out.println(year); + } + +} diff --git a/BasicJava_2018/YearDemo_parse_of/YearDemo/src/YearDemo3.java b/BasicJava_2018/YearDemo_parse_of/YearDemo/src/YearDemo3.java new file mode 100644 index 000000000..ac9ecb7e2 --- /dev/null +++ b/BasicJava_2018/YearDemo_parse_of/YearDemo/src/YearDemo3.java @@ -0,0 +1,21 @@ +import java.time.Year; + +public class YearDemo3 +{ + + public static void main(String[] args) + { + /* + * Parameters: + * + * isoYear - the ISO proleptic year to represent, from MIN_VALUE to MAX_VALUE + * + * Returns: + * + * the year, not null + */ + Year year = Year.of(2017); + System.out.println(year); + } + +} diff --git a/BasicJava_2018/YearDemo_parse_of/YearDemo1_Output.txt b/BasicJava_2018/YearDemo_parse_of/YearDemo1_Output.txt new file mode 100644 index 000000000..deaf8236e --- /dev/null +++ b/BasicJava_2018/YearDemo_parse_of/YearDemo1_Output.txt @@ -0,0 +1 @@ +2017 diff --git a/BasicJava_2018/YearDemo_parse_of/YearDemo2_Output.txt b/BasicJava_2018/YearDemo_parse_of/YearDemo2_Output.txt new file mode 100644 index 000000000..deaf8236e --- /dev/null +++ b/BasicJava_2018/YearDemo_parse_of/YearDemo2_Output.txt @@ -0,0 +1 @@ +2017 diff --git a/BasicJava_2018/YearDemo_parse_of/YearDemo3_Output.txt b/BasicJava_2018/YearDemo_parse_of/YearDemo3_Output.txt new file mode 100644 index 000000000..deaf8236e --- /dev/null +++ b/BasicJava_2018/YearDemo_parse_of/YearDemo3_Output.txt @@ -0,0 +1 @@ +2017 diff --git a/BasicJava_2018/YearDemo_plus/YearDemo/.classpath b/BasicJava_2018/YearDemo_plus/YearDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearDemo_plus/YearDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearDemo_plus/YearDemo/.project b/BasicJava_2018/YearDemo_plus/YearDemo/.project new file mode 100644 index 000000000..1da24220d --- /dev/null +++ b/BasicJava_2018/YearDemo_plus/YearDemo/.project @@ -0,0 +1,17 @@ + + + YearDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearDemo_plus/YearDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearDemo_plus/YearDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearDemo_plus/YearDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearDemo_plus/YearDemo/bin/YearDemo1.class b/BasicJava_2018/YearDemo_plus/YearDemo/bin/YearDemo1.class new file mode 100644 index 000000000..d6ac398a0 Binary files /dev/null and b/BasicJava_2018/YearDemo_plus/YearDemo/bin/YearDemo1.class differ diff --git a/BasicJava_2018/YearDemo_plus/YearDemo/bin/YearDemo2.class b/BasicJava_2018/YearDemo_plus/YearDemo/bin/YearDemo2.class new file mode 100644 index 000000000..cb7d5a5b7 Binary files /dev/null and b/BasicJava_2018/YearDemo_plus/YearDemo/bin/YearDemo2.class differ diff --git a/BasicJava_2018/YearDemo_plus/YearDemo/bin/YearDemo3.class b/BasicJava_2018/YearDemo_plus/YearDemo/bin/YearDemo3.class new file mode 100644 index 000000000..92e670379 Binary files /dev/null and b/BasicJava_2018/YearDemo_plus/YearDemo/bin/YearDemo3.class differ diff --git a/BasicJava_2018/YearDemo_plus/YearDemo/src/YearDemo1.java b/BasicJava_2018/YearDemo_plus/YearDemo/src/YearDemo1.java new file mode 100644 index 000000000..0d00462a6 --- /dev/null +++ b/BasicJava_2018/YearDemo_plus/YearDemo/src/YearDemo1.java @@ -0,0 +1,24 @@ +import java.time.Year; + +public class YearDemo1 +{ + + public static void main(String[] args) + { + Year year1 = Year.of(2017); + System.out.println("year1 = " + year1); + + /* + * Parameters: + * + * yearsToAdd - the years to add, may be negative + * + * Returns: + * + * a Year based on this year with the years added, not null + */ + Year year2 = year1.plusYears(2); + System.out.println("year2 = " + year2); + } + +} diff --git a/BasicJava_2018/YearDemo_plus/YearDemo/src/YearDemo2.java b/BasicJava_2018/YearDemo_plus/YearDemo/src/YearDemo2.java new file mode 100644 index 000000000..ea650e4ec --- /dev/null +++ b/BasicJava_2018/YearDemo_plus/YearDemo/src/YearDemo2.java @@ -0,0 +1,29 @@ +import java.time.Year; +import java.time.temporal.ChronoUnit; + +public class YearDemo2 +{ + + public static void main(String[] args) + { + Year year1 = Year.of(2017); + System.out.println("year1 = " + year1); + + /* + * Parameters: + * + * amountToAdd - the amount of the unit to add to the result, + * may be negative + * + * unit - the unit of the amount to add, not null + * + * Returns: + * + * a Year based on this year with the specified amount added, + * not null + */ + Year year2 = year1.plus(5, ChronoUnit.YEARS); + System.out.println("year2 = " + year2); + } + +} diff --git a/BasicJava_2018/YearDemo_plus/YearDemo/src/YearDemo3.java b/BasicJava_2018/YearDemo_plus/YearDemo/src/YearDemo3.java new file mode 100644 index 000000000..e94a87b40 --- /dev/null +++ b/BasicJava_2018/YearDemo_plus/YearDemo/src/YearDemo3.java @@ -0,0 +1,28 @@ +import java.time.Period; +import java.time.Year; + +public class YearDemo3 +{ + + public static void main(String[] args) + { + Year year1 = Year.of(2017); + System.out.println("year1 = " + year1); + + Period period = Period.ofYears(9); + System.out.println("period = " + period); + + /* + * Parameters: + * + * amountToAdd - the amount to add, not null + * + * Returns: + * + * a Year based on this year with the addition made, not null + */ + Year year2 = year1.plus(period); + System.out.println("year2 = " + year2); + } + +} diff --git a/BasicJava_2018/YearDemo_plus/YearDemo1_Output.txt b/BasicJava_2018/YearDemo_plus/YearDemo1_Output.txt new file mode 100644 index 000000000..608376c62 --- /dev/null +++ b/BasicJava_2018/YearDemo_plus/YearDemo1_Output.txt @@ -0,0 +1,2 @@ +year1 = 2017 +year2 = 2019 diff --git a/BasicJava_2018/YearDemo_plus/YearDemo2_Output.txt b/BasicJava_2018/YearDemo_plus/YearDemo2_Output.txt new file mode 100644 index 000000000..d53bb4466 --- /dev/null +++ b/BasicJava_2018/YearDemo_plus/YearDemo2_Output.txt @@ -0,0 +1,2 @@ +year1 = 2017 +year2 = 2022 diff --git a/BasicJava_2018/YearDemo_plus/YearDemo3_Output.txt b/BasicJava_2018/YearDemo_plus/YearDemo3_Output.txt new file mode 100644 index 000000000..6cc08d699 --- /dev/null +++ b/BasicJava_2018/YearDemo_plus/YearDemo3_Output.txt @@ -0,0 +1,3 @@ +year1 = 2017 +period = P9Y +year2 = 2026 diff --git a/BasicJava_2018/YearDemo_range/Output.txt b/BasicJava_2018/YearDemo_range/Output.txt new file mode 100644 index 000000000..4abd67003 --- /dev/null +++ b/BasicJava_2018/YearDemo_range/Output.txt @@ -0,0 +1,3 @@ +-999999999 - 999999999 +Min = -999999999 +Max = 999999999 diff --git a/BasicJava_2018/YearDemo_range/YearDemo/.classpath b/BasicJava_2018/YearDemo_range/YearDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearDemo_range/YearDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearDemo_range/YearDemo/.project b/BasicJava_2018/YearDemo_range/YearDemo/.project new file mode 100644 index 000000000..1da24220d --- /dev/null +++ b/BasicJava_2018/YearDemo_range/YearDemo/.project @@ -0,0 +1,17 @@ + + + YearDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearDemo_range/YearDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearDemo_range/YearDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearDemo_range/YearDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearDemo_range/YearDemo/bin/YearDemo.class b/BasicJava_2018/YearDemo_range/YearDemo/bin/YearDemo.class new file mode 100644 index 000000000..68be7075c Binary files /dev/null and b/BasicJava_2018/YearDemo_range/YearDemo/bin/YearDemo.class differ diff --git a/BasicJava_2018/YearDemo_range/YearDemo/src/YearDemo.java b/BasicJava_2018/YearDemo_range/YearDemo/src/YearDemo.java new file mode 100644 index 000000000..2ec4419f4 --- /dev/null +++ b/BasicJava_2018/YearDemo_range/YearDemo/src/YearDemo.java @@ -0,0 +1,24 @@ +import java.time.Year; +import java.time.temporal.ChronoField; +import java.time.temporal.ValueRange; + +public class YearDemo +{ + + public static void main(String[] args) + { + Year year = Year.of(2017); + + /* + * Returns: + * + * the year, MIN_VALUE to MAX_VALUE + */ + + ValueRange range = year.range(ChronoField.YEAR); + System.out.println(range); + System.out.println("Min = " + range.getMinimum()); + System.out.println("Max = " + range.getMaximum()); + } + +} diff --git a/BasicJava_2018/YearDemo_until/Output.txt b/BasicJava_2018/YearDemo_until/Output.txt new file mode 100644 index 000000000..37168440d --- /dev/null +++ b/BasicJava_2018/YearDemo_until/Output.txt @@ -0,0 +1,3 @@ +year1 = 2017 +year2 = 2030 +13 diff --git a/BasicJava_2018/YearDemo_until/YearDemo/.classpath b/BasicJava_2018/YearDemo_until/YearDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearDemo_until/YearDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearDemo_until/YearDemo/.project b/BasicJava_2018/YearDemo_until/YearDemo/.project new file mode 100644 index 000000000..1da24220d --- /dev/null +++ b/BasicJava_2018/YearDemo_until/YearDemo/.project @@ -0,0 +1,17 @@ + + + YearDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearDemo_until/YearDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearDemo_until/YearDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearDemo_until/YearDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearDemo_until/YearDemo/bin/YearDemo.class b/BasicJava_2018/YearDemo_until/YearDemo/bin/YearDemo.class new file mode 100644 index 000000000..b29f351a0 Binary files /dev/null and b/BasicJava_2018/YearDemo_until/YearDemo/bin/YearDemo.class differ diff --git a/BasicJava_2018/YearDemo_until/YearDemo/src/YearDemo.java b/BasicJava_2018/YearDemo_until/YearDemo/src/YearDemo.java new file mode 100644 index 000000000..71e87d4bb --- /dev/null +++ b/BasicJava_2018/YearDemo_until/YearDemo/src/YearDemo.java @@ -0,0 +1,32 @@ +import java.time.Year; +import java.time.temporal.ChronoUnit; + +public class YearDemo +{ + + public static void main(String[] args) + { + + Year year1 = Year.of(2017); + System.out.println("year1 = " + year1); + Year year2 = Year.of(2030); + System.out.println("year2 = " + year2); + + /* + * Parameters: + * + * endExclusive - the end date, exclusive, which is converted + * to a Year, not null + * + * unit - the unit to measure the amount in, not null + * + * Returns: + * + * the amount of time between this year and the end year + */ + long value = year1.until(year2, ChronoUnit.YEARS); + System.out.println(value); + + } + +} diff --git a/BasicJava_2018/YearDemo_with_fieldset/Output.txt b/BasicJava_2018/YearDemo_with_fieldset/Output.txt new file mode 100644 index 000000000..18e086051 --- /dev/null +++ b/BasicJava_2018/YearDemo_with_fieldset/Output.txt @@ -0,0 +1,2 @@ +year1 = 2017 +year2 = 2050 diff --git a/BasicJava_2018/YearDemo_with_fieldset/YearDemo/.classpath b/BasicJava_2018/YearDemo_with_fieldset/YearDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearDemo_with_fieldset/YearDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearDemo_with_fieldset/YearDemo/.project b/BasicJava_2018/YearDemo_with_fieldset/YearDemo/.project new file mode 100644 index 000000000..1da24220d --- /dev/null +++ b/BasicJava_2018/YearDemo_with_fieldset/YearDemo/.project @@ -0,0 +1,17 @@ + + + YearDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearDemo_with_fieldset/YearDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearDemo_with_fieldset/YearDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearDemo_with_fieldset/YearDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearDemo_with_fieldset/YearDemo/bin/YearDemo.class b/BasicJava_2018/YearDemo_with_fieldset/YearDemo/bin/YearDemo.class new file mode 100644 index 000000000..a2e8f3e2d Binary files /dev/null and b/BasicJava_2018/YearDemo_with_fieldset/YearDemo/bin/YearDemo.class differ diff --git a/BasicJava_2018/YearDemo_with_fieldset/YearDemo/src/YearDemo.java b/BasicJava_2018/YearDemo_with_fieldset/YearDemo/src/YearDemo.java new file mode 100644 index 000000000..86c6d63b3 --- /dev/null +++ b/BasicJava_2018/YearDemo_with_fieldset/YearDemo/src/YearDemo.java @@ -0,0 +1,32 @@ +import java.time.Year; +import java.time.temporal.ChronoField; + +public class YearDemo +{ + + public static void main(String[] args) + { + + Year year1 = Year.of(2017); + System.out.println("year1 = " + year1); + + /* + * Returns a copy of this year with the specified field set to + * a new value. + * + * Parameters: + * + * field - the field to set in the result, not null + * + * newValue - the new value of the field in the result + * + * Returns: + * + * a Year based on this with the specified field set, not null + */ + Year year2 = year1.with(ChronoField.YEAR, 2050); + System.out.println("year2 = " + year2); + + } + +} diff --git a/BasicJava_2018/YearDemo_with_temporalAdjuster/Output.txt b/BasicJava_2018/YearDemo_with_temporalAdjuster/Output.txt new file mode 100644 index 000000000..77ffed3fa --- /dev/null +++ b/BasicJava_2018/YearDemo_with_temporalAdjuster/Output.txt @@ -0,0 +1,3 @@ +year1 = 2017 +year2 = 2020 +year3 = 2020 diff --git a/BasicJava_2018/YearDemo_with_temporalAdjuster/YearDemo/.classpath b/BasicJava_2018/YearDemo_with_temporalAdjuster/YearDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearDemo_with_temporalAdjuster/YearDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearDemo_with_temporalAdjuster/YearDemo/.project b/BasicJava_2018/YearDemo_with_temporalAdjuster/YearDemo/.project new file mode 100644 index 000000000..1da24220d --- /dev/null +++ b/BasicJava_2018/YearDemo_with_temporalAdjuster/YearDemo/.project @@ -0,0 +1,17 @@ + + + YearDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearDemo_with_temporalAdjuster/YearDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearDemo_with_temporalAdjuster/YearDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearDemo_with_temporalAdjuster/YearDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearDemo_with_temporalAdjuster/YearDemo/bin/YearDemo.class b/BasicJava_2018/YearDemo_with_temporalAdjuster/YearDemo/bin/YearDemo.class new file mode 100644 index 000000000..b488d3cee Binary files /dev/null and b/BasicJava_2018/YearDemo_with_temporalAdjuster/YearDemo/bin/YearDemo.class differ diff --git a/BasicJava_2018/YearDemo_with_temporalAdjuster/YearDemo/src/YearDemo.java b/BasicJava_2018/YearDemo_with_temporalAdjuster/YearDemo/src/YearDemo.java new file mode 100644 index 000000000..5232a449e --- /dev/null +++ b/BasicJava_2018/YearDemo_with_temporalAdjuster/YearDemo/src/YearDemo.java @@ -0,0 +1,29 @@ +import java.time.Year; + +public class YearDemo +{ + + public static void main(String[] args) + { + + Year year1 = Year.of(2017); + System.out.println("year1 = "+year1); + + Year year2 = Year.of(2020); + System.out.println("year2 = "+year2); + + /* + * Parameters: + * + * adjuster - the adjuster to use, not null + * + * Returns: + * + * a Year based on this with the adjustment made, not null + */ + Year year3 = year1.with(year2); + System.out.println("year3 = "+year3); + + } + +} diff --git a/BasicJava_2018/YearMonthDemo_at/Output.txt b/BasicJava_2018/YearMonthDemo_at/Output.txt new file mode 100644 index 000000000..b178c905b --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_at/Output.txt @@ -0,0 +1,3 @@ +yearMonth = 2014-11 +localDate atDay(2) = 2014-11-02 +localDate atEndOfMonth() = 2014-11-30 diff --git a/BasicJava_2018/YearMonthDemo_at/YearMonthDemo/.classpath b/BasicJava_2018/YearMonthDemo_at/YearMonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_at/YearMonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearMonthDemo_at/YearMonthDemo/.project b/BasicJava_2018/YearMonthDemo_at/YearMonthDemo/.project new file mode 100644 index 000000000..acf4a2b45 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_at/YearMonthDemo/.project @@ -0,0 +1,17 @@ + + + YearMonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearMonthDemo_at/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearMonthDemo_at/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_at/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearMonthDemo_at/YearMonthDemo/bin/YearMonthDemo.class b/BasicJava_2018/YearMonthDemo_at/YearMonthDemo/bin/YearMonthDemo.class new file mode 100644 index 000000000..e0eeda8fe Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_at/YearMonthDemo/bin/YearMonthDemo.class differ diff --git a/BasicJava_2018/YearMonthDemo_at/YearMonthDemo/src/YearMonthDemo.java b/BasicJava_2018/YearMonthDemo_at/YearMonthDemo/src/YearMonthDemo.java new file mode 100644 index 000000000..9e450e882 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_at/YearMonthDemo/src/YearMonthDemo.java @@ -0,0 +1,36 @@ +import java.time.LocalDate; +import java.time.YearMonth; + +public class YearMonthDemo +{ + + public static void main(String[] args) + { + + YearMonth yearMonth = YearMonth.of(2014, 11); + System.out.println("yearMonth = " + yearMonth); + + /* + * Parameters: + * + * dayOfMonth - the day-of-month to use, from 1 to 31 + * + * Returns: + * + * the date formed from this year-month and the specified day, + * not null + */ + LocalDate localDate = yearMonth.atDay(2); + System.out.println("localDate atDay(2) = " + localDate); + + /* + * Returns: + * + * the last valid date of this year-month, not null + */ + localDate = yearMonth.atEndOfMonth(); + System.out.println("localDate atEndOfMonth() = " + localDate); + + } + +} diff --git a/BasicJava_2018/YearMonthDemo_equals_compareTo/Output.txt b/BasicJava_2018/YearMonthDemo_equals_compareTo/Output.txt new file mode 100644 index 000000000..aefe96ad0 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_equals_compareTo/Output.txt @@ -0,0 +1,4 @@ +yearMonth1 = 2016-03 +yearMonth2 = 2017-03 +2016-03 is equal to 2017-03 = false +2016-03 compare to 2017-03 = -1 diff --git a/BasicJava_2018/YearMonthDemo_equals_compareTo/YearMonthDemo/.classpath b/BasicJava_2018/YearMonthDemo_equals_compareTo/YearMonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_equals_compareTo/YearMonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearMonthDemo_equals_compareTo/YearMonthDemo/.project b/BasicJava_2018/YearMonthDemo_equals_compareTo/YearMonthDemo/.project new file mode 100644 index 000000000..acf4a2b45 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_equals_compareTo/YearMonthDemo/.project @@ -0,0 +1,17 @@ + + + YearMonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearMonthDemo_equals_compareTo/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearMonthDemo_equals_compareTo/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_equals_compareTo/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearMonthDemo_equals_compareTo/YearMonthDemo/bin/YearMonthDemo.class b/BasicJava_2018/YearMonthDemo_equals_compareTo/YearMonthDemo/bin/YearMonthDemo.class new file mode 100644 index 000000000..37807461e Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_equals_compareTo/YearMonthDemo/bin/YearMonthDemo.class differ diff --git a/BasicJava_2018/YearMonthDemo_equals_compareTo/YearMonthDemo/bin/YearMonthDemo1.class b/BasicJava_2018/YearMonthDemo_equals_compareTo/YearMonthDemo/bin/YearMonthDemo1.class new file mode 100644 index 000000000..72696c94d Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_equals_compareTo/YearMonthDemo/bin/YearMonthDemo1.class differ diff --git a/BasicJava_2018/YearMonthDemo_equals_compareTo/YearMonthDemo/bin/YearMonthDemo2.class b/BasicJava_2018/YearMonthDemo_equals_compareTo/YearMonthDemo/bin/YearMonthDemo2.class new file mode 100644 index 000000000..c7a776855 Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_equals_compareTo/YearMonthDemo/bin/YearMonthDemo2.class differ diff --git a/BasicJava_2018/YearMonthDemo_equals_compareTo/YearMonthDemo/src/YearMonthDemo.java b/BasicJava_2018/YearMonthDemo_equals_compareTo/YearMonthDemo/src/YearMonthDemo.java new file mode 100644 index 000000000..d5633aa26 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_equals_compareTo/YearMonthDemo/src/YearMonthDemo.java @@ -0,0 +1,42 @@ +import java.time.YearMonth; + +public class YearMonthDemo +{ + + public static void main(String[] args) + { + + YearMonth yearMonth1 = YearMonth.of(2016, 03); + System.out.println("yearMonth1 = "+yearMonth1); + + YearMonth yearMonth2 = YearMonth.of(2017, 03); + System.out.println("yearMonth2 = "+yearMonth2); + + /* + * Parameters: + * + * obj - the object to check, null returns false + * + * Returns: + * + * true if this is equal to the other year-month + */ + boolean isEqual = yearMonth1.equals(yearMonth2); + System.out.println(yearMonth1 + " is equal to " + yearMonth2 + " = " + isEqual); + + /* + * Parameters: + * + * other - the other year-month to compare to, not null + * + * Returns: + * + * the comparator value, negative if less, positive if greater + */ + + int result = yearMonth1.compareTo(yearMonth2); + System.out.println(yearMonth1 + " compare to " + yearMonth2 + " = " + result); + + } + +} diff --git a/BasicJava_2018/YearMonthDemo_from/Output.txt b/BasicJava_2018/YearMonthDemo_from/Output.txt new file mode 100644 index 000000000..aa978fff1 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_from/Output.txt @@ -0,0 +1,2 @@ +localDate = 2018-03-03 +yearMonth = 2018-03 diff --git a/BasicJava_2018/YearMonthDemo_from/YearMonthDemo/.classpath b/BasicJava_2018/YearMonthDemo_from/YearMonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_from/YearMonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearMonthDemo_from/YearMonthDemo/.project b/BasicJava_2018/YearMonthDemo_from/YearMonthDemo/.project new file mode 100644 index 000000000..acf4a2b45 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_from/YearMonthDemo/.project @@ -0,0 +1,17 @@ + + + YearMonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearMonthDemo_from/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearMonthDemo_from/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_from/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearMonthDemo_from/YearMonthDemo/bin/YearMonthDemo.class b/BasicJava_2018/YearMonthDemo_from/YearMonthDemo/bin/YearMonthDemo.class new file mode 100644 index 000000000..cf3040b4f Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_from/YearMonthDemo/bin/YearMonthDemo.class differ diff --git a/BasicJava_2018/YearMonthDemo_from/YearMonthDemo/src/YearMonthDemo.java b/BasicJava_2018/YearMonthDemo_from/YearMonthDemo/src/YearMonthDemo.java new file mode 100644 index 000000000..9617140bf --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_from/YearMonthDemo/src/YearMonthDemo.java @@ -0,0 +1,27 @@ +import java.time.LocalDate; +import java.time.YearMonth; + +public class YearMonthDemo +{ + + public static void main(String[] args) + { + + LocalDate localDate = LocalDate.now(); + System.out.println("localDate = "+localDate); + + /* + * Parameters: + * + * temporal - the temporal object to convert, not null + * + * Returns: + * + * the year-month, not null + */ + YearMonth yearMonth = YearMonth.from(localDate); + System.out.println("yearMonth = "+yearMonth); + + } + +} diff --git a/BasicJava_2018/YearMonthDemo_getLong/Output.txt b/BasicJava_2018/YearMonthDemo_getLong/Output.txt new file mode 100644 index 000000000..fc4041c1b --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_getLong/Output.txt @@ -0,0 +1,3 @@ +yearMonth = 2018-03 +year = 2018 +monthOfYear = 3 diff --git a/BasicJava_2018/YearMonthDemo_getLong/YearMonthDemo/.classpath b/BasicJava_2018/YearMonthDemo_getLong/YearMonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_getLong/YearMonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearMonthDemo_getLong/YearMonthDemo/.project b/BasicJava_2018/YearMonthDemo_getLong/YearMonthDemo/.project new file mode 100644 index 000000000..acf4a2b45 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_getLong/YearMonthDemo/.project @@ -0,0 +1,17 @@ + + + YearMonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearMonthDemo_getLong/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearMonthDemo_getLong/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_getLong/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearMonthDemo_getLong/YearMonthDemo/bin/YearMonthDemo.class b/BasicJava_2018/YearMonthDemo_getLong/YearMonthDemo/bin/YearMonthDemo.class new file mode 100644 index 000000000..55161b99c Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_getLong/YearMonthDemo/bin/YearMonthDemo.class differ diff --git a/BasicJava_2018/YearMonthDemo_getLong/YearMonthDemo/src/YearMonthDemo.java b/BasicJava_2018/YearMonthDemo_getLong/YearMonthDemo/src/YearMonthDemo.java new file mode 100644 index 000000000..1b9bbf6be --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_getLong/YearMonthDemo/src/YearMonthDemo.java @@ -0,0 +1,31 @@ +import java.time.YearMonth; +import java.time.temporal.ChronoField; + +public class YearMonthDemo +{ + + public static void main(String[] args) + { + + YearMonth yearMonth = YearMonth.now(); + System.out.println("yearMonth = " + yearMonth); + + /* + * Parameters: + * + * field - the field to get, not null + * + * Returns: + * + * the value for the field + */ + + long year = yearMonth.getLong(ChronoField.YEAR); + System.out.println("year = " + year); + + long monthOfYear = yearMonth.getLong(ChronoField.MONTH_OF_YEAR); + System.out.println("monthOfYear = " + monthOfYear); + + } + +} diff --git a/BasicJava_2018/YearMonthDemo_get_field/Output.txt b/BasicJava_2018/YearMonthDemo_get_field/Output.txt new file mode 100644 index 000000000..55a3c1e23 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_get_field/Output.txt @@ -0,0 +1,3 @@ +yearMonth = 2018-03 +year = 2018 +monthValue = 3 diff --git a/BasicJava_2018/YearMonthDemo_get_field/YearMonthDemo/.classpath b/BasicJava_2018/YearMonthDemo_get_field/YearMonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_get_field/YearMonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearMonthDemo_get_field/YearMonthDemo/.project b/BasicJava_2018/YearMonthDemo_get_field/YearMonthDemo/.project new file mode 100644 index 000000000..acf4a2b45 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_get_field/YearMonthDemo/.project @@ -0,0 +1,17 @@ + + + YearMonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearMonthDemo_get_field/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearMonthDemo_get_field/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_get_field/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearMonthDemo_get_field/YearMonthDemo/bin/YearMonthDemo.class b/BasicJava_2018/YearMonthDemo_get_field/YearMonthDemo/bin/YearMonthDemo.class new file mode 100644 index 000000000..145ac2bce Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_get_field/YearMonthDemo/bin/YearMonthDemo.class differ diff --git a/BasicJava_2018/YearMonthDemo_get_field/YearMonthDemo/bin/YearMonthDemo1.class b/BasicJava_2018/YearMonthDemo_get_field/YearMonthDemo/bin/YearMonthDemo1.class new file mode 100644 index 000000000..ce615effb Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_get_field/YearMonthDemo/bin/YearMonthDemo1.class differ diff --git a/BasicJava_2018/YearMonthDemo_get_field/YearMonthDemo/bin/YearMonthDemo2.class b/BasicJava_2018/YearMonthDemo_get_field/YearMonthDemo/bin/YearMonthDemo2.class new file mode 100644 index 000000000..e6b777aee Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_get_field/YearMonthDemo/bin/YearMonthDemo2.class differ diff --git a/BasicJava_2018/YearMonthDemo_get_field/YearMonthDemo/src/YearMonthDemo.java b/BasicJava_2018/YearMonthDemo_get_field/YearMonthDemo/src/YearMonthDemo.java new file mode 100644 index 000000000..69472cd8f --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_get_field/YearMonthDemo/src/YearMonthDemo.java @@ -0,0 +1,37 @@ +import java.time.YearMonth; +import java.time.temporal.ChronoField; + +public class YearMonthDemo +{ + + public static void main(String[] args) + { + YearMonth yearMonth = YearMonth.now(); + System.out.println("yearMonth = " + yearMonth); + + /* + * Parameters: + * + * field - the field to get, not null + * + * Returns: + * + * the value for the field + */ + int year = yearMonth.get(ChronoField.YEAR); + System.out.println("year = " + year); + + /* + * Parameters: + * + * field - the field to get, not null + * + * Returns: + * + * the value for the field + */ + int monthValue = yearMonth.get(ChronoField.MONTH_OF_YEAR); + System.out.println("monthValue = " + monthValue); + } + +} diff --git a/BasicJava_2018/YearMonthDemo_get_month_year/Output.txt b/BasicJava_2018/YearMonthDemo_get_month_year/Output.txt new file mode 100644 index 000000000..bf7292f56 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_get_month_year/Output.txt @@ -0,0 +1,4 @@ +yearMonth = 2018-03 +monthValue = 3 +year = 2018 +month = MARCH diff --git a/BasicJava_2018/YearMonthDemo_get_month_year/YearMonthDemo/.classpath b/BasicJava_2018/YearMonthDemo_get_month_year/YearMonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_get_month_year/YearMonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearMonthDemo_get_month_year/YearMonthDemo/.project b/BasicJava_2018/YearMonthDemo_get_month_year/YearMonthDemo/.project new file mode 100644 index 000000000..acf4a2b45 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_get_month_year/YearMonthDemo/.project @@ -0,0 +1,17 @@ + + + YearMonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearMonthDemo_get_month_year/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearMonthDemo_get_month_year/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_get_month_year/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearMonthDemo_get_month_year/YearMonthDemo/bin/YearMonthDemo.class b/BasicJava_2018/YearMonthDemo_get_month_year/YearMonthDemo/bin/YearMonthDemo.class new file mode 100644 index 000000000..f6b731f71 Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_get_month_year/YearMonthDemo/bin/YearMonthDemo.class differ diff --git a/BasicJava_2018/YearMonthDemo_get_month_year/YearMonthDemo/bin/YearMonthDemo1.class b/BasicJava_2018/YearMonthDemo_get_month_year/YearMonthDemo/bin/YearMonthDemo1.class new file mode 100644 index 000000000..ce615effb Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_get_month_year/YearMonthDemo/bin/YearMonthDemo1.class differ diff --git a/BasicJava_2018/YearMonthDemo_get_month_year/YearMonthDemo/bin/YearMonthDemo2.class b/BasicJava_2018/YearMonthDemo_get_month_year/YearMonthDemo/bin/YearMonthDemo2.class new file mode 100644 index 000000000..e6b777aee Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_get_month_year/YearMonthDemo/bin/YearMonthDemo2.class differ diff --git a/BasicJava_2018/YearMonthDemo_get_month_year/YearMonthDemo/src/YearMonthDemo.java b/BasicJava_2018/YearMonthDemo_get_month_year/YearMonthDemo/src/YearMonthDemo.java new file mode 100644 index 000000000..0394c9003 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_get_month_year/YearMonthDemo/src/YearMonthDemo.java @@ -0,0 +1,39 @@ +import java.time.Month; +import java.time.YearMonth; + +public class YearMonthDemo +{ + + public static void main(String[] args) + { + + YearMonth yearMonth = YearMonth.now(); + System.out.println("yearMonth = " + yearMonth); + + /* + * Returns: + * + * the month-of-year, from 1 to 12 + */ + int monthValue = yearMonth.getMonthValue(); + System.out.println("monthValue = " + monthValue); + + /* + * Returns: + * + * the year, from MIN_YEAR to MAX_YEAR + */ + int year = yearMonth.getYear(); + System.out.println("year = " + year); + + /* + * Returns: + * + * the month-of-year, not null + */ + Month month = yearMonth.getMonth(); + System.out.println("month = " + month); + + } + +} diff --git a/BasicJava_2018/YearMonthDemo_intro/Output.txt b/BasicJava_2018/YearMonthDemo_intro/Output.txt new file mode 100644 index 000000000..421c7a961 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_intro/Output.txt @@ -0,0 +1 @@ +2018-02 diff --git a/BasicJava_2018/YearMonthDemo_intro/YearMonthDemo/.classpath b/BasicJava_2018/YearMonthDemo_intro/YearMonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_intro/YearMonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearMonthDemo_intro/YearMonthDemo/.project b/BasicJava_2018/YearMonthDemo_intro/YearMonthDemo/.project new file mode 100644 index 000000000..acf4a2b45 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_intro/YearMonthDemo/.project @@ -0,0 +1,17 @@ + + + YearMonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearMonthDemo_intro/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearMonthDemo_intro/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_intro/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearMonthDemo_intro/YearMonthDemo/bin/YearMonthDemo.class b/BasicJava_2018/YearMonthDemo_intro/YearMonthDemo/bin/YearMonthDemo.class new file mode 100644 index 000000000..c99351b80 Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_intro/YearMonthDemo/bin/YearMonthDemo.class differ diff --git a/BasicJava_2018/YearMonthDemo_intro/YearMonthDemo/src/YearMonthDemo.java b/BasicJava_2018/YearMonthDemo_intro/YearMonthDemo/src/YearMonthDemo.java new file mode 100644 index 000000000..4afcc92fc --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_intro/YearMonthDemo/src/YearMonthDemo.java @@ -0,0 +1,20 @@ +import java.time.YearMonth; + +public class YearMonthDemo +{ + + public static void main(String[] args) + { + + /* + * Returns: + * + * the current year-month using the system clock and default + * time-zone, not null + */ + YearMonth yearMonth = YearMonth.now(); + System.out.println(yearMonth); + + } + +} diff --git a/BasicJava_2018/YearMonthDemo_isAfter_before/Output.txt b/BasicJava_2018/YearMonthDemo_isAfter_before/Output.txt new file mode 100644 index 000000000..905108677 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_isAfter_before/Output.txt @@ -0,0 +1,4 @@ +yearMonth1 = 2016-03 +yearMonth2 = 2017-03 +2016-03 is after 2017-03 = false +2016-03 is before 2017-03 = true diff --git a/BasicJava_2018/YearMonthDemo_isAfter_before/YearMonthDemo/.classpath b/BasicJava_2018/YearMonthDemo_isAfter_before/YearMonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_isAfter_before/YearMonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearMonthDemo_isAfter_before/YearMonthDemo/.project b/BasicJava_2018/YearMonthDemo_isAfter_before/YearMonthDemo/.project new file mode 100644 index 000000000..acf4a2b45 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_isAfter_before/YearMonthDemo/.project @@ -0,0 +1,17 @@ + + + YearMonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearMonthDemo_isAfter_before/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearMonthDemo_isAfter_before/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_isAfter_before/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearMonthDemo_isAfter_before/YearMonthDemo/bin/YearMonthDemo.class b/BasicJava_2018/YearMonthDemo_isAfter_before/YearMonthDemo/bin/YearMonthDemo.class new file mode 100644 index 000000000..3a88516d0 Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_isAfter_before/YearMonthDemo/bin/YearMonthDemo.class differ diff --git a/BasicJava_2018/YearMonthDemo_isAfter_before/YearMonthDemo/bin/YearMonthDemo1.class b/BasicJava_2018/YearMonthDemo_isAfter_before/YearMonthDemo/bin/YearMonthDemo1.class new file mode 100644 index 000000000..ce615effb Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_isAfter_before/YearMonthDemo/bin/YearMonthDemo1.class differ diff --git a/BasicJava_2018/YearMonthDemo_isAfter_before/YearMonthDemo/bin/YearMonthDemo2.class b/BasicJava_2018/YearMonthDemo_isAfter_before/YearMonthDemo/bin/YearMonthDemo2.class new file mode 100644 index 000000000..e6b777aee Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_isAfter_before/YearMonthDemo/bin/YearMonthDemo2.class differ diff --git a/BasicJava_2018/YearMonthDemo_isAfter_before/YearMonthDemo/src/YearMonthDemo.java b/BasicJava_2018/YearMonthDemo_isAfter_before/YearMonthDemo/src/YearMonthDemo.java new file mode 100644 index 000000000..9eea66ea2 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_isAfter_before/YearMonthDemo/src/YearMonthDemo.java @@ -0,0 +1,42 @@ +import java.time.YearMonth; + +public class YearMonthDemo +{ + + public static void main(String[] args) + { + + YearMonth yearMonth1 = YearMonth.of(2016, 03); + System.out.println("yearMonth1 = "+yearMonth1); + + YearMonth yearMonth2 = YearMonth.of(2017, 03); + System.out.println("yearMonth2 = "+yearMonth2); + + /* + * Parameters: + * + * other - the other year-month to compare to, not null + * + * Returns: + * + * true if this is after the specified year-month + */ + boolean result = yearMonth1.isAfter(yearMonth2); + System.out.println(yearMonth1+" is after "+yearMonth2+" = "+result); + + /* + * Parameters: + * + * other - the other year-month to compare to, not null + * + * Returns: + * + * true if this point is before the specified year-month + */ + + result = yearMonth1.isBefore(yearMonth2); + System.out.println(yearMonth1+" is before "+yearMonth2+" = "+result); + + } + +} diff --git a/BasicJava_2018/YearMonthDemo_isLeapYear/Output.txt b/BasicJava_2018/YearMonthDemo_isLeapYear/Output.txt new file mode 100644 index 000000000..620a3b294 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_isLeapYear/Output.txt @@ -0,0 +1,5 @@ +2016-03 +is 2016 Leap year? = true +------------------------ +2017-03 +is 2017 Leap year? = false diff --git a/BasicJava_2018/YearMonthDemo_isLeapYear/YearMonthDemo/.classpath b/BasicJava_2018/YearMonthDemo_isLeapYear/YearMonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_isLeapYear/YearMonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearMonthDemo_isLeapYear/YearMonthDemo/.project b/BasicJava_2018/YearMonthDemo_isLeapYear/YearMonthDemo/.project new file mode 100644 index 000000000..acf4a2b45 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_isLeapYear/YearMonthDemo/.project @@ -0,0 +1,17 @@ + + + YearMonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearMonthDemo_isLeapYear/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearMonthDemo_isLeapYear/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_isLeapYear/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearMonthDemo_isLeapYear/YearMonthDemo/bin/YearMonthDemo.class b/BasicJava_2018/YearMonthDemo_isLeapYear/YearMonthDemo/bin/YearMonthDemo.class new file mode 100644 index 000000000..fce6a695a Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_isLeapYear/YearMonthDemo/bin/YearMonthDemo.class differ diff --git a/BasicJava_2018/YearMonthDemo_isLeapYear/YearMonthDemo/src/YearMonthDemo.java b/BasicJava_2018/YearMonthDemo_isLeapYear/YearMonthDemo/src/YearMonthDemo.java new file mode 100644 index 000000000..491a915c1 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_isLeapYear/YearMonthDemo/src/YearMonthDemo.java @@ -0,0 +1,32 @@ +import java.time.YearMonth; + +public class YearMonthDemo +{ + + public static void main(String[] args) + { + + YearMonth yearMonth = YearMonth.of(2016, 03); + System.out.println(yearMonth); + + /* + * Returns: + * + * true if the year is leap, false otherwise + */ + boolean isLeapYear = yearMonth.isLeapYear(); + System.out.println("is " + yearMonth.getYear() + + " Leap year? = " + isLeapYear); + + System.out.println("------------------------"); + + yearMonth = YearMonth.of(2017, 03); + System.out.println(yearMonth); + + isLeapYear = yearMonth.isLeapYear(); + System.out.println("is " + yearMonth.getYear() + + " Leap year? = " + isLeapYear); + + } + +} diff --git a/BasicJava_2018/YearMonthDemo_isSupported/YearMonthDemo/.classpath b/BasicJava_2018/YearMonthDemo_isSupported/YearMonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_isSupported/YearMonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearMonthDemo_isSupported/YearMonthDemo/.project b/BasicJava_2018/YearMonthDemo_isSupported/YearMonthDemo/.project new file mode 100644 index 000000000..acf4a2b45 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_isSupported/YearMonthDemo/.project @@ -0,0 +1,17 @@ + + + YearMonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearMonthDemo_isSupported/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearMonthDemo_isSupported/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_isSupported/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearMonthDemo_isSupported/YearMonthDemo/bin/YearMonthDemo1.class b/BasicJava_2018/YearMonthDemo_isSupported/YearMonthDemo/bin/YearMonthDemo1.class new file mode 100644 index 000000000..501f2e2bf Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_isSupported/YearMonthDemo/bin/YearMonthDemo1.class differ diff --git a/BasicJava_2018/YearMonthDemo_isSupported/YearMonthDemo/bin/YearMonthDemo2.class b/BasicJava_2018/YearMonthDemo_isSupported/YearMonthDemo/bin/YearMonthDemo2.class new file mode 100644 index 000000000..484a52ed4 Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_isSupported/YearMonthDemo/bin/YearMonthDemo2.class differ diff --git a/BasicJava_2018/YearMonthDemo_isSupported/YearMonthDemo/src/YearMonthDemo1.java b/BasicJava_2018/YearMonthDemo_isSupported/YearMonthDemo/src/YearMonthDemo1.java new file mode 100644 index 000000000..7946ce4a8 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_isSupported/YearMonthDemo/src/YearMonthDemo1.java @@ -0,0 +1,35 @@ +import java.time.YearMonth; +import java.time.temporal.ChronoField; + +public class YearMonthDemo1 +{ + + public static void main(String[] args) + { + + YearMonth yearMonth = YearMonth.now(); + + /* + * Parameters: + * + * field - the field to check, null returns false + * + * Returns: + * + * true if the field is supported on this year-month, false if + * not + */ + boolean isYearSupported = yearMonth.isSupported(ChronoField.YEAR); + System.out.println("isYearSupported = " + isYearSupported); + + boolean isMonthYearSupported = yearMonth + .isSupported(ChronoField.MONTH_OF_YEAR); + System.out.println("isMonthYearSupported = " + isMonthYearSupported); + + boolean isDayOfMonthSupported = yearMonth + .isSupported(ChronoField.DAY_OF_MONTH); + System.out.println("isDayOfMonthSupported = " + isDayOfMonthSupported); + + } + +} diff --git a/BasicJava_2018/YearMonthDemo_isSupported/YearMonthDemo/src/YearMonthDemo2.java b/BasicJava_2018/YearMonthDemo_isSupported/YearMonthDemo/src/YearMonthDemo2.java new file mode 100644 index 000000000..ad703cdfa --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_isSupported/YearMonthDemo/src/YearMonthDemo2.java @@ -0,0 +1,26 @@ +import java.time.YearMonth; +import java.time.temporal.ChronoUnit; + +public class YearMonthDemo2 +{ + public static void main(String[] args) + { + YearMonth yearMonth = YearMonth.now(); + + /* + * Parameters: + * + * unit - the unit to check, null returns false + * + * Returns: + * + * true if the unit can be added/subtracted, false if not + */ + boolean isYearSupported = yearMonth.isSupported(ChronoUnit.YEARS); + System.out.println("isYearSupported = " + isYearSupported); + + boolean isDaysSupported = yearMonth.isSupported(ChronoUnit.DAYS); + System.out.println("isDaysSupported = " + isDaysSupported); + } + +} diff --git a/BasicJava_2018/YearMonthDemo_isSupported/YearMonthDemo1_Output.txt b/BasicJava_2018/YearMonthDemo_isSupported/YearMonthDemo1_Output.txt new file mode 100644 index 000000000..990ea77ef --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_isSupported/YearMonthDemo1_Output.txt @@ -0,0 +1,3 @@ +isYearSupported = true +isMonthYearSupported = true +isDayOfMonthSupported = false diff --git a/BasicJava_2018/YearMonthDemo_isSupported/YearMonthDemo2_Output.txt b/BasicJava_2018/YearMonthDemo_isSupported/YearMonthDemo2_Output.txt new file mode 100644 index 000000000..51cc1f90b --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_isSupported/YearMonthDemo2_Output.txt @@ -0,0 +1,2 @@ +isYearSupported = true +isDaysSupported = false diff --git a/BasicJava_2018/YearMonthDemo_isValidDay/Output.txt b/BasicJava_2018/YearMonthDemo_isValidDay/Output.txt new file mode 100644 index 000000000..17ded6f0f --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_isValidDay/Output.txt @@ -0,0 +1,3 @@ +yearMonth = 2017-02 +Day 12 isValidDay = true +Day 31 isValidDay = false diff --git a/BasicJava_2018/YearMonthDemo_isValidDay/YearMonthDemo/.classpath b/BasicJava_2018/YearMonthDemo_isValidDay/YearMonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_isValidDay/YearMonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearMonthDemo_isValidDay/YearMonthDemo/.project b/BasicJava_2018/YearMonthDemo_isValidDay/YearMonthDemo/.project new file mode 100644 index 000000000..acf4a2b45 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_isValidDay/YearMonthDemo/.project @@ -0,0 +1,17 @@ + + + YearMonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearMonthDemo_isValidDay/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearMonthDemo_isValidDay/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_isValidDay/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearMonthDemo_isValidDay/YearMonthDemo/bin/YearMonthDemo.class b/BasicJava_2018/YearMonthDemo_isValidDay/YearMonthDemo/bin/YearMonthDemo.class new file mode 100644 index 000000000..21f828ae7 Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_isValidDay/YearMonthDemo/bin/YearMonthDemo.class differ diff --git a/BasicJava_2018/YearMonthDemo_isValidDay/YearMonthDemo/src/YearMonthDemo.java b/BasicJava_2018/YearMonthDemo_isValidDay/YearMonthDemo/src/YearMonthDemo.java new file mode 100644 index 000000000..8dbe160a0 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_isValidDay/YearMonthDemo/src/YearMonthDemo.java @@ -0,0 +1,31 @@ +import java.time.YearMonth; + +public class YearMonthDemo +{ + + public static void main(String[] args) + { + + YearMonth yearMonth = YearMonth.of(2017,2); + System.out.println("yearMonth = "+yearMonth); + + /* + * Parameters: + * + * dayOfMonth - the day-of-month to validate, from 1 to 31, + * invalid value returns false + * + * Returns: + * + * true if the day is valid for this year-month + */ + + boolean isValidDay = yearMonth.isValidDay(12); + System.out.println("Day 12 isValidDay = "+isValidDay); + + isValidDay = yearMonth.isValidDay(31); + System.out.println("Day 31 isValidDay = "+isValidDay); + + } + +} diff --git a/BasicJava_2018/YearMonthDemo_length/Output.txt b/BasicJava_2018/YearMonthDemo_length/Output.txt new file mode 100644 index 000000000..17a8c70fe --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_length/Output.txt @@ -0,0 +1,3 @@ +2018-03 +lengthOfMonth = 31 +lengthOfYear = 365 diff --git a/BasicJava_2018/YearMonthDemo_length/YearMonthDemo/.classpath b/BasicJava_2018/YearMonthDemo_length/YearMonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_length/YearMonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearMonthDemo_length/YearMonthDemo/.project b/BasicJava_2018/YearMonthDemo_length/YearMonthDemo/.project new file mode 100644 index 000000000..acf4a2b45 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_length/YearMonthDemo/.project @@ -0,0 +1,17 @@ + + + YearMonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearMonthDemo_length/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearMonthDemo_length/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_length/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearMonthDemo_length/YearMonthDemo/bin/YearMonthDemo.class b/BasicJava_2018/YearMonthDemo_length/YearMonthDemo/bin/YearMonthDemo.class new file mode 100644 index 000000000..5b49df4c5 Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_length/YearMonthDemo/bin/YearMonthDemo.class differ diff --git a/BasicJava_2018/YearMonthDemo_length/YearMonthDemo/src/YearMonthDemo.java b/BasicJava_2018/YearMonthDemo_length/YearMonthDemo/src/YearMonthDemo.java new file mode 100644 index 000000000..b22d36761 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_length/YearMonthDemo/src/YearMonthDemo.java @@ -0,0 +1,29 @@ +import java.time.YearMonth; + +public class YearMonthDemo +{ + + public static void main(String[] args) + { + + YearMonth yearMonth = YearMonth.now(); + System.out.println(yearMonth); + + /* + * Returns: + * + * the length of the month in days, from 28 to 31 + */ + int lengthOfMonth = yearMonth.lengthOfMonth(); + System.out.println("lengthOfMonth = " + lengthOfMonth); + + /* + * Returns: + * + * 366 if the year is leap, 365 otherwise + */ + int lengthOfYear = yearMonth.lengthOfYear(); + System.out.println("lengthOfYear = " + lengthOfYear); + } + +} diff --git a/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo/.classpath b/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo/.project b/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo/.project new file mode 100644 index 000000000..acf4a2b45 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo/.project @@ -0,0 +1,17 @@ + + + YearMonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo/bin/YearMonthDemo1.class b/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo/bin/YearMonthDemo1.class new file mode 100644 index 000000000..27614c6c5 Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo/bin/YearMonthDemo1.class differ diff --git a/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo/bin/YearMonthDemo2.class b/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo/bin/YearMonthDemo2.class new file mode 100644 index 000000000..aa71e3d2c Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo/bin/YearMonthDemo2.class differ diff --git a/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo/bin/YearMonthDemo3.class b/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo/bin/YearMonthDemo3.class new file mode 100644 index 000000000..eee3189a2 Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo/bin/YearMonthDemo3.class differ diff --git a/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo/src/YearMonthDemo1.java b/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo/src/YearMonthDemo1.java new file mode 100644 index 000000000..ef6829680 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo/src/YearMonthDemo1.java @@ -0,0 +1,40 @@ +import java.time.YearMonth; + +public class YearMonthDemo1 +{ + + public static void main(String[] args) + { + + YearMonth yearMonth1 = YearMonth.now(); + + System.out.println("yearMonth1 = " + yearMonth1); + + /* + * Parameters: + * + * yearsToSubtract - the years to subtract, may be negative + * + * Returns: + * + * a YearMonth based on this year-month with the years + * subtracted, not null + */ + YearMonth yearMonth2 = yearMonth1.minusYears(5); + System.out.println("yearMonth2 = " + yearMonth2); + + /* + * Parameters: + * + * monthsToSubtract - the months to subtract, may be negative + * + * Returns: + * + * a YearMonth based on this year-month with the months + * subtracted, not null + */ + YearMonth yearMonth3 = yearMonth2.minusMonths(2); + System.out.println("yearMonth3 = " + yearMonth3); + } + +} diff --git a/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo/src/YearMonthDemo2.java b/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo/src/YearMonthDemo2.java new file mode 100644 index 000000000..748242a35 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo/src/YearMonthDemo2.java @@ -0,0 +1,35 @@ +import java.time.YearMonth; +import java.time.temporal.ChronoUnit; + +public class YearMonthDemo2 +{ + + public static void main(String[] args) + { + + YearMonth yearMonth1 = YearMonth.now(); + + System.out.println("yearMonth1 = " + yearMonth1); + + /* + * Parameters: + * + * amountToSubtract - the amount of the unit to subtract from + * the result, may be negative + * + * unit - the unit of the amount to subtract, not null + * + * Returns: + * + * a YearMonth based on this year-month with the specified + * amount subtracted, not null + */ + YearMonth yearMonth2 = yearMonth1.minus(30, ChronoUnit.YEARS); + System.out.println("yearMonth2 = " + yearMonth2); + + YearMonth yearMonth3 = yearMonth2.minus(1, ChronoUnit.MONTHS); + System.out.println("yearMonth3 = " + yearMonth3); + + } + +} diff --git a/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo/src/YearMonthDemo3.java b/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo/src/YearMonthDemo3.java new file mode 100644 index 000000000..b30b2bda4 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo/src/YearMonthDemo3.java @@ -0,0 +1,30 @@ +import java.time.Period; +import java.time.YearMonth; + +public class YearMonthDemo3 +{ + + public static void main(String[] args) + { + + YearMonth yearMonth1 = YearMonth.now(); + System.out.println("yearMonth1 = " + yearMonth1); + + Period period = Period.ofYears(9); + System.out.println("period = " + period); + + /* + * Parameters: + * + * amountToSubtract - the amount to subtract, not null + * + * Returns: + * + * a YearMonth based on this year-month with the subtraction + * made, not null + */ + YearMonth yearMonth2 = yearMonth1.minus(period); + System.out.println("yearMonth2 = " + yearMonth2); + } + +} diff --git a/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo1_Output.txt b/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo1_Output.txt new file mode 100644 index 000000000..ada4ab6a3 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo1_Output.txt @@ -0,0 +1,3 @@ +yearMonth1 = 2018-03 +yearMonth2 = 2013-03 +yearMonth3 = 2013-01 diff --git a/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo2_Output.txt b/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo2_Output.txt new file mode 100644 index 000000000..5f44d1547 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo2_Output.txt @@ -0,0 +1,3 @@ +yearMonth1 = 2018-03 +yearMonth2 = 1988-03 +yearMonth3 = 1988-02 diff --git a/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo3_Output.txt b/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo3_Output.txt new file mode 100644 index 000000000..c67ded5d6 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_minus/YearMonthDemo3_Output.txt @@ -0,0 +1,3 @@ +yearMonth1 = 2018-03 +period = P9Y +yearMonth2 = 2009-03 diff --git a/BasicJava_2018/YearMonthDemo_now_methods/YearMonthDemo/.classpath b/BasicJava_2018/YearMonthDemo_now_methods/YearMonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_now_methods/YearMonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearMonthDemo_now_methods/YearMonthDemo/.project b/BasicJava_2018/YearMonthDemo_now_methods/YearMonthDemo/.project new file mode 100644 index 000000000..acf4a2b45 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_now_methods/YearMonthDemo/.project @@ -0,0 +1,17 @@ + + + YearMonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearMonthDemo_now_methods/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearMonthDemo_now_methods/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_now_methods/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearMonthDemo_now_methods/YearMonthDemo/bin/YearMonthDemo1.class b/BasicJava_2018/YearMonthDemo_now_methods/YearMonthDemo/bin/YearMonthDemo1.class new file mode 100644 index 000000000..2146f7a7a Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_now_methods/YearMonthDemo/bin/YearMonthDemo1.class differ diff --git a/BasicJava_2018/YearMonthDemo_now_methods/YearMonthDemo/bin/YearMonthDemo2.class b/BasicJava_2018/YearMonthDemo_now_methods/YearMonthDemo/bin/YearMonthDemo2.class new file mode 100644 index 000000000..4d1c35775 Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_now_methods/YearMonthDemo/bin/YearMonthDemo2.class differ diff --git a/BasicJava_2018/YearMonthDemo_now_methods/YearMonthDemo/src/YearMonthDemo1.java b/BasicJava_2018/YearMonthDemo_now_methods/YearMonthDemo/src/YearMonthDemo1.java new file mode 100644 index 000000000..407b7ac35 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_now_methods/YearMonthDemo/src/YearMonthDemo1.java @@ -0,0 +1,26 @@ +import java.time.Clock; +import java.time.YearMonth; + +public class YearMonthDemo1 +{ + + public static void main(String[] args) + { + + Clock clock = Clock.systemDefaultZone(); + System.out.println("clock = "+clock); + /* + * Parameters: + * + * clock - the clock to use, not null + * + * Returns: + * + * the current year-month, not null + */ + YearMonth yearMonth = YearMonth.now(clock); + System.out.println("yearMonth = "+yearMonth); + + } + +} diff --git a/BasicJava_2018/YearMonthDemo_now_methods/YearMonthDemo/src/YearMonthDemo2.java b/BasicJava_2018/YearMonthDemo_now_methods/YearMonthDemo/src/YearMonthDemo2.java new file mode 100644 index 000000000..0bbddd14a --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_now_methods/YearMonthDemo/src/YearMonthDemo2.java @@ -0,0 +1,25 @@ +import java.time.YearMonth; +import java.time.ZoneId; + +public class YearMonthDemo2 +{ + + public static void main(String[] args) + { + + ZoneId zoneId = ZoneId.systemDefault(); + System.out.println("zoneId = "+zoneId); + /* + * Parameters: + * + * zone - the zone ID to use, not null + * + * Returns: + * + * the current year-month using the system clock, not null + */ + YearMonth yearMonth = YearMonth.now(zoneId); + System.out.println("yearMonth = "+yearMonth); + } + +} diff --git a/BasicJava_2018/YearMonthDemo_now_methods/YearMonthDemo1_Output.txt b/BasicJava_2018/YearMonthDemo_now_methods/YearMonthDemo1_Output.txt new file mode 100644 index 000000000..92af47ce3 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_now_methods/YearMonthDemo1_Output.txt @@ -0,0 +1,2 @@ +clock = SystemClock[Asia/Calcutta] +yearMonth = 2018-02 diff --git a/BasicJava_2018/YearMonthDemo_now_methods/YearMonthDemo2_Output.txt b/BasicJava_2018/YearMonthDemo_now_methods/YearMonthDemo2_Output.txt new file mode 100644 index 000000000..7baa2d1e6 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_now_methods/YearMonthDemo2_Output.txt @@ -0,0 +1,2 @@ +zoneId = Asia/Calcutta +yearMonth = 2018-02 diff --git a/BasicJava_2018/YearMonthDemo_of_methods/Output.txt b/BasicJava_2018/YearMonthDemo_of_methods/Output.txt new file mode 100644 index 000000000..d17de4f96 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_of_methods/Output.txt @@ -0,0 +1,2 @@ +2017-09 +2017-01 diff --git a/BasicJava_2018/YearMonthDemo_of_methods/YearMonthDemo/.classpath b/BasicJava_2018/YearMonthDemo_of_methods/YearMonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_of_methods/YearMonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearMonthDemo_of_methods/YearMonthDemo/.project b/BasicJava_2018/YearMonthDemo_of_methods/YearMonthDemo/.project new file mode 100644 index 000000000..acf4a2b45 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_of_methods/YearMonthDemo/.project @@ -0,0 +1,17 @@ + + + YearMonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearMonthDemo_of_methods/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearMonthDemo_of_methods/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_of_methods/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearMonthDemo_of_methods/YearMonthDemo/bin/YearMonthDemo.class b/BasicJava_2018/YearMonthDemo_of_methods/YearMonthDemo/bin/YearMonthDemo.class new file mode 100644 index 000000000..1c37c1f6c Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_of_methods/YearMonthDemo/bin/YearMonthDemo.class differ diff --git a/BasicJava_2018/YearMonthDemo_of_methods/YearMonthDemo/src/YearMonthDemo.java b/BasicJava_2018/YearMonthDemo_of_methods/YearMonthDemo/src/YearMonthDemo.java new file mode 100644 index 000000000..80ad433cc --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_of_methods/YearMonthDemo/src/YearMonthDemo.java @@ -0,0 +1,40 @@ +import java.time.Month; +import java.time.YearMonth; + +public class YearMonthDemo +{ + + public static void main(String[] args) + { + + /* + * Parameters: + * + * year - the year to represent, from MIN_YEAR to MAX_YEAR + * + * month - the month-of-year to represent, from 1 (January) to + * 12 (December) + * + * Returns: + * + * the year-month, not null + */ + YearMonth YearMonth1 = YearMonth.of(2017, 9); + System.out.println(YearMonth1); + + /* + * Parameters: + * + * year - the year to represent, from MIN_YEAR to MAX_YEAR + * + * month - the month-of-year to represent, not null + * + * Returns: + * + * the year-month, not null + */ + YearMonth YearMonth2 = YearMonth.of(2017, Month.JANUARY); + System.out.println(YearMonth2); + } + +} diff --git a/BasicJava_2018/YearMonthDemo_parse_methods/YearMonthDemo/.classpath b/BasicJava_2018/YearMonthDemo_parse_methods/YearMonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_parse_methods/YearMonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearMonthDemo_parse_methods/YearMonthDemo/.project b/BasicJava_2018/YearMonthDemo_parse_methods/YearMonthDemo/.project new file mode 100644 index 000000000..acf4a2b45 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_parse_methods/YearMonthDemo/.project @@ -0,0 +1,17 @@ + + + YearMonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearMonthDemo_parse_methods/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearMonthDemo_parse_methods/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_parse_methods/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearMonthDemo_parse_methods/YearMonthDemo/bin/YearMonthDemo1.class b/BasicJava_2018/YearMonthDemo_parse_methods/YearMonthDemo/bin/YearMonthDemo1.class new file mode 100644 index 000000000..91cc28782 Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_parse_methods/YearMonthDemo/bin/YearMonthDemo1.class differ diff --git a/BasicJava_2018/YearMonthDemo_parse_methods/YearMonthDemo/bin/YearMonthDemo2.class b/BasicJava_2018/YearMonthDemo_parse_methods/YearMonthDemo/bin/YearMonthDemo2.class new file mode 100644 index 000000000..d65bc9bb5 Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_parse_methods/YearMonthDemo/bin/YearMonthDemo2.class differ diff --git a/BasicJava_2018/YearMonthDemo_parse_methods/YearMonthDemo/src/YearMonthDemo1.java b/BasicJava_2018/YearMonthDemo_parse_methods/YearMonthDemo/src/YearMonthDemo1.java new file mode 100644 index 000000000..1f18409db --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_parse_methods/YearMonthDemo/src/YearMonthDemo1.java @@ -0,0 +1,23 @@ +import java.time.YearMonth; + +public class YearMonthDemo1 +{ + + public static void main(String[] args) + { + + /* + * Parameters: + * + * text - the text to parse such as "2007-12", not null + * + * Returns: + * + * the parsed year-month, not null + */ + YearMonth yearMonth = YearMonth.parse("2017-03"); + System.out.println(yearMonth); + + } + +} diff --git a/BasicJava_2018/YearMonthDemo_parse_methods/YearMonthDemo/src/YearMonthDemo2.java b/BasicJava_2018/YearMonthDemo_parse_methods/YearMonthDemo/src/YearMonthDemo2.java new file mode 100644 index 000000000..31220441a --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_parse_methods/YearMonthDemo/src/YearMonthDemo2.java @@ -0,0 +1,26 @@ +import java.time.YearMonth; +import java.time.format.DateTimeFormatter; + +public class YearMonthDemo2 +{ + + public static void main(String[] args) + { + + DateTimeFormatter dateTimeFormatter = DateTimeFormatter + .ofPattern("yyyy-MM"); + /* + * Parameters: + * + * text - the text to parse, not null formatter - the + * formatter to use, not null + * + * Returns: + * + * the parsed year-month, not null + */ + YearMonth yearMonth = YearMonth.parse("2017-09", dateTimeFormatter); + System.out.println(yearMonth); + } + +} diff --git a/BasicJava_2018/YearMonthDemo_parse_methods/YearMonthDemo1_Output.txt b/BasicJava_2018/YearMonthDemo_parse_methods/YearMonthDemo1_Output.txt new file mode 100644 index 000000000..2fc637e98 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_parse_methods/YearMonthDemo1_Output.txt @@ -0,0 +1 @@ +2017-03 diff --git a/BasicJava_2018/YearMonthDemo_parse_methods/YearMonthDemo2_Output.txt b/BasicJava_2018/YearMonthDemo_parse_methods/YearMonthDemo2_Output.txt new file mode 100644 index 000000000..3c59b349f --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_parse_methods/YearMonthDemo2_Output.txt @@ -0,0 +1 @@ +2017-09 diff --git a/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo/.classpath b/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo/.project b/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo/.project new file mode 100644 index 000000000..acf4a2b45 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo/.project @@ -0,0 +1,17 @@ + + + YearMonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo/bin/YearMonthDemo1.class b/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo/bin/YearMonthDemo1.class new file mode 100644 index 000000000..61bd72b17 Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo/bin/YearMonthDemo1.class differ diff --git a/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo/bin/YearMonthDemo2.class b/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo/bin/YearMonthDemo2.class new file mode 100644 index 000000000..20b22c119 Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo/bin/YearMonthDemo2.class differ diff --git a/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo/bin/YearMonthDemo3.class b/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo/bin/YearMonthDemo3.class new file mode 100644 index 000000000..231777b14 Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo/bin/YearMonthDemo3.class differ diff --git a/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo/src/YearMonthDemo1.java b/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo/src/YearMonthDemo1.java new file mode 100644 index 000000000..3390511ff --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo/src/YearMonthDemo1.java @@ -0,0 +1,40 @@ +import java.time.YearMonth; + +public class YearMonthDemo1 +{ + + public static void main(String[] args) + { + + YearMonth yearMonth1 = YearMonth.now(); + + System.out.println("yearMonth1 = " + yearMonth1); + + /* + * Parameters: + * + * yearsToAdd - the years to add, may be negative + * + * Returns: + * + * a YearMonth based on this year-month with the years + * added, not null + */ + YearMonth yearMonth2 = yearMonth1.plusYears(5); + System.out.println("yearMonth2 = " + yearMonth2); + + /* + * Parameters: + * + * monthsToAdd - the months to add, may be negative + * + * Returns: + * + * a YearMonth based on this year-month with the + * months added, not null + */ + YearMonth yearMonth3 = yearMonth2.plusMonths(2); + System.out.println("yearMonth3 = " + yearMonth3); + } + +} diff --git a/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo/src/YearMonthDemo2.java b/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo/src/YearMonthDemo2.java new file mode 100644 index 000000000..db473f43f --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo/src/YearMonthDemo2.java @@ -0,0 +1,35 @@ +import java.time.YearMonth; +import java.time.temporal.ChronoUnit; + +public class YearMonthDemo2 +{ + + public static void main(String[] args) + { + + YearMonth yearMonth1 = YearMonth.now(); + + System.out.println("yearMonth1 = " + yearMonth1); + + /* + * Parameters: + * + * amountToAdd - the amount of the unit to add to the result, + * may be negative + * + * unit - the unit of the amount to add, not null + * + * Returns: + * + * a YearMonth based on this year-month with the specified + * amount added, not null + */ + YearMonth yearMonth2 = yearMonth1.plus(30, ChronoUnit.YEARS); + System.out.println("yearMonth2 = " + yearMonth2); + + YearMonth yearMonth3 = yearMonth2.plus(1, ChronoUnit.MONTHS); + System.out.println("yearMonth3 = " + yearMonth3); + + } + +} diff --git a/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo/src/YearMonthDemo3.java b/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo/src/YearMonthDemo3.java new file mode 100644 index 000000000..68719e1fb --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo/src/YearMonthDemo3.java @@ -0,0 +1,30 @@ +import java.time.Period; +import java.time.YearMonth; + +public class YearMonthDemo3 +{ + + public static void main(String[] args) + { + + YearMonth yearMonth1 = YearMonth.now(); + System.out.println("yearMonth1 = " + yearMonth1); + + Period period = Period.ofYears(9); + System.out.println("period = " + period); + + /* + * Parameters: + * + * amountToAdd - the amount to add, not null + * + * Returns: + * + * a YearMonth based on this year-month with the addition + * made, not null + */ + YearMonth yearMonth2 = yearMonth1.plus(period); + System.out.println("yearMonth2 = " + yearMonth2); + } + +} diff --git a/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo1_Output.txt b/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo1_Output.txt new file mode 100644 index 000000000..9086c6b35 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo1_Output.txt @@ -0,0 +1,3 @@ +yearMonth1 = 2018-03 +yearMonth2 = 2023-03 +yearMonth3 = 2023-05 diff --git a/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo2_Output.txt b/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo2_Output.txt new file mode 100644 index 000000000..fceacfd16 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo2_Output.txt @@ -0,0 +1,3 @@ +yearMonth1 = 2018-03 +yearMonth2 = 2048-03 +yearMonth3 = 2048-04 diff --git a/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo3_Output.txt b/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo3_Output.txt new file mode 100644 index 000000000..2e07832f9 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_plus/YearMonthDemo3_Output.txt @@ -0,0 +1,3 @@ +yearMonth1 = 2018-03 +period = P9Y +yearMonth2 = 2027-03 diff --git a/BasicJava_2018/YearMonthDemo_range/Output.txt b/BasicJava_2018/YearMonthDemo_range/Output.txt new file mode 100644 index 000000000..ebe0e0661 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_range/Output.txt @@ -0,0 +1,6 @@ +-999999999 - 999999999 +Min = -999999999 +Max = 999999999 +1 - 12 +Min = 1 +Max = 12 diff --git a/BasicJava_2018/YearMonthDemo_range/YearMonthDemo/.classpath b/BasicJava_2018/YearMonthDemo_range/YearMonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_range/YearMonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearMonthDemo_range/YearMonthDemo/.project b/BasicJava_2018/YearMonthDemo_range/YearMonthDemo/.project new file mode 100644 index 000000000..acf4a2b45 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_range/YearMonthDemo/.project @@ -0,0 +1,17 @@ + + + YearMonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearMonthDemo_range/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearMonthDemo_range/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_range/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearMonthDemo_range/YearMonthDemo/bin/YearMonthDemo.class b/BasicJava_2018/YearMonthDemo_range/YearMonthDemo/bin/YearMonthDemo.class new file mode 100644 index 000000000..86d5c9e6d Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_range/YearMonthDemo/bin/YearMonthDemo.class differ diff --git a/BasicJava_2018/YearMonthDemo_range/YearMonthDemo/bin/YearMonthDemo1.class b/BasicJava_2018/YearMonthDemo_range/YearMonthDemo/bin/YearMonthDemo1.class new file mode 100644 index 000000000..72696c94d Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_range/YearMonthDemo/bin/YearMonthDemo1.class differ diff --git a/BasicJava_2018/YearMonthDemo_range/YearMonthDemo/bin/YearMonthDemo2.class b/BasicJava_2018/YearMonthDemo_range/YearMonthDemo/bin/YearMonthDemo2.class new file mode 100644 index 000000000..c7a776855 Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_range/YearMonthDemo/bin/YearMonthDemo2.class differ diff --git a/BasicJava_2018/YearMonthDemo_range/YearMonthDemo/src/YearMonthDemo.java b/BasicJava_2018/YearMonthDemo_range/YearMonthDemo/src/YearMonthDemo.java new file mode 100644 index 000000000..af7e08c7a --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_range/YearMonthDemo/src/YearMonthDemo.java @@ -0,0 +1,35 @@ +import java.time.YearMonth; +import java.time.temporal.ChronoField; +import java.time.temporal.ValueRange; + +public class YearMonthDemo +{ + + public static void main(String[] args) + { + + YearMonth yearMonth = YearMonth.now(); + + /* + * Parameters: + * + * field - the field to query the range for, not null + * + * Returns: + * + * the range of valid values for the field, not null + */ + + ValueRange yearRange = yearMonth.range(ChronoField.YEAR); + System.out.println(yearRange); + System.out.println("Min = " + yearRange.getMinimum()); + System.out.println("Max = " + yearRange.getMaximum()); + + ValueRange monthRange = yearMonth.range(ChronoField.MONTH_OF_YEAR); + System.out.println(monthRange); + System.out.println("Min = " + monthRange.getMinimum()); + System.out.println("Max = " + monthRange.getMaximum()); + + } + +} diff --git a/BasicJava_2018/YearMonthDemo_until/Output.txt b/BasicJava_2018/YearMonthDemo_until/Output.txt new file mode 100644 index 000000000..8fb9cb56c --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_until/Output.txt @@ -0,0 +1,4 @@ +yearMonth1 = 2014-11 +yearMonth2 = 2000-01 +yearDifference = -14 +monthDifference = -178 diff --git a/BasicJava_2018/YearMonthDemo_until/YearMonthDemo/.classpath b/BasicJava_2018/YearMonthDemo_until/YearMonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_until/YearMonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearMonthDemo_until/YearMonthDemo/.project b/BasicJava_2018/YearMonthDemo_until/YearMonthDemo/.project new file mode 100644 index 000000000..acf4a2b45 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_until/YearMonthDemo/.project @@ -0,0 +1,17 @@ + + + YearMonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearMonthDemo_until/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearMonthDemo_until/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_until/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearMonthDemo_until/YearMonthDemo/bin/YearMonthDemo.class b/BasicJava_2018/YearMonthDemo_until/YearMonthDemo/bin/YearMonthDemo.class new file mode 100644 index 000000000..e99a3a30e Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_until/YearMonthDemo/bin/YearMonthDemo.class differ diff --git a/BasicJava_2018/YearMonthDemo_until/YearMonthDemo/src/YearMonthDemo.java b/BasicJava_2018/YearMonthDemo_until/YearMonthDemo/src/YearMonthDemo.java new file mode 100644 index 000000000..0ce32fac5 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_until/YearMonthDemo/src/YearMonthDemo.java @@ -0,0 +1,37 @@ +import java.time.Month; +import java.time.YearMonth; +import java.time.temporal.ChronoUnit; + +public class YearMonthDemo +{ + + public static void main(String[] args) + { + + YearMonth yearMonth1 = YearMonth.of(2014, 11); + System.out.println("yearMonth1 = " + yearMonth1); + + YearMonth yearMonth2 = YearMonth.of(2000, Month.JANUARY); + System.out.println("yearMonth2 = " + yearMonth2); + + /* + * Parameters: + * + * endExclusive - the end date, exclusive, which is converted + * to a YearMonth, not null + * + * unit - the unit to measure the amount in, not null + * + * Returns: + * + * the amount of time between this year-month and the end + * year-month + */ + long yearDifference = yearMonth1.until(yearMonth2, ChronoUnit.YEARS); + System.out.println("yearDifference = " + yearDifference); + + long monthDifference = yearMonth1.until(yearMonth2, ChronoUnit.MONTHS); + System.out.println("monthDifference = " + monthDifference); + } + +} diff --git a/BasicJava_2018/YearMonthDemo_with/YearMonthDemo/.classpath b/BasicJava_2018/YearMonthDemo_with/YearMonthDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_with/YearMonthDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/YearMonthDemo_with/YearMonthDemo/.project b/BasicJava_2018/YearMonthDemo_with/YearMonthDemo/.project new file mode 100644 index 000000000..acf4a2b45 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_with/YearMonthDemo/.project @@ -0,0 +1,17 @@ + + + YearMonthDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/YearMonthDemo_with/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/YearMonthDemo_with/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_with/YearMonthDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/YearMonthDemo_with/YearMonthDemo/bin/YearMonthDemo1.class b/BasicJava_2018/YearMonthDemo_with/YearMonthDemo/bin/YearMonthDemo1.class new file mode 100644 index 000000000..778a68ff6 Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_with/YearMonthDemo/bin/YearMonthDemo1.class differ diff --git a/BasicJava_2018/YearMonthDemo_with/YearMonthDemo/bin/YearMonthDemo2.class b/BasicJava_2018/YearMonthDemo_with/YearMonthDemo/bin/YearMonthDemo2.class new file mode 100644 index 000000000..b5aa5ef92 Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_with/YearMonthDemo/bin/YearMonthDemo2.class differ diff --git a/BasicJava_2018/YearMonthDemo_with/YearMonthDemo/bin/YearMonthDemo3.class b/BasicJava_2018/YearMonthDemo_with/YearMonthDemo/bin/YearMonthDemo3.class new file mode 100644 index 000000000..a76403b21 Binary files /dev/null and b/BasicJava_2018/YearMonthDemo_with/YearMonthDemo/bin/YearMonthDemo3.class differ diff --git a/BasicJava_2018/YearMonthDemo_with/YearMonthDemo/src/YearMonthDemo1.java b/BasicJava_2018/YearMonthDemo_with/YearMonthDemo/src/YearMonthDemo1.java new file mode 100644 index 000000000..b86aefe69 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_with/YearMonthDemo/src/YearMonthDemo1.java @@ -0,0 +1,42 @@ +import java.time.YearMonth; + +public class YearMonthDemo1 +{ + + public static void main(String[] args) + { + + YearMonth yearMonth1 = YearMonth.of(2014, 11); + System.out.println("yearMonth1 = " + yearMonth1); + + /* + * Parameters: + * + * month - the month-of-year to set in the returned + * year-month, from 1 (January) to 12 (December) + * + * Returns: + * + * a YearMonth based on this year-month with the requested + * month, not null + */ + YearMonth yearMonth2 = yearMonth1.withMonth(3); + System.out.println("yearMonth2 = " + yearMonth2); + + /* + * Parameters: + * + * year - the year to set in the returned year-month, from + * MIN_YEAR to MAX_YEAR + * + * Returns: + * + * a YearMonth based on this year-month with the requested + * year, not null + */ + YearMonth yearMonth3 = yearMonth2.withYear(2017); + System.out.println("yearMonth3 = " + yearMonth3); + + } + +} diff --git a/BasicJava_2018/YearMonthDemo_with/YearMonthDemo/src/YearMonthDemo2.java b/BasicJava_2018/YearMonthDemo_with/YearMonthDemo/src/YearMonthDemo2.java new file mode 100644 index 000000000..04fd23521 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_with/YearMonthDemo/src/YearMonthDemo2.java @@ -0,0 +1,27 @@ +import java.time.YearMonth; + +public class YearMonthDemo2 +{ + public static void main(String[] args) + { + YearMonth yearMonth1 = YearMonth.of(2014, 11); + System.out.println("yearMonth1 = " + yearMonth1); + + YearMonth adjusterYearMonth= YearMonth.of(2013, 01); + System.out.println("adjusterYearMonth = " + adjusterYearMonth); + + /* + * Parameters: + * + * adjuster - the adjuster to use, not null + * + * Returns: + * + * a YearMonth based on this with the adjustment made, not + * null + */ + YearMonth yearMonth2 = yearMonth1.with(adjusterYearMonth); + System.out.println("yearMonth2 = " + yearMonth2); + } + +} diff --git a/BasicJava_2018/YearMonthDemo_with/YearMonthDemo/src/YearMonthDemo3.java b/BasicJava_2018/YearMonthDemo_with/YearMonthDemo/src/YearMonthDemo3.java new file mode 100644 index 000000000..195e74fdb --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_with/YearMonthDemo/src/YearMonthDemo3.java @@ -0,0 +1,27 @@ +import java.time.YearMonth; +import java.time.temporal.ChronoField; + +public class YearMonthDemo3 +{ + public static void main(String[] args) + { + YearMonth yearMonth1 = YearMonth.of(2020, 11); + System.out.println("yearMonth1 = " + yearMonth1); + + /* + * Parameters: + * + * field - the field to set in the result, not null + * + * newValue - the new value of the field in the result + * + * Returns: + * + * a YearMonth based on this with the specified field set, not + * null + */ + YearMonth yearMonth2 = yearMonth1.with(ChronoField.YEAR,2013); + System.out.println("yearMonth2 = " + yearMonth2); + } + +} diff --git a/BasicJava_2018/YearMonthDemo_with/YearMonthDemo1_Output.txt b/BasicJava_2018/YearMonthDemo_with/YearMonthDemo1_Output.txt new file mode 100644 index 000000000..c66c72dc8 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_with/YearMonthDemo1_Output.txt @@ -0,0 +1,3 @@ +yearMonth1 = 2014-11 +yearMonth2 = 2014-03 +yearMonth3 = 2017-03 diff --git a/BasicJava_2018/YearMonthDemo_with/YearMonthDemo2_Output.txt b/BasicJava_2018/YearMonthDemo_with/YearMonthDemo2_Output.txt new file mode 100644 index 000000000..3ff52b378 --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_with/YearMonthDemo2_Output.txt @@ -0,0 +1,3 @@ +yearMonth1 = 2014-11 +adjusterYearMonth = 2013-01 +yearMonth2 = 2013-01 diff --git a/BasicJava_2018/YearMonthDemo_with/YearMonthDemo3_Output.txt b/BasicJava_2018/YearMonthDemo_with/YearMonthDemo3_Output.txt new file mode 100644 index 000000000..23d2defdb --- /dev/null +++ b/BasicJava_2018/YearMonthDemo_with/YearMonthDemo3_Output.txt @@ -0,0 +1,2 @@ +yearMonth1 = 2020-11 +yearMonth2 = 2013-11 diff --git a/BasicJava_2018/ZoneOffsetDemo_compareTo_equals/Output.txt b/BasicJava_2018/ZoneOffsetDemo_compareTo_equals/Output.txt new file mode 100644 index 000000000..90434df22 --- /dev/null +++ b/BasicJava_2018/ZoneOffsetDemo_compareTo_equals/Output.txt @@ -0,0 +1,4 @@ +zoneOffset1 = +02:00 +zoneOffset2 = +01:00 +-3600 +false diff --git a/BasicJava_2018/ZoneOffsetDemo_compareTo_equals/ZoneOffsetDemo/.classpath b/BasicJava_2018/ZoneOffsetDemo_compareTo_equals/ZoneOffsetDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/ZoneOffsetDemo_compareTo_equals/ZoneOffsetDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/ZoneOffsetDemo_compareTo_equals/ZoneOffsetDemo/.project b/BasicJava_2018/ZoneOffsetDemo_compareTo_equals/ZoneOffsetDemo/.project new file mode 100644 index 000000000..51864dba3 --- /dev/null +++ b/BasicJava_2018/ZoneOffsetDemo_compareTo_equals/ZoneOffsetDemo/.project @@ -0,0 +1,17 @@ + + + ZoneOffsetDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/ZoneOffsetDemo_compareTo_equals/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/ZoneOffsetDemo_compareTo_equals/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/ZoneOffsetDemo_compareTo_equals/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/ZoneOffsetDemo_compareTo_equals/ZoneOffsetDemo/bin/ZoneOffsetDemo.class b/BasicJava_2018/ZoneOffsetDemo_compareTo_equals/ZoneOffsetDemo/bin/ZoneOffsetDemo.class new file mode 100644 index 000000000..314c0e906 Binary files /dev/null and b/BasicJava_2018/ZoneOffsetDemo_compareTo_equals/ZoneOffsetDemo/bin/ZoneOffsetDemo.class differ diff --git a/BasicJava_2018/ZoneOffsetDemo_compareTo_equals/ZoneOffsetDemo/src/ZoneOffsetDemo.java b/BasicJava_2018/ZoneOffsetDemo_compareTo_equals/ZoneOffsetDemo/src/ZoneOffsetDemo.java new file mode 100644 index 000000000..60aa159a3 --- /dev/null +++ b/BasicJava_2018/ZoneOffsetDemo_compareTo_equals/ZoneOffsetDemo/src/ZoneOffsetDemo.java @@ -0,0 +1,37 @@ +import java.time.ZoneOffset; + +public class ZoneOffsetDemo +{ + + public static void main(String[] args) + { + ZoneOffset zoneOffset1 = ZoneOffset.ofHours(2); + System.out.println("zoneOffset1 = " + zoneOffset1); + ZoneOffset zoneOffset2 = ZoneOffset.ofHours(1); + System.out.println("zoneOffset2 = " + zoneOffset2); + /* + * Parameters: + * + * other - the other date to compare to, not null + * + * Returns: + * + * the comparator value, negative if less, positive if greater + */ + int value = zoneOffset1.compareTo(zoneOffset2); + System.out.println(value); + + /* + * Parameters: + * + * obj - the object to check, null returns false + * + * Returns: + * + * true if this is equal to the other offset + */ + boolean isEqual = zoneOffset1.equals(zoneOffset2); + System.out.println(isEqual); + } + +} diff --git a/BasicJava_2018/ZoneOffsetDemo_from/Output.txt b/BasicJava_2018/ZoneOffsetDemo_from/Output.txt new file mode 100644 index 000000000..4a965b124 --- /dev/null +++ b/BasicJava_2018/ZoneOffsetDemo_from/Output.txt @@ -0,0 +1,2 @@ +zonedDateTime = 2018-02-20T09:14:33.284+05:30[Asia/Calcutta] +zoneOffset = +05:30 diff --git a/BasicJava_2018/ZoneOffsetDemo_from/ZoneOffsetDemo/.classpath b/BasicJava_2018/ZoneOffsetDemo_from/ZoneOffsetDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/ZoneOffsetDemo_from/ZoneOffsetDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/ZoneOffsetDemo_from/ZoneOffsetDemo/.project b/BasicJava_2018/ZoneOffsetDemo_from/ZoneOffsetDemo/.project new file mode 100644 index 000000000..51864dba3 --- /dev/null +++ b/BasicJava_2018/ZoneOffsetDemo_from/ZoneOffsetDemo/.project @@ -0,0 +1,17 @@ + + + ZoneOffsetDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/ZoneOffsetDemo_from/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/ZoneOffsetDemo_from/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/ZoneOffsetDemo_from/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/ZoneOffsetDemo_from/ZoneOffsetDemo/bin/ZoneOffsetDemo.class b/BasicJava_2018/ZoneOffsetDemo_from/ZoneOffsetDemo/bin/ZoneOffsetDemo.class new file mode 100644 index 000000000..e24f521f2 Binary files /dev/null and b/BasicJava_2018/ZoneOffsetDemo_from/ZoneOffsetDemo/bin/ZoneOffsetDemo.class differ diff --git a/BasicJava_2018/ZoneOffsetDemo_from/ZoneOffsetDemo/src/ZoneOffsetDemo.java b/BasicJava_2018/ZoneOffsetDemo_from/ZoneOffsetDemo/src/ZoneOffsetDemo.java new file mode 100644 index 000000000..d0e1595a5 --- /dev/null +++ b/BasicJava_2018/ZoneOffsetDemo_from/ZoneOffsetDemo/src/ZoneOffsetDemo.java @@ -0,0 +1,26 @@ +import java.time.ZoneOffset; +import java.time.ZonedDateTime; + +public class ZoneOffsetDemo +{ + + public static void main(String[] args) + { + + ZonedDateTime zonedDateTime = ZonedDateTime.now(); + System.out.println("zonedDateTime = "+zonedDateTime); + + /* + * Parameters: + * + * temporal - the temporal object to convert, not null + * + * Returns: + * + * the zone-offset, not null + */ + ZoneOffset zoneOffset = ZoneOffset.from(zonedDateTime); + System.out.println("zoneOffset = "+zoneOffset); + } + +} diff --git a/BasicJava_2018/ZoneOffsetDemo_isSupported/Output.txt b/BasicJava_2018/ZoneOffsetDemo_isSupported/Output.txt new file mode 100644 index 000000000..380431163 --- /dev/null +++ b/BasicJava_2018/ZoneOffsetDemo_isSupported/Output.txt @@ -0,0 +1,2 @@ +zoneOffset = Z +true diff --git a/BasicJava_2018/ZoneOffsetDemo_isSupported/ZoneOffsetDemo/.classpath b/BasicJava_2018/ZoneOffsetDemo_isSupported/ZoneOffsetDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/ZoneOffsetDemo_isSupported/ZoneOffsetDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/ZoneOffsetDemo_isSupported/ZoneOffsetDemo/.project b/BasicJava_2018/ZoneOffsetDemo_isSupported/ZoneOffsetDemo/.project new file mode 100644 index 000000000..51864dba3 --- /dev/null +++ b/BasicJava_2018/ZoneOffsetDemo_isSupported/ZoneOffsetDemo/.project @@ -0,0 +1,17 @@ + + + ZoneOffsetDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/ZoneOffsetDemo_isSupported/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/ZoneOffsetDemo_isSupported/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/ZoneOffsetDemo_isSupported/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/ZoneOffsetDemo_isSupported/ZoneOffsetDemo/bin/ZoneOffsetDemo.class b/BasicJava_2018/ZoneOffsetDemo_isSupported/ZoneOffsetDemo/bin/ZoneOffsetDemo.class new file mode 100644 index 000000000..17c767ae1 Binary files /dev/null and b/BasicJava_2018/ZoneOffsetDemo_isSupported/ZoneOffsetDemo/bin/ZoneOffsetDemo.class differ diff --git a/BasicJava_2018/ZoneOffsetDemo_isSupported/ZoneOffsetDemo/src/ZoneOffsetDemo.java b/BasicJava_2018/ZoneOffsetDemo_isSupported/ZoneOffsetDemo/src/ZoneOffsetDemo.java new file mode 100644 index 000000000..f73ae0d79 --- /dev/null +++ b/BasicJava_2018/ZoneOffsetDemo_isSupported/ZoneOffsetDemo/src/ZoneOffsetDemo.java @@ -0,0 +1,26 @@ +import java.time.ZoneOffset; +import java.time.temporal.ChronoField; + +public class ZoneOffsetDemo +{ + + public static void main(String[] args) + { + + ZoneOffset zoneOffset = ZoneOffset.UTC; + System.out.println("zoneOffset = "+zoneOffset); + + /* + * Parameters: + * + * field - the field to check, null returns false + * + * Returns: + * + * true if the field is supported on this offset, false if not + */ + boolean result = zoneOffset.isSupported(ChronoField.OFFSET_SECONDS); + System.out.println(result); + } + +} diff --git a/BasicJava_2018/ZoneOffsetDemo_ofTotalSeconds/Output.txt b/BasicJava_2018/ZoneOffsetDemo_ofTotalSeconds/Output.txt new file mode 100644 index 000000000..02c4ddb51 --- /dev/null +++ b/BasicJava_2018/ZoneOffsetDemo_ofTotalSeconds/Output.txt @@ -0,0 +1 @@ ++01:00 diff --git a/BasicJava_2018/ZoneOffsetDemo_ofTotalSeconds/ZoneOffsetDemo/.classpath b/BasicJava_2018/ZoneOffsetDemo_ofTotalSeconds/ZoneOffsetDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/ZoneOffsetDemo_ofTotalSeconds/ZoneOffsetDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/ZoneOffsetDemo_ofTotalSeconds/ZoneOffsetDemo/.project b/BasicJava_2018/ZoneOffsetDemo_ofTotalSeconds/ZoneOffsetDemo/.project new file mode 100644 index 000000000..51864dba3 --- /dev/null +++ b/BasicJava_2018/ZoneOffsetDemo_ofTotalSeconds/ZoneOffsetDemo/.project @@ -0,0 +1,17 @@ + + + ZoneOffsetDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/ZoneOffsetDemo_ofTotalSeconds/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/ZoneOffsetDemo_ofTotalSeconds/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/ZoneOffsetDemo_ofTotalSeconds/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/ZoneOffsetDemo_ofTotalSeconds/ZoneOffsetDemo/bin/ZoneOffsetDemo.class b/BasicJava_2018/ZoneOffsetDemo_ofTotalSeconds/ZoneOffsetDemo/bin/ZoneOffsetDemo.class new file mode 100644 index 000000000..2b67ab101 Binary files /dev/null and b/BasicJava_2018/ZoneOffsetDemo_ofTotalSeconds/ZoneOffsetDemo/bin/ZoneOffsetDemo.class differ diff --git a/BasicJava_2018/ZoneOffsetDemo_ofTotalSeconds/ZoneOffsetDemo/src/ZoneOffsetDemo.java b/BasicJava_2018/ZoneOffsetDemo_ofTotalSeconds/ZoneOffsetDemo/src/ZoneOffsetDemo.java new file mode 100644 index 000000000..c3db6ccf7 --- /dev/null +++ b/BasicJava_2018/ZoneOffsetDemo_ofTotalSeconds/ZoneOffsetDemo/src/ZoneOffsetDemo.java @@ -0,0 +1,22 @@ +import java.time.ZoneOffset; + +public class ZoneOffsetDemo +{ + + public static void main(String[] args) + { + /* + * Parameters: + * + * totalSeconds - the total time-zone offset in seconds, from + * -64800 to +64800 + * + * Returns: + * + * the ZoneOffset, not null + */ + ZoneOffset zoneOffset = ZoneOffset.ofTotalSeconds(3600); + System.out.println(zoneOffset); + } + +} diff --git a/BasicJava_2018/ZoneOffsetDemo_range/Output.txt b/BasicJava_2018/ZoneOffsetDemo_range/Output.txt new file mode 100644 index 000000000..6536b7f48 --- /dev/null +++ b/BasicJava_2018/ZoneOffsetDemo_range/Output.txt @@ -0,0 +1,3 @@ +range = -64800 - 64800 +Max = 64800 +Min = -64800 diff --git a/BasicJava_2018/ZoneOffsetDemo_range/ZoneOffsetDemo/.classpath b/BasicJava_2018/ZoneOffsetDemo_range/ZoneOffsetDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/BasicJava_2018/ZoneOffsetDemo_range/ZoneOffsetDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/BasicJava_2018/ZoneOffsetDemo_range/ZoneOffsetDemo/.project b/BasicJava_2018/ZoneOffsetDemo_range/ZoneOffsetDemo/.project new file mode 100644 index 000000000..51864dba3 --- /dev/null +++ b/BasicJava_2018/ZoneOffsetDemo_range/ZoneOffsetDemo/.project @@ -0,0 +1,17 @@ + + + ZoneOffsetDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/BasicJava_2018/ZoneOffsetDemo_range/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs b/BasicJava_2018/ZoneOffsetDemo_range/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/BasicJava_2018/ZoneOffsetDemo_range/ZoneOffsetDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/BasicJava_2018/ZoneOffsetDemo_range/ZoneOffsetDemo/bin/ZoneOffsetDemo.class b/BasicJava_2018/ZoneOffsetDemo_range/ZoneOffsetDemo/bin/ZoneOffsetDemo.class new file mode 100644 index 000000000..202419b04 Binary files /dev/null and b/BasicJava_2018/ZoneOffsetDemo_range/ZoneOffsetDemo/bin/ZoneOffsetDemo.class differ diff --git a/BasicJava_2018/ZoneOffsetDemo_range/ZoneOffsetDemo/src/ZoneOffsetDemo.java b/BasicJava_2018/ZoneOffsetDemo_range/ZoneOffsetDemo/src/ZoneOffsetDemo.java new file mode 100644 index 000000000..e92a9e88f --- /dev/null +++ b/BasicJava_2018/ZoneOffsetDemo_range/ZoneOffsetDemo/src/ZoneOffsetDemo.java @@ -0,0 +1,28 @@ +import java.time.ZoneOffset; +import java.time.temporal.ChronoField; +import java.time.temporal.ValueRange; + +public class ZoneOffsetDemo +{ + + public static void main(String[] args) + { + ZoneOffset zoneOffset = ZoneOffset.UTC; + + /* + * Parameters: + * + * field - the field to query the range for, not null + * + * Returns: + * + * the range of valid values for the field, not null + */ + + ValueRange range = zoneOffset.range(ChronoField.OFFSET_SECONDS); + System.out.println("range = "+range); + System.out.println("Max = " + range.getMaximum()); + System.out.println("Min = " + range.getMinimum()); + } + +} diff --git a/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo.war b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo.war new file mode 100644 index 000000000..08b5b130c Binary files /dev/null and b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo.war differ diff --git a/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/.classpath b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/.classpath new file mode 100644 index 000000000..b42037dde --- /dev/null +++ b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/.classpath @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/.project b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/.project new file mode 100644 index 000000000..a573faaae --- /dev/null +++ b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/.project @@ -0,0 +1,36 @@ + + + EmployeeInfoDemo + + + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.jdt.core.javanature + org.eclipse.wst.jsdt.core.jsNature + + diff --git a/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/.settings/.jsdtscope b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/.settings/.jsdtscope new file mode 100644 index 000000000..3a28de0c7 --- /dev/null +++ b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/.settings/.jsdtscope @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/.settings/org.eclipse.jdt.core.prefs b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..c537b6306 --- /dev/null +++ b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/.settings/org.eclipse.wst.common.component b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000..5e99765d4 --- /dev/null +++ b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/.settings/org.eclipse.wst.common.component @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/.settings/org.eclipse.wst.common.project.facet.core.xml b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000..0d3d10e2b --- /dev/null +++ b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/.settings/org.eclipse.wst.jsdt.ui.superType.container b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 000000000..3bd5d0a48 --- /dev/null +++ b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/.settings/org.eclipse.wst.jsdt.ui.superType.name b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 000000000..05bd71b6e --- /dev/null +++ b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/WebContent/META-INF/MANIFEST.MF b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/WebContent/META-INF/MANIFEST.MF new file mode 100644 index 000000000..254272e1c --- /dev/null +++ b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/WebContent/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/WebContent/WEB-INF/lib/javax.servlet.jar b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/WebContent/WEB-INF/lib/javax.servlet.jar new file mode 100644 index 000000000..ab2ab3c0e Binary files /dev/null and b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/WebContent/WEB-INF/lib/javax.servlet.jar differ diff --git a/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/WebContent/WEB-INF/web.xml b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/WebContent/WEB-INF/web.xml new file mode 100644 index 000000000..8ce02da69 --- /dev/null +++ b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/WebContent/WEB-INF/web.xml @@ -0,0 +1,27 @@ + + + EmployeeInfoDemo + + This is a simple web application with a source code organization + based on the recommendations of the Application Developer's Guide. + + + employeeInfoServlet + EmployeeInfoServlet + + + employeeInfoServlet + /employeeInfo + + + + DB Connection + jdbc/HRDB + javax.sql.DataSource + Container + + + \ No newline at end of file diff --git a/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/WebContent/index.html b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/WebContent/index.html new file mode 100644 index 000000000..f34ef0a1c --- /dev/null +++ b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/WebContent/index.html @@ -0,0 +1,14 @@ + + +Employee Information + + +

+

Employee Information

+

+ + diff --git a/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/build/classes/EmployeeInfoServlet.class b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/build/classes/EmployeeInfoServlet.class new file mode 100644 index 000000000..9983ccd47 Binary files /dev/null and b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/build/classes/EmployeeInfoServlet.class differ diff --git a/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/src/EmployeeInfoServlet.java b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/src/EmployeeInfoServlet.java new file mode 100644 index 000000000..f7519ae5b --- /dev/null +++ b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/EmployeeInfoDemo/src/EmployeeInfoServlet.java @@ -0,0 +1,172 @@ +import java.io.IOException; +import java.io.PrintWriter; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.servlet.ServletConfig; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.sql.DataSource; + +public class EmployeeInfoServlet extends HttpServlet +{ + + private static final long serialVersionUID = 1L; + + DataSource dataSource = null; + + public void init( ServletConfig config ) + { + try + { + + System.out + .println("-----------------------------------------------------"); + System.out + .println("init method has been called and servlet is initialized"); + + /* + * Using JDNI lookup get the DataSource. + */ + + Context initContext = new InitialContext(); + Context envContext = (Context) initContext.lookup("java:/comp/env"); + dataSource = (DataSource) envContext.lookup("jdbc/HRDB"); + + System.out.println("Using JDNI lookup got the DataSource : " + + dataSource); + + System.out + .println("-----------------------------------------------------"); + } + + catch( Exception exe ) + { + exe.printStackTrace(); + } + + } + + public void doGet( HttpServletRequest request, HttpServletResponse response ) + throws ServletException, IOException + { + + System.out + .println("-----------------------------------------------------"); + System.out.println("doGet method has been called"); + System.out + .println("-----------------------------------------------------"); + + response.setContentType("text/html"); + + PrintWriter out = response.getWriter(); + String title = "Employee Information From Oracle Database"; + out.print(""); + out.print("

" + title + "

\n"); + + showEmployeeInformation(out); + + out.print(""); + } + + public void destroy() + { + System.out + .println("-----------------------------------------------------"); + System.out + .println("destroy method has been called and servlet is destroyed"); + System.out + .println("-----------------------------------------------------"); + } + + private void showEmployeeInformation( PrintWriter out ) + { + Connection connection = null; + Statement stmt = null; + try + { + + /* + * Get connection from the DataSource + */ + + connection = dataSource.getConnection(); + + /* + * Execute the Query + */ + + stmt = connection.createStatement(); + String sql = "select employee_id,first_name,last_name,email,phone_number from employees"; + ResultSet rs = stmt.executeQuery(sql); + + /* + * Iterate the ResultSet and get each row Information. + */ + while( rs.next() ) + { + /* + * Retrieve by column name + */ + int id = rs.getInt("employee_id"); + String firstName = rs.getString("first_name"); + String lastName = rs.getString("last_name"); + String email = rs.getString("email"); + String phoneNumber = rs.getString("phone_number"); + + /* + * Display values + */ + out.print("employee_id: " + id+"
"); + out.print("first_name: " + firstName+"
"); + out.print("last_name: " + lastName+"
"); + out.print("email: " + email+"
"); + out.println("phone_number: " + phoneNumber+"
"); + out.println("-------------------------------------------"); + } + rs.close(); + + } + + catch( Exception e ) + { + e.printStackTrace(); + } + finally + { + /* + * finally block used to close resources + */ + try + { + if( stmt != null ) + { + stmt.close(); + } + } + catch( SQLException sqlException ) + { + sqlException.printStackTrace(); + } + try + { + if( connection != null ) + { + connection.close(); + } + } + catch( SQLException sqlException ) + { + sqlException.printStackTrace(); + } + } + + } + +} \ No newline at end of file diff --git a/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/HR.sql b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/HR.sql new file mode 100644 index 000000000..fd293aa36 --- /dev/null +++ b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/HR.sql @@ -0,0 +1,816 @@ +-------------------------------------------------------- +-- File created - Monday-September-01-2014 +-------------------------------------------------------- +-------------------------------------------------------- +-- DDL for Sequence DEPARTMENTS_SEQ +-------------------------------------------------------- + + CREATE SEQUENCE "HR"."DEPARTMENTS_SEQ" MINVALUE 1 MAXVALUE 9990 INCREMENT BY 10 START WITH 280 NOCACHE NOORDER NOCYCLE ; +-------------------------------------------------------- +-- DDL for Sequence EMPLOYEES_SEQ +-------------------------------------------------------- + + CREATE SEQUENCE "HR"."EMPLOYEES_SEQ" MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 207 NOCACHE NOORDER NOCYCLE ; +-------------------------------------------------------- +-- DDL for Sequence LOCATIONS_SEQ +-------------------------------------------------------- + + CREATE SEQUENCE "HR"."LOCATIONS_SEQ" MINVALUE 1 MAXVALUE 9900 INCREMENT BY 100 START WITH 3300 NOCACHE NOORDER NOCYCLE ; +-------------------------------------------------------- +-- DDL for Table COUNTRIES +-------------------------------------------------------- + + CREATE TABLE "HR"."COUNTRIES" + ( "COUNTRY_ID" CHAR(2 BYTE), + "COUNTRY_NAME" VARCHAR2(40 BYTE), + "REGION_ID" NUMBER, + CONSTRAINT "COUNTRY_C_ID_PK" PRIMARY KEY ("COUNTRY_ID") ENABLE + ) ORGANIZATION INDEX NOCOMPRESS PCTFREE 10 INITRANS 2 MAXTRANS 255 LOGGING + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" + PCTTHRESHOLD 50; + + COMMENT ON COLUMN "HR"."COUNTRIES"."COUNTRY_ID" IS 'Primary key of countries table.'; + COMMENT ON COLUMN "HR"."COUNTRIES"."COUNTRY_NAME" IS 'Country name'; + COMMENT ON COLUMN "HR"."COUNTRIES"."REGION_ID" IS 'Region ID for the country. Foreign key to region_id column in the departments table.'; + COMMENT ON TABLE "HR"."COUNTRIES" IS 'country table. Contains 25 rows. References with locations table.'; +-------------------------------------------------------- +-- DDL for Table DEPARTMENTS +-------------------------------------------------------- + + CREATE TABLE "HR"."DEPARTMENTS" + ( "DEPARTMENT_ID" NUMBER(4,0), + "DEPARTMENT_NAME" VARCHAR2(30 BYTE), + "MANAGER_ID" NUMBER(6,0), + "LOCATION_ID" NUMBER(4,0) + ) SEGMENT CREATION IMMEDIATE + PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ; + + COMMENT ON COLUMN "HR"."DEPARTMENTS"."DEPARTMENT_ID" IS 'Primary key column of departments table.'; + COMMENT ON COLUMN "HR"."DEPARTMENTS"."DEPARTMENT_NAME" IS 'A not null column that shows name of a department. Administration, +Marketing, Purchasing, Human Resources, Shipping, IT, Executive, Public +Relations, Sales, Finance, and Accounting. '; + COMMENT ON COLUMN "HR"."DEPARTMENTS"."MANAGER_ID" IS 'Manager_id of a department. Foreign key to employee_id column of employees table. The manager_id column of the employee table references this column.'; + COMMENT ON COLUMN "HR"."DEPARTMENTS"."LOCATION_ID" IS 'Location id where a department is located. Foreign key to location_id column of locations table.'; + COMMENT ON TABLE "HR"."DEPARTMENTS" IS 'Departments table that shows details of departments where employees +work. Contains 27 rows; references with locations, employees, and job_history tables.'; +-------------------------------------------------------- +-- DDL for Table EMPLOYEES +-------------------------------------------------------- + + CREATE TABLE "HR"."EMPLOYEES" + ( "EMPLOYEE_ID" NUMBER(6,0), + "FIRST_NAME" VARCHAR2(20 BYTE), + "LAST_NAME" VARCHAR2(25 BYTE), + "EMAIL" VARCHAR2(25 BYTE), + "PHONE_NUMBER" VARCHAR2(20 BYTE), + "HIRE_DATE" DATE, + "JOB_ID" VARCHAR2(10 BYTE), + "SALARY" NUMBER(8,2), + "COMMISSION_PCT" NUMBER(2,2), + "MANAGER_ID" NUMBER(6,0), + "DEPARTMENT_ID" NUMBER(4,0) + ) SEGMENT CREATION IMMEDIATE + PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ; + + COMMENT ON COLUMN "HR"."EMPLOYEES"."EMPLOYEE_ID" IS 'Primary key of employees table.'; + COMMENT ON COLUMN "HR"."EMPLOYEES"."FIRST_NAME" IS 'First name of the employee. A not null column.'; + COMMENT ON COLUMN "HR"."EMPLOYEES"."LAST_NAME" IS 'Last name of the employee. A not null column.'; + COMMENT ON COLUMN "HR"."EMPLOYEES"."EMAIL" IS 'Email id of the employee'; + COMMENT ON COLUMN "HR"."EMPLOYEES"."PHONE_NUMBER" IS 'Phone number of the employee; includes country code and area code'; + COMMENT ON COLUMN "HR"."EMPLOYEES"."HIRE_DATE" IS 'Date when the employee started on this job. A not null column.'; + COMMENT ON COLUMN "HR"."EMPLOYEES"."JOB_ID" IS 'Current job of the employee; foreign key to job_id column of the +jobs table. A not null column.'; + COMMENT ON COLUMN "HR"."EMPLOYEES"."SALARY" IS 'Monthly salary of the employee. Must be greater +than zero (enforced by constraint emp_salary_min)'; + COMMENT ON COLUMN "HR"."EMPLOYEES"."COMMISSION_PCT" IS 'Commission percentage of the employee; Only employees in sales +department elgible for commission percentage'; + COMMENT ON COLUMN "HR"."EMPLOYEES"."MANAGER_ID" IS 'Manager id of the employee; has same domain as manager_id in +departments table. Foreign key to employee_id column of employees table. +(useful for reflexive joins and CONNECT BY query)'; + COMMENT ON COLUMN "HR"."EMPLOYEES"."DEPARTMENT_ID" IS 'Department id where employee works; foreign key to department_id +column of the departments table'; + COMMENT ON TABLE "HR"."EMPLOYEES" IS 'employees table. Contains 107 rows. References with departments, +jobs, job_history tables. Contains a self reference.'; +-------------------------------------------------------- +-- DDL for Table JOBS +-------------------------------------------------------- + + CREATE TABLE "HR"."JOBS" + ( "JOB_ID" VARCHAR2(10 BYTE), + "JOB_TITLE" VARCHAR2(35 BYTE), + "MIN_SALARY" NUMBER(6,0), + "MAX_SALARY" NUMBER(6,0) + ) SEGMENT CREATION IMMEDIATE + PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ; + + COMMENT ON COLUMN "HR"."JOBS"."JOB_ID" IS 'Primary key of jobs table.'; + COMMENT ON COLUMN "HR"."JOBS"."JOB_TITLE" IS 'A not null column that shows job title, e.g. AD_VP, FI_ACCOUNTANT'; + COMMENT ON COLUMN "HR"."JOBS"."MIN_SALARY" IS 'Minimum salary for a job title.'; + COMMENT ON COLUMN "HR"."JOBS"."MAX_SALARY" IS 'Maximum salary for a job title'; + COMMENT ON TABLE "HR"."JOBS" IS 'jobs table with job titles and salary ranges. Contains 19 rows. +References with employees and job_history table.'; +-------------------------------------------------------- +-- DDL for Table JOB_HISTORY +-------------------------------------------------------- + + CREATE TABLE "HR"."JOB_HISTORY" + ( "EMPLOYEE_ID" NUMBER(6,0), + "START_DATE" DATE, + "END_DATE" DATE, + "JOB_ID" VARCHAR2(10 BYTE), + "DEPARTMENT_ID" NUMBER(4,0) + ) SEGMENT CREATION IMMEDIATE + PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ; + + COMMENT ON COLUMN "HR"."JOB_HISTORY"."EMPLOYEE_ID" IS 'A not null column in the complex primary key employee_id+start_date. +Foreign key to employee_id column of the employee table'; + COMMENT ON COLUMN "HR"."JOB_HISTORY"."START_DATE" IS 'A not null column in the complex primary key employee_id+start_date. +Must be less than the end_date of the job_history table. (enforced by +constraint jhist_date_interval)'; + COMMENT ON COLUMN "HR"."JOB_HISTORY"."END_DATE" IS 'Last day of the employee in this job role. A not null column. Must be +greater than the start_date of the job_history table. +(enforced by constraint jhist_date_interval)'; + COMMENT ON COLUMN "HR"."JOB_HISTORY"."JOB_ID" IS 'Job role in which the employee worked in the past; foreign key to +job_id column in the jobs table. A not null column.'; + COMMENT ON COLUMN "HR"."JOB_HISTORY"."DEPARTMENT_ID" IS 'Department id in which the employee worked in the past; foreign key to deparment_id column in the departments table'; + COMMENT ON TABLE "HR"."JOB_HISTORY" IS 'Table that stores job history of the employees. If an employee +changes departments within the job or changes jobs within the department, +new rows get inserted into this table with old job information of the +employee. Contains a complex primary key: employee_id+start_date. +Contains 25 rows. References with jobs, employees, and departments tables.'; +-------------------------------------------------------- +-- DDL for Table LOCATIONS +-------------------------------------------------------- + + CREATE TABLE "HR"."LOCATIONS" + ( "LOCATION_ID" NUMBER(4,0), + "STREET_ADDRESS" VARCHAR2(40 BYTE), + "POSTAL_CODE" VARCHAR2(12 BYTE), + "CITY" VARCHAR2(30 BYTE), + "STATE_PROVINCE" VARCHAR2(25 BYTE), + "COUNTRY_ID" CHAR(2 BYTE) + ) SEGMENT CREATION IMMEDIATE + PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ; + + COMMENT ON COLUMN "HR"."LOCATIONS"."LOCATION_ID" IS 'Primary key of locations table'; + COMMENT ON COLUMN "HR"."LOCATIONS"."STREET_ADDRESS" IS 'Street address of an office, warehouse, or production site of a company. +Contains building number and street name'; + COMMENT ON COLUMN "HR"."LOCATIONS"."POSTAL_CODE" IS 'Postal code of the location of an office, warehouse, or production site +of a company. '; + COMMENT ON COLUMN "HR"."LOCATIONS"."CITY" IS 'A not null column that shows city where an office, warehouse, or +production site of a company is located. '; + COMMENT ON COLUMN "HR"."LOCATIONS"."STATE_PROVINCE" IS 'State or Province where an office, warehouse, or production site of a +company is located.'; + COMMENT ON COLUMN "HR"."LOCATIONS"."COUNTRY_ID" IS 'Country where an office, warehouse, or production site of a company is +located. Foreign key to country_id column of the countries table.'; + COMMENT ON TABLE "HR"."LOCATIONS" IS 'Locations table that contains specific address of a specific office, +warehouse, and/or production site of a company. Does not store addresses / +locations of customers. Contains 23 rows; references with the +departments and countries tables. '; +-------------------------------------------------------- +-- DDL for Table REGIONS +-------------------------------------------------------- + + CREATE TABLE "HR"."REGIONS" + ( "REGION_ID" NUMBER, + "REGION_NAME" VARCHAR2(25 BYTE) + ) SEGMENT CREATION IMMEDIATE + PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ; +-------------------------------------------------------- +-- DDL for View EMP_DETAILS_VIEW +-------------------------------------------------------- + + CREATE OR REPLACE FORCE VIEW "HR"."EMP_DETAILS_VIEW" ("EMPLOYEE_ID", "JOB_ID", "MANAGER_ID", "DEPARTMENT_ID", "LOCATION_ID", "COUNTRY_ID", "FIRST_NAME", "LAST_NAME", "SALARY", "COMMISSION_PCT", "DEPARTMENT_NAME", "JOB_TITLE", "CITY", "STATE_PROVINCE", "COUNTRY_NAME", "REGION_NAME") AS + SELECT + e.employee_id, + e.job_id, + e.manager_id, + e.department_id, + d.location_id, + l.country_id, + e.first_name, + e.last_name, + e.salary, + e.commission_pct, + d.department_name, + j.job_title, + l.city, + l.state_province, + c.country_name, + r.region_name +FROM + employees e, + departments d, + jobs j, + locations l, + countries c, + regions r +WHERE e.department_id = d.department_id + AND d.location_id = l.location_id + AND l.country_id = c.country_id + AND c.region_id = r.region_id + AND j.job_id = e.job_id +WITH READ ONLY; +REM INSERTING into HR.COUNTRIES +SET DEFINE OFF; +Insert into HR.COUNTRIES (COUNTRY_ID,COUNTRY_NAME,REGION_ID) values ('AR','Argentina',2); +Insert into HR.COUNTRIES (COUNTRY_ID,COUNTRY_NAME,REGION_ID) values ('AU','Australia',3); +Insert into HR.COUNTRIES (COUNTRY_ID,COUNTRY_NAME,REGION_ID) values ('BE','Belgium',1); +Insert into HR.COUNTRIES (COUNTRY_ID,COUNTRY_NAME,REGION_ID) values ('BR','Brazil',2); +Insert into HR.COUNTRIES (COUNTRY_ID,COUNTRY_NAME,REGION_ID) values ('CA','Canada',2); +Insert into HR.COUNTRIES (COUNTRY_ID,COUNTRY_NAME,REGION_ID) values ('CH','Switzerland',1); +Insert into HR.COUNTRIES (COUNTRY_ID,COUNTRY_NAME,REGION_ID) values ('CN','China',3); +Insert into HR.COUNTRIES (COUNTRY_ID,COUNTRY_NAME,REGION_ID) values ('DE','Germany',1); +Insert into HR.COUNTRIES (COUNTRY_ID,COUNTRY_NAME,REGION_ID) values ('DK','Denmark',1); +Insert into HR.COUNTRIES (COUNTRY_ID,COUNTRY_NAME,REGION_ID) values ('EG','Egypt',4); +Insert into HR.COUNTRIES (COUNTRY_ID,COUNTRY_NAME,REGION_ID) values ('FR','France',1); +Insert into HR.COUNTRIES (COUNTRY_ID,COUNTRY_NAME,REGION_ID) values ('IL','Israel',4); +Insert into HR.COUNTRIES (COUNTRY_ID,COUNTRY_NAME,REGION_ID) values ('IN','India',3); +Insert into HR.COUNTRIES (COUNTRY_ID,COUNTRY_NAME,REGION_ID) values ('IT','Italy',1); +Insert into HR.COUNTRIES (COUNTRY_ID,COUNTRY_NAME,REGION_ID) values ('JP','Japan',3); +Insert into HR.COUNTRIES (COUNTRY_ID,COUNTRY_NAME,REGION_ID) values ('KW','Kuwait',4); +Insert into HR.COUNTRIES (COUNTRY_ID,COUNTRY_NAME,REGION_ID) values ('ML','Malaysia',3); +Insert into HR.COUNTRIES (COUNTRY_ID,COUNTRY_NAME,REGION_ID) values ('MX','Mexico',2); +Insert into HR.COUNTRIES (COUNTRY_ID,COUNTRY_NAME,REGION_ID) values ('NG','Nigeria',4); +Insert into HR.COUNTRIES (COUNTRY_ID,COUNTRY_NAME,REGION_ID) values ('NL','Netherlands',1); +Insert into HR.COUNTRIES (COUNTRY_ID,COUNTRY_NAME,REGION_ID) values ('SG','Singapore',3); +Insert into HR.COUNTRIES (COUNTRY_ID,COUNTRY_NAME,REGION_ID) values ('UK','United Kingdom',1); +Insert into HR.COUNTRIES (COUNTRY_ID,COUNTRY_NAME,REGION_ID) values ('US','United States of America',2); +Insert into HR.COUNTRIES (COUNTRY_ID,COUNTRY_NAME,REGION_ID) values ('ZM','Zambia',4); +Insert into HR.COUNTRIES (COUNTRY_ID,COUNTRY_NAME,REGION_ID) values ('ZW','Zimbabwe',4); +REM INSERTING into HR.DEPARTMENTS +SET DEFINE OFF; +Insert into HR.DEPARTMENTS (DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID) values (10,'Administration',200,1700); +Insert into HR.DEPARTMENTS (DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID) values (20,'Marketing',201,1800); +Insert into HR.DEPARTMENTS (DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID) values (30,'Purchasing',114,1700); +Insert into HR.DEPARTMENTS (DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID) values (40,'Human Resources',203,2400); +Insert into HR.DEPARTMENTS (DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID) values (50,'Shipping',121,1500); +Insert into HR.DEPARTMENTS (DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID) values (60,'IT',103,1400); +Insert into HR.DEPARTMENTS (DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID) values (70,'Public Relations',204,2700); +Insert into HR.DEPARTMENTS (DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID) values (80,'Sales',145,2500); +Insert into HR.DEPARTMENTS (DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID) values (90,'Executive',100,1700); +Insert into HR.DEPARTMENTS (DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID) values (100,'Finance',108,1700); +Insert into HR.DEPARTMENTS (DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID) values (110,'Accounting',205,1700); +Insert into HR.DEPARTMENTS (DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID) values (120,'Treasury',null,1700); +Insert into HR.DEPARTMENTS (DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID) values (130,'Corporate Tax',null,1700); +Insert into HR.DEPARTMENTS (DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID) values (140,'Control And Credit',null,1700); +Insert into HR.DEPARTMENTS (DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID) values (150,'Shareholder Services',null,1700); +Insert into HR.DEPARTMENTS (DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID) values (160,'Benefits',null,1700); +Insert into HR.DEPARTMENTS (DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID) values (170,'Manufacturing',null,1700); +Insert into HR.DEPARTMENTS (DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID) values (180,'Construction',null,1700); +Insert into HR.DEPARTMENTS (DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID) values (190,'Contracting',null,1700); +Insert into HR.DEPARTMENTS (DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID) values (200,'Operations',null,1700); +Insert into HR.DEPARTMENTS (DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID) values (210,'IT Support',null,1700); +Insert into HR.DEPARTMENTS (DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID) values (220,'NOC',null,1700); +Insert into HR.DEPARTMENTS (DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID) values (230,'IT Helpdesk',null,1700); +Insert into HR.DEPARTMENTS (DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID) values (240,'Government Sales',null,1700); +Insert into HR.DEPARTMENTS (DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID) values (250,'Retail Sales',null,1700); +Insert into HR.DEPARTMENTS (DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID) values (260,'Recruiting',null,1700); +Insert into HR.DEPARTMENTS (DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID) values (270,'Payroll',null,1700); +REM INSERTING into HR.EMPLOYEES +SET DEFINE OFF; +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (100,'Steven','King','SKING','515.123.4567',to_date('17-JUN-03','DD-MON-RR'),'AD_PRES',24000,null,null,90); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (101,'Neena','Kochhar','NKOCHHAR','515.123.4568',to_date('21-SEP-05','DD-MON-RR'),'AD_VP',17000,null,100,90); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (102,'Lex','De Haan','LDEHAAN','515.123.4569',to_date('13-JAN-01','DD-MON-RR'),'AD_VP',17000,null,100,90); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (103,'Alexander','Hunold','AHUNOLD','590.423.4567',to_date('03-JAN-06','DD-MON-RR'),'IT_PROG',9000,null,102,60); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (104,'Bruce','Ernst','BERNST','590.423.4568',to_date('21-MAY-07','DD-MON-RR'),'IT_PROG',6000,null,103,60); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (105,'David','Austin','DAUSTIN','590.423.4569',to_date('25-JUN-05','DD-MON-RR'),'IT_PROG',4800,null,103,60); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (106,'Valli','Pataballa','VPATABAL','590.423.4560',to_date('05-FEB-06','DD-MON-RR'),'IT_PROG',4800,null,103,60); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (107,'Diana','Lorentz','DLORENTZ','590.423.5567',to_date('07-FEB-07','DD-MON-RR'),'IT_PROG',4200,null,103,60); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (108,'Nancy','Greenberg','NGREENBE','515.124.4569',to_date('17-AUG-02','DD-MON-RR'),'FI_MGR',12008,null,101,100); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (109,'Daniel','Faviet','DFAVIET','515.124.4169',to_date('16-AUG-02','DD-MON-RR'),'FI_ACCOUNT',9000,null,108,100); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (110,'John','Chen','JCHEN','515.124.4269',to_date('28-SEP-05','DD-MON-RR'),'FI_ACCOUNT',8200,null,108,100); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (111,'Ismael','Sciarra','ISCIARRA','515.124.4369',to_date('30-SEP-05','DD-MON-RR'),'FI_ACCOUNT',7700,null,108,100); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (112,'Jose Manuel','Urman','JMURMAN','515.124.4469',to_date('07-MAR-06','DD-MON-RR'),'FI_ACCOUNT',7800,null,108,100); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (113,'Luis','Popp','LPOPP','515.124.4567',to_date('07-DEC-07','DD-MON-RR'),'FI_ACCOUNT',6900,null,108,100); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (114,'Den','Raphaely','DRAPHEAL','515.127.4561',to_date('07-DEC-02','DD-MON-RR'),'PU_MAN',11000,null,100,30); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (115,'Alexander','Khoo','AKHOO','515.127.4562',to_date('18-MAY-03','DD-MON-RR'),'PU_CLERK',3100,null,114,30); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (116,'Shelli','Baida','SBAIDA','515.127.4563',to_date('24-DEC-05','DD-MON-RR'),'PU_CLERK',2900,null,114,30); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (117,'Sigal','Tobias','STOBIAS','515.127.4564',to_date('24-JUL-05','DD-MON-RR'),'PU_CLERK',2800,null,114,30); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (118,'Guy','Himuro','GHIMURO','515.127.4565',to_date('15-NOV-06','DD-MON-RR'),'PU_CLERK',2600,null,114,30); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (119,'Karen','Colmenares','KCOLMENA','515.127.4566',to_date('10-AUG-07','DD-MON-RR'),'PU_CLERK',2500,null,114,30); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (120,'Matthew','Weiss','MWEISS','650.123.1234',to_date('18-JUL-04','DD-MON-RR'),'ST_MAN',8000,null,100,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (121,'Adam','Fripp','AFRIPP','650.123.2234',to_date('10-APR-05','DD-MON-RR'),'ST_MAN',8200,null,100,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (122,'Payam','Kaufling','PKAUFLIN','650.123.3234',to_date('01-MAY-03','DD-MON-RR'),'ST_MAN',7900,null,100,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (123,'Shanta','Vollman','SVOLLMAN','650.123.4234',to_date('10-OCT-05','DD-MON-RR'),'ST_MAN',6500,null,100,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (124,'Kevin','Mourgos','KMOURGOS','650.123.5234',to_date('16-NOV-07','DD-MON-RR'),'ST_MAN',5800,null,100,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (125,'Julia','Nayer','JNAYER','650.124.1214',to_date('16-JUL-05','DD-MON-RR'),'ST_CLERK',3200,null,120,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (126,'Irene','Mikkilineni','IMIKKILI','650.124.1224',to_date('28-SEP-06','DD-MON-RR'),'ST_CLERK',2700,null,120,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (127,'James','Landry','JLANDRY','650.124.1334',to_date('14-JAN-07','DD-MON-RR'),'ST_CLERK',2400,null,120,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (128,'Steven','Markle','SMARKLE','650.124.1434',to_date('08-MAR-08','DD-MON-RR'),'ST_CLERK',2200,null,120,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (129,'Laura','Bissot','LBISSOT','650.124.5234',to_date('20-AUG-05','DD-MON-RR'),'ST_CLERK',3300,null,121,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (130,'Mozhe','Atkinson','MATKINSO','650.124.6234',to_date('30-OCT-05','DD-MON-RR'),'ST_CLERK',2800,null,121,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (131,'James','Marlow','JAMRLOW','650.124.7234',to_date('16-FEB-05','DD-MON-RR'),'ST_CLERK',2500,null,121,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (132,'TJ','Olson','TJOLSON','650.124.8234',to_date('10-APR-07','DD-MON-RR'),'ST_CLERK',2100,null,121,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (133,'Jason','Mallin','JMALLIN','650.127.1934',to_date('14-JUN-04','DD-MON-RR'),'ST_CLERK',3300,null,122,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (134,'Michael','Rogers','MROGERS','650.127.1834',to_date('26-AUG-06','DD-MON-RR'),'ST_CLERK',2900,null,122,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (135,'Ki','Gee','KGEE','650.127.1734',to_date('12-DEC-07','DD-MON-RR'),'ST_CLERK',2400,null,122,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (136,'Hazel','Philtanker','HPHILTAN','650.127.1634',to_date('06-FEB-08','DD-MON-RR'),'ST_CLERK',2200,null,122,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (137,'Renske','Ladwig','RLADWIG','650.121.1234',to_date('14-JUL-03','DD-MON-RR'),'ST_CLERK',3600,null,123,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (138,'Stephen','Stiles','SSTILES','650.121.2034',to_date('26-OCT-05','DD-MON-RR'),'ST_CLERK',3200,null,123,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (139,'John','Seo','JSEO','650.121.2019',to_date('12-FEB-06','DD-MON-RR'),'ST_CLERK',2700,null,123,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (140,'Joshua','Patel','JPATEL','650.121.1834',to_date('06-APR-06','DD-MON-RR'),'ST_CLERK',2500,null,123,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (141,'Trenna','Rajs','TRAJS','650.121.8009',to_date('17-OCT-03','DD-MON-RR'),'ST_CLERK',3500,null,124,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (142,'Curtis','Davies','CDAVIES','650.121.2994',to_date('29-JAN-05','DD-MON-RR'),'ST_CLERK',3100,null,124,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (143,'Randall','Matos','RMATOS','650.121.2874',to_date('15-MAR-06','DD-MON-RR'),'ST_CLERK',2600,null,124,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (144,'Peter','Vargas','PVARGAS','650.121.2004',to_date('09-JUL-06','DD-MON-RR'),'ST_CLERK',2500,null,124,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (145,'John','Russell','JRUSSEL','011.44.1344.429268',to_date('01-OCT-04','DD-MON-RR'),'SA_MAN',14000,0.4,100,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (146,'Karen','Partners','KPARTNER','011.44.1344.467268',to_date('05-JAN-05','DD-MON-RR'),'SA_MAN',13500,0.3,100,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (147,'Alberto','Errazuriz','AERRAZUR','011.44.1344.429278',to_date('10-MAR-05','DD-MON-RR'),'SA_MAN',12000,0.3,100,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (148,'Gerald','Cambrault','GCAMBRAU','011.44.1344.619268',to_date('15-OCT-07','DD-MON-RR'),'SA_MAN',11000,0.3,100,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (149,'Eleni','Zlotkey','EZLOTKEY','011.44.1344.429018',to_date('29-JAN-08','DD-MON-RR'),'SA_MAN',10500,0.2,100,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (150,'Peter','Tucker','PTUCKER','011.44.1344.129268',to_date('30-JAN-05','DD-MON-RR'),'SA_REP',10000,0.3,145,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (151,'David','Bernstein','DBERNSTE','011.44.1344.345268',to_date('24-MAR-05','DD-MON-RR'),'SA_REP',9500,0.25,145,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (152,'Peter','Hall','PHALL','011.44.1344.478968',to_date('20-AUG-05','DD-MON-RR'),'SA_REP',9000,0.25,145,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (153,'Christopher','Olsen','COLSEN','011.44.1344.498718',to_date('30-MAR-06','DD-MON-RR'),'SA_REP',8000,0.2,145,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (154,'Nanette','Cambrault','NCAMBRAU','011.44.1344.987668',to_date('09-DEC-06','DD-MON-RR'),'SA_REP',7500,0.2,145,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (155,'Oliver','Tuvault','OTUVAULT','011.44.1344.486508',to_date('23-NOV-07','DD-MON-RR'),'SA_REP',7000,0.15,145,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (156,'Janette','King','JKING','011.44.1345.429268',to_date('30-JAN-04','DD-MON-RR'),'SA_REP',10000,0.35,146,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (157,'Patrick','Sully','PSULLY','011.44.1345.929268',to_date('04-MAR-04','DD-MON-RR'),'SA_REP',9500,0.35,146,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (158,'Allan','McEwen','AMCEWEN','011.44.1345.829268',to_date('01-AUG-04','DD-MON-RR'),'SA_REP',9000,0.35,146,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (159,'Lindsey','Smith','LSMITH','011.44.1345.729268',to_date('10-MAR-05','DD-MON-RR'),'SA_REP',8000,0.3,146,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (160,'Louise','Doran','LDORAN','011.44.1345.629268',to_date('15-DEC-05','DD-MON-RR'),'SA_REP',7500,0.3,146,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (161,'Sarath','Sewall','SSEWALL','011.44.1345.529268',to_date('03-NOV-06','DD-MON-RR'),'SA_REP',7000,0.25,146,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (162,'Clara','Vishney','CVISHNEY','011.44.1346.129268',to_date('11-NOV-05','DD-MON-RR'),'SA_REP',10500,0.25,147,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (163,'Danielle','Greene','DGREENE','011.44.1346.229268',to_date('19-MAR-07','DD-MON-RR'),'SA_REP',9500,0.15,147,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (164,'Mattea','Marvins','MMARVINS','011.44.1346.329268',to_date('24-JAN-08','DD-MON-RR'),'SA_REP',7200,0.1,147,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (165,'David','Lee','DLEE','011.44.1346.529268',to_date('23-FEB-08','DD-MON-RR'),'SA_REP',6800,0.1,147,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (166,'Sundar','Ande','SANDE','011.44.1346.629268',to_date('24-MAR-08','DD-MON-RR'),'SA_REP',6400,0.1,147,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (167,'Amit','Banda','ABANDA','011.44.1346.729268',to_date('21-APR-08','DD-MON-RR'),'SA_REP',6200,0.1,147,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (168,'Lisa','Ozer','LOZER','011.44.1343.929268',to_date('11-MAR-05','DD-MON-RR'),'SA_REP',11500,0.25,148,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (169,'Harrison','Bloom','HBLOOM','011.44.1343.829268',to_date('23-MAR-06','DD-MON-RR'),'SA_REP',10000,0.2,148,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (170,'Tayler','Fox','TFOX','011.44.1343.729268',to_date('24-JAN-06','DD-MON-RR'),'SA_REP',9600,0.2,148,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (171,'William','Smith','WSMITH','011.44.1343.629268',to_date('23-FEB-07','DD-MON-RR'),'SA_REP',7400,0.15,148,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (172,'Elizabeth','Bates','EBATES','011.44.1343.529268',to_date('24-MAR-07','DD-MON-RR'),'SA_REP',7300,0.15,148,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (173,'Sundita','Kumar','SKUMAR','011.44.1343.329268',to_date('21-APR-08','DD-MON-RR'),'SA_REP',6100,0.1,148,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (174,'Ellen','Abel','EABEL','011.44.1644.429267',to_date('11-MAY-04','DD-MON-RR'),'SA_REP',11000,0.3,149,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (175,'Alyssa','Hutton','AHUTTON','011.44.1644.429266',to_date('19-MAR-05','DD-MON-RR'),'SA_REP',8800,0.25,149,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (176,'Jonathon','Taylor','JTAYLOR','011.44.1644.429265',to_date('24-MAR-06','DD-MON-RR'),'SA_REP',8600,0.2,149,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (177,'Jack','Livingston','JLIVINGS','011.44.1644.429264',to_date('23-APR-06','DD-MON-RR'),'SA_REP',8400,0.2,149,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (178,'Kimberely','Grant','KGRANT','011.44.1644.429263',to_date('24-MAY-07','DD-MON-RR'),'SA_REP',7000,0.15,149,null); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (179,'Charles','Johnson','CJOHNSON','011.44.1644.429262',to_date('04-JAN-08','DD-MON-RR'),'SA_REP',6200,0.1,149,80); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (180,'Winston','Taylor','WTAYLOR','650.507.9876',to_date('24-JAN-06','DD-MON-RR'),'SH_CLERK',3200,null,120,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (181,'Jean','Fleaur','JFLEAUR','650.507.9877',to_date('23-FEB-06','DD-MON-RR'),'SH_CLERK',3100,null,120,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (182,'Martha','Sullivan','MSULLIVA','650.507.9878',to_date('21-JUN-07','DD-MON-RR'),'SH_CLERK',2500,null,120,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (183,'Girard','Geoni','GGEONI','650.507.9879',to_date('03-FEB-08','DD-MON-RR'),'SH_CLERK',2800,null,120,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (184,'Nandita','Sarchand','NSARCHAN','650.509.1876',to_date('27-JAN-04','DD-MON-RR'),'SH_CLERK',4200,null,121,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (185,'Alexis','Bull','ABULL','650.509.2876',to_date('20-FEB-05','DD-MON-RR'),'SH_CLERK',4100,null,121,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (186,'Julia','Dellinger','JDELLING','650.509.3876',to_date('24-JUN-06','DD-MON-RR'),'SH_CLERK',3400,null,121,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (187,'Anthony','Cabrio','ACABRIO','650.509.4876',to_date('07-FEB-07','DD-MON-RR'),'SH_CLERK',3000,null,121,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (188,'Kelly','Chung','KCHUNG','650.505.1876',to_date('14-JUN-05','DD-MON-RR'),'SH_CLERK',3800,null,122,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (189,'Jennifer','Dilly','JDILLY','650.505.2876',to_date('13-AUG-05','DD-MON-RR'),'SH_CLERK',3600,null,122,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (190,'Timothy','Gates','TGATES','650.505.3876',to_date('11-JUL-06','DD-MON-RR'),'SH_CLERK',2900,null,122,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (191,'Randall','Perkins','RPERKINS','650.505.4876',to_date('19-DEC-07','DD-MON-RR'),'SH_CLERK',2500,null,122,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (192,'Sarah','Bell','SBELL','650.501.1876',to_date('04-FEB-04','DD-MON-RR'),'SH_CLERK',4000,null,123,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (193,'Britney','Everett','BEVERETT','650.501.2876',to_date('03-MAR-05','DD-MON-RR'),'SH_CLERK',3900,null,123,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (194,'Samuel','McCain','SMCCAIN','650.501.3876',to_date('01-JUL-06','DD-MON-RR'),'SH_CLERK',3200,null,123,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (195,'Vance','Jones','VJONES','650.501.4876',to_date('17-MAR-07','DD-MON-RR'),'SH_CLERK',2800,null,123,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (196,'Alana','Walsh','AWALSH','650.507.9811',to_date('24-APR-06','DD-MON-RR'),'SH_CLERK',3100,null,124,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (197,'Kevin','Feeney','KFEENEY','650.507.9822',to_date('23-MAY-06','DD-MON-RR'),'SH_CLERK',3000,null,124,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (198,'Donald','OConnell','DOCONNEL','650.507.9833',to_date('21-JUN-07','DD-MON-RR'),'SH_CLERK',2600,null,124,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (199,'Douglas','Grant','DGRANT','650.507.9844',to_date('13-JAN-08','DD-MON-RR'),'SH_CLERK',2600,null,124,50); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (200,'Jennifer','Whalen','JWHALEN','515.123.4444',to_date('17-SEP-03','DD-MON-RR'),'AD_ASST',4400,null,101,10); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (201,'Michael','Hartstein','MHARTSTE','515.123.5555',to_date('17-FEB-04','DD-MON-RR'),'MK_MAN',13000,null,100,20); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (202,'Pat','Fay','PFAY','603.123.6666',to_date('17-AUG-05','DD-MON-RR'),'MK_REP',6000,null,201,20); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (203,'Susan','Mavris','SMAVRIS','515.123.7777',to_date('07-JUN-02','DD-MON-RR'),'HR_REP',6500,null,101,40); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (204,'Hermann','Baer','HBAER','515.123.8888',to_date('07-JUN-02','DD-MON-RR'),'PR_REP',10000,null,101,70); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (205,'Shelley','Higgins','SHIGGINS','515.123.8080',to_date('07-JUN-02','DD-MON-RR'),'AC_MGR',12008,null,101,110); +Insert into HR.EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID) values (206,'William','Gietz','WGIETZ','515.123.8181',to_date('07-JUN-02','DD-MON-RR'),'AC_ACCOUNT',8300,null,205,110); +REM INSERTING into HR.JOBS +SET DEFINE OFF; +Insert into HR.JOBS (JOB_ID,JOB_TITLE,MIN_SALARY,MAX_SALARY) values ('AD_PRES','President',20080,40000); +Insert into HR.JOBS (JOB_ID,JOB_TITLE,MIN_SALARY,MAX_SALARY) values ('AD_VP','Administration Vice President',15000,30000); +Insert into HR.JOBS (JOB_ID,JOB_TITLE,MIN_SALARY,MAX_SALARY) values ('AD_ASST','Administration Assistant',3000,6000); +Insert into HR.JOBS (JOB_ID,JOB_TITLE,MIN_SALARY,MAX_SALARY) values ('FI_MGR','Finance Manager',8200,16000); +Insert into HR.JOBS (JOB_ID,JOB_TITLE,MIN_SALARY,MAX_SALARY) values ('FI_ACCOUNT','Accountant',4200,9000); +Insert into HR.JOBS (JOB_ID,JOB_TITLE,MIN_SALARY,MAX_SALARY) values ('AC_MGR','Accounting Manager',8200,16000); +Insert into HR.JOBS (JOB_ID,JOB_TITLE,MIN_SALARY,MAX_SALARY) values ('AC_ACCOUNT','Public Accountant',4200,9000); +Insert into HR.JOBS (JOB_ID,JOB_TITLE,MIN_SALARY,MAX_SALARY) values ('SA_MAN','Sales Manager',10000,20080); +Insert into HR.JOBS (JOB_ID,JOB_TITLE,MIN_SALARY,MAX_SALARY) values ('SA_REP','Sales Representative',6000,12008); +Insert into HR.JOBS (JOB_ID,JOB_TITLE,MIN_SALARY,MAX_SALARY) values ('PU_MAN','Purchasing Manager',8000,15000); +Insert into HR.JOBS (JOB_ID,JOB_TITLE,MIN_SALARY,MAX_SALARY) values ('PU_CLERK','Purchasing Clerk',2500,5500); +Insert into HR.JOBS (JOB_ID,JOB_TITLE,MIN_SALARY,MAX_SALARY) values ('ST_MAN','Stock Manager',5500,8500); +Insert into HR.JOBS (JOB_ID,JOB_TITLE,MIN_SALARY,MAX_SALARY) values ('ST_CLERK','Stock Clerk',2008,5000); +Insert into HR.JOBS (JOB_ID,JOB_TITLE,MIN_SALARY,MAX_SALARY) values ('SH_CLERK','Shipping Clerk',2500,5500); +Insert into HR.JOBS (JOB_ID,JOB_TITLE,MIN_SALARY,MAX_SALARY) values ('IT_PROG','Programmer',4000,10000); +Insert into HR.JOBS (JOB_ID,JOB_TITLE,MIN_SALARY,MAX_SALARY) values ('MK_MAN','Marketing Manager',9000,15000); +Insert into HR.JOBS (JOB_ID,JOB_TITLE,MIN_SALARY,MAX_SALARY) values ('MK_REP','Marketing Representative',4000,9000); +Insert into HR.JOBS (JOB_ID,JOB_TITLE,MIN_SALARY,MAX_SALARY) values ('HR_REP','Human Resources Representative',4000,9000); +Insert into HR.JOBS (JOB_ID,JOB_TITLE,MIN_SALARY,MAX_SALARY) values ('PR_REP','Public Relations Representative',4500,10500); +REM INSERTING into HR.JOB_HISTORY +SET DEFINE OFF; +Insert into HR.JOB_HISTORY (EMPLOYEE_ID,START_DATE,END_DATE,JOB_ID,DEPARTMENT_ID) values (102,to_date('13-JAN-01','DD-MON-RR'),to_date('24-JUL-06','DD-MON-RR'),'IT_PROG',60); +Insert into HR.JOB_HISTORY (EMPLOYEE_ID,START_DATE,END_DATE,JOB_ID,DEPARTMENT_ID) values (101,to_date('21-SEP-97','DD-MON-RR'),to_date('27-OCT-01','DD-MON-RR'),'AC_ACCOUNT',110); +Insert into HR.JOB_HISTORY (EMPLOYEE_ID,START_DATE,END_DATE,JOB_ID,DEPARTMENT_ID) values (101,to_date('28-OCT-01','DD-MON-RR'),to_date('15-MAR-05','DD-MON-RR'),'AC_MGR',110); +Insert into HR.JOB_HISTORY (EMPLOYEE_ID,START_DATE,END_DATE,JOB_ID,DEPARTMENT_ID) values (201,to_date('17-FEB-04','DD-MON-RR'),to_date('19-DEC-07','DD-MON-RR'),'MK_REP',20); +Insert into HR.JOB_HISTORY (EMPLOYEE_ID,START_DATE,END_DATE,JOB_ID,DEPARTMENT_ID) values (114,to_date('24-MAR-06','DD-MON-RR'),to_date('31-DEC-07','DD-MON-RR'),'ST_CLERK',50); +Insert into HR.JOB_HISTORY (EMPLOYEE_ID,START_DATE,END_DATE,JOB_ID,DEPARTMENT_ID) values (122,to_date('01-JAN-07','DD-MON-RR'),to_date('31-DEC-07','DD-MON-RR'),'ST_CLERK',50); +Insert into HR.JOB_HISTORY (EMPLOYEE_ID,START_DATE,END_DATE,JOB_ID,DEPARTMENT_ID) values (200,to_date('17-SEP-95','DD-MON-RR'),to_date('17-JUN-01','DD-MON-RR'),'AD_ASST',90); +Insert into HR.JOB_HISTORY (EMPLOYEE_ID,START_DATE,END_DATE,JOB_ID,DEPARTMENT_ID) values (176,to_date('24-MAR-06','DD-MON-RR'),to_date('31-DEC-06','DD-MON-RR'),'SA_REP',80); +Insert into HR.JOB_HISTORY (EMPLOYEE_ID,START_DATE,END_DATE,JOB_ID,DEPARTMENT_ID) values (176,to_date('01-JAN-07','DD-MON-RR'),to_date('31-DEC-07','DD-MON-RR'),'SA_MAN',80); +Insert into HR.JOB_HISTORY (EMPLOYEE_ID,START_DATE,END_DATE,JOB_ID,DEPARTMENT_ID) values (200,to_date('01-JUL-02','DD-MON-RR'),to_date('31-DEC-06','DD-MON-RR'),'AC_ACCOUNT',90); +REM INSERTING into HR.LOCATIONS +SET DEFINE OFF; +Insert into HR.LOCATIONS (LOCATION_ID,STREET_ADDRESS,POSTAL_CODE,CITY,STATE_PROVINCE,COUNTRY_ID) values (1000,'1297 Via Cola di Rie','00989','Roma',null,'IT'); +Insert into HR.LOCATIONS (LOCATION_ID,STREET_ADDRESS,POSTAL_CODE,CITY,STATE_PROVINCE,COUNTRY_ID) values (1100,'93091 Calle della Testa','10934','Venice',null,'IT'); +Insert into HR.LOCATIONS (LOCATION_ID,STREET_ADDRESS,POSTAL_CODE,CITY,STATE_PROVINCE,COUNTRY_ID) values (1200,'2017 Shinjuku-ku','1689','Tokyo','Tokyo Prefecture','JP'); +Insert into HR.LOCATIONS (LOCATION_ID,STREET_ADDRESS,POSTAL_CODE,CITY,STATE_PROVINCE,COUNTRY_ID) values (1300,'9450 Kamiya-cho','6823','Hiroshima',null,'JP'); +Insert into HR.LOCATIONS (LOCATION_ID,STREET_ADDRESS,POSTAL_CODE,CITY,STATE_PROVINCE,COUNTRY_ID) values (1400,'2014 Jabberwocky Rd','26192','Southlake','Texas','US'); +Insert into HR.LOCATIONS (LOCATION_ID,STREET_ADDRESS,POSTAL_CODE,CITY,STATE_PROVINCE,COUNTRY_ID) values (1500,'2011 Interiors Blvd','99236','South San Francisco','California','US'); +Insert into HR.LOCATIONS (LOCATION_ID,STREET_ADDRESS,POSTAL_CODE,CITY,STATE_PROVINCE,COUNTRY_ID) values (1600,'2007 Zagora St','50090','South Brunswick','New Jersey','US'); +Insert into HR.LOCATIONS (LOCATION_ID,STREET_ADDRESS,POSTAL_CODE,CITY,STATE_PROVINCE,COUNTRY_ID) values (1700,'2004 Charade Rd','98199','Seattle','Washington','US'); +Insert into HR.LOCATIONS (LOCATION_ID,STREET_ADDRESS,POSTAL_CODE,CITY,STATE_PROVINCE,COUNTRY_ID) values (1800,'147 Spadina Ave','M5V 2L7','Toronto','Ontario','CA'); +Insert into HR.LOCATIONS (LOCATION_ID,STREET_ADDRESS,POSTAL_CODE,CITY,STATE_PROVINCE,COUNTRY_ID) values (1900,'6092 Boxwood St','YSW 9T2','Whitehorse','Yukon','CA'); +Insert into HR.LOCATIONS (LOCATION_ID,STREET_ADDRESS,POSTAL_CODE,CITY,STATE_PROVINCE,COUNTRY_ID) values (2000,'40-5-12 Laogianggen','190518','Beijing',null,'CN'); +Insert into HR.LOCATIONS (LOCATION_ID,STREET_ADDRESS,POSTAL_CODE,CITY,STATE_PROVINCE,COUNTRY_ID) values (2100,'1298 Vileparle (E)','490231','Bombay','Maharashtra','IN'); +Insert into HR.LOCATIONS (LOCATION_ID,STREET_ADDRESS,POSTAL_CODE,CITY,STATE_PROVINCE,COUNTRY_ID) values (2200,'12-98 Victoria Street','2901','Sydney','New South Wales','AU'); +Insert into HR.LOCATIONS (LOCATION_ID,STREET_ADDRESS,POSTAL_CODE,CITY,STATE_PROVINCE,COUNTRY_ID) values (2300,'198 Clementi North','540198','Singapore',null,'SG'); +Insert into HR.LOCATIONS (LOCATION_ID,STREET_ADDRESS,POSTAL_CODE,CITY,STATE_PROVINCE,COUNTRY_ID) values (2400,'8204 Arthur St',null,'London',null,'UK'); +Insert into HR.LOCATIONS (LOCATION_ID,STREET_ADDRESS,POSTAL_CODE,CITY,STATE_PROVINCE,COUNTRY_ID) values (2500,'Magdalen Centre, The Oxford Science Park','OX9 9ZB','Oxford','Oxford','UK'); +Insert into HR.LOCATIONS (LOCATION_ID,STREET_ADDRESS,POSTAL_CODE,CITY,STATE_PROVINCE,COUNTRY_ID) values (2600,'9702 Chester Road','09629850293','Stretford','Manchester','UK'); +Insert into HR.LOCATIONS (LOCATION_ID,STREET_ADDRESS,POSTAL_CODE,CITY,STATE_PROVINCE,COUNTRY_ID) values (2700,'Schwanthalerstr. 7031','80925','Munich','Bavaria','DE'); +Insert into HR.LOCATIONS (LOCATION_ID,STREET_ADDRESS,POSTAL_CODE,CITY,STATE_PROVINCE,COUNTRY_ID) values (2800,'Rua Frei Caneca 1360 ','01307-002','Sao Paulo','Sao Paulo','BR'); +Insert into HR.LOCATIONS (LOCATION_ID,STREET_ADDRESS,POSTAL_CODE,CITY,STATE_PROVINCE,COUNTRY_ID) values (2900,'20 Rue des Corps-Saints','1730','Geneva','Geneve','CH'); +Insert into HR.LOCATIONS (LOCATION_ID,STREET_ADDRESS,POSTAL_CODE,CITY,STATE_PROVINCE,COUNTRY_ID) values (3000,'Murtenstrasse 921','3095','Bern','BE','CH'); +Insert into HR.LOCATIONS (LOCATION_ID,STREET_ADDRESS,POSTAL_CODE,CITY,STATE_PROVINCE,COUNTRY_ID) values (3100,'Pieter Breughelstraat 837','3029SK','Utrecht','Utrecht','NL'); +Insert into HR.LOCATIONS (LOCATION_ID,STREET_ADDRESS,POSTAL_CODE,CITY,STATE_PROVINCE,COUNTRY_ID) values (3200,'Mariano Escobedo 9991','11932','Mexico City','Distrito Federal,','MX'); +REM INSERTING into HR.REGIONS +SET DEFINE OFF; +Insert into HR.REGIONS (REGION_ID,REGION_NAME) values (1,'Europe'); +Insert into HR.REGIONS (REGION_ID,REGION_NAME) values (2,'Americas'); +Insert into HR.REGIONS (REGION_ID,REGION_NAME) values (3,'Asia'); +Insert into HR.REGIONS (REGION_ID,REGION_NAME) values (4,'Middle East and Africa'); +-------------------------------------------------------- +-- DDL for Index LOC_STATE_PROVINCE_IX +-------------------------------------------------------- + + CREATE INDEX "HR"."LOC_STATE_PROVINCE_IX" ON "HR"."LOCATIONS" ("STATE_PROVINCE") + PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ; +-------------------------------------------------------- +-- DDL for Index LOC_ID_PK +-------------------------------------------------------- + + CREATE UNIQUE INDEX "HR"."LOC_ID_PK" ON "HR"."LOCATIONS" ("LOCATION_ID") + PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ; +-------------------------------------------------------- +-- DDL for Index EMP_DEPARTMENT_IX +-------------------------------------------------------- + + CREATE INDEX "HR"."EMP_DEPARTMENT_IX" ON "HR"."EMPLOYEES" ("DEPARTMENT_ID") + PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ; +-------------------------------------------------------- +-- DDL for Index EMP_EMAIL_UK +-------------------------------------------------------- + + CREATE UNIQUE INDEX "HR"."EMP_EMAIL_UK" ON "HR"."EMPLOYEES" ("EMAIL") + PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ; +-------------------------------------------------------- +-- DDL for Index EMP_NAME_IX +-------------------------------------------------------- + + CREATE INDEX "HR"."EMP_NAME_IX" ON "HR"."EMPLOYEES" ("LAST_NAME", "FIRST_NAME") + PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ; +-------------------------------------------------------- +-- DDL for Index EMP_MANAGER_IX +-------------------------------------------------------- + + CREATE INDEX "HR"."EMP_MANAGER_IX" ON "HR"."EMPLOYEES" ("MANAGER_ID") + PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ; +-------------------------------------------------------- +-- DDL for Index DEPT_LOCATION_IX +-------------------------------------------------------- + + CREATE INDEX "HR"."DEPT_LOCATION_IX" ON "HR"."DEPARTMENTS" ("LOCATION_ID") + PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ; +-------------------------------------------------------- +-- DDL for Index REG_ID_PK +-------------------------------------------------------- + + CREATE UNIQUE INDEX "HR"."REG_ID_PK" ON "HR"."REGIONS" ("REGION_ID") + PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ; +-------------------------------------------------------- +-- DDL for Index JHIST_EMP_ID_ST_DATE_PK +-------------------------------------------------------- + + CREATE UNIQUE INDEX "HR"."JHIST_EMP_ID_ST_DATE_PK" ON "HR"."JOB_HISTORY" ("EMPLOYEE_ID", "START_DATE") + PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ; +-------------------------------------------------------- +-- DDL for Index JHIST_DEPARTMENT_IX +-------------------------------------------------------- + + CREATE INDEX "HR"."JHIST_DEPARTMENT_IX" ON "HR"."JOB_HISTORY" ("DEPARTMENT_ID") + PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ; +-------------------------------------------------------- +-- DDL for Index EMP_EMP_ID_PK +-------------------------------------------------------- + + CREATE UNIQUE INDEX "HR"."EMP_EMP_ID_PK" ON "HR"."EMPLOYEES" ("EMPLOYEE_ID") + PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ; +-------------------------------------------------------- +-- DDL for Index DEPT_ID_PK +-------------------------------------------------------- + + CREATE UNIQUE INDEX "HR"."DEPT_ID_PK" ON "HR"."DEPARTMENTS" ("DEPARTMENT_ID") + PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ; +-------------------------------------------------------- +-- DDL for Index COUNTRY_C_ID_PK +-------------------------------------------------------- + + CREATE UNIQUE INDEX "HR"."COUNTRY_C_ID_PK" ON "HR"."COUNTRIES" ("COUNTRY_ID") + PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ; +-------------------------------------------------------- +-- DDL for Index JHIST_JOB_IX +-------------------------------------------------------- + + CREATE INDEX "HR"."JHIST_JOB_IX" ON "HR"."JOB_HISTORY" ("JOB_ID") + PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ; +-------------------------------------------------------- +-- DDL for Index JHIST_EMPLOYEE_IX +-------------------------------------------------------- + + CREATE INDEX "HR"."JHIST_EMPLOYEE_IX" ON "HR"."JOB_HISTORY" ("EMPLOYEE_ID") + PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ; +-------------------------------------------------------- +-- DDL for Index LOC_COUNTRY_IX +-------------------------------------------------------- + + CREATE INDEX "HR"."LOC_COUNTRY_IX" ON "HR"."LOCATIONS" ("COUNTRY_ID") + PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ; +-------------------------------------------------------- +-- DDL for Index EMP_JOB_IX +-------------------------------------------------------- + + CREATE INDEX "HR"."EMP_JOB_IX" ON "HR"."EMPLOYEES" ("JOB_ID") + PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ; +-------------------------------------------------------- +-- DDL for Index LOC_CITY_IX +-------------------------------------------------------- + + CREATE INDEX "HR"."LOC_CITY_IX" ON "HR"."LOCATIONS" ("CITY") + PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ; +-------------------------------------------------------- +-- DDL for Index JOB_ID_PK +-------------------------------------------------------- + + CREATE UNIQUE INDEX "HR"."JOB_ID_PK" ON "HR"."JOBS" ("JOB_ID") + PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ; +-------------------------------------------------------- +-- Constraints for Table REGIONS +-------------------------------------------------------- + + ALTER TABLE "HR"."REGIONS" ADD CONSTRAINT "REG_ID_PK" PRIMARY KEY ("REGION_ID") + USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ENABLE; + ALTER TABLE "HR"."REGIONS" MODIFY ("REGION_ID" CONSTRAINT "REGION_ID_NN" NOT NULL ENABLE); +-------------------------------------------------------- +-- Constraints for Table LOCATIONS +-------------------------------------------------------- + + ALTER TABLE "HR"."LOCATIONS" ADD CONSTRAINT "LOC_ID_PK" PRIMARY KEY ("LOCATION_ID") + USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ENABLE; + ALTER TABLE "HR"."LOCATIONS" MODIFY ("CITY" CONSTRAINT "LOC_CITY_NN" NOT NULL ENABLE); +-------------------------------------------------------- +-- Constraints for Table EMPLOYEES +-------------------------------------------------------- + + ALTER TABLE "HR"."EMPLOYEES" ADD CONSTRAINT "EMP_EMP_ID_PK" PRIMARY KEY ("EMPLOYEE_ID") + USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ENABLE; + ALTER TABLE "HR"."EMPLOYEES" ADD CONSTRAINT "EMP_EMAIL_UK" UNIQUE ("EMAIL") + USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ENABLE; + ALTER TABLE "HR"."EMPLOYEES" ADD CONSTRAINT "EMP_SALARY_MIN" CHECK (salary > 0) ENABLE; + ALTER TABLE "HR"."EMPLOYEES" MODIFY ("JOB_ID" CONSTRAINT "EMP_JOB_NN" NOT NULL ENABLE); + ALTER TABLE "HR"."EMPLOYEES" MODIFY ("HIRE_DATE" CONSTRAINT "EMP_HIRE_DATE_NN" NOT NULL ENABLE); + ALTER TABLE "HR"."EMPLOYEES" MODIFY ("EMAIL" CONSTRAINT "EMP_EMAIL_NN" NOT NULL ENABLE); + ALTER TABLE "HR"."EMPLOYEES" MODIFY ("LAST_NAME" CONSTRAINT "EMP_LAST_NAME_NN" NOT NULL ENABLE); +-------------------------------------------------------- +-- Constraints for Table DEPARTMENTS +-------------------------------------------------------- + + ALTER TABLE "HR"."DEPARTMENTS" ADD CONSTRAINT "DEPT_ID_PK" PRIMARY KEY ("DEPARTMENT_ID") + USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ENABLE; + ALTER TABLE "HR"."DEPARTMENTS" MODIFY ("DEPARTMENT_NAME" CONSTRAINT "DEPT_NAME_NN" NOT NULL ENABLE); +-------------------------------------------------------- +-- Constraints for Table JOB_HISTORY +-------------------------------------------------------- + + ALTER TABLE "HR"."JOB_HISTORY" ADD CONSTRAINT "JHIST_EMP_ID_ST_DATE_PK" PRIMARY KEY ("EMPLOYEE_ID", "START_DATE") + USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ENABLE; + ALTER TABLE "HR"."JOB_HISTORY" ADD CONSTRAINT "JHIST_DATE_INTERVAL" CHECK (end_date > start_date) ENABLE; + ALTER TABLE "HR"."JOB_HISTORY" MODIFY ("JOB_ID" CONSTRAINT "JHIST_JOB_NN" NOT NULL ENABLE); + ALTER TABLE "HR"."JOB_HISTORY" MODIFY ("END_DATE" CONSTRAINT "JHIST_END_DATE_NN" NOT NULL ENABLE); + ALTER TABLE "HR"."JOB_HISTORY" MODIFY ("START_DATE" CONSTRAINT "JHIST_START_DATE_NN" NOT NULL ENABLE); + ALTER TABLE "HR"."JOB_HISTORY" MODIFY ("EMPLOYEE_ID" CONSTRAINT "JHIST_EMPLOYEE_NN" NOT NULL ENABLE); +-------------------------------------------------------- +-- Constraints for Table COUNTRIES +-------------------------------------------------------- + + ALTER TABLE "HR"."COUNTRIES" ADD CONSTRAINT "COUNTRY_C_ID_PK" PRIMARY KEY ("COUNTRY_ID") + USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ENABLE; + ALTER TABLE "HR"."COUNTRIES" MODIFY ("COUNTRY_ID" CONSTRAINT "COUNTRY_ID_NN" NOT NULL ENABLE); +-------------------------------------------------------- +-- Constraints for Table JOBS +-------------------------------------------------------- + + ALTER TABLE "HR"."JOBS" ADD CONSTRAINT "JOB_ID_PK" PRIMARY KEY ("JOB_ID") + USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS + STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 + PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) + TABLESPACE "USERS" ENABLE; + ALTER TABLE "HR"."JOBS" MODIFY ("JOB_TITLE" CONSTRAINT "JOB_TITLE_NN" NOT NULL ENABLE); +-------------------------------------------------------- +-- Ref Constraints for Table COUNTRIES +-------------------------------------------------------- + + ALTER TABLE "HR"."COUNTRIES" ADD CONSTRAINT "COUNTR_REG_FK" FOREIGN KEY ("REGION_ID") + REFERENCES "HR"."REGIONS" ("REGION_ID") ENABLE; +-------------------------------------------------------- +-- Ref Constraints for Table DEPARTMENTS +-------------------------------------------------------- + + ALTER TABLE "HR"."DEPARTMENTS" ADD CONSTRAINT "DEPT_LOC_FK" FOREIGN KEY ("LOCATION_ID") + REFERENCES "HR"."LOCATIONS" ("LOCATION_ID") ENABLE; + ALTER TABLE "HR"."DEPARTMENTS" ADD CONSTRAINT "DEPT_MGR_FK" FOREIGN KEY ("MANAGER_ID") + REFERENCES "HR"."EMPLOYEES" ("EMPLOYEE_ID") ENABLE; +-------------------------------------------------------- +-- Ref Constraints for Table EMPLOYEES +-------------------------------------------------------- + + ALTER TABLE "HR"."EMPLOYEES" ADD CONSTRAINT "EMP_DEPT_FK" FOREIGN KEY ("DEPARTMENT_ID") + REFERENCES "HR"."DEPARTMENTS" ("DEPARTMENT_ID") ENABLE; + ALTER TABLE "HR"."EMPLOYEES" ADD CONSTRAINT "EMP_JOB_FK" FOREIGN KEY ("JOB_ID") + REFERENCES "HR"."JOBS" ("JOB_ID") ENABLE; + ALTER TABLE "HR"."EMPLOYEES" ADD CONSTRAINT "EMP_MANAGER_FK" FOREIGN KEY ("MANAGER_ID") + REFERENCES "HR"."EMPLOYEES" ("EMPLOYEE_ID") ENABLE; +-------------------------------------------------------- +-- Ref Constraints for Table JOB_HISTORY +-------------------------------------------------------- + + ALTER TABLE "HR"."JOB_HISTORY" ADD CONSTRAINT "JHIST_DEPT_FK" FOREIGN KEY ("DEPARTMENT_ID") + REFERENCES "HR"."DEPARTMENTS" ("DEPARTMENT_ID") ENABLE; + ALTER TABLE "HR"."JOB_HISTORY" ADD CONSTRAINT "JHIST_EMP_FK" FOREIGN KEY ("EMPLOYEE_ID") + REFERENCES "HR"."EMPLOYEES" ("EMPLOYEE_ID") ENABLE; + ALTER TABLE "HR"."JOB_HISTORY" ADD CONSTRAINT "JHIST_JOB_FK" FOREIGN KEY ("JOB_ID") + REFERENCES "HR"."JOBS" ("JOB_ID") ENABLE; +-------------------------------------------------------- +-- Ref Constraints for Table LOCATIONS +-------------------------------------------------------- + + ALTER TABLE "HR"."LOCATIONS" ADD CONSTRAINT "LOC_C_ID_FK" FOREIGN KEY ("COUNTRY_ID") + REFERENCES "HR"."COUNTRIES" ("COUNTRY_ID") ENABLE; +-------------------------------------------------------- +-- DDL for Trigger SECURE_EMPLOYEES +-------------------------------------------------------- + + CREATE OR REPLACE TRIGGER "HR"."SECURE_EMPLOYEES" + BEFORE INSERT OR UPDATE OR DELETE ON employees +BEGIN + secure_dml; +END secure_employees; +/ +ALTER TRIGGER "HR"."SECURE_EMPLOYEES" DISABLE; +-------------------------------------------------------- +-- DDL for Trigger UPDATE_JOB_HISTORY +-------------------------------------------------------- + + CREATE OR REPLACE TRIGGER "HR"."UPDATE_JOB_HISTORY" + AFTER UPDATE OF job_id, department_id ON employees + FOR EACH ROW +BEGIN + add_job_history(:old.employee_id, :old.hire_date, sysdate, + :old.job_id, :old.department_id); +END; +/ +ALTER TRIGGER "HR"."UPDATE_JOB_HISTORY" ENABLE; +-------------------------------------------------------- +-- DDL for Procedure ADD_JOB_HISTORY +-------------------------------------------------------- +set define off; + + CREATE OR REPLACE PROCEDURE "HR"."ADD_JOB_HISTORY" + ( p_emp_id job_history.employee_id%type + , p_start_date job_history.start_date%type + , p_end_date job_history.end_date%type + , p_job_id job_history.job_id%type + , p_department_id job_history.department_id%type + ) +IS +BEGIN + INSERT INTO job_history (employee_id, start_date, end_date, + job_id, department_id) + VALUES(p_emp_id, p_start_date, p_end_date, p_job_id, p_department_id); +END add_job_history; + +/ +-------------------------------------------------------- +-- DDL for Procedure SECURE_DML +-------------------------------------------------------- +set define off; + + CREATE OR REPLACE PROCEDURE "HR"."SECURE_DML" +IS +BEGIN + IF TO_CHAR (SYSDATE, 'HH24:MI') NOT BETWEEN '08:00' AND '18:00' + OR TO_CHAR (SYSDATE, 'DY') IN ('SAT', 'SUN') THEN + RAISE_APPLICATION_ERROR (-20205, + 'You may only make changes during normal office hours'); + END IF; +END secure_dml; + +/ diff --git a/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/context.xml b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/context.xml new file mode 100644 index 000000000..be2e06376 --- /dev/null +++ b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/context.xml @@ -0,0 +1,65 @@ + + + + + + + WEB-INF/web.xml + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/ojdbc6.jar b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/ojdbc6.jar new file mode 100644 index 000000000..d20359ea4 Binary files /dev/null and b/JDBC/EmployeeInfoDemoTomcatDBCPOracleApp/ojdbc6.jar differ diff --git a/Later/Java_Networking/1/Java_Networking_Intro.pptx b/Later/Java_Networking/1/Java_Networking_Intro.pptx new file mode 100644 index 000000000..dc80570c8 Binary files /dev/null and b/Later/Java_Networking/1/Java_Networking_Intro.pptx differ diff --git a/Later/Java_Networking/1/What is networking.pptx b/Later/Java_Networking/1/What is networking.pptx new file mode 100644 index 000000000..186b5a749 Binary files /dev/null and b/Later/Java_Networking/1/What is networking.pptx differ diff --git a/Later/Java_Networking/1/What is networking_V2.pptx b/Later/Java_Networking/1/What is networking_V2.pptx new file mode 100644 index 000000000..472f0b0e7 Binary files /dev/null and b/Later/Java_Networking/1/What is networking_V2.pptx differ diff --git a/Later/Java_Networking/1/What is networking_V3.pptx b/Later/Java_Networking/1/What is networking_V3.pptx new file mode 100644 index 000000000..48f4933f5 Binary files /dev/null and b/Later/Java_Networking/1/What is networking_V3.pptx differ diff --git a/Later/Java_Networking/1/What is networking_V4.pptx b/Later/Java_Networking/1/What is networking_V4.pptx new file mode 100644 index 000000000..46603a0c6 Binary files /dev/null and b/Later/Java_Networking/1/What is networking_V4.pptx differ diff --git a/Later/Java_Networking/2/Java Networking Terminology.pptx b/Later/Java_Networking/2/Java Networking Terminology.pptx new file mode 100644 index 000000000..303fb8926 Binary files /dev/null and b/Later/Java_Networking/2/Java Networking Terminology.pptx differ diff --git a/Later/Java_Networking/3/Java Socket Programming.pptx b/Later/Java_Networking/3/Java Socket Programming.pptx new file mode 100644 index 000000000..199529f67 Binary files /dev/null and b/Later/Java_Networking/3/Java Socket Programming.pptx differ diff --git a/Later/Java_Networking/4/Java Socket Programming Example.pptx b/Later/Java_Networking/4/Java Socket Programming Example.pptx new file mode 100644 index 000000000..ff8713eb6 Binary files /dev/null and b/Later/Java_Networking/4/Java Socket Programming Example.pptx differ diff --git a/Later/Java_Networking/4/SocketDemo/.classpath b/Later/Java_Networking/4/SocketDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Networking/4/SocketDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Networking/4/SocketDemo/.project b/Later/Java_Networking/4/SocketDemo/.project new file mode 100644 index 000000000..7161aeb6a --- /dev/null +++ b/Later/Java_Networking/4/SocketDemo/.project @@ -0,0 +1,17 @@ + + + SocketDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Networking/4/SocketDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Networking/4/SocketDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Networking/4/SocketDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Networking/4/SocketDemo/bin/Client.class b/Later/Java_Networking/4/SocketDemo/bin/Client.class new file mode 100644 index 000000000..6234cbd31 Binary files /dev/null and b/Later/Java_Networking/4/SocketDemo/bin/Client.class differ diff --git a/Later/Java_Networking/4/SocketDemo/bin/Server.class b/Later/Java_Networking/4/SocketDemo/bin/Server.class new file mode 100644 index 000000000..363e9cdb6 Binary files /dev/null and b/Later/Java_Networking/4/SocketDemo/bin/Server.class differ diff --git a/Later/Java_Networking/4/SocketDemo/src/Client.java b/Later/Java_Networking/4/SocketDemo/src/Client.java new file mode 100644 index 000000000..031d6c71d --- /dev/null +++ b/Later/Java_Networking/4/SocketDemo/src/Client.java @@ -0,0 +1,56 @@ +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.net.Socket; + +public class Client +{ + public static void main(String[] args) + { + Socket socket = null; + DataOutputStream dout = null; + try + { + /* + * Creates a stream socket and connects it to the + * specified port number at the specified IP address. + */ + socket = new Socket("localhost", 6666); + + /* + * returns the OutputStream attached with this socket. + */ + OutputStream outputStream = socket.getOutputStream(); + dout = new DataOutputStream(outputStream); + dout.writeUTF("Hello Server"); + System.out.println("Client sent the message to server "); + dout.flush(); + + } + catch (Exception exe) + { + exe.printStackTrace(); + } + finally + { + try + { + if (dout != null) + { + dout.close(); + } + if (socket != null) + { + /* + * closes this socket + */ + socket.close(); + } + } + catch (IOException e) + { + e.printStackTrace(); + } + } + } +} \ No newline at end of file diff --git a/Later/Java_Networking/4/SocketDemo/src/Server.java b/Later/Java_Networking/4/SocketDemo/src/Server.java new file mode 100644 index 000000000..9677728f7 --- /dev/null +++ b/Later/Java_Networking/4/SocketDemo/src/Server.java @@ -0,0 +1,58 @@ +import java.io.DataInputStream; +import java.io.IOException; +import java.net.ServerSocket; +import java.net.Socket; + +public class Server +{ + + public static void main(String[] args) + { + ServerSocket serverSocket = null; + try + { + /* + * Creates a server socket, bound to the specified port. + */ + serverSocket = new ServerSocket(6666); + System.out.println( + "Server is Waiting for client request... "); + + /* + * Listens for a connection to be made to this socket and + * accepts it. The method blocks until a connection is + * made. + */ + Socket s = serverSocket.accept(); + DataInputStream dis = new DataInputStream( + s.getInputStream()); + String str = (String) dis.readUTF(); + System.out.println( + "Server received message from by client is = " + + str); + } + catch (Exception exe) + { + exe.printStackTrace(); + } + finally + { + try + { + if (serverSocket != null) + { + /* + * closes the server socket. + */ + serverSocket.close(); + } + } + catch (IOException e) + { + e.printStackTrace(); + } + } + + } + +} diff --git a/Later/Java_Networking/5/SocketDemo/.classpath b/Later/Java_Networking/5/SocketDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Networking/5/SocketDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Networking/5/SocketDemo/.project b/Later/Java_Networking/5/SocketDemo/.project new file mode 100644 index 000000000..7161aeb6a --- /dev/null +++ b/Later/Java_Networking/5/SocketDemo/.project @@ -0,0 +1,17 @@ + + + SocketDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Networking/5/SocketDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Networking/5/SocketDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Networking/5/SocketDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Networking/5/SocketDemo/bin/Client.class b/Later/Java_Networking/5/SocketDemo/bin/Client.class new file mode 100644 index 000000000..616931bd3 Binary files /dev/null and b/Later/Java_Networking/5/SocketDemo/bin/Client.class differ diff --git a/Later/Java_Networking/5/SocketDemo/bin/Server.class b/Later/Java_Networking/5/SocketDemo/bin/Server.class new file mode 100644 index 000000000..161a63264 Binary files /dev/null and b/Later/Java_Networking/5/SocketDemo/bin/Server.class differ diff --git a/Later/Java_Networking/5/SocketDemo/src/Client.java b/Later/Java_Networking/5/SocketDemo/src/Client.java new file mode 100644 index 000000000..0076c54d7 --- /dev/null +++ b/Later/Java_Networking/5/SocketDemo/src/Client.java @@ -0,0 +1,82 @@ +import java.io.BufferedReader; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.Socket; + +public class Client +{ + public static void main(String[] args) + { + Socket socket = null; + DataInputStream din = null; + DataOutputStream dout = null; + BufferedReader br = null; + + try + { + /* + * Creates a stream socket and connects it to the + * specified port number at the specified IP address. + */ + socket = new Socket("localhost", 6666); + + /* + * returns the OutputStream attached with this socket. + */ + OutputStream outputStream = socket.getOutputStream(); + dout = new DataOutputStream(outputStream); + din = new DataInputStream(socket.getInputStream()); + br = new BufferedReader(new InputStreamReader(System.in)); + + String strFromServer = "", strToClient = ""; + while (!strFromServer.equals("stop")) + { + strFromServer = br.readLine(); + dout.writeUTF(strFromServer); + dout.flush(); + strToClient = din.readUTF(); + System.out.println("Server says: " + strToClient); + } + + } + catch (Exception exe) + { + exe.printStackTrace(); + } + finally + { + try + { + + if (br != null) + { + br.close(); + } + + if (din != null) + { + din.close(); + } + + if (dout != null) + { + dout.close(); + } + if (socket != null) + { + /* + * closes this socket + */ + socket.close(); + } + } + catch (IOException e) + { + e.printStackTrace(); + } + } + } +} \ No newline at end of file diff --git a/Later/Java_Networking/5/SocketDemo/src/Server.java b/Later/Java_Networking/5/SocketDemo/src/Server.java new file mode 100644 index 000000000..f1a69ddf2 --- /dev/null +++ b/Later/Java_Networking/5/SocketDemo/src/Server.java @@ -0,0 +1,89 @@ +import java.io.BufferedReader; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.ServerSocket; +import java.net.Socket; + +public class Server +{ + + public static void main(String[] args) + { + DataInputStream din = null; + ServerSocket serverSocket = null; + DataOutputStream dout = null; + BufferedReader br = null; + try + { + /* + * Creates a server socket, bound to the specified port. + */ + serverSocket = new ServerSocket(6666); + System.out.println( + "Server is Waiting for client request... "); + + /* + * Listens for a connection to be made to this socket and + * accepts it. The method blocks until a connection is + * made. + */ + Socket socket = serverSocket.accept(); + DataInputStream dis = new DataInputStream( + socket.getInputStream()); + OutputStream outputStream = socket.getOutputStream(); + dout = new DataOutputStream(outputStream); + din = new DataInputStream(socket.getInputStream()); + br = new BufferedReader(new InputStreamReader(System.in)); + + String strFromClient = "", strToClient = ""; + while (!strFromClient.equals("stop")) + { + strFromClient = din.readUTF(); + System.out.println("client says: " + strFromClient); + strToClient = br.readLine(); + dout.writeUTF(strToClient); + dout.flush(); + } + } + catch (Exception exe) + { + exe.printStackTrace(); + } + finally + { + try + { + if (br != null) + { + br.close(); + } + + if (din != null) + { + din.close(); + } + + if (dout != null) + { + dout.close(); + } + if (serverSocket != null) + { + /* + * closes the server socket. + */ + serverSocket.close(); + } + } + catch (IOException e) + { + e.printStackTrace(); + } + } + + } + +} diff --git a/Later/Java_Util_package/Arrays/10_parallelPrefix/1/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/10_parallelPrefix/1/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/10_parallelPrefix/1/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/10_parallelPrefix/1/ArraysDemo/.project b/Later/Java_Util_package/Arrays/10_parallelPrefix/1/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/10_parallelPrefix/1/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/10_parallelPrefix/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/10_parallelPrefix/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/10_parallelPrefix/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/10_parallelPrefix/1/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/10_parallelPrefix/1/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..cbbff4c83 Binary files /dev/null and b/Later/Java_Util_package/Arrays/10_parallelPrefix/1/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/10_parallelPrefix/1/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/10_parallelPrefix/1/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..0ded70e8f Binary files /dev/null and b/Later/Java_Util_package/Arrays/10_parallelPrefix/1/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/10_parallelPrefix/1/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/10_parallelPrefix/1/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..478144753 --- /dev/null +++ b/Later/Java_Util_package/Arrays/10_parallelPrefix/1/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,42 @@ +import java.util.Arrays; +import java.util.function.IntBinaryOperator; + +/** + * + * public static void parallelPrefix(int[] array, IntBinaryOperator + * op) + * + * Cumulates, in parallel, each element of the given array in place, + * using the supplied function. For example if the array initially + * holds [2, 1, 0, 3] and the operation performs addition, then upon + * return the array holds [2, 3, 3, 6]. Parallel prefix computation is + * usually more efficient than sequential loops for large arrays. + * + * Parameters: + * + * array - the array, which is modified in-place by this method + * + * op - a side-effect-free, associative function to perform the + * cumulation + */ + +public class ArraysDemo1 +{ + // Performs addition + static int compute(int x, int y) + { + return x + y; + } + + public static void main(String[] args) + { + int[] intArray = { 10, 20, 30, 40 }; + + IntBinaryOperator intBinaryOperator = (x, y) -> compute(x, y); + + Arrays.parallelPrefix(intArray, intBinaryOperator); + + Arrays.stream(intArray).forEach(e -> System.out.print(e + " ")); + } + +} diff --git a/Later/Java_Util_package/Arrays/10_parallelPrefix/1/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/10_parallelPrefix/1/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..0da61cb78 --- /dev/null +++ b/Later/Java_Util_package/Arrays/10_parallelPrefix/1/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,46 @@ +import java.util.Arrays; +import java.util.function.IntBinaryOperator; + +/** + * + * public static void parallelPrefix(int[] array, int fromIndex, int + * toIndex, IntBinaryOperator op) + * + * Cumulates, in parallel, each element of the given array in place, + * using the supplied function. For example if the array initially + * holds [2, 1, 0, 3] and the operation performs addition, then upon + * return the array holds [2, 3, 3, 6]. Parallel prefix computation is + * usually more efficient than sequential loops for large arrays. + * + * Parameters: + * + * array - the array + * + * fromIndex - the index of the first element, inclusive + * + * toIndex - the index of the last element, exclusive + * + * op - a side-effect-free, associative function to perform the + * cumulation + */ +public class ArraysDemo2 +{ + + // Performs addition + static int compute(int x, int y) + { + return x + y; + } + + public static void main(String[] args) + { + int[] intArray = { 10, 20, 30, 40, 50 }; + + IntBinaryOperator intBinaryOperator = (x, y) -> compute(x, y); + + Arrays.parallelPrefix(intArray, 0, 3, intBinaryOperator); + + Arrays.stream(intArray).forEach(e -> System.out.print(e + " ")); + } + +} diff --git a/Later/Java_Util_package/Arrays/10_parallelPrefix/2/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/10_parallelPrefix/2/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/10_parallelPrefix/2/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/10_parallelPrefix/2/ArraysDemo/.project b/Later/Java_Util_package/Arrays/10_parallelPrefix/2/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/10_parallelPrefix/2/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/10_parallelPrefix/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/10_parallelPrefix/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/10_parallelPrefix/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/10_parallelPrefix/2/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/10_parallelPrefix/2/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..e95204690 Binary files /dev/null and b/Later/Java_Util_package/Arrays/10_parallelPrefix/2/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/10_parallelPrefix/2/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/10_parallelPrefix/2/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..a39352d12 Binary files /dev/null and b/Later/Java_Util_package/Arrays/10_parallelPrefix/2/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/10_parallelPrefix/2/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/10_parallelPrefix/2/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..fe1860d1c --- /dev/null +++ b/Later/Java_Util_package/Arrays/10_parallelPrefix/2/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,42 @@ +import java.util.Arrays; +import java.util.function.LongBinaryOperator; + +/** + * + * public static void parallelPrefix(long[] array, LongBinaryOperator + * op) + * + * Cumulates, in parallel, each element of the given array in place, + * using the supplied function. For example if the array initially + * holds [2, 1, 0, 3] and the operation performs addition, then upon + * return the array holds [2, 3, 3, 6]. Parallel prefix computation is + * usually more efficient than sequential loops for large arrays. + * + * Parameters: + * + * array - the array, which is modified in-place by this method + * + * op - a side-effect-free, associative function to perform the + * cumulation + */ + +public class ArraysDemo1 +{ + // Performs addition + static long compute(long x, long y) + { + return x + y; + } + + public static void main(String[] args) + { + long[] longArray = { 10, 20, 30, 40 }; + + LongBinaryOperator longBinaryOperator = (x, y) -> compute(x, y); + + Arrays.parallelPrefix(longArray, longBinaryOperator); + + Arrays.stream(longArray).forEach(e -> System.out.print(e + " ")); + } + +} diff --git a/Later/Java_Util_package/Arrays/10_parallelPrefix/2/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/10_parallelPrefix/2/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..5213bd0c4 --- /dev/null +++ b/Later/Java_Util_package/Arrays/10_parallelPrefix/2/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,46 @@ +import java.util.Arrays; +import java.util.function.LongBinaryOperator; + +/** + * + * public static void parallelPrefix(long[] array, int fromIndex, int + * toIndex, LongBinaryOperator op) + * + * Cumulates, in parallel, each element of the given array in place, + * using the supplied function. For example if the array initially + * holds [2, 1, 0, 3] and the operation performs addition, then upon + * return the array holds [2, 3, 3, 6]. Parallel prefix computation is + * usually more efficient than sequential loops for large arrays. + * + * Parameters: + * + * array - the array + * + * fromIndex - the index of the first element, inclusive + * + * toIndex - the index of the last element, exclusive + * + * op - a side-effect-free, associative function to perform the + * cumulation + */ +public class ArraysDemo2 +{ + + // Performs addition + static long compute(long x, long y) + { + return x + y; + } + + public static void main(String[] args) + { + long[] longArray = { 10, 20, 30, 40, 50 }; + + LongBinaryOperator longBinaryOperator = (x, y) -> compute(x, y); + + Arrays.parallelPrefix(longArray, 0, 3, longBinaryOperator); + + Arrays.stream(longArray).forEach(e -> System.out.print(e + " ")); + } + +} diff --git a/Later/Java_Util_package/Arrays/10_parallelPrefix/3/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/10_parallelPrefix/3/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/10_parallelPrefix/3/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/10_parallelPrefix/3/ArraysDemo/.project b/Later/Java_Util_package/Arrays/10_parallelPrefix/3/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/10_parallelPrefix/3/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/10_parallelPrefix/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/10_parallelPrefix/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/10_parallelPrefix/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/10_parallelPrefix/3/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/10_parallelPrefix/3/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..84419abc5 Binary files /dev/null and b/Later/Java_Util_package/Arrays/10_parallelPrefix/3/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/10_parallelPrefix/3/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/10_parallelPrefix/3/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..fcdea4eab Binary files /dev/null and b/Later/Java_Util_package/Arrays/10_parallelPrefix/3/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/10_parallelPrefix/3/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/10_parallelPrefix/3/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..7256f96d4 --- /dev/null +++ b/Later/Java_Util_package/Arrays/10_parallelPrefix/3/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,43 @@ +import java.util.Arrays; +import java.util.function.DoubleBinaryOperator; + +/** + * + * public static void parallelPrefix(double[] array, + * DoubleBinaryOperator op) + * + * Cumulates, in parallel, each element of the given array in place, + * using the supplied function. For example if the array initially + * holds [2.0, 1.0, 0.0, 3.0] and the operation performs addition, + * then upon return the array holds [2.0, 3.0, 3.0, 6.0]. Parallel + * prefix computation is usually more efficient than sequential loops + * for large arrays. + * + * Parameters: + * + * array - the array, which is modified in-place by this method + * + * op - a side-effect-free, associative function to perform the + * cumulation + */ + +public class ArraysDemo1 +{ + // Performs addition + static double compute(double x, double y) + { + return x + y; + } + + public static void main(String[] args) + { + double[] doubleArray = { 10.11, 20.11, 30.11, 40.11 }; + + DoubleBinaryOperator doubleBinaryOperator = (x, y) -> compute(x, y); + + Arrays.parallelPrefix(doubleArray, doubleBinaryOperator); + + Arrays.stream(doubleArray).forEach(e -> System.out.print(e + " ")); + } + +} diff --git a/Later/Java_Util_package/Arrays/10_parallelPrefix/3/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/10_parallelPrefix/3/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..9636d1d00 --- /dev/null +++ b/Later/Java_Util_package/Arrays/10_parallelPrefix/3/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,43 @@ +import java.util.Arrays; +import java.util.function.DoubleBinaryOperator; + +/** + * + * public static void parallelPrefix(double[] array, int fromIndex, + * int toIndex, DoubleBinaryOperator op) + * + * Performs parallelPrefix(double[], DoubleBinaryOperator) for the + * given subrange of the array. + * + * Parameters: + * + * array - the array + * + * fromIndex - the index of the first element, inclusive + * + * toIndex - the index of the last element, exclusive + * + * op - a side-effect-free, associative function to perform the + * cumulation + */ +public class ArraysDemo2 +{ + + // Performs addition + static double compute(double x, double y) + { + return x + y; + } + + public static void main(String[] args) + { + double[] doubleArray = { 10.11, 20.11, 30.11, 40.11 }; + + DoubleBinaryOperator doubleBinaryOperator = (x, y) -> compute(x, y); + + Arrays.parallelPrefix(doubleArray, 0, 3, doubleBinaryOperator); + + Arrays.stream(doubleArray).forEach(e -> System.out.print(e + " ")); + } + +} diff --git a/Later/Java_Util_package/Arrays/10_parallelPrefix/4/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/10_parallelPrefix/4/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/10_parallelPrefix/4/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/10_parallelPrefix/4/ArraysDemo/.project b/Later/Java_Util_package/Arrays/10_parallelPrefix/4/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/10_parallelPrefix/4/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/10_parallelPrefix/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/10_parallelPrefix/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/10_parallelPrefix/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/10_parallelPrefix/4/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/10_parallelPrefix/4/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..b21594894 Binary files /dev/null and b/Later/Java_Util_package/Arrays/10_parallelPrefix/4/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/10_parallelPrefix/4/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/10_parallelPrefix/4/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..aaf837f00 Binary files /dev/null and b/Later/Java_Util_package/Arrays/10_parallelPrefix/4/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/10_parallelPrefix/4/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/10_parallelPrefix/4/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..c3a4ba948 --- /dev/null +++ b/Later/Java_Util_package/Arrays/10_parallelPrefix/4/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,42 @@ +import java.util.Arrays; +import java.util.function.BinaryOperator; + +/** + * + * public static void parallelPrefix(T[] array, BinaryOperator + * op) + * + * Cumulates, in parallel, each element of the given array in place, + * using the supplied function. For example if the array initially + * holds [2, 1, 0, 3] and the operation performs addition, then upon + * return the array holds [2, 3, 3, 6]. Parallel prefix computation is + * usually more efficient than sequential loops for large arrays. + * + * Parameters: + * + * array - the array, which is modified in-place by this method + * + * op - a side-effect-free, associative function to perform the + * cumulation + */ + +public class ArraysDemo1 +{ + // Performs addition + static Integer compute(Object x, Object y) + { + return (Integer) x + (Integer) y; + } + + public static void main(String[] args) + { + Integer[] doubleArray = { 10, 20, 30, 40, 50 }; + + BinaryOperator binaryOperator = (x, y) -> compute(x, y); + + Arrays.parallelPrefix(doubleArray, binaryOperator); + + Arrays.stream(doubleArray).forEach(e -> System.out.print(e + " ")); + } + +} diff --git a/Later/Java_Util_package/Arrays/10_parallelPrefix/4/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/10_parallelPrefix/4/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..3a884092c --- /dev/null +++ b/Later/Java_Util_package/Arrays/10_parallelPrefix/4/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,43 @@ +import java.util.Arrays; +import java.util.function.BinaryOperator; + +/** + * + * public static void parallelPrefix(double[] array, int fromIndex, + * int toIndex, DoubleBinaryOperator op) + * + * Performs parallelPrefix(Object[], BinaryOperator) for the given + * subrange of the array. + * + * Parameters: + * + * array - the array + * + * fromIndex - the index of the first element, inclusive + * + * toIndex - the index of the last element, exclusive + * + * op - a side-effect-free, associative function to perform the + * cumulation + */ +public class ArraysDemo2 +{ + + // Performs addition + static Integer compute(Object x, Object y) + { + return (Integer) x + (Integer) y; + } + + public static void main(String[] args) + { + Integer[] dousableArray = { 10, 20, 30, 40, 50 }; + + BinaryOperator binaryOperator = (x, y) -> compute(x, y); + + Arrays.parallelPrefix(doubleArray, 0, 3, binaryOperator); + + Arrays.stream(doubleArray).forEach(e -> System.out.print(e + " ")); + } + +} diff --git a/Later/Java_Util_package/Arrays/11_setAll/1/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/11_setAll/1/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/11_setAll/1/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/11_setAll/1/ArraysDemo/.project b/Later/Java_Util_package/Arrays/11_setAll/1/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/11_setAll/1/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/11_setAll/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/11_setAll/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/11_setAll/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/11_setAll/1/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/11_setAll/1/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..fdc5d76fd Binary files /dev/null and b/Later/Java_Util_package/Arrays/11_setAll/1/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/11_setAll/1/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/11_setAll/1/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..1cca3dc0e Binary files /dev/null and b/Later/Java_Util_package/Arrays/11_setAll/1/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/11_setAll/1/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/11_setAll/1/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..a40b91dd2 --- /dev/null +++ b/Later/Java_Util_package/Arrays/11_setAll/1/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,28 @@ +import java.util.Arrays; + +/** + * + * public static void setAll(int[] array, IntUnaryOperator generator) + * + * Set all elements of the specified array, using the provided + * generator function to compute each element. + * + * Parameters: + * + * array - array to be initialized + * + * generator - a function accepting an index and producing the desired + * value for that position + */ + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + int[] intArray = new int[5]; + Arrays.setAll(intArray, (index) -> index * 10); + System.out.println(Arrays.toString(intArray)); + } + +} diff --git a/Later/Java_Util_package/Arrays/11_setAll/1/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/11_setAll/1/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..e4d8447b4 --- /dev/null +++ b/Later/Java_Util_package/Arrays/11_setAll/1/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,29 @@ +import java.util.Arrays; + +/** + * + * public static void setAll(long[] array, + IntToLongFunction generator) + * + * Set all elements of the specified array, using the provided + * generator function to compute each element. + * + * Parameters: + * + * array - array to be initialized + * + * generator - a function accepting an index and producing the desired + * value for that position + */ + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + long[] longArray = new long[5]; + Arrays.setAll(longArray, (index) -> index * 20); + System.out.println(Arrays.toString(longArray)); + } + +} diff --git a/Later/Java_Util_package/Arrays/11_setAll/2/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/11_setAll/2/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/11_setAll/2/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/11_setAll/2/ArraysDemo/.project b/Later/Java_Util_package/Arrays/11_setAll/2/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/11_setAll/2/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/11_setAll/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/11_setAll/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/11_setAll/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/11_setAll/2/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/11_setAll/2/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..6079ddebc Binary files /dev/null and b/Later/Java_Util_package/Arrays/11_setAll/2/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/11_setAll/2/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/11_setAll/2/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..1cca3dc0e Binary files /dev/null and b/Later/Java_Util_package/Arrays/11_setAll/2/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/11_setAll/2/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/11_setAll/2/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..63fce4073 --- /dev/null +++ b/Later/Java_Util_package/Arrays/11_setAll/2/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,29 @@ +import java.util.Arrays; + +/** + * + * public static void setAll(double[] array, + IntToDoubleFunction generator) + * + * Set all elements of the specified array, using the provided + * generator function to compute each element. + * + * Parameters: + * + * array - array to be initialized + * + * generator - a function accepting an index and producing the desired + * value for that position + */ + +public class ArraysDemo +{ + + public static void main(String[] args) + { + double[] doubleArray = new double[5]; + Arrays.setAll(doubleArray, (index) -> index + 10.5); + System.out.println(Arrays.toString(doubleArray)); + } + +} diff --git a/Later/Java_Util_package/Arrays/11_setAll/3/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/11_setAll/3/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/11_setAll/3/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/11_setAll/3/ArraysDemo/.project b/Later/Java_Util_package/Arrays/11_setAll/3/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/11_setAll/3/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/11_setAll/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/11_setAll/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/11_setAll/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/11_setAll/3/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/11_setAll/3/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..4a3c34f04 Binary files /dev/null and b/Later/Java_Util_package/Arrays/11_setAll/3/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/11_setAll/3/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/11_setAll/3/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..020facf30 --- /dev/null +++ b/Later/Java_Util_package/Arrays/11_setAll/3/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,33 @@ +import java.util.Arrays; + +/** + * + * public static void setAll(T[] array, IntFunction + * generator) + * + * Set all elements of the specified array, using the provided + * generator function to compute each element. + * + * Type Parameters: + * + * T - type of elements of the array + * + * Parameters: + * + * array - array to be initialized + * + * generator - a function accepting an index and producing the desired + * value for that position + */ + +public class ArraysDemo +{ + + public static void main(String[] args) + { + Integer[] integerArray = new Integer[5]; + Arrays.setAll(integerArray, (index) -> index + 10); + System.out.println(Arrays.toString(integerArray)); + } + +} diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/1/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/12_parralelSort/1/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/1/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/1/ArraysDemo/.project b/Later/Java_Util_package/Arrays/12_parralelSort/1/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/1/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/12_parralelSort/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/1/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/12_parralelSort/1/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..6844f8654 Binary files /dev/null and b/Later/Java_Util_package/Arrays/12_parralelSort/1/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/1/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/12_parralelSort/1/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..5fa115ec0 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/1/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,27 @@ +import java.util.Arrays; + +/** + * + * public static void parallelSort(int[] a) + * + * Sorts the specified array into ascending numerical order. + * + * The sorting algorithm is a parallel sort-merge that breaks the + * array into sub-arrays that are themselves sorted and then merged. + * + * Parameters: + * + * a - the array to be sorted + */ + +public class ArraysDemo +{ + + public static void main(String[] args) + { + int[] intArray = { 8, 9, 4, 3, 5, 1 }; + Arrays.parallelSort(intArray); + System.out.println(Arrays.toString(intArray)); + } + +} diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/10/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/12_parralelSort/10/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/10/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/10/ArraysDemo/.project b/Later/Java_Util_package/Arrays/12_parralelSort/10/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/10/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/10/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/12_parralelSort/10/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/10/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/10/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/12_parralelSort/10/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..72c891b97 Binary files /dev/null and b/Later/Java_Util_package/Arrays/12_parralelSort/10/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/10/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/12_parralelSort/10/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..759b92f83 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/10/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,35 @@ +import java.util.Arrays; + +/** + * + * public static void parallelSort(short[] a, + int fromIndex, + int toIndex) + * + * Sorts the specified range of the array into ascending numerical + * order. The range to be sorted extends from the index fromIndex, + * inclusive, to the index toIndex, exclusive. + * + * The sorting algorithm is a parallel sort-merge that breaks the + * array into sub-arrays that are themselves sorted and then merged. + * + * Parameters: + * + * a - the array to be sorted + * + * fromIndex - the index of the first element, inclusive, to be sorted + * + * toIndex - the index of the last element, exclusive, to be sorted + */ + +public class ArraysDemo +{ + + public static void main(String[] args) + { + short[] shortArray = { 8, 9, 4, 3, 5, 1 }; + Arrays.parallelSort(shortArray, 0, 4); + System.out.println(Arrays.toString(shortArray)); + } + +} diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/11/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/12_parralelSort/11/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/11/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/11/ArraysDemo/.project b/Later/Java_Util_package/Arrays/12_parralelSort/11/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/11/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/11/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/12_parralelSort/11/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/11/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/11/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/12_parralelSort/11/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..3cf2e5c68 Binary files /dev/null and b/Later/Java_Util_package/Arrays/12_parralelSort/11/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/11/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/12_parralelSort/11/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..cc2c96796 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/11/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,29 @@ +import java.util.Arrays; + +/** + * + * public static void parallelSort(byte[] a) + * + * Sorts the specified range of the array into ascending numerical + * order. + * + * The sorting algorithm is a parallel sort-merge that breaks the + * array into sub-arrays that are themselves sorted and then merged. + * + * Parameters: + * + * a - the array to be sorted + * + */ + +public class ArraysDemo +{ + + public static void main(String[] args) + { + byte[] byteArray = { 8, 9, 4, 3, 5, 1 }; + Arrays.parallelSort(byteArray); + System.out.println(Arrays.toString(byteArray)); + } + +} diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/12/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/12_parralelSort/12/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/12/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/12/ArraysDemo/.project b/Later/Java_Util_package/Arrays/12_parralelSort/12/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/12/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/12/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/12_parralelSort/12/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/12/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/12/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/12_parralelSort/12/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..a5b7dc077 Binary files /dev/null and b/Later/Java_Util_package/Arrays/12_parralelSort/12/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/12/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/12_parralelSort/12/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..c010d8fe3 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/12/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,34 @@ +import java.util.Arrays; + +/** + * + * public static void parallelSort(byte[] a, int fromIndex, int + * toIndex) + * + * Sorts the specified range of the array into ascending numerical + * order. The range to be sorted extends from the index fromIndex, + * inclusive, to the index toIndex, exclusive. + * + * The sorting algorithm is a parallel sort-merge that breaks the + * array into sub-arrays that are themselves sorted and then merged. + * + * Parameters: + * + * a - the array to be sorted + * + * fromIndex - the index of the first element, inclusive, to be sorted + * + * toIndex - the index of the last element, exclusive, to be sorted + */ + +public class ArraysDemo +{ + + public static void main(String[] args) + { + byte[] byteArray = { 8, 9, 4, 3, 5, 1 }; + Arrays.parallelSort(byteArray, 0, 4); + System.out.println(Arrays.toString(byteArray)); + } + +} diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/13/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/12_parralelSort/13/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/13/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/13/ArraysDemo/.project b/Later/Java_Util_package/Arrays/12_parralelSort/13/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/13/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/13/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/12_parralelSort/13/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/13/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/13/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/12_parralelSort/13/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..7956725c3 Binary files /dev/null and b/Later/Java_Util_package/Arrays/12_parralelSort/13/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/13/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/12_parralelSort/13/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..45b52a4a2 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/13/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,29 @@ +import java.util.Arrays; + +/** + * + * public static void parallelSort(char[] a) + * + * Sorts the specified range of the array into ascending numerical + * order. + * + * The sorting algorithm is a parallel sort-merge that breaks the + * array into sub-arrays that are themselves sorted and then merged. + * + * Parameters: + * + * a - the array to be sorted + * + */ + +public class ArraysDemo +{ + + public static void main(String[] args) + { + char[] charArray = { 'c', 'b', 'e', 'd', 'f', 'a' }; + Arrays.parallelSort(charArray); + System.out.println(Arrays.toString(charArray)); + } + +} diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/14/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/12_parralelSort/14/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/14/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/14/ArraysDemo/.project b/Later/Java_Util_package/Arrays/12_parralelSort/14/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/14/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/14/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/12_parralelSort/14/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/14/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/14/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/12_parralelSort/14/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..1d58b2124 Binary files /dev/null and b/Later/Java_Util_package/Arrays/12_parralelSort/14/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/14/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/12_parralelSort/14/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..4c85c383b --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/14/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,34 @@ +import java.util.Arrays; + +/** + * + * public static void parallelSort(char[] a, int fromIndex, int + * toIndex) + * + * Sorts the specified range of the array into ascending numerical + * order. The range to be sorted extends from the index fromIndex, + * inclusive, to the index toIndex, exclusive. + * + * The sorting algorithm is a parallel sort-merge that breaks the + * array into sub-arrays that are themselves sorted and then merged. + * + * Parameters: + * + * a - the array to be sorted + * + * fromIndex - the index of the first element, inclusive, to be sorted + * + * toIndex - the index of the last element, exclusive, to be sorted + */ + +public class ArraysDemo +{ + + public static void main(String[] args) + { + char[] charArray = { 'c', 'b', 'e', 'd', 'f', 'a' }; + Arrays.parallelSort(charArray, 0, 4); + System.out.println(Arrays.toString(charArray)); + } + +} diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/15/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/12_parralelSort/15/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/15/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/15/ArraysDemo/.project b/Later/Java_Util_package/Arrays/12_parralelSort/15/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/15/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/15/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/12_parralelSort/15/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/15/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/15/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/12_parralelSort/15/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..e2e16fa1d Binary files /dev/null and b/Later/Java_Util_package/Arrays/12_parralelSort/15/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/15/ArraysDemo/bin/User.class b/Later/Java_Util_package/Arrays/12_parralelSort/15/ArraysDemo/bin/User.class new file mode 100644 index 000000000..d4c860202 Binary files /dev/null and b/Later/Java_Util_package/Arrays/12_parralelSort/15/ArraysDemo/bin/User.class differ diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/15/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/12_parralelSort/15/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..c37976775 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/15/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,52 @@ +import java.util.Arrays; +import java.util.function.Consumer; + +/** + * + * public static > void + * parallelSort(T[] a) + * + * Sorts the specified array of objects into ascending order, + * according to the natural ordering of its elements. All elements in + * the array must implement the Comparable interface. Furthermore, all + * elements in the array must be mutually comparable (that is, + * e1.compareTo(e2) must not throw a ClassCastException for any + * elements e1 and e2 in the array). + * + * The sorting algorithm is a parallel sort-merge that breaks the + * array into sub-arrays that are themselves sorted and then merged. + * + * Type Parameters: + * + * T - the class of the objects to be sorted + * + * Parameters: + * + * a - the array to be sorted + * + */ + +public class ArraysDemo +{ + + public static void main(String[] args) + { + User[] users = getUsers(); + Arrays.parallelSort(users); + Consumer printUser = u -> System.out + .println(u.getName() + "-" + u.getAge()); + Arrays.stream(users).forEach(printUser); + } + + public static User[] getUsers() + { + User[] users = new User[5]; + users[0] = new User("Ram", 25); + users[1] = new User("Peter", 22); + users[2] = new User("Mohan", 21); + users[3] = new User("Suresh", 30); + users[4] = new User("Arvind", 20); + return users; + } + +} diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/15/ArraysDemo/src/User.java b/Later/Java_Util_package/Arrays/12_parralelSort/15/ArraysDemo/src/User.java new file mode 100644 index 000000000..5a7d61078 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/15/ArraysDemo/src/User.java @@ -0,0 +1,39 @@ + +public class User implements Comparable +{ + + private String name; + private int age; + + public User(String name, int age) + { + this.name = name; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + @Override + public int compareTo(User user) + { + return name.compareTo(user.name); + } +} diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/16/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/12_parralelSort/16/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/16/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/16/ArraysDemo/.project b/Later/Java_Util_package/Arrays/12_parralelSort/16/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/16/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/16/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/12_parralelSort/16/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/16/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/16/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/12_parralelSort/16/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..917da330d Binary files /dev/null and b/Later/Java_Util_package/Arrays/12_parralelSort/16/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/16/ArraysDemo/bin/User.class b/Later/Java_Util_package/Arrays/12_parralelSort/16/ArraysDemo/bin/User.class new file mode 100644 index 000000000..d4c860202 Binary files /dev/null and b/Later/Java_Util_package/Arrays/12_parralelSort/16/ArraysDemo/bin/User.class differ diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/16/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/12_parralelSort/16/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..d8a7f97aa --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/16/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,58 @@ +import java.util.Arrays; +import java.util.function.Consumer; + +/** + * + * public static > void + * parallelSort(T[] a, int fromIndex, int toIndex) + * + * Sorts the specified range of the specified array of objects into + * ascending order, according to the natural ordering of its elements. + * The range to be sorted extends from index fromIndex, inclusive, to + * index toIndex, exclusive. All elements in the array must implement + * the Comparable interface. Furthermore, all elements in the array + * must be mutually comparable (that is, e1.compareTo(e2) must not + * throw a ClassCastException for any elements e1 and e2 in the + * array). + * + * The sorting algorithm is a parallel sort-merge that breaks the + * array into sub-arrays that are themselves sorted and then merged. + * + * Type Parameters: + * + * T - the class of the objects to be sorted + * + * Parameters: + * + * a - the array to be sorted + * + * fromIndex - the index of the first element (inclusive) to be sorted + * + * toIndex - the index of the last element (exclusive) to be sorted + * + */ + +public class ArraysDemo +{ + + public static void main(String[] args) + { + User[] users = getUsers(); + Arrays.parallelSort(users, 0, 3); + Consumer printUser = u -> System.out + .println(u.getName() + "-" + u.getAge()); + Arrays.stream(users).forEach(printUser); + } + + public static User[] getUsers() + { + User[] users = new User[5]; + users[0] = new User("Ram", 25); + users[1] = new User("Peter", 22); + users[2] = new User("Mohan", 21); + users[3] = new User("Suresh", 30); + users[4] = new User("Arvind", 20); + return users; + } + +} diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/16/ArraysDemo/src/User.java b/Later/Java_Util_package/Arrays/12_parralelSort/16/ArraysDemo/src/User.java new file mode 100644 index 000000000..5a7d61078 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/16/ArraysDemo/src/User.java @@ -0,0 +1,39 @@ + +public class User implements Comparable +{ + + private String name; + private int age; + + public User(String name, int age) + { + this.name = name; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + @Override + public int compareTo(User user) + { + return name.compareTo(user.name); + } +} diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/17/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/12_parralelSort/17/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/17/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/17/ArraysDemo/.project b/Later/Java_Util_package/Arrays/12_parralelSort/17/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/17/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/17/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/12_parralelSort/17/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/17/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/17/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/12_parralelSort/17/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..a14995f27 Binary files /dev/null and b/Later/Java_Util_package/Arrays/12_parralelSort/17/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/17/ArraysDemo/bin/User.class b/Later/Java_Util_package/Arrays/12_parralelSort/17/ArraysDemo/bin/User.class new file mode 100644 index 000000000..d4c860202 Binary files /dev/null and b/Later/Java_Util_package/Arrays/12_parralelSort/17/ArraysDemo/bin/User.class differ diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/17/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/12_parralelSort/17/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..e397c0470 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/17/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,60 @@ +import java.util.Arrays; +import java.util.Comparator; +import java.util.function.Consumer; + +/** + * + * public static void parallelSort(T[] a, Comparator + * cmp) + * + * Sorts the specified array of objects according to the order induced + * by the specified comparator. All elements in the array must be + * mutually comparable by the specified comparator (that is, + * c.compare(e1, e2) must not throw a ClassCastException for any + * elements e1 and e2 in the array). + * + * The sorting algorithm is a parallel sort-merge that breaks the + * array into sub-arrays that are themselves sorted and then merged. + * + * Type Parameters: + * + * T - the class of the objects to be sorted + * + * Parameters: + * + * a - the array to be sorted + * + * cmp - the comparator to determine the order of the array. A null + * value indicates that the elements' natural ordering should be used. + * + */ + +public class ArraysDemo +{ + + public static void main(String[] args) + { + User[] users = getUsers(); + Comparator ageComparator = Comparator.comparing(User::getAge); + + System.out.println("--Sort complete array--"); + Arrays.parallelSort(users, ageComparator); + + Consumer printUser = u -> System.out + .println(u.getName() + "-" + u.getAge()); + + Arrays.stream(users).forEach(printUser); + } + + public static User[] getUsers() + { + User[] users = new User[5]; + users[0] = new User("Ram", 25); + users[1] = new User("Peter", 22); + users[2] = new User("Mohan", 21); + users[3] = new User("Suresh", 30); + users[4] = new User("Arvind", 20); + return users; + } + +} diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/17/ArraysDemo/src/User.java b/Later/Java_Util_package/Arrays/12_parralelSort/17/ArraysDemo/src/User.java new file mode 100644 index 000000000..5a7d61078 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/17/ArraysDemo/src/User.java @@ -0,0 +1,39 @@ + +public class User implements Comparable +{ + + private String name; + private int age; + + public User(String name, int age) + { + this.name = name; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + @Override + public int compareTo(User user) + { + return name.compareTo(user.name); + } +} diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/18/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/12_parralelSort/18/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/18/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/18/ArraysDemo/.project b/Later/Java_Util_package/Arrays/12_parralelSort/18/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/18/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/18/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/12_parralelSort/18/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/18/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/18/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/12_parralelSort/18/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..9f8eba124 Binary files /dev/null and b/Later/Java_Util_package/Arrays/12_parralelSort/18/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/18/ArraysDemo/bin/User.class b/Later/Java_Util_package/Arrays/12_parralelSort/18/ArraysDemo/bin/User.class new file mode 100644 index 000000000..d4c860202 Binary files /dev/null and b/Later/Java_Util_package/Arrays/12_parralelSort/18/ArraysDemo/bin/User.class differ diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/18/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/12_parralelSort/18/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..3870131fc --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/18/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,63 @@ +import java.util.Arrays; +import java.util.Comparator; +import java.util.function.Consumer; + +/** + * + * public static void parallelSort(T[] a, int fromIndex, int + * toIndex, Comparator cmp) + * + * Sorts the specified array of objects according to the order induced + * by the specified comparator. All elements in the array must be + * mutually comparable by the specified comparator (that is, + * c.compare(e1, e2) must not throw a ClassCastException for any + * elements e1 and e2 in the array). + * + * The sorting algorithm is a parallel sort-merge that breaks the + * array into sub-arrays that are themselves sorted and then merged. + * + * Type Parameters: + * + * T - the class of the objects to be sorted + * + * Parameters: + * + * a - the array to be sorted + * + * fromIndex - the index of the first element (inclusive) to be sorted + * + * toIndex - the index of the last element (exclusive) to be sorted + * + * cmp - the comparator to determine the order of the array. A null + * value indicates that the elements' natural ordering should be used. + * + */ + +public class ArraysDemo +{ + + public static void main(String[] args) + { + User[] users = getUsers(); + Comparator ageComparator = Comparator.comparing(User::getAge); + + Arrays.parallelSort(users, 0, 3, ageComparator); + + Consumer printUser = u -> System.out + .println(u.getName() + "-" + u.getAge()); + + Arrays.stream(users).forEach(printUser); + } + + public static User[] getUsers() + { + User[] users = new User[5]; + users[0] = new User("Ram", 25); + users[1] = new User("Peter", 22); + users[2] = new User("Mohan", 21); + users[3] = new User("Suresh", 30); + users[4] = new User("Arvind", 20); + return users; + } + +} diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/18/ArraysDemo/src/User.java b/Later/Java_Util_package/Arrays/12_parralelSort/18/ArraysDemo/src/User.java new file mode 100644 index 000000000..5a7d61078 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/18/ArraysDemo/src/User.java @@ -0,0 +1,39 @@ + +public class User implements Comparable +{ + + private String name; + private int age; + + public User(String name, int age) + { + this.name = name; + this.age = age; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + @Override + public int compareTo(User user) + { + return name.compareTo(user.name); + } +} diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/2/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/12_parralelSort/2/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/2/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/2/ArraysDemo/.project b/Later/Java_Util_package/Arrays/12_parralelSort/2/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/2/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/12_parralelSort/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/2/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/12_parralelSort/2/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..8378a1e9d Binary files /dev/null and b/Later/Java_Util_package/Arrays/12_parralelSort/2/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/2/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/12_parralelSort/2/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..a29ce1c0b --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/2/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,34 @@ +import java.util.Arrays; + +/** + * + * public static void parallelSort(int[] a, int fromIndex, int + * toIndex) + * + * Sorts the specified range of the array into ascending numerical + * order. The range to be sorted extends from the index fromIndex, + * inclusive, to the index toIndex, exclusive. + * + * The sorting algorithm is a parallel sort-merge that breaks the + * array into sub-arrays that are themselves sorted and then merged. + * + * Parameters: + * + * a - the array to be sorted + * + * fromIndex - the index of the first element, inclusive, to be sorted + * + * toIndex - the index of the last element, exclusive, to be sorted + */ + +public class ArraysDemo +{ + + public static void main(String[] args) + { + int[] intArray = { 8, 9, 4, 3, 5, 1 }; + Arrays.parallelSort(intArray, 0, 4); + System.out.println(Arrays.toString(intArray)); + } + +} diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/3/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/12_parralelSort/3/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/3/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/3/ArraysDemo/.project b/Later/Java_Util_package/Arrays/12_parralelSort/3/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/3/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/12_parralelSort/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/3/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/12_parralelSort/3/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..76b079319 Binary files /dev/null and b/Later/Java_Util_package/Arrays/12_parralelSort/3/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/3/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/12_parralelSort/3/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..4e5fe1156 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/3/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,27 @@ +import java.util.Arrays; + +/** + * + * public static void parallelSort(long[] a) + * + * Sorts the specified array into ascending numerical order. + * + * The sorting algorithm is a parallel sort-merge that breaks the + * array into sub-arrays that are themselves sorted and then merged. + * + * Parameters: + * + * a - the array to be sorted + */ + +public class ArraysDemo +{ + + public static void main(String[] args) + { + long[] longArray = { 8, 9, 4, 3, 5, 1 }; + Arrays.parallelSort(longArray); + System.out.println(Arrays.toString(longArray)); + } + +} diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/4/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/12_parralelSort/4/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/4/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/4/ArraysDemo/.project b/Later/Java_Util_package/Arrays/12_parralelSort/4/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/4/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/12_parralelSort/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/4/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/12_parralelSort/4/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..0249e3265 Binary files /dev/null and b/Later/Java_Util_package/Arrays/12_parralelSort/4/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/4/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/12_parralelSort/4/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..32b0b8a94 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/4/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,34 @@ +import java.util.Arrays; + +/** + * + * public static void parallelSort(long[] a, int fromIndex, int + * toIndex) + * + * Sorts the specified range of the array into ascending numerical + * order. The range to be sorted extends from the index fromIndex, + * inclusive, to the index toIndex, exclusive. + * + * The sorting algorithm is a parallel sort-merge that breaks the + * array into sub-arrays that are themselves sorted and then merged. + * + * Parameters: + * + * a - the array to be sorted + * + * fromIndex - the index of the first element, inclusive, to be sorted + * + * toIndex - the index of the last element, exclusive, to be sorted + */ + +public class ArraysDemo +{ + + public static void main(String[] args) + { + long[] longArray = { 8, 9, 4, 3, 5, 1 }; + Arrays.parallelSort(longArray, 0, 4); + System.out.println(Arrays.toString(longArray)); + } + +} diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/5/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/12_parralelSort/5/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/5/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/5/ArraysDemo/.project b/Later/Java_Util_package/Arrays/12_parralelSort/5/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/5/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/5/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/12_parralelSort/5/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/5/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/5/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/12_parralelSort/5/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..2fff5a7a4 Binary files /dev/null and b/Later/Java_Util_package/Arrays/12_parralelSort/5/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/5/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/12_parralelSort/5/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..6d2db672e --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/5/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,28 @@ +import java.util.Arrays; + +/** + * + * public static void parallelSort(double[] a) + * + * Sorts the specified array into ascending numerical order. + * + * The sorting algorithm is a parallel sort-merge that breaks the + * array into sub-arrays that are themselves sorted and then merged. + * + * Parameters: + * + * a - the array to be sorted + * + */ + +public class ArraysDemo +{ + + public static void main(String[] args) + { + double[] doubleArray = { 8.1, 9.2, 4.4, 3.5, 5.2, 1.3 }; + Arrays.parallelSort(doubleArray); + System.out.println(Arrays.toString(doubleArray)); + } + +} diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/6/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/12_parralelSort/6/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/6/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/6/ArraysDemo/.project b/Later/Java_Util_package/Arrays/12_parralelSort/6/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/6/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/6/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/12_parralelSort/6/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/6/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/6/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/12_parralelSort/6/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..b42bd3182 Binary files /dev/null and b/Later/Java_Util_package/Arrays/12_parralelSort/6/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/6/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/12_parralelSort/6/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..67034050c --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/6/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,34 @@ +import java.util.Arrays; + +/** + * + * public static void parallelSort(double[] a, int fromIndex, int + * toIndex) + * + * Sorts the specified range of the array into ascending numerical + * order. The range to be sorted extends from the index fromIndex, + * inclusive, to the index toIndex, exclusive. + * + * The sorting algorithm is a parallel sort-merge that breaks the + * array into sub-arrays that are themselves sorted and then merged. + * + * Parameters: + * + * a - the array to be sorted + * + * fromIndex - the index of the first element, inclusive, to be sorted + * + * toIndex - the index of the last element, exclusive, to be sorted + */ + +public class ArraysDemo +{ + + public static void main(String[] args) + { + double[] doubleArray = { 8.1, 9.2, 4.4, 3.5, 5.2, 1.3 }; + Arrays.parallelSort(doubleArray, 0, 4); + System.out.println(Arrays.toString(doubleArray)); + } + +} diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/7/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/12_parralelSort/7/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/7/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/7/ArraysDemo/.project b/Later/Java_Util_package/Arrays/12_parralelSort/7/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/7/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/7/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/12_parralelSort/7/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/7/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/7/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/12_parralelSort/7/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..55c0396e4 Binary files /dev/null and b/Later/Java_Util_package/Arrays/12_parralelSort/7/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/7/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/12_parralelSort/7/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..2c86619dc --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/7/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,28 @@ +import java.util.Arrays; + +/** + * + * public static void parallelSort(float[] a) + * + * Sorts the specified array into ascending numerical order. + * + * The sorting algorithm is a parallel sort-merge that breaks the + * array into sub-arrays that are themselves sorted and then merged. + * + * Parameters: + * + * a - the array to be sorted + * + */ + +public class ArraysDemo +{ + + public static void main(String[] args) + { + float[] floatArray = { 8.1f, 9.2f, 4.4f, 3.5f, 5.2f, 1.3f }; + Arrays.parallelSort(floatArray); + System.out.println(Arrays.toString(floatArray)); + } + +} diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/8/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/12_parralelSort/8/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/8/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/8/ArraysDemo/.project b/Later/Java_Util_package/Arrays/12_parralelSort/8/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/8/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/8/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/12_parralelSort/8/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/8/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/8/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/12_parralelSort/8/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..825f44ec5 Binary files /dev/null and b/Later/Java_Util_package/Arrays/12_parralelSort/8/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/8/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/12_parralelSort/8/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..445708e07 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/8/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,34 @@ +import java.util.Arrays; + +/** + * + * public static void parallelSort(float[] a, + int fromIndex, + int toIndex) + * + * Sorts the specified array into ascending numerical order. + * + * The sorting algorithm is a parallel sort-merge that breaks the + * array into sub-arrays that are themselves sorted and then merged. + * + * Parameters: + * + * a - the array to be sorted + * + * fromIndex - the index of the first element, inclusive, to be sorted + * + * toIndex - the index of the last element, exclusive, to be sorted + * + */ + +public class ArraysDemo +{ + + public static void main(String[] args) + { + float[] floatArray = { 8.1f, 9.2f, 4.4f, 3.5f, 5.2f, 1.3f }; + Arrays.parallelSort(floatArray, 0, 4); + System.out.println(Arrays.toString(floatArray)); + } + +} diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/9/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/12_parralelSort/9/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/9/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/9/ArraysDemo/.project b/Later/Java_Util_package/Arrays/12_parralelSort/9/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/9/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/9/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/12_parralelSort/9/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/9/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/9/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/12_parralelSort/9/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..d8ec61b17 Binary files /dev/null and b/Later/Java_Util_package/Arrays/12_parralelSort/9/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/12_parralelSort/9/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/12_parralelSort/9/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..20f88042d --- /dev/null +++ b/Later/Java_Util_package/Arrays/12_parralelSort/9/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,27 @@ +import java.util.Arrays; + +/** + * + *public static void parallelSort(short[] a) + * + * Sorts the specified array into ascending numerical order. + * + * The sorting algorithm is a parallel sort-merge that breaks the + * array into sub-arrays that are themselves sorted and then merged. + * + * Parameters: + * + * a - the array to be sorted + */ + +public class ArraysDemo +{ + + public static void main(String[] args) + { + short[] shortArray = { 8, 9, 4, 3, 5, 1 }; + Arrays.parallelSort(shortArray); + System.out.println(Arrays.toString(shortArray)); + } + +} diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/1.1/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/13_Spliterator/1.1/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/13_Spliterator/1.1/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/1.1/ArraysDemo/.project b/Later/Java_Util_package/Arrays/13_Spliterator/1.1/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/13_Spliterator/1.1/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/1.1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/13_Spliterator/1.1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/13_Spliterator/1.1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/1.1/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/13_Spliterator/1.1/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..7890a159e Binary files /dev/null and b/Later/Java_Util_package/Arrays/13_Spliterator/1.1/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/1.1/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/13_Spliterator/1.1/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..d2aa3ab8c --- /dev/null +++ b/Later/Java_Util_package/Arrays/13_Spliterator/1.1/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,49 @@ +import java.util.Arrays; +import java.util.Spliterator; + +/** + * + * public static Spliterator.OfInt spliterator(int[] array, int + * startInclusive, int endExclusive) + * + * Returns a Spliterator.OfInt covering all of the specified array. + * + */ + +public class ArraysDemo +{ + + public static void main(String[] args) + { + int[] intArray = { 1, 2, 3, 4, 5, 6 }; + + /* + * Parameters: + * + * array - the array, assumed to be unmodified during use + * + * startInclusive - the first index to cover, inclusive + * + * endExclusive - index immediately past the last index to + * cover + * + * Returns: + * + * a spliterator for the array elements + */ + Spliterator s1 = Arrays.spliterator(intArray, 0, 3); + + /* + * Returns:a Spliterator covering some portion of the + * elements, or null if this spliterator cannot be split + */ + Spliterator s2 = s1.trySplit(); + + System.out.println("spliterator 1"); + s1.forEachRemaining(System.out::println); + + System.out.println("\nspliterator 2"); + s2.forEachRemaining(System.out::println); + } + +} diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/1/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/13_Spliterator/1/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/13_Spliterator/1/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/1/ArraysDemo/.project b/Later/Java_Util_package/Arrays/13_Spliterator/1/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/13_Spliterator/1/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/13_Spliterator/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/13_Spliterator/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/1/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/13_Spliterator/1/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..5b610c68c Binary files /dev/null and b/Later/Java_Util_package/Arrays/13_Spliterator/1/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/1/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/13_Spliterator/1/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..93bb16a87 --- /dev/null +++ b/Later/Java_Util_package/Arrays/13_Spliterator/1/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,43 @@ +import java.util.Arrays; +import java.util.Spliterator; + +/** + * + * public static Spliterator.OfInt spliterator(int[] array) + * + * Returns a Spliterator.OfInt covering all of the specified array. + * + */ + +public class ArraysDemo +{ + + public static void main(String[] args) + { + int[] intArray = { 1, 2, 3, 4, 5, 6 }; + + /* + * Parameters: + * + * array - the array, assumed to be unmodified during use + * + * Returns: + * + * a spliterator for the array elements + */ + Spliterator s1 = Arrays.spliterator(intArray); + + /* + * Returns:a Spliterator covering some portion of the + * elements, or null if this spliterator cannot be split + */ + Spliterator s2 = s1.trySplit(); + + System.out.println("spliterator 1"); + s1.forEachRemaining(System.out::println); + + System.out.println("\nspliterator 2"); + s2.forEachRemaining(System.out::println); + } + +} diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/2.1/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/13_Spliterator/2.1/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/13_Spliterator/2.1/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/2.1/ArraysDemo/.project b/Later/Java_Util_package/Arrays/13_Spliterator/2.1/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/13_Spliterator/2.1/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/2.1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/13_Spliterator/2.1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/13_Spliterator/2.1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/2.1/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/13_Spliterator/2.1/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..1a04a2364 Binary files /dev/null and b/Later/Java_Util_package/Arrays/13_Spliterator/2.1/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/2.1/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/13_Spliterator/2.1/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..adc661689 --- /dev/null +++ b/Later/Java_Util_package/Arrays/13_Spliterator/2.1/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,50 @@ +import java.util.Arrays; +import java.util.Spliterator; + +/** + * + * public static Spliterator.OfLong spliterator(long[] array, int + * startInclusive, int endExclusive) + * + * Returns a Spliterator.OfLong covering the specified range of the + * specified array + * + */ + +public class ArraysDemo +{ + + public static void main(String[] args) + { + long[] longArray = { 1, 2, 3, 4, 5, 6 }; + + /* + * Parameters: + * + * array - the array, assumed to be unmodified during use + * + * startInclusive - the first index to cover, inclusive + * + * endExclusive - index immediately past the last index to + * cover + * + * Returns: + * + * a spliterator for the array elements + */ + Spliterator s1 = Arrays.spliterator(longArray, 0, 3); + + /* + * Returns:a Spliterator covering some portion of the + * elements, or null if this spliterator cannot be split + */ + Spliterator s2 = s1.trySplit(); + + System.out.println("spliterator 1"); + s1.forEachRemaining(System.out::println); + + System.out.println("\nspliterator 2"); + s2.forEachRemaining(System.out::println); + } + +} diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/2/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/13_Spliterator/2/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/13_Spliterator/2/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/2/ArraysDemo/.project b/Later/Java_Util_package/Arrays/13_Spliterator/2/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/13_Spliterator/2/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/13_Spliterator/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/13_Spliterator/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/2/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/13_Spliterator/2/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..a7db7f7ef Binary files /dev/null and b/Later/Java_Util_package/Arrays/13_Spliterator/2/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/2/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/13_Spliterator/2/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..7684f72b2 --- /dev/null +++ b/Later/Java_Util_package/Arrays/13_Spliterator/2/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,43 @@ +import java.util.Arrays; +import java.util.Spliterator; + +/** + * + * public static Spliterator.OfLong spliterator(long[] array) + * + * Returns a Spliterator.OfLong covering all of the specified array. + * + */ + +public class ArraysDemo +{ + + public static void main(String[] args) + { + long[] longArray = { 1, 2, 3, 4, 5, 6 }; + + /* + * Parameters: + * + * array - the array, assumed to be unmodified during use + * + * Returns: + * + * a spliterator for the array elements + */ + Spliterator s1 = Arrays.spliterator(longArray); + + /* + * Returns:a Spliterator covering some portion of the + * elements, or null if this spliterator cannot be split + */ + Spliterator s2 = s1.trySplit(); + + System.out.println("spliterator 1"); + s1.forEachRemaining(System.out::println); + + System.out.println("\nspliterator 2"); + s2.forEachRemaining(System.out::println); + } + +} diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/3/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/13_Spliterator/3/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/13_Spliterator/3/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/3/ArraysDemo/.project b/Later/Java_Util_package/Arrays/13_Spliterator/3/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/13_Spliterator/3/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/13_Spliterator/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/13_Spliterator/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/3/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/13_Spliterator/3/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..6b87f69c5 Binary files /dev/null and b/Later/Java_Util_package/Arrays/13_Spliterator/3/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/3/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/13_Spliterator/3/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..55727327d --- /dev/null +++ b/Later/Java_Util_package/Arrays/13_Spliterator/3/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,43 @@ +import java.util.Arrays; +import java.util.Spliterator; + +/** + * + * public static Spliterator.OfDouble spliterator(double[] array) + * + * Returns a Spliterator.OfDouble covering all of the specified array. + * + */ + +public class ArraysDemo +{ + + public static void main(String[] args) + { + double[] doubleArray = { 1.1, 2.2, 3.3, 4.4, 5.5, 6.6 }; + + /* + * Parameters: + * + * array - the array, assumed to be unmodified during use + * + * Returns: + * + * a spliterator for the array elements + */ + Spliterator s1 = Arrays.spliterator(doubleArray); + + /* + * Returns:a Spliterator covering some portion of the + * elements, or null if this spliterator cannot be split + */ + Spliterator s2 = s1.trySplit(); + + System.out.println("spliterator 1"); + s1.forEachRemaining(System.out::println); + + System.out.println("\nspliterator 2"); + s2.forEachRemaining(System.out::println); + } + +} diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/4/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/13_Spliterator/4/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/13_Spliterator/4/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/4/ArraysDemo/.project b/Later/Java_Util_package/Arrays/13_Spliterator/4/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/13_Spliterator/4/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/13_Spliterator/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/13_Spliterator/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/4/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/13_Spliterator/4/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..4729330d8 Binary files /dev/null and b/Later/Java_Util_package/Arrays/13_Spliterator/4/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/4/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/13_Spliterator/4/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..2097457f7 --- /dev/null +++ b/Later/Java_Util_package/Arrays/13_Spliterator/4/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,51 @@ +import java.util.Arrays; +import java.util.Spliterator; + +/** + * + * public static Spliterator.OfInt spliterator(int[] array, int + * startInclusive, int endExclusive) + * + * Returns a Spliterator.OfDouble covering all of the specified array. + * + */ + +public class ArraysDemo +{ + + public static void main(String[] args) + { + double[] doubleArray = { 1.1, 2.2, 3.3, 4.4, 5.5, 6.6 }; + + /* + * Parameters: + * + * array - the array, assumed to be unmodified during use + * + * startInclusive - the first index to cover, inclusive + * + * endExclusive - index immediately past the last index to + * cover + * + * Returns: + * + * a spliterator for the array elements + */ + Spliterator s1 = Arrays.spliterator(doubleArray, 0, 3); + + /* + * Returns: + * + * a Spliterator covering some portion of the elements, or + * null if this spliterator cannot be split + */ + Spliterator s2 = s1.trySplit(); + + System.out.println("spliterator 1"); + s1.forEachRemaining(System.out::println); + + System.out.println("\nspliterator 2"); + s2.forEachRemaining(System.out::println); + } + +} diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/5/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/13_Spliterator/5/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/13_Spliterator/5/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/5/ArraysDemo/.project b/Later/Java_Util_package/Arrays/13_Spliterator/5/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/13_Spliterator/5/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/5/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/13_Spliterator/5/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/13_Spliterator/5/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/5/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/13_Spliterator/5/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..081a32492 Binary files /dev/null and b/Later/Java_Util_package/Arrays/13_Spliterator/5/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/5/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/13_Spliterator/5/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..0eb6d447b --- /dev/null +++ b/Later/Java_Util_package/Arrays/13_Spliterator/5/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,47 @@ +import java.util.Arrays; +import java.util.Spliterator; + +/** + * + * public static Spliterator spliterator(T[] array) + * + * Returns a Spliterator covering all of the specified array. + * + */ + +public class ArraysDemo +{ + + public static void main(String[] args) + { + String[] strArray = { "Apple", "banana", "Orange" }; + + /* + * Type Parameters: + * + * T - type of elements + * + * Parameters: + * + * array - the array, assumed to be unmodified during use + * + * Returns: + * + * a spliterator for the array elements + */ + Spliterator s1 = Arrays.spliterator(strArray); + + /* + * Returns:a Spliterator covering some portion of the + * elements, or null if this spliterator cannot be split + */ + Spliterator s2 = s1.trySplit(); + + System.out.println("spliterator 1"); + s1.forEachRemaining(System.out::println); + + System.out.println("\nspliterator 2"); + s2.forEachRemaining(System.out::println); + } + +} diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/6/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/13_Spliterator/6/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/13_Spliterator/6/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/6/ArraysDemo/.project b/Later/Java_Util_package/Arrays/13_Spliterator/6/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/13_Spliterator/6/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/6/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/13_Spliterator/6/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/13_Spliterator/6/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/6/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/13_Spliterator/6/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..9ebb08f22 Binary files /dev/null and b/Later/Java_Util_package/Arrays/13_Spliterator/6/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/13_Spliterator/6/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/13_Spliterator/6/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..e268e8f63 --- /dev/null +++ b/Later/Java_Util_package/Arrays/13_Spliterator/6/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,55 @@ +import java.util.Arrays; +import java.util.Spliterator; + +/** + * + * public static Spliterator spliterator(T[] array, int + * startInclusive, int endExclusive) + * + * Returns a Spliterator covering the specified range of the specified + * array. + * + */ + +public class ArraysDemo +{ + + public static void main(String[] args) + { + String[] strArray = { "Apple", "banana", "Orange", "Grapes", + "Mango" }; + + /* + * Type Parameters: + * + * T - type of elements + * + * Parameters: + * + * array - the array, assumed to be unmodified during use + * + * startInclusive - the first index to cover, inclusive + * + * endExclusive - index immediately past the last index to + * cover + * + * Returns: + * + * a spliterator for the array elements + */ + Spliterator s1 = Arrays.spliterator(strArray, 0, 3); + + /* + * Returns:a Spliterator covering some portion of the + * elements, or null if this spliterator cannot be split + */ + Spliterator s2 = s1.trySplit(); + + System.out.println("spliterator 1"); + s1.forEachRemaining(System.out::println); + + System.out.println("\nspliterator 2"); + s2.forEachRemaining(System.out::println); + } + +} diff --git a/Later/Java_Util_package/Arrays/1_sort/1/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/1_sort/1/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/1/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/1_sort/1/ArraysDemo/.project b/Later/Java_Util_package/Arrays/1_sort/1/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/1/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/1_sort/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/1_sort/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/1_sort/1/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/1_sort/1/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..8d3d8423e Binary files /dev/null and b/Later/Java_Util_package/Arrays/1_sort/1/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/1_sort/1/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/1_sort/1/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..b15449f40 Binary files /dev/null and b/Later/Java_Util_package/Arrays/1_sort/1/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/1_sort/1/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/1_sort/1/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..6112447e2 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/1/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,31 @@ +import java.util.Arrays; + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + + byte[] byteArray = { 5, 2, 7, 3, 9 }; + + /* + * Sorts the specified array into ascending numerical order. + * + * Parameters: + * + * a - the array to be sorted + * + */ + Arrays.sort(byteArray); + + System.out.println("The sorted int array is:"); + int i = 0; + for (byte number : byteArray) + { + System.out.println("Index = " + i + ", Number = " + number); + ++i; + } + + } + +} diff --git a/Later/Java_Util_package/Arrays/1_sort/1/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/1_sort/1/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..ce7f00e7e --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/1/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,39 @@ +import java.util.Arrays; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + + byte[] byteArray = { 5, 2, 7, 3, 9 }; + + /* + * Sorts the specified range of the array into ascending + * order. The range to be sorted extends from the index + * fromIndex, inclusive, to the index toIndex, exclusive. If + * fromIndex == toIndex, the range to be sorted is empty. + * + * Parameters: + * + * a - the array to be sorted + * + * fromIndex - the index of the first element, inclusive, to + * be sorted + * + * toIndex - the index of the last element, exclusive, to be + * sorted + * + */ + Arrays.sort(byteArray, 2, 5); + + System.out.println("The sorted int array is:"); + int i = 0; + for (byte number : byteArray) + { + System.out.println("Index = " + i + ", Number = " + number); + ++i; + } + } + +} diff --git a/Later/Java_Util_package/Arrays/1_sort/10/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/1_sort/10/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/10/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/1_sort/10/ArraysDemo/.project b/Later/Java_Util_package/Arrays/1_sort/10/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/10/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/1_sort/10/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/1_sort/10/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/10/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/1_sort/10/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/1_sort/10/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..77c836578 Binary files /dev/null and b/Later/Java_Util_package/Arrays/1_sort/10/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/1_sort/10/ArraysDemo/bin/Employee.class b/Later/Java_Util_package/Arrays/1_sort/10/ArraysDemo/bin/Employee.class new file mode 100644 index 000000000..6ac5faa50 Binary files /dev/null and b/Later/Java_Util_package/Arrays/1_sort/10/ArraysDemo/bin/Employee.class differ diff --git a/Later/Java_Util_package/Arrays/1_sort/10/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/1_sort/10/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..1d001bbe6 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/10/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,35 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + Employee[] employeeArray = new Employee[4]; + + employeeArray[0] = new Employee("Peter", 24, 80000); + employeeArray[1] = new Employee("Ram", 12, 75000); + employeeArray[2] = new Employee("Alex", 34, 120000); + employeeArray[3] = new Employee("John", 28, 60000); + + System.out.println("Before Sort= " + Arrays.toString(employeeArray)); + + /* + * public static void sort(Object[] a) + * + * Sorts the specified array of objects into ascending order, + * according to the natural ordering of its elements. All + * elements in the array must implement the Comparable + * interface + * + * Parameters: + * + * a - the array to be sorted + * + */ + Arrays.sort(employeeArray); + System.out.println("\nAfter Sort = " + Arrays.toString(employeeArray)); + } + +} diff --git a/Later/Java_Util_package/Arrays/1_sort/10/ArraysDemo/src/Employee.java b/Later/Java_Util_package/Arrays/1_sort/10/ArraysDemo/src/Employee.java new file mode 100644 index 000000000..722628c4f --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/10/ArraysDemo/src/Employee.java @@ -0,0 +1,58 @@ + +public class Employee implements Comparable +{ + private String name; + private int age; + private int salary; + + public Employee(String name, int age, int salary) + { + this.name = name; + this.age = age; + this.salary = salary; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + public int getSalary() + { + return salary; + } + + public void setSalary(int salary) + { + this.salary = salary; + } + + @Override + public int compareTo(Employee employee) + { + return this.salary - employee.salary; + } + + @Override + public String toString() + { + return "Employee [name=" + name + ", age=" + age + ", salary=" + salary + + "]"; + } + +} diff --git a/Later/Java_Util_package/Arrays/1_sort/11/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/1_sort/11/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/11/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/1_sort/11/ArraysDemo/.project b/Later/Java_Util_package/Arrays/1_sort/11/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/11/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/1_sort/11/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/1_sort/11/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/11/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/1_sort/11/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/1_sort/11/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..feebeda95 Binary files /dev/null and b/Later/Java_Util_package/Arrays/1_sort/11/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/1_sort/11/ArraysDemo/bin/Employee.class b/Later/Java_Util_package/Arrays/1_sort/11/ArraysDemo/bin/Employee.class new file mode 100644 index 000000000..94b057f29 Binary files /dev/null and b/Later/Java_Util_package/Arrays/1_sort/11/ArraysDemo/bin/Employee.class differ diff --git a/Later/Java_Util_package/Arrays/1_sort/11/ArraysDemo/bin/EmployeeSalaryComparator.class b/Later/Java_Util_package/Arrays/1_sort/11/ArraysDemo/bin/EmployeeSalaryComparator.class new file mode 100644 index 000000000..5c9103f0d Binary files /dev/null and b/Later/Java_Util_package/Arrays/1_sort/11/ArraysDemo/bin/EmployeeSalaryComparator.class differ diff --git a/Later/Java_Util_package/Arrays/1_sort/11/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/1_sort/11/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..ea64e8062 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/11/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,45 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + Employee[] employeeArray = new Employee[4]; + + employeeArray[0] = new Employee("Peter", 24, 80000); + employeeArray[1] = new Employee("Ram", 12, 75000); + employeeArray[2] = new Employee("Alex", 34, 120000); + employeeArray[3] = new Employee("John", 28, 60000); + + System.out.println("Before Sort= " + Arrays.toString(employeeArray)); + + EmployeeSalaryComparator employeeSalaryComparator = new EmployeeSalaryComparator(); + + /* + * public static void sort(T[] a, Comparator c) + * + * Sorts the specified array of objects into ascending order, + * according to the natural ordering of its elements. All + * elements in the array must implement the Comparable + * interface + * + * Type Parameters: + * + * T - the class of the objects to be sorted + * + * Parameters: + * + * a - the array to be sorted + * + * c - the comparator to determine the order of the array. A + * null value indicates that the elements' natural ordering + * should be used. + * + */ + Arrays.sort(employeeArray, employeeSalaryComparator); + System.out.println("\nAfter Sort = " + Arrays.toString(employeeArray)); + } + +} diff --git a/Later/Java_Util_package/Arrays/1_sort/11/ArraysDemo/src/Employee.java b/Later/Java_Util_package/Arrays/1_sort/11/ArraysDemo/src/Employee.java new file mode 100644 index 000000000..bcac41410 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/11/ArraysDemo/src/Employee.java @@ -0,0 +1,52 @@ + +public class Employee +{ + private String name; + private int age; + private int salary; + + public Employee(String name, int age, int salary) + { + this.name = name; + this.age = age; + this.salary = salary; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + public int getSalary() + { + return salary; + } + + public void setSalary(int salary) + { + this.salary = salary; + } + + @Override + public String toString() + { + return "Employee [name=" + name + ", age=" + age + ", salary=" + salary + + "]"; + } + +} diff --git a/Later/Java_Util_package/Arrays/1_sort/11/ArraysDemo/src/EmployeeSalaryComparator.java b/Later/Java_Util_package/Arrays/1_sort/11/ArraysDemo/src/EmployeeSalaryComparator.java new file mode 100644 index 000000000..ab5d4cfe4 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/11/ArraysDemo/src/EmployeeSalaryComparator.java @@ -0,0 +1,12 @@ +import java.util.Comparator; + +public class EmployeeSalaryComparator implements Comparator +{ + + @Override + public int compare(Employee emp1, Employee emp2) + { + return emp1.getSalary() - emp2.getSalary(); + } + +} diff --git a/Later/Java_Util_package/Arrays/1_sort/12/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/1_sort/12/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/12/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/1_sort/12/ArraysDemo/.project b/Later/Java_Util_package/Arrays/1_sort/12/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/12/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/1_sort/12/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/1_sort/12/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/12/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/1_sort/12/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/1_sort/12/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..c19e0ca64 Binary files /dev/null and b/Later/Java_Util_package/Arrays/1_sort/12/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/1_sort/12/ArraysDemo/bin/Employee.class b/Later/Java_Util_package/Arrays/1_sort/12/ArraysDemo/bin/Employee.class new file mode 100644 index 000000000..94b057f29 Binary files /dev/null and b/Later/Java_Util_package/Arrays/1_sort/12/ArraysDemo/bin/Employee.class differ diff --git a/Later/Java_Util_package/Arrays/1_sort/12/ArraysDemo/bin/EmployeeSalaryComparator.class b/Later/Java_Util_package/Arrays/1_sort/12/ArraysDemo/bin/EmployeeSalaryComparator.class new file mode 100644 index 000000000..5c9103f0d Binary files /dev/null and b/Later/Java_Util_package/Arrays/1_sort/12/ArraysDemo/bin/EmployeeSalaryComparator.class differ diff --git a/Later/Java_Util_package/Arrays/1_sort/12/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/1_sort/12/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..28fa166eb --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/12/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,54 @@ +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + Employee[] employeeArray = new Employee[4]; + + employeeArray[0] = new Employee("Peter", 24, 80000); + employeeArray[1] = new Employee("Ram", 12, 75000); + employeeArray[2] = new Employee("Alex", 34, 120000); + employeeArray[3] = new Employee("John", 28, 60000); + + System.out.println("Before Sort= " + Arrays.toString(employeeArray)); + + EmployeeSalaryComparator employeeSalaryComparator = new EmployeeSalaryComparator(); + + /* + * This method returns a comparator that imposes the reverse + * ordering of the specified comparator. + */ + Comparator descendingEmployeeSalaryComparator = Collections + .reverseOrder(employeeSalaryComparator); + + /* + * public static void sort(T[] a, Comparator c) + * + * Sorts the specified array of objects into ascending order, + * according to the natural ordering of its elements. All + * elements in the array must implement the Comparable + * interface + * + * Type Parameters: + * + * T - the class of the objects to be sorted + * + * Parameters: + * + * a - the array to be sorted + * + * c - the comparator to determine the order of the array. A + * null value indicates that the elements' natural ordering + * should be used. + * + */ + Arrays.sort(employeeArray, descendingEmployeeSalaryComparator); + System.out.println("\nAfter Sort = " + Arrays.toString(employeeArray)); + } + +} diff --git a/Later/Java_Util_package/Arrays/1_sort/12/ArraysDemo/src/Employee.java b/Later/Java_Util_package/Arrays/1_sort/12/ArraysDemo/src/Employee.java new file mode 100644 index 000000000..bcac41410 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/12/ArraysDemo/src/Employee.java @@ -0,0 +1,52 @@ + +public class Employee +{ + private String name; + private int age; + private int salary; + + public Employee(String name, int age, int salary) + { + this.name = name; + this.age = age; + this.salary = salary; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + public int getSalary() + { + return salary; + } + + public void setSalary(int salary) + { + this.salary = salary; + } + + @Override + public String toString() + { + return "Employee [name=" + name + ", age=" + age + ", salary=" + salary + + "]"; + } + +} diff --git a/Later/Java_Util_package/Arrays/1_sort/12/ArraysDemo/src/EmployeeSalaryComparator.java b/Later/Java_Util_package/Arrays/1_sort/12/ArraysDemo/src/EmployeeSalaryComparator.java new file mode 100644 index 000000000..ab5d4cfe4 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/12/ArraysDemo/src/EmployeeSalaryComparator.java @@ -0,0 +1,12 @@ +import java.util.Comparator; + +public class EmployeeSalaryComparator implements Comparator +{ + + @Override + public int compare(Employee emp1, Employee emp2) + { + return emp1.getSalary() - emp2.getSalary(); + } + +} diff --git a/Later/Java_Util_package/Arrays/1_sort/13/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/1_sort/13/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/13/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/1_sort/13/ArraysDemo/.project b/Later/Java_Util_package/Arrays/1_sort/13/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/13/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/1_sort/13/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/1_sort/13/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/13/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/1_sort/13/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/1_sort/13/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..41d326989 Binary files /dev/null and b/Later/Java_Util_package/Arrays/1_sort/13/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/1_sort/13/ArraysDemo/bin/Employee.class b/Later/Java_Util_package/Arrays/1_sort/13/ArraysDemo/bin/Employee.class new file mode 100644 index 000000000..94b057f29 Binary files /dev/null and b/Later/Java_Util_package/Arrays/1_sort/13/ArraysDemo/bin/Employee.class differ diff --git a/Later/Java_Util_package/Arrays/1_sort/13/ArraysDemo/bin/EmployeeSalaryComparator.class b/Later/Java_Util_package/Arrays/1_sort/13/ArraysDemo/bin/EmployeeSalaryComparator.class new file mode 100644 index 000000000..5c9103f0d Binary files /dev/null and b/Later/Java_Util_package/Arrays/1_sort/13/ArraysDemo/bin/EmployeeSalaryComparator.class differ diff --git a/Later/Java_Util_package/Arrays/1_sort/13/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/1_sort/13/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..b6e18eecd --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/13/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,30 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + String[] fruits = new String[] { "Pineapple", "Apple", "Orange", + "Banana" }; + System.out.println("Before sort = " + Arrays.toString(fruits)); + + /* + * public static void sort(Object[] a) + * + * Sorts the specified array of objects into ascending order, + * according to the natural ordering of its elements. All + * elements in the array must implement the Comparable + * interface. + * + * Parameters: + * + * a - the array to be sorted + */ + Arrays.sort(fruits); + + System.out.println("After Sort = " + Arrays.toString(fruits)); + } + +} diff --git a/Later/Java_Util_package/Arrays/1_sort/14/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/1_sort/14/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/14/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/1_sort/14/ArraysDemo/.project b/Later/Java_Util_package/Arrays/1_sort/14/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/14/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/1_sort/14/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/1_sort/14/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/14/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/1_sort/14/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/1_sort/14/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..a27aa6c2e Binary files /dev/null and b/Later/Java_Util_package/Arrays/1_sort/14/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/1_sort/14/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/1_sort/14/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..386bd53d1 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/14/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,47 @@ +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + Integer[] integerArray = new Integer[] { 3, 1, 4, 2, 7, 0 }; + System.out.println("Before Sort= " + Arrays.toString(integerArray)); + + Comparator comp = Collections.reverseOrder(); + + /* + * public static void sort(T[] a, Comparator c) + * + * Sorts the specified range of the specified array of objects + * according to the order induced by the specified comparator. + * The range to be sorted extends from index fromIndex, + * inclusive, to index toIndex, exclusive. + * + * Type Parameters: + * + * T - the class of the objects to be sorted + * + * Parameters: + * + * a - the array to be sorted + * + * fromIndex - the index of the first element (inclusive) to + * be sorted + * + * toIndex - the index of the last element (exclusive) to be + * sorted + * + * c - the comparator to determine the order of the array. A + * null value indicates that the elements' natural ordering + * should be used. + * + */ + Arrays.sort(integerArray, 0, 3, comp); + System.out.println("After Sort = " + Arrays.toString(integerArray)); + } + +} diff --git a/Later/Java_Util_package/Arrays/1_sort/15/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/1_sort/15/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/15/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/1_sort/15/ArraysDemo/.project b/Later/Java_Util_package/Arrays/1_sort/15/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/15/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/1_sort/15/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/1_sort/15/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/15/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/1_sort/15/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/1_sort/15/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..0852c2e17 Binary files /dev/null and b/Later/Java_Util_package/Arrays/1_sort/15/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/1_sort/15/ArraysDemo/bin/Employee.class b/Later/Java_Util_package/Arrays/1_sort/15/ArraysDemo/bin/Employee.class new file mode 100644 index 000000000..94b057f29 Binary files /dev/null and b/Later/Java_Util_package/Arrays/1_sort/15/ArraysDemo/bin/Employee.class differ diff --git a/Later/Java_Util_package/Arrays/1_sort/15/ArraysDemo/bin/EmployeeSalaryComparator.class b/Later/Java_Util_package/Arrays/1_sort/15/ArraysDemo/bin/EmployeeSalaryComparator.class new file mode 100644 index 000000000..5c9103f0d Binary files /dev/null and b/Later/Java_Util_package/Arrays/1_sort/15/ArraysDemo/bin/EmployeeSalaryComparator.class differ diff --git a/Later/Java_Util_package/Arrays/1_sort/15/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/1_sort/15/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..540eeee15 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/15/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,55 @@ +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + Employee[] employeeArray = new Employee[5]; + + employeeArray[0] = new Employee("Peter", 24, 80000); + employeeArray[1] = new Employee("Ram", 12, 75000); + employeeArray[2] = new Employee("Alex", 34, 120000); + employeeArray[3] = new Employee("John", 28, 90000); + employeeArray[4] = new Employee("David", 38, 200000); + + System.out.println("Before Sort= " + Arrays.toString(employeeArray)); + + EmployeeSalaryComparator employeeSalaryComparator = new EmployeeSalaryComparator(); + + /* + * This method returns a comparator that imposes the reverse + * ordering of the specified comparator. + */ + Comparator descendingEmployeeSalaryComparator = Collections + .reverseOrder(employeeSalaryComparator); + + /* + * public static void sort(T[] a, Comparator c) + * + * Sorts the specified array of objects into ascending order, + * according to the natural ordering of its elements. All + * elements in the array must implement the Comparable + * interface + * + * Type Parameters: + * + * T - the class of the objects to be sorted + * + * Parameters: + * + * a - the array to be sorted + * + * c - the comparator to determine the order of the array. A + * null value indicates that the elements' natural ordering + * should be used. + * + */ + Arrays.sort(employeeArray, 0, 3, descendingEmployeeSalaryComparator); + System.out.println("\nAfter Sort = " + Arrays.toString(employeeArray)); + } + +} diff --git a/Later/Java_Util_package/Arrays/1_sort/15/ArraysDemo/src/Employee.java b/Later/Java_Util_package/Arrays/1_sort/15/ArraysDemo/src/Employee.java new file mode 100644 index 000000000..bcac41410 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/15/ArraysDemo/src/Employee.java @@ -0,0 +1,52 @@ + +public class Employee +{ + private String name; + private int age; + private int salary; + + public Employee(String name, int age, int salary) + { + this.name = name; + this.age = age; + this.salary = salary; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public int getAge() + { + return age; + } + + public void setAge(int age) + { + this.age = age; + } + + public int getSalary() + { + return salary; + } + + public void setSalary(int salary) + { + this.salary = salary; + } + + @Override + public String toString() + { + return "Employee [name=" + name + ", age=" + age + ", salary=" + salary + + "]"; + } + +} diff --git a/Later/Java_Util_package/Arrays/1_sort/15/ArraysDemo/src/EmployeeSalaryComparator.java b/Later/Java_Util_package/Arrays/1_sort/15/ArraysDemo/src/EmployeeSalaryComparator.java new file mode 100644 index 000000000..ab5d4cfe4 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/15/ArraysDemo/src/EmployeeSalaryComparator.java @@ -0,0 +1,12 @@ +import java.util.Comparator; + +public class EmployeeSalaryComparator implements Comparator +{ + + @Override + public int compare(Employee emp1, Employee emp2) + { + return emp1.getSalary() - emp2.getSalary(); + } + +} diff --git a/Later/Java_Util_package/Arrays/1_sort/2/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/1_sort/2/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/2/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/1_sort/2/ArraysDemo/.project b/Later/Java_Util_package/Arrays/1_sort/2/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/2/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/1_sort/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/1_sort/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/1_sort/2/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/1_sort/2/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..7fda99d60 Binary files /dev/null and b/Later/Java_Util_package/Arrays/1_sort/2/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/1_sort/2/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/1_sort/2/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..7a4daeb1e Binary files /dev/null and b/Later/Java_Util_package/Arrays/1_sort/2/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/1_sort/2/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/1_sort/2/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..53ec81b09 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/2/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,31 @@ +import java.util.Arrays; + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + + short[] shortArray = { 5, 2, 7, 3, 9 }; + + /* + * Sorts the specified array into ascending numerical order. + * + * Parameters: + * + * a - the array to be sorted + * + */ + Arrays.sort(shortArray); + + System.out.println("The sorted int array is:"); + int i = 0; + for (short number : shortArray) + { + System.out.println("Index = " + i + ", Number = " + number); + ++i; + } + + } + +} diff --git a/Later/Java_Util_package/Arrays/1_sort/2/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/1_sort/2/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..c939891fc --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/2/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,39 @@ +import java.util.Arrays; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + + short[] shortArray = { 5, 2, 7, 3, 9 }; + + /* + * Sorts the specified range of the array into ascending + * order. The range to be sorted extends from the index + * fromIndex, inclusive, to the index toIndex, exclusive. If + * fromIndex == toIndex, the range to be sorted is empty. + * + * Parameters: + * + * a - the array to be sorted + * + * fromIndex - the index of the first element, inclusive, to + * be sorted + * + * toIndex - the index of the last element, exclusive, to be + * sorted + * + */ + Arrays.sort(shortArray, 2, 5); + + System.out.println("The sorted int array is:"); + int i = 0; + for (short number : shortArray) + { + System.out.println("Index = " + i + ", Number = " + number); + ++i; + } + } + +} diff --git a/Later/Java_Util_package/Arrays/1_sort/3/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/1_sort/3/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/3/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/1_sort/3/ArraysDemo/.project b/Later/Java_Util_package/Arrays/1_sort/3/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/3/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/1_sort/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/1_sort/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/1_sort/3/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/1_sort/3/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..11ce827f6 Binary files /dev/null and b/Later/Java_Util_package/Arrays/1_sort/3/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/1_sort/3/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/1_sort/3/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..d07654ec6 Binary files /dev/null and b/Later/Java_Util_package/Arrays/1_sort/3/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/1_sort/3/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/1_sort/3/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..e17f26f22 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/3/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,31 @@ +import java.util.Arrays; + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + + int[] intArray = { 5, 2, 7, 3, 9 }; + + /* + * Sorts the specified array into ascending numerical order. + * + * Parameters: + * + * a - the array to be sorted + * + */ + Arrays.sort(intArray); + + System.out.println("The sorted int array is:"); + int i = 0; + for (int number : intArray) + { + System.out.println("Index = " + i + ", Number = " + number); + ++i; + } + + } + +} diff --git a/Later/Java_Util_package/Arrays/1_sort/3/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/1_sort/3/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..5d4f7ac75 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/3/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,39 @@ +import java.util.Arrays; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + + int[] intArray = { 5, 2, 7, 3, 9 }; + + /* + * Sorts the specified range of the array into ascending + * order. The range to be sorted extends from the index + * fromIndex, inclusive, to the index toIndex, exclusive. If + * fromIndex == toIndex, the range to be sorted is empty. + * + * Parameters: + * + * a - the array to be sorted + * + * fromIndex - the index of the first element, inclusive, to + * be sorted + * + * toIndex - the index of the last element, exclusive, to be + * sorted + * + */ + Arrays.sort(intArray, 2, 5); + + System.out.println("The sorted int array is:"); + int i = 0; + for (int number : intArray) + { + System.out.println("Index = " + i + ", Number = " + number); + ++i; + } + } + +} diff --git a/Later/Java_Util_package/Arrays/1_sort/4/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/1_sort/4/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/4/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/1_sort/4/ArraysDemo/.project b/Later/Java_Util_package/Arrays/1_sort/4/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/4/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/1_sort/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/1_sort/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/1_sort/4/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/1_sort/4/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..b05b7c602 Binary files /dev/null and b/Later/Java_Util_package/Arrays/1_sort/4/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/1_sort/4/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/1_sort/4/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..e4a6ae0f5 Binary files /dev/null and b/Later/Java_Util_package/Arrays/1_sort/4/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/1_sort/4/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/1_sort/4/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..e33ff78ea --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/4/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,31 @@ +import java.util.Arrays; + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + + long[] longArray = { 5, 2, 7, 3, 9 }; + + /* + * Sorts the specified array into ascending numerical order. + * + * Parameters: + * + * a - the array to be sorted + * + */ + Arrays.sort(longArray); + + System.out.println("The sorted long array is:"); + int i = 0; + for (long number : longArray) + { + System.out.println("Index = " + i + ", Number = " + number); + ++i; + } + + } + +} diff --git a/Later/Java_Util_package/Arrays/1_sort/4/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/1_sort/4/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..6d51c0089 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/4/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,39 @@ +import java.util.Arrays; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + + long[] longArray = { 5, 2, 7, 3, 9 }; + + /* + * Sorts the specified range of the array into ascending + * order. The range to be sorted extends from the index + * fromIndex, inclusive, to the index toIndex, exclusive. If + * fromIndex == toIndex, the range to be sorted is empty. + * + * Parameters: + * + * a - the array to be sorted + * + * fromIndex - the index of the first element, inclusive, to + * be sorted + * + * toIndex - the index of the last element, exclusive, to be + * sorted + * + */ + Arrays.sort(longArray, 2, 5); + + System.out.println("The sorted long array is:"); + int i = 0; + for (long number : longArray) + { + System.out.println("Index = " + i + ", Number = " + number); + ++i; + } + } + +} diff --git a/Later/Java_Util_package/Arrays/1_sort/5/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/1_sort/5/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/5/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/1_sort/5/ArraysDemo/.project b/Later/Java_Util_package/Arrays/1_sort/5/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/5/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/1_sort/5/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/1_sort/5/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/5/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/1_sort/5/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/1_sort/5/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..984cf2e97 Binary files /dev/null and b/Later/Java_Util_package/Arrays/1_sort/5/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/1_sort/5/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/1_sort/5/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..7aba62bcc Binary files /dev/null and b/Later/Java_Util_package/Arrays/1_sort/5/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/1_sort/5/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/1_sort/5/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..51c2c5db4 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/5/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,31 @@ +import java.util.Arrays; + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + + float[] floatArray = { 5.2f, 2.3f, 7.6f, 3.4f, 9.8f }; + + /* + * Sorts the specified array into ascending numerical order. + * + * Parameters: + * + * a - the array to be sorted + * + */ + Arrays.sort(floatArray); + + System.out.println("The sorted float array is:"); + int i = 0; + for (float number : floatArray) + { + System.out.println("Index = " + i + ", Number = " + number); + ++i; + } + + } + +} diff --git a/Later/Java_Util_package/Arrays/1_sort/5/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/1_sort/5/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..de9fc7fdf --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/5/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,39 @@ +import java.util.Arrays; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + + float[] floatArray = { 5.2f, 2.3f, 7.6f, 3.4f, 9.8f }; + + /* + * Sorts the specified range of the array into ascending + * order. The range to be sorted extends from the index + * fromIndex, inclusive, to the index toIndex, exclusive. If + * fromIndex == toIndex, the range to be sorted is empty. + * + * Parameters: + * + * a - the array to be sorted + * + * fromIndex - the index of the first element, inclusive, to + * be sorted + * + * toIndex - the index of the last element, exclusive, to be + * sorted + * + */ + Arrays.sort(floatArray, 2, 5); + + System.out.println("The sorted float array is:"); + int i = 0; + for (float number : floatArray) + { + System.out.println("Index = " + i + ", Number = " + number); + ++i; + } + } + +} diff --git a/Later/Java_Util_package/Arrays/1_sort/6/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/1_sort/6/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/6/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/1_sort/6/ArraysDemo/.project b/Later/Java_Util_package/Arrays/1_sort/6/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/6/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/1_sort/6/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/1_sort/6/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/6/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/1_sort/6/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/1_sort/6/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..cf0e7a1c2 Binary files /dev/null and b/Later/Java_Util_package/Arrays/1_sort/6/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/1_sort/6/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/1_sort/6/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..5dbf9ea1f Binary files /dev/null and b/Later/Java_Util_package/Arrays/1_sort/6/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/1_sort/6/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/1_sort/6/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..015d6bfcb --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/6/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,31 @@ +import java.util.Arrays; + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + + double[] doubleArray = { 5.2f, 2.3f, 7.6f, 3.4f, 9.8f }; + + /* + * Sorts the specified array into ascending numerical order. + * + * Parameters: + * + * a - the array to be sorted + * + */ + Arrays.sort(doubleArray); + + System.out.println("The sorted double array is:"); + int i = 0; + for (double number : doubleArray) + { + System.out.println("Index = " + i + ", Number = " + number); + ++i; + } + + } + +} diff --git a/Later/Java_Util_package/Arrays/1_sort/6/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/1_sort/6/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..c538083cd --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/6/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,39 @@ +import java.util.Arrays; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + + double[] doubleArray = { 5.2f, 2.3f, 7.6f, 3.4f, 9.8f }; + + /* + * Sorts the specified range of the array into ascending + * order. The range to be sorted extends from the index + * fromIndex, inclusive, to the index toIndex, exclusive. If + * fromIndex == toIndex, the range to be sorted is empty. + * + * Parameters: + * + * a - the array to be sorted + * + * fromIndex - the index of the first element, inclusive, to + * be sorted + * + * toIndex - the index of the last element, exclusive, to be + * sorted + * + */ + Arrays.sort(doubleArray, 2, 5); + + System.out.println("The sorted double array is:"); + int i = 0; + for (double number : doubleArray) + { + System.out.println("Index = " + i + ", Number = " + number); + ++i; + } + } + +} diff --git a/Later/Java_Util_package/Arrays/1_sort/7/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/1_sort/7/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/7/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/1_sort/7/ArraysDemo/.project b/Later/Java_Util_package/Arrays/1_sort/7/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/7/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/1_sort/7/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/1_sort/7/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/7/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/1_sort/7/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/1_sort/7/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..a1f73f06e Binary files /dev/null and b/Later/Java_Util_package/Arrays/1_sort/7/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/1_sort/7/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/1_sort/7/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..b152b7948 Binary files /dev/null and b/Later/Java_Util_package/Arrays/1_sort/7/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/1_sort/7/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/1_sort/7/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..7635cbe4d --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/7/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,31 @@ +import java.util.Arrays; + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + + Object[] objectArray = { 5, 2, 7, 3, 9 }; + + /* + * Sorts the specified array into ascending numerical order. + * + * Parameters: + * + * a - the array to be sorted + * + */ + Arrays.sort(objectArray); + + System.out.println("The sorted Object array is:"); + int i = 0; + for (Object number : objectArray) + { + System.out.println("Index = " + i + ", Number = " + number); + ++i; + } + + } + +} diff --git a/Later/Java_Util_package/Arrays/1_sort/7/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/1_sort/7/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..9fa868476 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/7/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,39 @@ +import java.util.Arrays; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + + Object[] objectArray = { 5, 2, 7, 3, 9 }; + + /* + * Sorts the specified range of the array into ascending + * order. The range to be sorted extends from the index + * fromIndex, inclusive, to the index toIndex, exclusive. If + * fromIndex == toIndex, the range to be sorted is empty. + * + * Parameters: + * + * a - the array to be sorted + * + * fromIndex - the index of the first element, inclusive, to + * be sorted + * + * toIndex - the index of the last element, exclusive, to be + * sorted + * + */ + Arrays.sort(objectArray, 2, 5); + + System.out.println("The sorted Object array is:"); + int i = 0; + for (Object number : objectArray) + { + System.out.println("Index = " + i + ", Number = " + number); + ++i; + } + } + +} diff --git a/Later/Java_Util_package/Arrays/1_sort/8/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/1_sort/8/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/8/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/1_sort/8/ArraysDemo/.project b/Later/Java_Util_package/Arrays/1_sort/8/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/8/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/1_sort/8/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/1_sort/8/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/8/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/1_sort/8/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/1_sort/8/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..aa540feab Binary files /dev/null and b/Later/Java_Util_package/Arrays/1_sort/8/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/1_sort/8/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/1_sort/8/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..a5f09c685 Binary files /dev/null and b/Later/Java_Util_package/Arrays/1_sort/8/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/1_sort/8/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/1_sort/8/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..386c72921 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/8/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,31 @@ +import java.util.Arrays; + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + + char[] charArray = {'d','b','e','a','c'}; + + /* + * Sorts the specified array into ascending numerical order. + * + * Parameters: + * + * a - the array to be sorted + * + */ + Arrays.sort(charArray); + + System.out.println("The sorted Object array is:"); + int i = 0; + for (char ch : charArray) + { + System.out.println("Index = " + i + ", Number = " + ch); + ++i; + } + + } + +} diff --git a/Later/Java_Util_package/Arrays/1_sort/8/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/1_sort/8/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..5363ad792 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/8/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,39 @@ +import java.util.Arrays; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + + char[] charArray = {'d','b','e','a','c'}; + + /* + * Sorts the specified range of the array into ascending + * order. The range to be sorted extends from the index + * fromIndex, inclusive, to the index toIndex, exclusive. If + * fromIndex == toIndex, the range to be sorted is empty. + * + * Parameters: + * + * a - the array to be sorted + * + * fromIndex - the index of the first element, inclusive, to + * be sorted + * + * toIndex - the index of the last element, exclusive, to be + * sorted + * + */ + Arrays.sort(charArray, 2, 4); + + System.out.println("The sorted Object array is:"); + int i = 0; + for (char ch : charArray) + { + System.out.println("Index = " + i + ", Number = " + ch); + ++i; + } + } + +} diff --git a/Later/Java_Util_package/Arrays/1_sort/9/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/1_sort/9/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/9/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/1_sort/9/ArraysDemo/.project b/Later/Java_Util_package/Arrays/1_sort/9/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/9/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/1_sort/9/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/1_sort/9/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/9/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/1_sort/9/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/1_sort/9/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..30b14008d Binary files /dev/null and b/Later/Java_Util_package/Arrays/1_sort/9/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/1_sort/9/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/1_sort/9/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..1b60a675f --- /dev/null +++ b/Later/Java_Util_package/Arrays/1_sort/9/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,39 @@ +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + Integer[] integerArray = new Integer[] { 3, 1, 4, 2 }; + System.out.println("Before Sort= " + Arrays.toString(integerArray)); + + Comparator comp = Collections.reverseOrder(); + + /* + * public static void sort(T[] a, Comparator c) + * + * Sorts the specified array of objects according to the order + * induced by the specified comparator. + * + * Type Parameters: + * + * T - the class of the objects to be sorted + * + * Parameters: + * + * a - the array to be sorted + * + * c - the comparator to determine the order of the array. A + * null value indicates that the elements' natural ordering + * should be used. + * + */ + Arrays.sort(integerArray, comp); + System.out.println("After Sort = " + Arrays.toString(integerArray)); + } + +} diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/1/Arrays.pptx b/Later/Java_Util_package/Arrays/2_binarySearch/1/Arrays.pptx new file mode 100644 index 000000000..9e9057d50 Binary files /dev/null and b/Later/Java_Util_package/Arrays/2_binarySearch/1/Arrays.pptx differ diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/1/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/2_binarySearch/1/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/1/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/1/ArraysDemo/.project b/Later/Java_Util_package/Arrays/2_binarySearch/1/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/1/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/2_binarySearch/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/1/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/2_binarySearch/1/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..8d7e4e016 Binary files /dev/null and b/Later/Java_Util_package/Arrays/2_binarySearch/1/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/1/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/2_binarySearch/1/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..425de0b4b --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/1/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,30 @@ +import java.util.Arrays; +import java.util.List; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + String[] nameArray = new String[] { "Ram", "Peter", "Dave" }; + + /* + * Returns a fixed-size list backed by the specified array. + * (Changes to the returned list "write through" to the + * array.) + * + * Parameters: + * + * a - the array by which the list will be backed + * + * Returns: + * + * a list view of the specified array + */ + List nameList = Arrays.asList(nameArray); + + System.out.println(nameList); + } + +} diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/2/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/2_binarySearch/2/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/2/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/2/ArraysDemo/.project b/Later/Java_Util_package/Arrays/2_binarySearch/2/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/2/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/2_binarySearch/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/2/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/2_binarySearch/2/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..d21c862ce Binary files /dev/null and b/Later/Java_Util_package/Arrays/2_binarySearch/2/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/2/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/2_binarySearch/2/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..1ed67a7e5 Binary files /dev/null and b/Later/Java_Util_package/Arrays/2_binarySearch/2/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/2/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/2_binarySearch/2/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..0e3bdf6bb --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/2/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,50 @@ +import java.util.Arrays; + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + + int[] intArr = { 10, 5, 8, 90, 50, 40 }; + + Arrays.sort(intArr); + + System.out.println("The sorted int array is:"); + int i = 0; + for (int number : intArr) + { + System.out.println("Index = " + i + ", Number = " + number); + ++i; + } + + /* + * Searches the specified array of ints for the specified + * value using the binary search algorithm. + * + * The array must be sorted (as by the sort(int[]) method) + * prior to making this call. If it is not sorted, the results + * are undefined. + * + * If the array contains multiple elements with the specified + * value, there is no guarantee which one will be found. + * + * Parameters: + * + * a - the array to be searched + * + * key - the value to be searched for + * + * Returns: + * + * index of the search key, if it is contained in the array; + * otherwise, (-(insertion point) - 1). + */ + int searchKey = 50; + int indexOfSearchKey = Arrays.binarySearch(intArr, searchKey); + + System.out.println( + "indexOfSearchKey " + searchKey + " is = " + indexOfSearchKey); + } + +} diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/2/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/2_binarySearch/2/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..375f5ff11 --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/2/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,57 @@ +import java.util.Arrays; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + + int[] intArr = { 10, 5, 8, 90, 50, 40 }; + + Arrays.sort(intArr); + + System.out.println("The sorted int array is:"); + int i = 0; + for (int number : intArr) + { + System.out.println("Index = " + i + ", Number = " + number); + ++i; + } + + /* + * Searches a range of the specified array of ints for the + * specified value using the binary search algorithm. + * + * The range must be sorted (as by the sort(int[], int, int) + * method) prior to making this call. If it is not sorted, the + * results are undefined. + * + * If the range contains multiple elements with the specified + * value, there is no guarantee which one will be found. + * + * Parameters: + * + * a - the array to be searched + * + * fromIndex - the index of the first element (inclusive) to + * be searched + * + * toIndex - the index of the last element (exclusive) to be + * searched + * + * key - the value to be searched for + * + * Returns: + * + * index of the search key, if it is contained in the array + * within the specified range; otherwise, (-(insertion point) + * - 1). + */ + int searchKey = 8; + int indexOfSearchKey = Arrays.binarySearch(intArr, 0, 3, searchKey); + + System.out.println( + "indexOfSearchKey " + searchKey + " is = " + indexOfSearchKey); + } + +} diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/3/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/2_binarySearch/3/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/3/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/3/ArraysDemo/.project b/Later/Java_Util_package/Arrays/2_binarySearch/3/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/3/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/2_binarySearch/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/3/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/2_binarySearch/3/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..b5a0774f2 Binary files /dev/null and b/Later/Java_Util_package/Arrays/2_binarySearch/3/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/3/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/2_binarySearch/3/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..d22e7ae83 Binary files /dev/null and b/Later/Java_Util_package/Arrays/2_binarySearch/3/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/3/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/2_binarySearch/3/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..5ab05f672 --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/3/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,50 @@ +import java.util.Arrays; + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + + long[] longArray = { 10, 5, 8, 90, 50, 40 }; + + Arrays.sort(longArray); + + System.out.println("The sorted int array is:"); + int i = 0; + for (long number : longArray) + { + System.out.println("Index = " + i + ", Number = " + number); + ++i; + } + + /* + * Searches the specified array of longs for the specified + * value using the binary search algorithm. + * + * The array must be sorted (as by the sort(long[]) method) + * prior to making this call. If it is not sorted, the results + * are undefined. + * + * If the array contains multiple elements with the specified + * value, there is no guarantee which one will be found. + * + * Parameters: + * + * a - the array to be searched + * + * key - the value to be searched for + * + * Returns: + * + * index of the search key, if it is contained in the array; + * otherwise, (-(insertion point) - 1). + */ + int searchKey = 50; + int indexOfSearchKey = Arrays.binarySearch(longArray, searchKey); + + System.out.println( + "indexOfSearchKey " + searchKey + " is = " + indexOfSearchKey); + } + +} diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/3/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/2_binarySearch/3/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..a0493a68e --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/3/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,57 @@ +import java.util.Arrays; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + + long[] longArray = { 10, 5, 8, 90, 50, 40 }; + + Arrays.sort(longArray); + + System.out.println("The sorted int array is:"); + int i = 0; + for (long number : longArray) + { + System.out.println("Index = " + i + ", Number = " + number); + ++i; + } + + /* + * Searches a range of the specified array of longs for the + * specified value using the binary search algorithm. + * + * The range must be sorted (as by the sort(long[], int, int) + * method) prior to making this call. If it is not sorted, the + * results are undefined. + * + * If the range contains multiple elements with the specified + * value, there is no guarantee which one will be found. + * + * Parameters: + * + * a - the array to be searched + * + * fromIndex - the index of the first element (inclusive) to + * be searched + * + * toIndex - the index of the last element (exclusive) to be + * searched + * + * key - the value to be searched for + * + * Returns: + * + * index of the search key, if it is contained in the array + * within the specified range; otherwise, (-(insertion point) + * - 1). + */ + int searchKey = 8; + int indexOfSearchKey = Arrays.binarySearch(longArray, 0, 3, searchKey); + + System.out.println( + "indexOfSearchKey " + searchKey + " is = " + indexOfSearchKey); + } + +} diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/4/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/2_binarySearch/4/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/4/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/4/ArraysDemo/.project b/Later/Java_Util_package/Arrays/2_binarySearch/4/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/4/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/2_binarySearch/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/4/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/2_binarySearch/4/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..1108aa1d2 Binary files /dev/null and b/Later/Java_Util_package/Arrays/2_binarySearch/4/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/4/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/2_binarySearch/4/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..19927cd1c Binary files /dev/null and b/Later/Java_Util_package/Arrays/2_binarySearch/4/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/4/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/2_binarySearch/4/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..7a991e360 --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/4/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,50 @@ +import java.util.Arrays; + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + + float[] floatArray = { 10.1f, 5.9f, 8.6f, 90.4f, 50.2f, 40.5f }; + + Arrays.sort(floatArray); + + System.out.println("The sorted int array is:"); + int i = 0; + for (float number : floatArray) + { + System.out.println("Index = " + i + ", Number = " + number); + ++i; + } + + /* + * Searches the specified array of floats for the specified + * value using the binary search algorithm. + * + * The array must be sorted (as by the sort(float[]) method) + * prior to making this call. If it is not sorted, the results + * are undefined. + * + * If the array contains multiple elements with the specified + * value, there is no guarantee which one will be found. + * + * Parameters: + * + * a - the array to be searched + * + * key - the value to be searched for + * + * Returns: + * + * index of the search key, if it is contained in the array; + * otherwise, (-(insertion point) - 1). + */ + float searchKey = 40.5f; + int indexOfSearchKey = Arrays.binarySearch(floatArray, searchKey); + + System.out.println( + "indexOfSearchKey " + searchKey + " is = " + indexOfSearchKey); + } + +} diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/4/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/2_binarySearch/4/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..425d8776f --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/4/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,57 @@ +import java.util.Arrays; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + + float[] floatArray = { 10.1f, 5.9f, 8.6f, 90.4f, 50.2f, 40.5f }; + + Arrays.sort(floatArray); + + System.out.println("The sorted int array is:"); + int i = 0; + for (float number : floatArray) + { + System.out.println("Index = " + i + ", Number = " + number); + ++i; + } + + /* + * Searches a range of the specified array of floats for the + * specified value using the binary search algorithm. + * + * The range must be sorted (as by the sort(float[], int, int) + * method) prior to making this call. If it is not sorted, the + * results are undefined. + * + * If the range contains multiple elements with the specified + * value, there is no guarantee which one will be found. + * + * Parameters: + * + * a - the array to be searched + * + * fromIndex - the index of the first element (inclusive) to + * be searched + * + * toIndex - the index of the last element (exclusive) to be + * searched + * + * key - the value to be searched for + * + * Returns: + * + * index of the search key, if it is contained in the array + * within the specified range; otherwise, (-(insertion point) + * - 1). + */ + float searchKey = 8.6f; + int indexOfSearchKey = Arrays.binarySearch(floatArray, 0, 3, searchKey); + + System.out.println( + "indexOfSearchKey " + searchKey + " is = " + indexOfSearchKey); + } + +} diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/5/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/2_binarySearch/5/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/5/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/5/ArraysDemo/.project b/Later/Java_Util_package/Arrays/2_binarySearch/5/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/5/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/5/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/2_binarySearch/5/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/5/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/5/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/2_binarySearch/5/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..54b1a17dd Binary files /dev/null and b/Later/Java_Util_package/Arrays/2_binarySearch/5/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/5/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/2_binarySearch/5/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..63701ac09 Binary files /dev/null and b/Later/Java_Util_package/Arrays/2_binarySearch/5/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/5/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/2_binarySearch/5/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..e7746070f --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/5/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,50 @@ +import java.util.Arrays; + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + + double[] doubleArray = { 10.1, 5.9, 8.6, 90.4, 50.2, 40.5 }; + + Arrays.sort(doubleArray); + + System.out.println("The sorted int array is:"); + int i = 0; + for (double number : doubleArray) + { + System.out.println("Index = " + i + ", Number = " + number); + ++i; + } + + /* + * Searches the specified array of doubles for the specified + * value using the binary search algorithm. + * + * The array must be sorted (as by the sort(double[]) method) + * prior to making this call. If it is not sorted, the results + * are undefined. + * + * If the array contains multiple elements with the specified + * value, there is no guarantee which one will be found. + * + * Parameters: + * + * a - the array to be searched + * + * key - the value to be searched for + * + * Returns: + * + * index of the search key, if it is contained in the array; + * otherwise, (-(insertion point) - 1). + */ + double searchKey = 40.5; + int indexOfSearchKey = Arrays.binarySearch(doubleArray, searchKey); + + System.out.println( + "indexOfSearchKey " + searchKey + " is = " + indexOfSearchKey); + } + +} diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/5/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/2_binarySearch/5/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..2151736e6 --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/5/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,58 @@ +import java.util.Arrays; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + + double[] doubleArray = { 10.1, 5.9, 8.6, 90.4, 50.2, 40.5 }; + + Arrays.sort(doubleArray); + + System.out.println("The sorted int array is:"); + int i = 0; + for (double number : doubleArray) + { + System.out.println("Index = " + i + ", Number = " + number); + ++i; + } + + /* + * Searches a range of the specified array of doubles for the + * specified value using the binary search algorithm. + * + * The range must be sorted (as by the sort(double[], int, + * int) method) prior to making this call. If it is not + * sorted, the results are undefined. + * + * If the range contains multiple elements with the specified + * value, there is no guarantee which one will be found. + * + * Parameters: + * + * a - the array to be searched + * + * fromIndex - the index of the first element (inclusive) to + * be searched + * + * toIndex - the index of the last element (exclusive) to be + * searched + * + * key - the value to be searched for + * + * Returns: + * + * index of the search key, if it is contained in the array + * within the specified range; otherwise, (-(insertion point) + * - 1). + */ + double searchKey = 8.6; + int indexOfSearchKey = Arrays.binarySearch(doubleArray, 0, 3, + searchKey); + + System.out.println( + "indexOfSearchKey " + searchKey + " is = " + indexOfSearchKey); + } + +} diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/6/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/2_binarySearch/6/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/6/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/6/ArraysDemo/.project b/Later/Java_Util_package/Arrays/2_binarySearch/6/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/6/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/6/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/2_binarySearch/6/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/6/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/6/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/2_binarySearch/6/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..f929e92af Binary files /dev/null and b/Later/Java_Util_package/Arrays/2_binarySearch/6/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/6/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/2_binarySearch/6/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..00efee633 Binary files /dev/null and b/Later/Java_Util_package/Arrays/2_binarySearch/6/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/6/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/2_binarySearch/6/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..91af05bf9 --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/6/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,50 @@ +import java.util.Arrays; + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + + char[] charArray = { 'a', 'c', 'g', 'z', 'd' }; + + Arrays.sort(charArray); + + System.out.println("The sorted char array is:"); + int i = 0; + for (char ch : charArray) + { + System.out.println("Index = " + i + ", char = " + ch); + ++i; + } + + /* + * Searches the specified array of chars for the specified + * value using the binary search algorithm. + * + * The array must be sorted (as by the sort(char[]) method) + * prior to making this call. If it is not sorted, the results + * are undefined. + * + * If the array contains multiple elements with the specified + * value, there is no guarantee which one will be found. + * + * Parameters: + * + * a - the array to be searched + * + * key - the value to be searched for + * + * Returns: + * + * index of the search key, if it is contained in the array; + * otherwise, (-(insertion point) - 1). + */ + char searchKey = 'g'; + int indexOfSearchKey = Arrays.binarySearch(charArray, searchKey); + + System.out.println( + "indexOfSearchKey " + searchKey + " is = " + indexOfSearchKey); + } + +} diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/6/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/2_binarySearch/6/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..e87e806fe --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/6/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,58 @@ +import java.util.Arrays; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + + char[] charArray = { 'a', 'c', 'g', 'z', 'd' }; + + Arrays.sort(charArray); + + System.out.println("The sorted char array is:"); + int i = 0; + for (char ch : charArray) + { + System.out.println("Index = " + i + ", char = " + ch); + ++i; + } + + /* + * + * Searches a range of the specified array of chars for the + * specified value using the binary search algorithm. + * + * The range must be sorted (as by the sort(char[], int, int) + * method) prior to making this call. If it is not sorted, the + * results are undefined. + * + * If the range contains multiple elements with the specified + * value, there is no guarantee which one will be found. + * + * + * Parameters: + * + * a - the array to be searched + * + * fromIndex - the index of the first element (inclusive) to + * be searched + * + * toIndex - the index of the last element (exclusive) to be + * searched + * + * key - the value to be searched for + * + * Returns: + * + * index of the search key, if it is contained in the array; + * otherwise, (-(insertion point) - 1). + */ + char searchKey = 'c'; + int indexOfSearchKey = Arrays.binarySearch(charArray, 0, 3, searchKey); + + System.out.println( + "indexOfSearchKey " + searchKey + " is = " + indexOfSearchKey); + } + +} diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/7/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/2_binarySearch/7/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/7/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/7/ArraysDemo/.project b/Later/Java_Util_package/Arrays/2_binarySearch/7/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/7/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/7/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/2_binarySearch/7/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/7/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/7/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/2_binarySearch/7/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..13c48ff80 Binary files /dev/null and b/Later/Java_Util_package/Arrays/2_binarySearch/7/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/7/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/2_binarySearch/7/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..9f69570cf Binary files /dev/null and b/Later/Java_Util_package/Arrays/2_binarySearch/7/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/7/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/2_binarySearch/7/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..1043acaa7 --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/7/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,50 @@ +import java.util.Arrays; + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + + byte[] byteArray = { 10, 5, 8, 90, 50, 40 }; + + Arrays.sort(byteArray); + + System.out.println("The sorted int array is:"); + int i = 0; + for (byte number : byteArray) + { + System.out.println("Index = " + i + ", Number = " + number); + ++i; + } + + /* + * Searches the specified array of bytes for the specified + * value using the binary search algorithm. + * + * The array must be sorted (as by the sort(byte[]) method) + * prior to making this call. If it is not sorted, the results + * are undefined. + * + * If the array contains multiple elements with the specified + * value, there is no guarantee which one will be found. + * + * Parameters: + * + * a - the array to be searched + * + * key - the value to be searched for + * + * Returns: + * + * index of the search key, if it is contained in the array; + * otherwise, (-(insertion point) - 1). + */ + byte searchKey = 40; + int indexOfSearchKey = Arrays.binarySearch(byteArray, searchKey); + + System.out.println( + "indexOfSearchKey " + searchKey + " is = " + indexOfSearchKey); + } + +} diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/7/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/2_binarySearch/7/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..0071ab5b6 --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/7/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,56 @@ +import java.util.Arrays; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + + byte[] byteArray = { 10, 5, 8, 90, 50, 40 }; + + Arrays.sort(byteArray); + + System.out.println("The sorted int array is:"); + int i = 0; + for (byte number : byteArray) + { + System.out.println("Index = " + i + ", Number = " + number); + ++i; + } + + /* + * Searches a range of the specified array of bytes for the + * specified value using the binary search algorithm. + * + * The range must be sorted (as by the sort(byte[], int, int) + * method) prior to making this call. If it is not sorted, the + * results are undefined. + * + * If the range contains multiple elements with the specified + * value, there is no guarantee which one will be found. + * + * Parameters: + * + * a - the array to be searched + * + * fromIndex - the index of the first element (inclusive) to + * be searched + * + * toIndex - the index of the last element (exclusive) to be + * searched + * + * key - the value to be searched for + * + * Returns: + * + * index of the search key, if it is contained in the array; + * otherwise, (-(insertion point) - 1). + */ + byte searchKey = 8; + int indexOfSearchKey = Arrays.binarySearch(byteArray, 0, 3, searchKey); + + System.out.println( + "indexOfSearchKey " + searchKey + " is = " + indexOfSearchKey); + } + +} diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/8/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/2_binarySearch/8/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/8/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/8/ArraysDemo/.project b/Later/Java_Util_package/Arrays/2_binarySearch/8/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/8/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/8/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/2_binarySearch/8/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/8/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/8/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/2_binarySearch/8/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..9fbdba2f8 Binary files /dev/null and b/Later/Java_Util_package/Arrays/2_binarySearch/8/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/8/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/2_binarySearch/8/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..e1c1aa634 Binary files /dev/null and b/Later/Java_Util_package/Arrays/2_binarySearch/8/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/8/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/2_binarySearch/8/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..8773f939b --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/8/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,50 @@ +import java.util.Arrays; + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + + short[] shortArray = { 10, 5, 8, 90, 50, 40 }; + + Arrays.sort(shortArray); + + System.out.println("The sorted int array is:"); + int i = 0; + for (short number : shortArray) + { + System.out.println("Index = " + i + ", Number = " + number); + ++i; + } + + /* + * Searches the specified array of shorts for the specified + * value using the binary search algorithm. + * + * The array must be sorted (as by the sort(short[]) method) + * prior to making this call. If it is not sorted, the results + * are undefined. + * + * If the array contains multiple elements with the specified + * value, there is no guarantee which one will be found. + * + * Parameters: + * + * a - the array to be searched + * + * key - the value to be searched for + * + * Returns: + * + * index of the search key, if it is contained in the array; + * otherwise, (-(insertion point) - 1). + */ + short searchKey = 40; + int indexOfSearchKey = Arrays.binarySearch(shortArray, searchKey); + + System.out.println( + "indexOfSearchKey " + searchKey + " is = " + indexOfSearchKey); + } + +} diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/8/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/2_binarySearch/8/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..d23e3b945 --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/8/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,56 @@ +import java.util.Arrays; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + + short[] shortArray = { 10, 5, 8, 90, 50, 40 }; + + Arrays.sort(shortArray); + + System.out.println("The sorted int array is:"); + int i = 0; + for (short number : shortArray) + { + System.out.println("Index = " + i + ", Number = " + number); + ++i; + } + + /* + * Searches a range of the specified array of shorts for the + * specified value using the binary search algorithm. + * + * The range must be sorted (as by the sort(short[], int, int) + * method) prior to making this call. If it is not sorted, the + * results are undefined. + * + * If the range contains multiple elements with the specified + * value, there is no guarantee which one will be found. + * + * Parameters: + * + * a - the array to be searched + * + * fromIndex - the index of the first element (inclusive) to + * be searched + * + * toIndex - the index of the last element (exclusive) to be + * searched + * + * key - the value to be searched for + * + * Returns: + * + * index of the search key, if it is contained in the array; + * otherwise, (-(insertion point) - 1). + */ + short searchKey = 8; + int indexOfSearchKey = Arrays.binarySearch(shortArray, 0, 3, searchKey); + + System.out.println( + "indexOfSearchKey " + searchKey + " is = " + indexOfSearchKey); + } + +} diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/9/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/2_binarySearch/9/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/9/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/9/ArraysDemo/.project b/Later/Java_Util_package/Arrays/2_binarySearch/9/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/9/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/9/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/2_binarySearch/9/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/9/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/9/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/2_binarySearch/9/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..d50486624 Binary files /dev/null and b/Later/Java_Util_package/Arrays/2_binarySearch/9/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/9/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/2_binarySearch/9/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..69917ea3c Binary files /dev/null and b/Later/Java_Util_package/Arrays/2_binarySearch/9/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/9/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/2_binarySearch/9/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..7fe35ffd2 --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/9/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,54 @@ +import java.util.Arrays; + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + + Object[] objArray = { 10, 5, 8, 90, 50, 40 }; + + Arrays.sort(objArray); + + System.out.println("The sorted int array is:"); + int i = 0; + for (Object number : objArray) + { + System.out.println("Index = " + i + ", Number = " + number); + ++i; + } + + /* + * Searches the specified array for the specified object using + * the binary search algorithm. The array must be sorted into + * ascending order according to the natural ordering of its + * elements (as by the sort(Object[]) method) prior to making + * this call. + * + * If it is not sorted, the results are undefined. (If the + * array contains elements that are not mutually comparable + * (for example, strings and integers), it cannot be sorted + * according to the natural ordering of its elements, hence + * results are undefined.) If the array contains multiple + * elements equal to the specified object, there is no + * guarantee which one will be found. + * + * Parameters: + * + * a - the array to be searched + * + * key - the value to be searched for + * + * Returns: + * + * index of the search key, if it is contained in the array; + * otherwise, (-(insertion point) - 1). + */ + Object searchKey = 40; + int indexOfSearchKey = Arrays.binarySearch(objArray, searchKey); + + System.out.println( + "indexOfSearchKey " + searchKey + " is = " + indexOfSearchKey); + } + +} diff --git a/Later/Java_Util_package/Arrays/2_binarySearch/9/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/2_binarySearch/9/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..fc88bfc91 --- /dev/null +++ b/Later/Java_Util_package/Arrays/2_binarySearch/9/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,60 @@ +import java.util.Arrays; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + + Object[] objArray = { 10, 5, 8, 90, 50, 40 }; + + Arrays.sort(objArray); + + System.out.println("The sorted int array is:"); + int i = 0; + for (Object number : objArray) + { + System.out.println("Index = " + i + ", Number = " + number); + ++i; + } + + /* + * Searches a range of the specified array for the specified + * object using the binary search algorithm. The range must be + * sorted into ascending order according to the natural + * ordering of its elements (as by the sort(Object[], int, + * int) method) prior to making this call. + * + * If it is not sorted, the results are undefined. (If the + * range contains elements that are not mutually comparable + * (for example, strings and integers), it cannot be sorted + * according to the natural ordering of its elements, hence + * results are undefined.) If the range contains multiple + * elements equal to the specified object, there is no + * guarantee which one will be found. + * + * Parameters: + * + * a - the array to be searched + * + * fromIndex - the index of the first element (inclusive) to + * be searched + * + * toIndex - the index of the last element (exclusive) to be + * searched + * + * key - the value to be searched for + * + * Returns: + * + * index of the search key, if it is contained in the array; + * otherwise, (-(insertion point) - 1). + */ + Object searchKey = 8; + int indexOfSearchKey = Arrays.binarySearch(objArray, 0, 3, searchKey); + + System.out.println( + "indexOfSearchKey " + searchKey + " is = " + indexOfSearchKey); + } + +} diff --git a/Later/Java_Util_package/Arrays/3_fill/1/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/3_fill/1/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/1/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/3_fill/1/ArraysDemo/.project b/Later/Java_Util_package/Arrays/3_fill/1/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/1/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/3_fill/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/3_fill/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/3_fill/1/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/3_fill/1/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..52b168a58 Binary files /dev/null and b/Later/Java_Util_package/Arrays/3_fill/1/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/3_fill/1/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/3_fill/1/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..fc8503858 Binary files /dev/null and b/Later/Java_Util_package/Arrays/3_fill/1/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/3_fill/1/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/3_fill/1/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..55bb00646 --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/1/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,38 @@ +import java.util.Arrays; + +check next example + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + + byte byteArray[] = new byte[] { 2, 7, 9, 7, 8 }; + + System.out.println("Actual values: "); + for (byte value : byteArray) + { + System.out.println("Value = " + value); + } + + /* + * Assigns the specified byte value to each element of the + * specified array of bytes. + * + * Parameters:a - the array to be filled + * + * val - the value to be stored in all elements of the array + */ + Arrays.fill(byteArray, (byte) 8); + + System.out.println("New values after using fill() method: "); + + for (byte value : byteArray) + { + System.out.println("Value = " + value); + } + + } + +} diff --git a/Later/Java_Util_package/Arrays/3_fill/1/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/3_fill/1/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..6072a53fb --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/1/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,47 @@ +import java.util.Arrays; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + + byte byteArray[] = new byte[] { 2, 7, 9, 7, 8 }; + + System.out.println("Actual values: "); + for (byte value : byteArray) + { + System.out.println("Value = " + value); + } + + /* + * Assigns the specified byte value to each element of the + * specified range of the specified array of bytes. The range + * to be filled extends from index fromIndex, inclusive, to + * index toIndex, exclusive. (If fromIndex==toIndex, the range + * to be filled is empty.) + * + * Parameters: + * + * a - the array to be filled + * + * fromIndex - the index of the first element (inclusive) to + * be filled with the specified value + * + * toIndex - the index of the last element (exclusive) to be + * filled with the specified value + * + * val - the value to be stored in all elements of the array + */ + Arrays.fill(byteArray, 1, 3, (byte) 8); + + System.out.println("New values after using fill() method: "); + + for (byte value : byteArray) + { + System.out.println("Value = " + value); + } + + } + +} diff --git a/Later/Java_Util_package/Arrays/3_fill/2/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/3_fill/2/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/2/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/3_fill/2/ArraysDemo/.project b/Later/Java_Util_package/Arrays/3_fill/2/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/2/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/3_fill/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/3_fill/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/3_fill/2/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/3_fill/2/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..73c1ca235 Binary files /dev/null and b/Later/Java_Util_package/Arrays/3_fill/2/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/3_fill/2/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/3_fill/2/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..4d5a1d3b7 Binary files /dev/null and b/Later/Java_Util_package/Arrays/3_fill/2/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/3_fill/2/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/3_fill/2/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..84605ff3d --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/2/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,40 @@ +import java.util.Arrays; + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + + short[] shortArray = new short[] { 2, 7, 9, 7, 8 }; + + System.out.println("Actual values: "); + printArrayDetails(shortArray); + + /* + * Assigns the specified short value to each element of the + * specified array of shorts. + * + * Parameters:a - the array to be filled + * + * val - the value to be stored in all elements of the array + */ + + short shortValue = 8; + Arrays.fill(shortArray, shortValue); + + System.out.println("\nNew values after using fill() method: "); + + printArrayDetails(shortArray); + + } + + private static void printArrayDetails(short[] shortArray) + { + for (short value : shortArray) + { + System.out.println("Value = " + value); + } + } + +} diff --git a/Later/Java_Util_package/Arrays/3_fill/2/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/3_fill/2/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..cf41fe340 --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/2/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,50 @@ +import java.util.Arrays; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + + short[] shortArray = new short[] { 2, 7, 9, 7, 8 }; + + System.out.println("Actual values: "); + printArrayDetails(shortArray); + + /* + * Assigns the specified short value to each element of the + * specified range of the specified array of shorts. The range + * to be filled extends from index fromIndex, inclusive, to + * index toIndex, exclusive. (If fromIndex==toIndex, the range + * to be filled is empty.) + * + * Parameters: + * + * a - the array to be filled + * + * fromIndex - the index of the first element (inclusive) to + * be filled with the specified value + * + * toIndex - the index of the last element (exclusive) to be + * filled with the specified value + * + * val - the value to be stored in all elements of the array + */ + + short shortValue = 1; + Arrays.fill(shortArray, 1, 3, shortValue); + + System.out.println("\nNew values after using fill() method: "); + + printArrayDetails(shortArray); + } + + private static void printArrayDetails(short[] shortArray) + { + for (short value : shortArray) + { + System.out.println("Value = " + value); + } + } + +} diff --git a/Later/Java_Util_package/Arrays/3_fill/3/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/3_fill/3/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/3/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/3_fill/3/ArraysDemo/.project b/Later/Java_Util_package/Arrays/3_fill/3/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/3/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/3_fill/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/3_fill/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/3_fill/3/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/3_fill/3/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..6e1fb84ac Binary files /dev/null and b/Later/Java_Util_package/Arrays/3_fill/3/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/3_fill/3/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/3_fill/3/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..e0c9f47f2 Binary files /dev/null and b/Later/Java_Util_package/Arrays/3_fill/3/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/3_fill/3/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/3_fill/3/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..b13cd2f60 --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/3/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,42 @@ +import java.util.Arrays; + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + + int[] intArray = new int[] { 2, 7, 9, 7, 8 }; + + System.out.println("Actual values: "); + printArrayDetails(intArray); + + /* + * Assigns the specified int value to each element of the + * specified array of ints. + * + * Parameters: + * + * a - the array to be filled + * + * val - the value to be stored in all elements of the array + */ + + int intValue = 8; + Arrays.fill(intArray, intValue); + + System.out.println("\nNew values after using fill() method: "); + + printArrayDetails(intArray); + + } + + private static void printArrayDetails(int[] intArray) + { + for (int value : intArray) + { + System.out.println("Value = " + value); + } + } + +} diff --git a/Later/Java_Util_package/Arrays/3_fill/3/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/3_fill/3/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..06d40ce1d --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/3/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,50 @@ +import java.util.Arrays; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + + int[] intArray = new int[] { 2, 7, 9, 7, 8 }; + + System.out.println("Actual values: "); + printArrayDetails(intArray); + + /* + * Assigns the specified int value to each element of the + * specified range of the specified array of ints. The range + * to be filled extends from index fromIndex, inclusive, to + * index toIndex, exclusive. (If fromIndex==toIndex, the range + * to be filled is empty.) + * + * Parameters: + * + * a - the array to be filled + * + * fromIndex - the index of the first element (inclusive) to + * be filled with the specified value + * + * toIndex - the index of the last element (exclusive) to be + * filled with the specified value + * + * val - the value to be stored in all elements of the array + */ + + int intValue = 1; + Arrays.fill(intArray, 1, 3, intValue); + + System.out.println("\nNew values after using fill() method: "); + + printArrayDetails(intArray); + } + + private static void printArrayDetails(int[] intArray) + { + for (int value : intArray) + { + System.out.println("Value = " + value); + } + } + +} diff --git a/Later/Java_Util_package/Arrays/3_fill/4/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/3_fill/4/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/4/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/3_fill/4/ArraysDemo/.project b/Later/Java_Util_package/Arrays/3_fill/4/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/4/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/3_fill/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/3_fill/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/3_fill/4/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/3_fill/4/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..28c7e97f9 Binary files /dev/null and b/Later/Java_Util_package/Arrays/3_fill/4/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/3_fill/4/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/3_fill/4/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..63dfb80e1 Binary files /dev/null and b/Later/Java_Util_package/Arrays/3_fill/4/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/3_fill/4/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/3_fill/4/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..2b941d059 --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/4/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,42 @@ +import java.util.Arrays; + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + + long[] longArray = new long[] { 2, 7, 9, 1, 6 }; + + System.out.println("Actual values: "); + prlongArrayDetails(longArray); + + /* + * Assigns the specified long value to each element of the + * specified array of longs. + * + * Parameters: + * + * a - the array to be filled + * + * val - the value to be stored in all elements of the array + */ + + long longValue = 8; + Arrays.fill(longArray, longValue); + + System.out.println("\nNew values after using fill() method: "); + + prlongArrayDetails(longArray); + + } + + private static void prlongArrayDetails(long[] longArray) + { + for (long value : longArray) + { + System.out.println("Value = " + value); + } + } + +} diff --git a/Later/Java_Util_package/Arrays/3_fill/4/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/3_fill/4/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..eb9aeac1a --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/4/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,50 @@ +import java.util.Arrays; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + + long[] longArray = new long[] { 2, 7, 9, 1, 6 }; + + System.out.println("Actual values: "); + prlongArrayDetails(longArray); + + /* + * Assigns the specified long value to each element of the + * specified range of the specified array of longs. The range + * to be filled extends from index fromIndex, inclusive, to + * index toIndex, exclusive. (If fromIndex==toIndex, the range + * to be filled is empty.) + * + * Parameters: + * + * a - the array to be filled + * + * fromIndex - the index of the first element (inclusive) to + * be filled with the specified value + * + * toIndex - the index of the last element (exclusive) to be + * filled with the specified value + * + * val - the value to be stored in all elements of the array + */ + + long longValue = 8; + Arrays.fill(longArray, 1, 3, longValue); + + System.out.println("\nNew values after using fill() method: "); + + prlongArrayDetails(longArray); + } + + private static void prlongArrayDetails(long[] longArray) + { + for (long value : longArray) + { + System.out.println("Value = " + value); + } + } + +} diff --git a/Later/Java_Util_package/Arrays/3_fill/5/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/3_fill/5/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/5/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/3_fill/5/ArraysDemo/.project b/Later/Java_Util_package/Arrays/3_fill/5/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/5/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/3_fill/5/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/3_fill/5/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/5/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/3_fill/5/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/3_fill/5/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..8a7d2c361 Binary files /dev/null and b/Later/Java_Util_package/Arrays/3_fill/5/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/3_fill/5/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/3_fill/5/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..c6dca64e6 Binary files /dev/null and b/Later/Java_Util_package/Arrays/3_fill/5/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/3_fill/5/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/3_fill/5/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..5e5c8254c --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/5/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,42 @@ +import java.util.Arrays; + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + + float[] floatArray = new float[] { 2.1f, 7.2f, 9.4f, 1.4f, 6.5f }; + + System.out.println("Actual values: "); + prfloatArrayDetails(floatArray); + + /* + * Assigns the specified float value to each element of the + * specified array of floats. + * + * Parameters: + * + * a - the array to be filled + * + * val - the value to be stored in all elements of the array + */ + + float floatValue = 8.9f; + Arrays.fill(floatArray, floatValue); + + System.out.println("\nNew values after using fill() method: "); + + prfloatArrayDetails(floatArray); + + } + + private static void prfloatArrayDetails(float[] floatArray) + { + for (float value : floatArray) + { + System.out.println("Value = " + value); + } + } + +} diff --git a/Later/Java_Util_package/Arrays/3_fill/5/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/3_fill/5/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..49a4f289b --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/5/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,50 @@ +import java.util.Arrays; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + + float[] floatArray = new float[] { 2.1f, 7.2f, 9.4f, 1.4f, 6.5f }; + + System.out.println("Actual values: "); + prfloatArrayDetails(floatArray); + + /* + * Assigns the specified float value to each element of the + * specified range of the specified array of floats. The range + * to be filled extends from index fromIndex, inclusive, to + * index toIndex, exclusive. (If fromIndex==toIndex, the range + * to be filled is empty.) + * + * Parameters: + * + * a - the array to be filled + * + * fromIndex - the index of the first element (inclusive) to + * be filled with the specified value + * + * toIndex - the index of the last element (exclusive) to be + * filled with the specified value + * + * val - the value to be stored in all elements of the array + */ + + float floatValue = 8.9f; + Arrays.fill(floatArray, 1, 3, floatValue); + + System.out.println("\nNew values after using fill() method: "); + + prfloatArrayDetails(floatArray); + } + + private static void prfloatArrayDetails(float[] floatArray) + { + for (float value : floatArray) + { + System.out.println("Value = " + value); + } + } + +} diff --git a/Later/Java_Util_package/Arrays/3_fill/6/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/3_fill/6/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/6/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/3_fill/6/ArraysDemo/.project b/Later/Java_Util_package/Arrays/3_fill/6/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/6/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/3_fill/6/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/3_fill/6/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/6/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/3_fill/6/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/3_fill/6/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..b096db8c1 Binary files /dev/null and b/Later/Java_Util_package/Arrays/3_fill/6/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/3_fill/6/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/3_fill/6/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..114287df2 Binary files /dev/null and b/Later/Java_Util_package/Arrays/3_fill/6/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/3_fill/6/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/3_fill/6/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..6f9e45f00 --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/6/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,42 @@ +import java.util.Arrays; + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + + double[] doubleArray = new double[] { 2.1, 7.2, 9.4, 1.4, 6.5 }; + + System.out.println("Actual values: "); + prdoubleArrayDetails(doubleArray); + + /* + * Assigns the specified double value to each element of the + * specified array of doubles. + * + * Parameters: + * + * a - the array to be filled + * + * val - the value to be stored in all elements of the array + */ + + double doubleValue = 8.9; + Arrays.fill(doubleArray, doubleValue); + + System.out.println("\nNew values after using fill() method: "); + + prdoubleArrayDetails(doubleArray); + + } + + private static void prdoubleArrayDetails(double[] doubleArray) + { + for (double value : doubleArray) + { + System.out.println("Value = " + value); + } + } + +} diff --git a/Later/Java_Util_package/Arrays/3_fill/6/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/3_fill/6/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..42a84a5b0 --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/6/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,50 @@ +import java.util.Arrays; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + + double[] doubleArray = new double[] { 2.1, 7.2, 9.4, 1.4, 6.5 }; + + System.out.println("Actual values: "); + prdoubleArrayDetails(doubleArray); + + /* + * Assigns the specified double value to each element of the + * specified range of the specified array of doubles. The range + * to be filled extends from index fromIndex, inclusive, to + * index toIndex, exclusive. (If fromIndex==toIndex, the range + * to be filled is empty.) + * + * Parameters: + * + * a - the array to be filled + * + * fromIndex - the index of the first element (inclusive) to + * be filled with the specified value + * + * toIndex - the index of the last element (exclusive) to be + * filled with the specified value + * + * val - the value to be stored in all elements of the array + */ + + double doubleValue = 8.9; + Arrays.fill(doubleArray, 1, 3, doubleValue); + + System.out.println("\nNew values after using fill() method: "); + + prdoubleArrayDetails(doubleArray); + } + + private static void prdoubleArrayDetails(double[] doubleArray) + { + for (double value : doubleArray) + { + System.out.println("Value = " + value); + } + } + +} diff --git a/Later/Java_Util_package/Arrays/3_fill/7/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/3_fill/7/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/7/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/3_fill/7/ArraysDemo/.project b/Later/Java_Util_package/Arrays/3_fill/7/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/7/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/3_fill/7/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/3_fill/7/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/7/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/3_fill/7/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/3_fill/7/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..cb004b1f6 Binary files /dev/null and b/Later/Java_Util_package/Arrays/3_fill/7/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/3_fill/7/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/3_fill/7/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..d9b5d3bfd Binary files /dev/null and b/Later/Java_Util_package/Arrays/3_fill/7/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/3_fill/7/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/3_fill/7/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..deeb8a79c --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/7/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,42 @@ +import java.util.Arrays; + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + + Object[] objectArray = new Object[] { 2.1, 7.2, 9.4, 1.4, 6.5 }; + + System.out.println("Actual values: "); + prObjectArrayDetails(objectArray); + + /* + * Assigns the specified Object reference to each element of + * the specified array of Objects. + * + * Parameters: + * + * a - the array to be filled + * + * val - the value to be stored in all elements of the array + */ + + Object objectValue = 8.9; + Arrays.fill(objectArray, objectValue); + + System.out.println("\nNew values after using fill() method: "); + + prObjectArrayDetails(objectArray); + + } + + private static void prObjectArrayDetails(Object[] ObjectArray) + { + for (Object objectValue : ObjectArray) + { + System.out.println("objectValue = " + objectValue); + } + } + +} diff --git a/Later/Java_Util_package/Arrays/3_fill/7/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/3_fill/7/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..0878a5071 --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/7/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,49 @@ +import java.util.Arrays; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + + Object[] objectArray = new Object[] { 2.1, 7.2, 9.4, 1.4, 6.5 }; + + System.out.println("Actual values: "); + prObjectArrayDetails(objectArray); + + /* + * Assigns the specified Object reference to each element of + * the specified range of the specified array of Objects. The + * range to be filled extends from index fromIndex, inclusive, + * to index toIndex, exclusive. (If fromIndex==toIndex, the + * range to be filled is empty.) + * + * Parameters: + * + * a - the array to be filled + * + * fromIndex - the index of the first element (inclusive) to + * be filled with the specified value + * + * toIndex - the index of the last element (exclusive) to be + * filled with the specified value + * + * val - the value to be stored in all elements of the array + */ + + Object objectValue = 8.9; + Arrays.fill(objectArray, 1, 3, objectValue); + + System.out.println("\nNew values after using fill() method: "); + + prObjectArrayDetails(objectArray); + } + + private static void prObjectArrayDetails(Object[] ObjectArray) + { + for (Object objectValue : ObjectArray) + { + System.out.println("objectValue = " + objectValue); + } + } +} diff --git a/Later/Java_Util_package/Arrays/3_fill/8/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/3_fill/8/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/8/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/3_fill/8/ArraysDemo/.project b/Later/Java_Util_package/Arrays/3_fill/8/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/8/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/3_fill/8/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/3_fill/8/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/8/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/3_fill/8/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/3_fill/8/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..0fc872e83 Binary files /dev/null and b/Later/Java_Util_package/Arrays/3_fill/8/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/3_fill/8/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/3_fill/8/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..ac87b0beb Binary files /dev/null and b/Later/Java_Util_package/Arrays/3_fill/8/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/3_fill/8/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/3_fill/8/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..0a3065eda --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/8/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,42 @@ +import java.util.Arrays; + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + + char[] charArray = new char[] { 'a', 'b', 'c', 'd', 'e' }; + + System.out.println("Actual values: "); + printArrayDetails(charArray); + + /* + * Assigns the specified char value to each element of the + * specified array of chars. + * + * Parameters: + * + * a - the array to be filled + * + * val - the value to be stored in all elements of the array + */ + + char charValue = 'z'; + Arrays.fill(charArray, charValue); + + System.out.println("\nNew values after using fill() method: "); + + printArrayDetails(charArray); + + } + + private static void printArrayDetails(char[] charArray) + { + for (char charValue : charArray) + { + System.out.println("charValue = " + charValue); + } + } + +} diff --git a/Later/Java_Util_package/Arrays/3_fill/8/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/3_fill/8/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..18d8c2488 --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/8/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,50 @@ +import java.util.Arrays; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + + char[] charArray = new char[] { 'a', 'b', 'c', 'd', 'e' }; + + System.out.println("Actual values: "); + printArrayDetails(charArray); + + /* + * Assigns the specified char value to each element of the + * specified range of the specified array of chars. The range + * to be filled extends from index fromIndex, inclusive, to + * index toIndex, exclusive. (If fromIndex==toIndex, the range + * to be filled is empty.) + * + * Parameters: + * + * a - the array to be filled + * + * fromIndex - the index of the first element (inclusive) to + * be filled with the specified value + * + * toIndex - the index of the last element (exclusive) to be + * filled with the specified value + * + * val - the value to be stored in all elements of the array + */ + + char charValue = 'z'; + Arrays.fill(charArray, 1, 4, charValue); + + System.out.println("\nNew values after using fill() method: "); + + printArrayDetails(charArray); + + } + + private static void printArrayDetails(char[] charArray) + { + for (char charValue : charArray) + { + System.out.println("charValue = " + charValue); + } + } +} diff --git a/Later/Java_Util_package/Arrays/3_fill/9/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/3_fill/9/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/9/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/3_fill/9/ArraysDemo/.project b/Later/Java_Util_package/Arrays/3_fill/9/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/9/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/3_fill/9/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/3_fill/9/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/9/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/3_fill/9/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/3_fill/9/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..11a40e622 Binary files /dev/null and b/Later/Java_Util_package/Arrays/3_fill/9/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/3_fill/9/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/3_fill/9/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..dcc0917ef Binary files /dev/null and b/Later/Java_Util_package/Arrays/3_fill/9/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/3_fill/9/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/3_fill/9/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..da283dba6 --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/9/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,42 @@ +import java.util.Arrays; + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + + boolean[] booleanArray = new boolean[] { true, true, true, true, true }; + + System.out.println("Actual values: "); + printArrayDetails(booleanArray); + + /* + * Assigns the specified boolean value to each element of the + * specified array of booleans. + * + * Parameters: + * + * a - the array to be filled + * + * val - the value to be stored in all elements of the array + */ + + boolean booleanValue = false; + Arrays.fill(booleanArray, booleanValue); + + System.out.println("\nNew values after using fill() method: "); + + printArrayDetails(booleanArray); + + } + + private static void printArrayDetails(boolean[] booleanArray) + { + for (boolean booleanValue : booleanArray) + { + System.out.println("booleanValue = " + booleanValue); + } + } + +} diff --git a/Later/Java_Util_package/Arrays/3_fill/9/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/3_fill/9/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..9263c9308 --- /dev/null +++ b/Later/Java_Util_package/Arrays/3_fill/9/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,50 @@ +import java.util.Arrays; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + + boolean[] booleanArray = new boolean[] { true, true, true, true, true }; + + System.out.println("Actual values: "); + printArrayDetails(booleanArray); + + /* + * Assigns the specified boolean value to each element of the + * specified range of the specified array of booleans. The + * range to be filled extends from index fromIndex, inclusive, + * to index toIndex, exclusive. (If fromIndex==toIndex, the + * range to be filled is empty.) + * + * Parameters: + * + * a - the array to be filled + * + * fromIndex - the index of the first element (inclusive) to + * be filled with the specified value + * + * toIndex - the index of the last element (exclusive) to be + * filled with the specified value + * + * val - the value to be stored in all elements of the array + */ + + boolean booleanValue = false; + Arrays.fill(booleanArray, 1, 4, booleanValue); + + System.out.println("\nNew values after using fill() method: "); + + printArrayDetails(booleanArray); + + } + + private static void printArrayDetails(boolean[] booleanArray) + { + for (boolean booleanValue : booleanArray) + { + System.out.println("booleanValue = " + booleanValue); + } + } +} diff --git a/Later/Java_Util_package/Arrays/4_copyOf/1/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/4_copyOf/1/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/1/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/4_copyOf/1/ArraysDemo/.project b/Later/Java_Util_package/Arrays/4_copyOf/1/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/1/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/4_copyOf/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/4_copyOf/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/4_copyOf/1/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/4_copyOf/1/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..d9f23c69e Binary files /dev/null and b/Later/Java_Util_package/Arrays/4_copyOf/1/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/4_copyOf/1/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/4_copyOf/1/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..dcc0917ef Binary files /dev/null and b/Later/Java_Util_package/Arrays/4_copyOf/1/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/4_copyOf/1/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/4_copyOf/1/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..30e96ba1d --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/1/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,55 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + byte[] byteArray1 = new byte[] { 3, 5, 2 }; + + System.out.println("Printing byteArray1:"); + printArrayDetails(byteArray1); + + /* + * Copies the specified array, truncating or padding with + * zeros (if necessary) so the copy has the specified length. + * + * Parameters: + * + * original - the array to be copied + * + * newLength - the length of the copy to be returned + * + * Returns: + * + * a copy of the original array, truncated or padded with + * zeros to obtain the specified length + */ + + byte[] byteArray2 = Arrays.copyOf(byteArray1, 3); + + System.out.println("\nPrinting byteArray2:"); + printArrayDetails(byteArray2); + + } + + private static void printArrayDetails(byte[] byteArray) + { + for (byte byteValue : byteArray) + { + System.out.println("byteValue = " + byteValue); + } + } + + private static void prlongArrayDetails(long[] longArray) + { + int i = 0; + for (long longValue : longArray) + { + System.out.println("longArray["+ i +"] = " + longValue); + ++i; + } + } + +} diff --git a/Later/Java_Util_package/Arrays/4_copyOf/10/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/4_copyOf/10/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/10/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/4_copyOf/10/ArraysDemo/.project b/Later/Java_Util_package/Arrays/4_copyOf/10/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/10/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/4_copyOf/10/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/4_copyOf/10/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/10/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/4_copyOf/10/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/4_copyOf/10/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..194d406bb Binary files /dev/null and b/Later/Java_Util_package/Arrays/4_copyOf/10/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/4_copyOf/10/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/4_copyOf/10/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..9e452b080 --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/10/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,57 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + Integer[] integerArray = new Integer[] { 2, 4, 6 }; + + System.out.println("Printing integerArray:"); + int i = 0; + for (Integer integerValue : integerArray) + { + System.out.println("integerArray[" + i + "] = " + integerValue); + ++i; + } + + /* + * public static T[] copyOf(U[] original, int newLength, + * Class newType) + * + * Copies the specified array, truncating or padding with + * zeros (if necessary) so the copy has the specified length. + * + * Type Parameters: + * + * U - the class of the objects in the original array + * T - the class of the objects in the returned array + * + * Parameters: + * + * original - the array to be copied + * + * newLength - the length of the copy to be returned + * + * newType - the class of the copy to be returned + * + * Returns: + * + * a copy of the original array, truncated or padded with + * zeros to obtain the specified length + */ + + Number[] numberArray = Arrays.copyOf(integerArray, 3, Number[].class); + + System.out.println("\nPrinting doubleArray:"); + int j = 0; + for (Number numberValue : numberArray) + { + System.out.println("numberArray[" + j + "] = " + numberValue); + ++j; + } + + } + +} diff --git a/Later/Java_Util_package/Arrays/4_copyOf/2/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/4_copyOf/2/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/2/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/4_copyOf/2/ArraysDemo/.project b/Later/Java_Util_package/Arrays/4_copyOf/2/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/2/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/4_copyOf/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/4_copyOf/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/4_copyOf/2/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/4_copyOf/2/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..a1228d6f3 Binary files /dev/null and b/Later/Java_Util_package/Arrays/4_copyOf/2/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/4_copyOf/2/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/4_copyOf/2/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..6dcfa9ff2 --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/2/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,55 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + short[] shortArray1 = new short[] { 3, 5, 2 }; + + System.out.println("Printing shortArray1:"); + printArrayDetails(shortArray1); + + /* + * Copies the specified array, truncating or padding with + * zeros (if necessary) so the copy has the specified length. + * + * Parameters: + * + * original - the array to be copied + * + * newLength - the length of the copy to be returned + * + * Returns: + * + * a copy of the original array, truncated or padded with + * zeros to obtain the specified length + */ + + short[] shortArray2 = Arrays.copyOf(shortArray1, 3); + + System.out.println("\nPrinting shortArray2:"); + printArrayDetails(shortArray2); + + } + + private static void printArrayDetails(short[] shortArray) + { + for (short shortValue : shortArray) + { + System.out.println("shortValue = " + shortValue); + } + } + + private static void prlongArrayDetails(long[] longArray) + { + int i = 0; + for (long longValue : longArray) + { + System.out.println("longArray["+ i +"] = " + longValue); + ++i; + } + } + +} diff --git a/Later/Java_Util_package/Arrays/4_copyOf/3/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/4_copyOf/3/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/3/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/4_copyOf/3/ArraysDemo/.project b/Later/Java_Util_package/Arrays/4_copyOf/3/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/3/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/4_copyOf/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/4_copyOf/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/4_copyOf/3/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/4_copyOf/3/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..7382a2dbd Binary files /dev/null and b/Later/Java_Util_package/Arrays/4_copyOf/3/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/4_copyOf/3/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/4_copyOf/3/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..557ee83f9 --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/3/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,55 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + int[] intArray1 = new int[] { 3, 5, 2 }; + + System.out.println("Printing intArray1:"); + printArrayDetails(intArray1); + + /* + * Copies the specified array, truncating or padding with + * zeros (if necessary) so the copy has the specified length. + * + * Parameters: + * + * original - the array to be copied + * + * newLength - the length of the copy to be returned + * + * Returns: + * + * a copy of the original array, truncated or padded with + * zeros to obtain the specified length + */ + + int[] intArray2 = Arrays.copyOf(intArray1, 3); + + System.out.println("\nPrinting intArray2:"); + printArrayDetails(intArray2); + + } + + private static void printArrayDetails(int[] intArray) + { + for (int intValue : intArray) + { + System.out.println("intValue = " + intValue); + } + } + + private static void prlongArrayDetails(long[] longArray) + { + int i = 0; + for (long longValue : longArray) + { + System.out.println("longArray["+ i +"] = " + longValue); + ++i; + } + } + +} diff --git a/Later/Java_Util_package/Arrays/4_copyOf/4/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/4_copyOf/4/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/4/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/4_copyOf/4/ArraysDemo/.project b/Later/Java_Util_package/Arrays/4_copyOf/4/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/4/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/4_copyOf/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/4_copyOf/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/4_copyOf/4/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/4_copyOf/4/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..51436d734 Binary files /dev/null and b/Later/Java_Util_package/Arrays/4_copyOf/4/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/4_copyOf/4/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/4_copyOf/4/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..e991a279a --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/4/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,47 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + long[] longArray1 = new long[] { 3, 5, 2 }; + + System.out.println("Prlonging longArray1:"); + prlongArrayDetails(longArray1); + + /* + * Copies the specified array, truncating or padding with + * zeros (if necessary) so the copy has the specified length. + * + * Parameters: + * + * original - the array to be copied + * + * newLength - the length of the copy to be returned + * + * Returns: + * + * a copy of the original array, truncated or padded with + * zeros to obtain the specified length + */ + + long[] longArray2 = Arrays.copyOf(longArray1, 3); + + System.out.println("\nPrlonging longArray2:"); + prlongArrayDetails(longArray2); + + } + + private static void prlongArrayDetails(long[] longArray) + { + int i = 0; + for (long longValue : longArray) + { + System.out.println("longArray["+ i +"] = " + longValue); + ++i; + } + } + +} diff --git a/Later/Java_Util_package/Arrays/4_copyOf/5/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/4_copyOf/5/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/5/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/4_copyOf/5/ArraysDemo/.project b/Later/Java_Util_package/Arrays/4_copyOf/5/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/5/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/4_copyOf/5/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/4_copyOf/5/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/5/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/4_copyOf/5/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/4_copyOf/5/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..bd9645cad Binary files /dev/null and b/Later/Java_Util_package/Arrays/4_copyOf/5/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/4_copyOf/5/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/4_copyOf/5/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..e2ff46fd2 --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/5/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,47 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + float[] floatArray1 = new float[] { 3.2f, 5.5f, 2.4f }; + + System.out.println("Printing floatArray1:"); + printArrayDetails(floatArray1); + + /* + * Copies the specified array, truncating or padding with + * zeros (if necessary) so the copy has the specified length. + * + * Parameters: + * + * original - the array to be copied + * + * newLength - the length of the copy to be returned + * + * Returns: + * + * a copy of the original array, truncated or padded with + * zeros to obtain the specified length + */ + + float[] floatArray2 = Arrays.copyOf(floatArray1, 3); + + System.out.println("\nPrinting floatArray2:"); + printArrayDetails(floatArray2); + + } + + private static void printArrayDetails(float[] floatArray) + { + int i = 0; + for (float floatValue : floatArray) + { + System.out.println("floatArray["+ i +"] = " + floatValue); + ++i; + } + } + +} diff --git a/Later/Java_Util_package/Arrays/4_copyOf/6/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/4_copyOf/6/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/6/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/4_copyOf/6/ArraysDemo/.project b/Later/Java_Util_package/Arrays/4_copyOf/6/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/6/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/4_copyOf/6/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/4_copyOf/6/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/6/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/4_copyOf/6/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/4_copyOf/6/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..7dd1d6eec Binary files /dev/null and b/Later/Java_Util_package/Arrays/4_copyOf/6/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/4_copyOf/6/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/4_copyOf/6/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..7e771c1dd --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/6/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,47 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + double[] doubleArray1 = new double[] { 3.2, 5.5, 2.4 }; + + System.out.println("Printing doubleArray1:"); + printArrayDetails(doubleArray1); + + /* + * Copies the specified array, truncating or padding with + * zeros (if necessary) so the copy has the specified length. + * + * Parameters: + * + * original - the array to be copied + * + * newLength - the length of the copy to be returned + * + * Returns: + * + * a copy of the original array, truncated or padded with + * zeros to obtain the specified length + */ + + double[] doubleArray2 = Arrays.copyOf(doubleArray1, 3); + + System.out.println("\nPrinting doubleArray2:"); + printArrayDetails(doubleArray2); + + } + + private static void printArrayDetails(double[] doubleArray) + { + int i = 0; + for (double doubleValue : doubleArray) + { + System.out.println("doubleArray["+ i +"] = " + doubleValue); + ++i; + } + } + +} diff --git a/Later/Java_Util_package/Arrays/4_copyOf/7/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/4_copyOf/7/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/7/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/4_copyOf/7/ArraysDemo/.project b/Later/Java_Util_package/Arrays/4_copyOf/7/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/7/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/4_copyOf/7/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/4_copyOf/7/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/7/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/4_copyOf/7/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/4_copyOf/7/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..68fd09333 Binary files /dev/null and b/Later/Java_Util_package/Arrays/4_copyOf/7/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/4_copyOf/7/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/4_copyOf/7/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..bc76f0004 --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/7/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,47 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + char[] charArray1 = new char[] {'a', 'v', 'g'}; + + System.out.println("Printing charArray1:"); + printArrayDetails(charArray1); + + /* + * Copies the specified array, truncating or padding with + * zeros (if necessary) so the copy has the specified length. + * + * Parameters: + * + * original - the array to be copied + * + * newLength - the length of the copy to be returned + * + * Returns: + * + * a copy of the original array, truncated or padded with + * zeros to obtain the specified length + */ + + char[] charArray2 = Arrays.copyOf(charArray1, 3); + + System.out.println("\nPrinting charArray2:"); + printArrayDetails(charArray2); + + } + + private static void printArrayDetails(char[] charArray) + { + int i = 0; + for (char charValue : charArray) + { + System.out.println("char["+ i +"] = " + charValue); + ++i; + } + } + +} diff --git a/Later/Java_Util_package/Arrays/4_copyOf/8/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/4_copyOf/8/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/8/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/4_copyOf/8/ArraysDemo/.project b/Later/Java_Util_package/Arrays/4_copyOf/8/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/8/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/4_copyOf/8/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/4_copyOf/8/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/8/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/4_copyOf/8/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/4_copyOf/8/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..786e53053 Binary files /dev/null and b/Later/Java_Util_package/Arrays/4_copyOf/8/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/4_copyOf/8/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/4_copyOf/8/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..a492b6b5d --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/8/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,47 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + boolean[] booleanArray1 = new boolean[] { true, false, true }; + + System.out.println("Printing booleanArray1:"); + printArrayDetails(booleanArray1); + + /* + * Copies the specified array, truncating or padding with + * zeros (if necessary) so the copy has the specified length. + * + * Parameters: + * + * original - the array to be copied + * + * newLength - the length of the copy to be returned + * + * Returns: + * + * a copy of the original array, truncated or padded with + * zeros to obtain the specified length + */ + + boolean[] booleanArray2 = Arrays.copyOf(booleanArray1, 3); + + System.out.println("\nPrinting booleanArray2:"); + printArrayDetails(booleanArray2); + + } + + private static void printArrayDetails(boolean[] booleanArray) + { + int i = 0; + for (boolean booleanValue : booleanArray) + { + System.out.println("booleanArray[" + i + "] = " + booleanValue); + ++i; + } + } + +} diff --git a/Later/Java_Util_package/Arrays/4_copyOf/9/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/4_copyOf/9/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/9/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/4_copyOf/9/ArraysDemo/.project b/Later/Java_Util_package/Arrays/4_copyOf/9/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/9/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/4_copyOf/9/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/4_copyOf/9/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/9/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/4_copyOf/9/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/4_copyOf/9/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..6bed9443a Binary files /dev/null and b/Later/Java_Util_package/Arrays/4_copyOf/9/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/4_copyOf/9/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/4_copyOf/9/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..99cf0c248 --- /dev/null +++ b/Later/Java_Util_package/Arrays/4_copyOf/9/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,53 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + Integer[] integerArray1 = new Integer[] { 2, 4, 6 }; + + System.out.println("Printing integerArray1:"); + printArrayDetails(integerArray1); + + /* + * public static T[] copyOf(T[] original, int newLength) + * + * Copies the specified array, truncating or padding with + * zeros (if necessary) so the copy has the specified length. + * + * Type Parameters: + * + * T - the class of the objects in the array + * + * Parameters: + * + * original - the array to be copied + * + * newLength - the length of the copy to be returned + * + * Returns: + * + * a copy of the original array, truncated or padded with + * zeros to obtain the specified length + */ + + Integer[] integerArray2 = Arrays.copyOf(integerArray1, 3); + + System.out.println("\nPrinting integerArray2:"); + printArrayDetails(integerArray2); + + } + + private static void printArrayDetails(Integer[] integerArray) + { + int i = 0; + for (Integer integerValue : integerArray) + { + System.out.println("integerArray[" + i + "] = " + integerValue); + ++i; + } + } + +} diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/1/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/5_copyOfRange/1/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/1/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/1/ArraysDemo/.project b/Later/Java_Util_package/Arrays/5_copyOfRange/1/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/1/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/5_copyOfRange/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/1/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/5_copyOfRange/1/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..86d459459 Binary files /dev/null and b/Later/Java_Util_package/Arrays/5_copyOfRange/1/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/1/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/5_copyOfRange/1/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..7510be138 --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/1/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,52 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + byte[] byteArray1 = new byte[] { 5, 10, 15 }; + + System.out.println("Printing byteArray1:"); + printArrayDetails(byteArray1); + + /* + * Copies the specified range of the specified array into a + * new array. + * + * Parameters: + * + * original - the array from which a range is to be copied + * + * from - the initial index of the range to be copied, + * inclusive + * + * to - the final index of the range to be copied, exclusive. + * (This index may lie outside the array.) + * + * Returns: + * + * a new array containing the specified range from the + * original array, truncated or padded with zeros to obtain + * the required length + */ + + byte[] byteArray2 = Arrays.copyOfRange(byteArray1, 1, 5); + + System.out.println("\nPrinting byteArray2:"); + printArrayDetails(byteArray2); + + } + + private static void printArrayDetails(byte[] byteArray) + { + int i = 0; + for (byte byteValue : byteArray) + { + System.out.println("byteArray[" + i + "] = " + byteValue); + ++i; + } + } + +} diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/10/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/5_copyOfRange/10/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/10/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/10/ArraysDemo/.project b/Later/Java_Util_package/Arrays/5_copyOfRange/10/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/10/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/10/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/5_copyOfRange/10/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/10/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/10/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/5_copyOfRange/10/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..c8af63875 Binary files /dev/null and b/Later/Java_Util_package/Arrays/5_copyOfRange/10/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/10/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/5_copyOfRange/10/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..8d0fb9ed8 --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/10/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,70 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + Integer[] integerArray1 = new Integer[] { 5, 10, 15 }; + + System.out.println("printing integerArray1:"); + printIntegerArrayDetails(integerArray1); + + /* + * copyOfRange public static T[] copyOfRange(U[] + * original, int from, int to, Class newType) + * + * + * Type Parameters: + * + * U - the class of the objects in the original array + * + * T - the class of the objects in the array + * + * Parameters: + * + * original - the array from which a range is to be copied + * + * from - the initial index of the range to be copied, + * inclusive + * + * to - the final index of the range to be copied, exclusive. + * (This index may lie outside the array.) + * + * newType - the class of the copy to be returned Returns: + * + * a new array containing the specified range from the + * original array, truncated or padded with nulls to obtain + * the required length + */ + + Number[] numberArray = Arrays.copyOfRange(integerArray1, 1, 5, + Number[].class); + + System.out.println("\nprinting numberArray:"); + printNumberArrayDetails(numberArray); + + } + + private static void printIntegerArrayDetails(Integer[] integerArray) + { + Integer i = 0; + for (Integer integerValue : integerArray) + { + System.out.println("integerArray[" + i + "] = " + integerValue); + ++i; + } + } + + private static void printNumberArrayDetails(Number[] numberArray) + { + Integer i = 0; + for (Number numberValue : numberArray) + { + System.out.println("numberArray[" + i + "] = " + numberValue); + ++i; + } + } + +} diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/2/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/5_copyOfRange/2/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/2/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/2/ArraysDemo/.project b/Later/Java_Util_package/Arrays/5_copyOfRange/2/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/2/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/5_copyOfRange/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/2/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/5_copyOfRange/2/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..bf13fd8e9 Binary files /dev/null and b/Later/Java_Util_package/Arrays/5_copyOfRange/2/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/2/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/5_copyOfRange/2/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..2067234c8 --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/2/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,52 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + short[] shortArray1 = new short[] { 5, 10, 15 }; + + System.out.println("Printing shortArray1:"); + printArrayDetails(shortArray1); + + /* + * Copies the specified range of the specified array into a + * new array. + * + * Parameters: + * + * original - the array from which a range is to be copied + * + * from - the initial index of the range to be copied, + * inclusive + * + * to - the final index of the range to be copied, exclusive. + * (This index may lie outside the array.) + * + * Returns: + * + * a new array containing the specified range from the + * original array, truncated or padded with zeros to obtain + * the required length + */ + + short[] shortArray2 = Arrays.copyOfRange(shortArray1, 1, 5); + + System.out.println("\nPrinting shortArray2:"); + printArrayDetails(shortArray2); + + } + + private static void printArrayDetails(short[] shortArray) + { + int i = 0; + for (short shortValue : shortArray) + { + System.out.println("shortArray[" + i + "] = " + shortValue); + ++i; + } + } + +} diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/3/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/5_copyOfRange/3/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/3/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/3/ArraysDemo/.project b/Later/Java_Util_package/Arrays/5_copyOfRange/3/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/3/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/5_copyOfRange/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/3/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/5_copyOfRange/3/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..656e1f97f Binary files /dev/null and b/Later/Java_Util_package/Arrays/5_copyOfRange/3/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/3/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/5_copyOfRange/3/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..12205527e --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/3/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,52 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + int[] intArray1 = new int[] { 5, 10, 15 }; + + System.out.println("Printing intArray1:"); + printArrayDetails(intArray1); + + /* + * Copies the specified range of the specified array into a + * new array. + * + * Parameters: + * + * original - the array from which a range is to be copied + * + * from - the initial index of the range to be copied, + * inclusive + * + * to - the final index of the range to be copied, exclusive. + * (This index may lie outside the array.) + * + * Returns: + * + * a new array containing the specified range from the + * original array, truncated or padded with zeros to obtain + * the required length + */ + + int[] intArray2 = Arrays.copyOfRange(intArray1, 1, 5); + + System.out.println("\nPrinting intArray2:"); + printArrayDetails(intArray2); + + } + + private static void printArrayDetails(int[] intArray) + { + int i = 0; + for (int intValue : intArray) + { + System.out.println("intArray[" + i + "] = " + intValue); + ++i; + } + } + +} diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/4/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/5_copyOfRange/4/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/4/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/4/ArraysDemo/.project b/Later/Java_Util_package/Arrays/5_copyOfRange/4/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/4/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/5_copyOfRange/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/4/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/5_copyOfRange/4/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..a32393bd8 Binary files /dev/null and b/Later/Java_Util_package/Arrays/5_copyOfRange/4/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/4/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/5_copyOfRange/4/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..504323a83 --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/4/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,52 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + long[] longArray1 = new long[] { 5, 10, 15 }; + + System.out.println("Printing longArray1:"); + printArrayDetails(longArray1); + + /* + * Copies the specified range of the specified array longo a + * new array. + * + * Parameters: + * + * original - the array from which a range is to be copied + * + * from - the initial index of the range to be copied, + * inclusive + * + * to - the final index of the range to be copied, exclusive. + * (This index may lie outside the array.) + * + * Returns: + * + * a new array containing the specified range from the + * original array, truncated or padded with zeros to obtain + * the required length + */ + + long[] longArray2 = Arrays.copyOfRange(longArray1, 1, 5); + + System.out.println("\nPrinting longArray2:"); + printArrayDetails(longArray2); + + } + + private static void printArrayDetails(long[] longArray) + { + long i = 0; + for (long longValue : longArray) + { + System.out.println("longArray[" + i + "] = " + longValue); + ++i; + } + } + +} diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/5/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/5_copyOfRange/5/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/5/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/5/ArraysDemo/.project b/Later/Java_Util_package/Arrays/5_copyOfRange/5/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/5/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/5/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/5_copyOfRange/5/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/5/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/5/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/5_copyOfRange/5/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..79aecc427 Binary files /dev/null and b/Later/Java_Util_package/Arrays/5_copyOfRange/5/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/5/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/5_copyOfRange/5/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..a33293dca --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/5/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,52 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + float[] floatArray1 = new float[] { 5.5f, 10.1f, 15.4f }; + + System.out.println("Printing floatArray1:"); + printArrayDetails(floatArray1); + + /* + * Copies the specified range of the specified array floato a + * new array. + * + * Parameters: + * + * original - the array from which a range is to be copied + * + * from - the initial index of the range to be copied, + * inclusive + * + * to - the final index of the range to be copied, exclusive. + * (This index may lie outside the array.) + * + * Returns: + * + * a new array containing the specified range from the + * original array, truncated or padded with zeros to obtain + * the required length + */ + + float[] floatArray2 = Arrays.copyOfRange(floatArray1, 1, 5); + + System.out.println("\nPrinting floatArray2:"); + printArrayDetails(floatArray2); + + } + + private static void printArrayDetails(float[] floatArray) + { + float i = 0; + for (float floatValue : floatArray) + { + System.out.println("floatArray[" + i + "] = " + floatValue); + ++i; + } + } + +} diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/6/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/5_copyOfRange/6/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/6/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/6/ArraysDemo/.project b/Later/Java_Util_package/Arrays/5_copyOfRange/6/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/6/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/6/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/5_copyOfRange/6/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/6/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/6/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/5_copyOfRange/6/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..20cb5b65c Binary files /dev/null and b/Later/Java_Util_package/Arrays/5_copyOfRange/6/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/6/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/5_copyOfRange/6/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..9424c2fb3 --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/6/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,52 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + double[] doubleArray1 = new double[] { 5.5, 10.1, 15.4 }; + + System.out.println("Printing doubleArray1:"); + printArrayDetails(doubleArray1); + + /* + * Copies the specified range of the specified array doubleo a + * new array. + * + * Parameters: + * + * original - the array from which a range is to be copied + * + * from - the initial index of the range to be copied, + * inclusive + * + * to - the final index of the range to be copied, exclusive. + * (This index may lie outside the array.) + * + * Returns: + * + * a new array containing the specified range from the + * original array, truncated or padded with zeros to obtain + * the required length + */ + + double[] doubleArray2 = Arrays.copyOfRange(doubleArray1, 1, 5); + + System.out.println("\nPrinting doubleArray2:"); + printArrayDetails(doubleArray2); + + } + + private static void printArrayDetails(double[] doubleArray) + { + double i = 0; + for (double doubleValue : doubleArray) + { + System.out.println("doubleArray[" + i + "] = " + doubleValue); + ++i; + } + } + +} diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/7/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/5_copyOfRange/7/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/7/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/7/ArraysDemo/.project b/Later/Java_Util_package/Arrays/5_copyOfRange/7/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/7/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/7/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/5_copyOfRange/7/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/7/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/7/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/5_copyOfRange/7/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..495c0e7a7 Binary files /dev/null and b/Later/Java_Util_package/Arrays/5_copyOfRange/7/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/7/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/5_copyOfRange/7/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..65c33a07d --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/7/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,52 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + char[] charArray1 = new char[] { 'a', 'b', 'c' }; + + System.out.println("Printing charArray1:"); + printArrayDetails(charArray1); + + /* + * Copies the specified range of the specified array charo a + * new array. + * + * Parameters: + * + * original - the array from which a range is to be copied + * + * from - the initial index of the range to be copied, + * inclusive + * + * to - the final index of the range to be copied, exclusive. + * (This index may lie outside the array.) + * + * Returns: + * + * a new array containing the specified range from the + * original array, truncated or padded with null characters to + * obtain the required length + */ + + char[] charArray2 = Arrays.copyOfRange(charArray1, 1, 5); + + System.out.println("\nPrinting charArray2:"); + printArrayDetails(charArray2); + + } + + private static void printArrayDetails(char[] charArray) + { + int i = 0; + for (char charValue : charArray) + { + System.out.println("charArray[" + i + "] = " + charValue); + ++i; + } + } + +} diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/8/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/5_copyOfRange/8/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/8/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/8/ArraysDemo/.project b/Later/Java_Util_package/Arrays/5_copyOfRange/8/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/8/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/8/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/5_copyOfRange/8/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/8/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/8/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/5_copyOfRange/8/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..44413aa86 Binary files /dev/null and b/Later/Java_Util_package/Arrays/5_copyOfRange/8/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/8/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/5_copyOfRange/8/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..88b0cc7d3 --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/8/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,52 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + boolean[] booleanArray1 = new boolean[] { true, true, true }; + + System.out.println("Printing booleanArray1:"); + printArrayDetails(booleanArray1); + + /* + * Copies the specified range of the specified array booleano + * a new array. + * + * Parameters: + * + * original - the array from which a range is to be copied + * + * from - the initial index of the range to be copied, + * inclusive + * + * to - the final index of the range to be copied, exclusive. + * (This index may lie outside the array.) + * + * Returns: + * + * a new array containing the specified range from the + * original array, truncated or padded with false elements to + * obtain the required length + */ + + boolean[] booleanArray2 = Arrays.copyOfRange(booleanArray1, 1, 5); + + System.out.println("\nPrinting booleanArray2:"); + printArrayDetails(booleanArray2); + + } + + private static void printArrayDetails(boolean[] booleanArray) + { + int i = 0; + for (boolean booleanValue : booleanArray) + { + System.out.println("booleanArray[" + i + "] = " + booleanValue); + ++i; + } + } + +} diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/9/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/5_copyOfRange/9/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/9/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/9/ArraysDemo/.project b/Later/Java_Util_package/Arrays/5_copyOfRange/9/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/9/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/9/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/5_copyOfRange/9/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/9/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/9/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/5_copyOfRange/9/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..5a59558d6 Binary files /dev/null and b/Later/Java_Util_package/Arrays/5_copyOfRange/9/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/5_copyOfRange/9/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/5_copyOfRange/9/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..05d1b98fa --- /dev/null +++ b/Later/Java_Util_package/Arrays/5_copyOfRange/9/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,56 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + Integer[] integerArray1 = new Integer[] { 5, 10, 15 }; + + System.out.println("printing IntegerArray1:"); + prIntegerArrayDetails(IntegerArray1); + + /* + * public static T[] copyOfRange(T[] original, int from, + * int to) + * + * Type Parameters: + * + * T - the class of the objects in the array + * + * Parameters: + * + * original - the array from which a range is to be copied + * + * from - the initial index of the range to be copied, + * inclusive + * + * to - the final index of the range to be copied, exclusive. + * (This index may lie outside the array.) + * + * Returns: + * + * a new array containing the specified range from the + * original array, truncated or padded with nulls to obtain + * the required length + */ + + Integer[] integerArray2 = Arrays.copyOfRange(IntegerArray1, 1, 5); + + System.out.println("\nprinting IntegerArray2:"); + prIntegerArrayDetails(IntegerArray2); + + } + + private static void prIntegerArrayDetails(Integer[] integerArray) + { + Integer i = 0; + for (Integer IntegerValue : IntegerArray) + { + System.out.println("IntegerArray[" + i + "] = " + IntegerValue); + ++i; + } + } + +} diff --git a/Later/Java_Util_package/Arrays/6_equals/1/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/6_equals/1/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/1/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/6_equals/1/ArraysDemo/.project b/Later/Java_Util_package/Arrays/6_equals/1/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/1/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/6_equals/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/6_equals/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/6_equals/1/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/6_equals/1/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..5bd6534ce Binary files /dev/null and b/Later/Java_Util_package/Arrays/6_equals/1/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/6_equals/1/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/6_equals/1/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..ae62a85bd --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/1/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,35 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + byte[] byteArray1 = new byte[] { 1, 2, 3, 4 }; + byte[] byteArray2 = new byte[] { 1, 2, 3, 4 }; + byte[] byteArray3 = new byte[] { 10, 11, 12, 13 }; + + /* + * Returns true if the two specified arrays of bytes are equal + * to one another. + * + * Parameters: + * + * a - one array to be tested for equality + * + * a2 - the other array to be tested for equality + * + * Returns: + * + * true if the two arrays are equal + */ + boolean isEqual = Arrays.equals(byteArray1, byteArray2); + System.out.println("is byteArray1 equal to byteArray2? = " + isEqual); + + isEqual = Arrays.equals(byteArray1, byteArray3); + System.out.println("is byteArray1 equal to byteArray3? = " + isEqual); + + } + +} diff --git a/Later/Java_Util_package/Arrays/6_equals/10/Arrays-deepEquals.pptx b/Later/Java_Util_package/Arrays/6_equals/10/Arrays-deepEquals.pptx new file mode 100644 index 000000000..89a7e8b00 Binary files /dev/null and b/Later/Java_Util_package/Arrays/6_equals/10/Arrays-deepEquals.pptx differ diff --git a/Later/Java_Util_package/Arrays/6_equals/10/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/6_equals/10/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/10/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/6_equals/10/ArraysDemo/.project b/Later/Java_Util_package/Arrays/6_equals/10/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/10/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/6_equals/10/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/6_equals/10/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/10/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/6_equals/10/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/6_equals/10/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..895f464a4 Binary files /dev/null and b/Later/Java_Util_package/Arrays/6_equals/10/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/6_equals/10/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/6_equals/10/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..63339ff2a --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/10/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,39 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + int a1[][] = { { 10, 20 }, { 40, 50 }, { 60, 70 } }; + + int a2[][] = { { 30, 20 }, { 10, 0 }, { 60, 80 } }; + + int a3[][] = { { 10, 20 }, { 40, 50 }, { 60, 70 } }; + + /* + * Returns true if the two specified arrays are deeply equal + * to one another. + * + * Parameters: + * + * a1 - one array to be tested for equality + * + * a2 - the other array to be tested for equality + * + * Returns: + * + * true if the two arrays are equal + */ + + System.out.println( + "Check if a1 is equal to a2 = " + Arrays.deepEquals(a1, a2)); + + System.out.println( + "Check if a2 is equal to a3 = " + Arrays.deepEquals(a2, a3)); + + System.out.println( + "Check if a1 is equal to a3 = " + Arrays.deepEquals(a1, a3)); + } + +} diff --git a/Later/Java_Util_package/Arrays/6_equals/11/Arrays-deepEquals_emp.pptx b/Later/Java_Util_package/Arrays/6_equals/11/Arrays-deepEquals_emp.pptx new file mode 100644 index 000000000..89a7e8b00 Binary files /dev/null and b/Later/Java_Util_package/Arrays/6_equals/11/Arrays-deepEquals_emp.pptx differ diff --git a/Later/Java_Util_package/Arrays/6_equals/11/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/6_equals/11/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/11/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/6_equals/11/ArraysDemo/.project b/Later/Java_Util_package/Arrays/6_equals/11/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/11/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/6_equals/11/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/6_equals/11/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/11/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/6_equals/11/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/6_equals/11/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..d32de303f Binary files /dev/null and b/Later/Java_Util_package/Arrays/6_equals/11/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/6_equals/11/ArraysDemo/bin/Employee.class b/Later/Java_Util_package/Arrays/6_equals/11/ArraysDemo/bin/Employee.class new file mode 100644 index 000000000..146dc1fce Binary files /dev/null and b/Later/Java_Util_package/Arrays/6_equals/11/ArraysDemo/bin/Employee.class differ diff --git a/Later/Java_Util_package/Arrays/6_equals/11/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/6_equals/11/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..dbbb92562 --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/11/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,46 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + Employee a1[][] = { + { new Employee(10, "Peter1"), new Employee(11, "Peter2") }, + { new Employee(12, "Peter3"), new Employee(13, "Peter4") } }; + + Employee a2[][] = { + { new Employee(10, "Peter1"), new Employee(11, "Peter2") }, + { new Employee(12, "Peter3"), new Employee(13, "Peter4") } }; + + Employee a3[][] = { + { new Employee(12, "Peter2"), new Employee(25, "Peter4") }, + { new Employee(15, "Peter3"), new Employee(30, "Peter1") } }; + + /* + * Returns true if the two specified arrays are deeply equal + * to one another. + * + * Parameters: + * + * a1 - one array to be tested for equality + * + * a2 - the other array to be tested for equality + * + * Returns: + * + * true if the two arrays are equal + */ + + System.out.println( + "Check if a1 is equal to a2 = " + Arrays.deepEquals(a1, a2)); + + System.out.println( + "Check if a2 is equal to a3 = " + Arrays.deepEquals(a2, a3)); + + System.out.println( + "Check if a1 is equal to a3 = " + Arrays.deepEquals(a1, a3)); + } + +} diff --git a/Later/Java_Util_package/Arrays/6_equals/11/ArraysDemo/src/Employee.java b/Later/Java_Util_package/Arrays/6_equals/11/ArraysDemo/src/Employee.java new file mode 100644 index 000000000..820498786 --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/11/ArraysDemo/src/Employee.java @@ -0,0 +1,41 @@ + +public class Employee +{ + private int id; + private String name; + + public Employee(int id, String name) + { + super(); + this.id = id; + this.name = name; + } + + public int getId() + { + return id; + } + + public void setId(int id) + { + this.id = id; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public boolean equals(Object obj) + { + // type casting obj to Employee + Employee employee = (Employee) obj; + return (this.id == employee.id && this.name.equals(employee.name)); + } + +} diff --git a/Later/Java_Util_package/Arrays/6_equals/2/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/6_equals/2/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/2/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/6_equals/2/ArraysDemo/.project b/Later/Java_Util_package/Arrays/6_equals/2/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/2/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/6_equals/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/6_equals/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/6_equals/2/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/6_equals/2/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..c16ef6684 Binary files /dev/null and b/Later/Java_Util_package/Arrays/6_equals/2/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/6_equals/2/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/6_equals/2/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..f31379ec5 --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/2/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,35 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + int[] intArray1 = new int[] { 1, 2, 3, 4 }; + int[] intArray2 = new int[] { 1, 2, 3, 4 }; + int[] intArray3 = new int[] { 10, 11, 12, 13 }; + + /* + * Returns true if the two specified arrays of ints are equal + * to one another. + * + * Parameters: + * + * a - one array to be tested for equality + * + * a2 - the other array to be tested for equality + * + * Returns: + * + * true if the two arrays are equal + */ + boolean isEqual = Arrays.equals(intArray1, intArray2); + System.out.println("is intArray1 equal to intArray2? = " + isEqual); + + isEqual = Arrays.equals(intArray1, intArray3); + System.out.println("is intArray1 equal to intArray3? = " + isEqual); + + } + +} diff --git a/Later/Java_Util_package/Arrays/6_equals/3/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/6_equals/3/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/3/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/6_equals/3/ArraysDemo/.project b/Later/Java_Util_package/Arrays/6_equals/3/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/3/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/6_equals/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/6_equals/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/6_equals/3/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/6_equals/3/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..ba7956e7f Binary files /dev/null and b/Later/Java_Util_package/Arrays/6_equals/3/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/6_equals/3/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/6_equals/3/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..994eda2df --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/3/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,35 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + long[] longArray1 = new long[] { 1, 2, 3, 4 }; + long[] longArray2 = new long[] { 1, 2, 3, 4 }; + long[] longArray3 = new long[] { 10, 11, 12, 13 }; + + /* + * Returns true if the two specified arrays of longs are equal + * to one another. + * + * Parameters: + * + * a - one array to be tested for equality + * + * a2 - the other array to be tested for equality + * + * Returns: + * + * true if the two arrays are equal + */ + boolean isEqual = Arrays.equals(longArray1, longArray2); + System.out.println("is longArray1 equal to longArray2? = " + isEqual); + + isEqual = Arrays.equals(longArray1, longArray3); + System.out.println("is longArray1 equal to longArray3? = " + isEqual); + + } + +} diff --git a/Later/Java_Util_package/Arrays/6_equals/4/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/6_equals/4/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/4/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/6_equals/4/ArraysDemo/.project b/Later/Java_Util_package/Arrays/6_equals/4/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/4/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/6_equals/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/6_equals/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/6_equals/4/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/6_equals/4/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..18b5570d6 Binary files /dev/null and b/Later/Java_Util_package/Arrays/6_equals/4/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/6_equals/4/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/6_equals/4/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..2cbb456d9 --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/4/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,35 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + short[] shortArray1 = new short[] { 1, 2, 3, 4 }; + short[] shortArray2 = new short[] { 1, 2, 3, 4 }; + short[] shortArray3 = new short[] { 10, 11, 12, 13 }; + + /* + * Returns true if the two specified arrays of shorts are equal + * to one another. + * + * Parameters: + * + * a - one array to be tested for equality + * + * a2 - the other array to be tested for equality + * + * Returns: + * + * true if the two arrays are equal + */ + boolean isEqual = Arrays.equals(shortArray1, shortArray2); + System.out.println("is shortArray1 equal to shortArray2? = " + isEqual); + + isEqual = Arrays.equals(shortArray1, shortArray3); + System.out.println("is shortArray1 equal to shortArray3? = " + isEqual); + + } + +} diff --git a/Later/Java_Util_package/Arrays/6_equals/5/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/6_equals/5/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/5/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/6_equals/5/ArraysDemo/.project b/Later/Java_Util_package/Arrays/6_equals/5/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/5/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/6_equals/5/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/6_equals/5/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/5/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/6_equals/5/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/6_equals/5/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..5ca3b013d Binary files /dev/null and b/Later/Java_Util_package/Arrays/6_equals/5/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/6_equals/5/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/6_equals/5/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..4819dff4f --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/5/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,37 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + float[] floatArray1 = new float[] { 1.1f, 2.2f, 3.3f, 4.4f }; + float[] floatArray2 = new float[] { 1.1f, 2.2f, 3.3f, 4.4f }; + float[] floatArray3 = new float[] { 10.1f, 11.1f, 12.2f, 13.3f }; + + /* + * Returns true if the two specified arrays of floats are + * equal to one another. + * + * Parameters: + * + * a - one array to be tested for equality + * + * a2 - the other array to be tested for equality + * + * Returns: + * + * true if the two arrays are equal + */ + boolean isEqual = Arrays.equals(floatArray1, floatArray2); + System.out + .println("is floatArray1 equal to floatArray2? = " + isEqual); + + isEqual = Arrays.equals(floatArray1, floatArray3); + System.out + .println("is floatArray1 equal to floatArray3? = " + isEqual); + + } + +} diff --git a/Later/Java_Util_package/Arrays/6_equals/6/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/6_equals/6/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/6/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/6_equals/6/ArraysDemo/.project b/Later/Java_Util_package/Arrays/6_equals/6/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/6/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/6_equals/6/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/6_equals/6/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/6/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/6_equals/6/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/6_equals/6/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..aee7ebe70 Binary files /dev/null and b/Later/Java_Util_package/Arrays/6_equals/6/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/6_equals/6/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/6_equals/6/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..2f7357a8d --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/6/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,37 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + double[] doubleArray1 = new double[] { 1.1, 2.2, 3.3, 4.4 }; + double[] doubleArray2 = new double[] { 1.1, 2.2, 3.3, 4.4 }; + double[] doubleArray3 = new double[] { 10.1, 11.1, 12.2, 13.3 }; + + /* + * Returns true if the two specified arrays of doubles are + * equal to one another. + * + * Parameters: + * + * a - one array to be tested for equality + * + * a2 - the other array to be tested for equality + * + * Returns: + * + * true if the two arrays are equal + */ + boolean isEqual = Arrays.equals(doubleArray1, doubleArray2); + System.out + .println("is doubleArray1 equal to doubleArray2? = " + isEqual); + + isEqual = Arrays.equals(doubleArray1, doubleArray3); + System.out + .println("is doubleArray1 equal to doubleArray3? = " + isEqual); + + } + +} diff --git a/Later/Java_Util_package/Arrays/6_equals/7/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/6_equals/7/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/7/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/6_equals/7/ArraysDemo/.project b/Later/Java_Util_package/Arrays/6_equals/7/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/7/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/6_equals/7/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/6_equals/7/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/7/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/6_equals/7/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/6_equals/7/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..bc0893340 Binary files /dev/null and b/Later/Java_Util_package/Arrays/6_equals/7/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/6_equals/7/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/6_equals/7/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..afaf3e1f0 --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/7/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,35 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + char[] charArray1 = new char[] { 'a', 'b', 'c', 'd' }; + char[] charArray2 = new char[] { 'a', 'b', 'c', 'd' }; + char[] charArray3 = new char[] { 'e', 'f', 'g', 'h' }; + + /* + * Returns true if the two specified arrays of chars are equal + * to one another. + * + * Parameters: + * + * a - one array to be tested for equality + * + * a2 - the other array to be tested for equality + * + * Returns: + * + * true if the two arrays are equal + */ + boolean isEqual = Arrays.equals(charArray1, charArray2); + System.out.println("is charArray1 equal to charArray2? = " + isEqual); + + isEqual = Arrays.equals(charArray1, charArray3); + System.out.println("is charArray1 equal to charArray3? = " + isEqual); + + } + +} diff --git a/Later/Java_Util_package/Arrays/6_equals/8/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/6_equals/8/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/8/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/6_equals/8/ArraysDemo/.project b/Later/Java_Util_package/Arrays/6_equals/8/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/8/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/6_equals/8/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/6_equals/8/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/8/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/6_equals/8/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/6_equals/8/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..600d4bc33 Binary files /dev/null and b/Later/Java_Util_package/Arrays/6_equals/8/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/6_equals/8/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/6_equals/8/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..33f6fc58a --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/8/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,37 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + boolean[] booleanArray1 = new boolean[] { true, true, true }; + boolean[] booleanArray2 = new boolean[] { true, true, true }; + boolean[] booleanArray3 = new boolean[] { false, false, false }; + + /* + * Returns true if the two specified arrays of booleans are + * equal to one another. + * + * Parameters: + * + * a - one array to be tested for equality + * + * a2 - the other array to be tested for equality + * + * Returns: + * + * true if the two arrays are equal + */ + boolean isEqual = Arrays.equals(booleanArray1, booleanArray2); + System.out.println( + "is booleanArray1 equal to booleanArray2? = " + isEqual); + + isEqual = Arrays.equals(booleanArray1, booleanArray3); + System.out.println( + "is booleanArray1 equal to booleanArray3? = " + isEqual); + + } + +} diff --git a/Later/Java_Util_package/Arrays/6_equals/9/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/6_equals/9/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/9/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/6_equals/9/ArraysDemo/.project b/Later/Java_Util_package/Arrays/6_equals/9/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/9/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/6_equals/9/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/6_equals/9/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/9/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/6_equals/9/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/6_equals/9/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..ffe7f3ca2 Binary files /dev/null and b/Later/Java_Util_package/Arrays/6_equals/9/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/6_equals/9/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/6_equals/9/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..bd7f5fa6a --- /dev/null +++ b/Later/Java_Util_package/Arrays/6_equals/9/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,39 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + + Integer[] IntegerArray1 = new Integer[] { 1, 2, 3 }; + Integer[] IntegerArray2 = new Integer[] { 1, 2, 3 }; + Integer[] IntegerArray3 = new Integer[] { 4, 5, 6 }; + + /* + * boolean java.util.Arrays.equals(Object[] a, Object[] a2) + * + * Returns true if the two specified arrays of Objects are + * equal to one another. + * + * Parameters: + * + * a - one array to be tested for equality + * + * a2 - the other array to be tested for equality + * + * Returns: + * + * true if the two arrays are equal + */ + boolean isEqual = Arrays.equals(IntegerArray1, IntegerArray2); + System.out.println( + "is IntegerArray1 equal to IntegerArray2? = " + isEqual); + + isEqual = Arrays.equals(IntegerArray1, IntegerArray3); + System.out.println( + "is IntegerArray1 equal to IntegerArray3? = " + isEqual); + + } + +} diff --git a/Later/Java_Util_package/Arrays/7_toString/1/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/7_toString/1/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/7_toString/1/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/7_toString/1/ArraysDemo/.project b/Later/Java_Util_package/Arrays/7_toString/1/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/7_toString/1/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/7_toString/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/7_toString/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/7_toString/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/7_toString/1/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/7_toString/1/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..6cfce146c Binary files /dev/null and b/Later/Java_Util_package/Arrays/7_toString/1/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/7_toString/1/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/7_toString/1/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..b92429d4b Binary files /dev/null and b/Later/Java_Util_package/Arrays/7_toString/1/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/7_toString/1/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/7_toString/1/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..0ef62a950 --- /dev/null +++ b/Later/Java_Util_package/Arrays/7_toString/1/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,26 @@ +import java.util.Arrays; + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + byte[] byteArray = new byte[] { 10, 15, 20 }; + + /* + * Returns a string representation of the contents of the + * specified array. + * + * Parameters: + * + * a - the array whose string representation to return + * + * Returns: + * + * a string representation of a + */ + String strByteArray = Arrays.toString(byteArray); + System.out.println(strByteArray); + } + +} diff --git a/Later/Java_Util_package/Arrays/7_toString/1/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/7_toString/1/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..4b32097b0 --- /dev/null +++ b/Later/Java_Util_package/Arrays/7_toString/1/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,26 @@ +import java.util.Arrays; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + short[] shortArray = new short[] { 101, 102, 103}; + + /* + * Returns a string representation of the contents of the + * specified array. + * + * Parameters: + * + * a - the array whose string representation to return + * + * Returns: + * + * a string representation of a + */ + String strShortArray = Arrays.toString(shortArray); + System.out.println(strShortArray); + } + +} diff --git a/Later/Java_Util_package/Arrays/7_toString/2/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/7_toString/2/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/7_toString/2/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/7_toString/2/ArraysDemo/.project b/Later/Java_Util_package/Arrays/7_toString/2/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/7_toString/2/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/7_toString/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/7_toString/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/7_toString/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/7_toString/2/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/7_toString/2/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..be6da182b Binary files /dev/null and b/Later/Java_Util_package/Arrays/7_toString/2/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/7_toString/2/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/7_toString/2/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..26e79875a Binary files /dev/null and b/Later/Java_Util_package/Arrays/7_toString/2/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/7_toString/2/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/7_toString/2/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..eca9a50a8 --- /dev/null +++ b/Later/Java_Util_package/Arrays/7_toString/2/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,26 @@ +import java.util.Arrays; + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + int[] intArray = new int[] { 10, 15, 20 }; + + /* + * Returns a string representation of the contents of the + * specified array. + * + * Parameters: + * + * a - the array whose string representation to return + * + * Returns: + * + * a string representation of a + */ + String strIntArray = Arrays.toString(intArray); + System.out.println(strIntArray); + } + +} diff --git a/Later/Java_Util_package/Arrays/7_toString/2/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/7_toString/2/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..9ffde32d0 --- /dev/null +++ b/Later/Java_Util_package/Arrays/7_toString/2/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,26 @@ +import java.util.Arrays; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + long[] longArray = new long[] { 101, 102, 103}; + + /* + * Returns a string representation of the contents of the + * specified array. + * + * Parameters: + * + * a - the array whose string representation to return + * + * Returns: + * + * a string representation of a + */ + String strLongArray = Arrays.toString(longArray); + System.out.println(strLongArray); + } + +} diff --git a/Later/Java_Util_package/Arrays/7_toString/3/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/7_toString/3/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/7_toString/3/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/7_toString/3/ArraysDemo/.project b/Later/Java_Util_package/Arrays/7_toString/3/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/7_toString/3/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/7_toString/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/7_toString/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/7_toString/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/7_toString/3/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/7_toString/3/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..23a745f92 Binary files /dev/null and b/Later/Java_Util_package/Arrays/7_toString/3/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/7_toString/3/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/7_toString/3/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..26e79875a Binary files /dev/null and b/Later/Java_Util_package/Arrays/7_toString/3/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/7_toString/3/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/7_toString/3/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..ad88c3df9 --- /dev/null +++ b/Later/Java_Util_package/Arrays/7_toString/3/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,26 @@ +import java.util.Arrays; + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + float[] floatArray = new float[] { 10.1f, 15.5f, 20.3f }; + + /* + * Returns a string representation of the contents of the + * specified array. + * + * Parameters: + * + * a - the array whose string representation to return + * + * Returns: + * + * a string representation of a + */ + String strFloatArray = Arrays.toString(floatArray); + System.out.println(strFloatArray); + } + +} diff --git a/Later/Java_Util_package/Arrays/7_toString/3/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/7_toString/3/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..a4daf01fb --- /dev/null +++ b/Later/Java_Util_package/Arrays/7_toString/3/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,26 @@ +import java.util.Arrays; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + double[] doubleArray = new double[] { 10.1, 15.5, 20.3 }; + + /* + * Returns a string representation of the contents of the + * specified array. + * + * Parameters: + * + * a - the array whose string representation to return + * + * Returns: + * + * a string representation of a + */ + String strDoubleArray = Arrays.toString(doubleArray); + System.out.println(strDoubleArray); + } + +} diff --git a/Later/Java_Util_package/Arrays/7_toString/4/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/7_toString/4/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/7_toString/4/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/7_toString/4/ArraysDemo/.project b/Later/Java_Util_package/Arrays/7_toString/4/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/7_toString/4/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/7_toString/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/7_toString/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/7_toString/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/7_toString/4/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/7_toString/4/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..e14b2d492 Binary files /dev/null and b/Later/Java_Util_package/Arrays/7_toString/4/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/7_toString/4/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/7_toString/4/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..deaa0f27e Binary files /dev/null and b/Later/Java_Util_package/Arrays/7_toString/4/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/7_toString/4/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/7_toString/4/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..1a958ed79 --- /dev/null +++ b/Later/Java_Util_package/Arrays/7_toString/4/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,26 @@ +import java.util.Arrays; + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + char[] charArray = new char[] { 'a', 'e', 'f' }; + + /* + * Returns a string representation of the contents of the + * specified array. + * + * Parameters: + * + * a - the array whose string representation to return + * + * Returns: + * + * a string representation of a + */ + String strCharArray = Arrays.toString(charArray); + System.out.println(strCharArray); + } + +} diff --git a/Later/Java_Util_package/Arrays/7_toString/4/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/7_toString/4/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..6b61daee6 --- /dev/null +++ b/Later/Java_Util_package/Arrays/7_toString/4/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,26 @@ +import java.util.Arrays; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + boolean[] booleanArray = new boolean[] { true, false, true }; + + /* + * Returns a string representation of the contents of the + * specified array. + * + * Parameters: + * + * a - the array whose string representation to return + * + * Returns: + * + * a string representation of a + */ + String strBooleanArray = Arrays.toString(booleanArray); + System.out.println(strBooleanArray); + } + +} diff --git a/Later/Java_Util_package/Arrays/7_toString/5/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/7_toString/5/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/7_toString/5/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/7_toString/5/ArraysDemo/.project b/Later/Java_Util_package/Arrays/7_toString/5/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/7_toString/5/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/7_toString/5/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/7_toString/5/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/7_toString/5/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/7_toString/5/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/7_toString/5/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..9e5b4a4cd Binary files /dev/null and b/Later/Java_Util_package/Arrays/7_toString/5/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/7_toString/5/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/7_toString/5/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..64537d6e1 --- /dev/null +++ b/Later/Java_Util_package/Arrays/7_toString/5/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,26 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + Integer[] IntegerArray = new Integer[] { 22, 33, 44 }; + + /* + * Returns a string representation of the contents of the + * specified array. + * + * Parameters: + * + * a - the array whose string representation to return + * + * Returns: + * + * a string representation of a + */ + String strIntegerArray = Arrays.toString(IntegerArray); + System.out.println(strIntegerArray); + } + +} diff --git a/Later/Java_Util_package/Arrays/7_toString/6/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/7_toString/6/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/7_toString/6/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/7_toString/6/ArraysDemo/.project b/Later/Java_Util_package/Arrays/7_toString/6/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/7_toString/6/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/7_toString/6/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/7_toString/6/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/7_toString/6/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/7_toString/6/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/7_toString/6/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..9e4da8897 Binary files /dev/null and b/Later/Java_Util_package/Arrays/7_toString/6/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/7_toString/6/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/7_toString/6/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..0dcf81990 --- /dev/null +++ b/Later/Java_Util_package/Arrays/7_toString/6/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,30 @@ +import java.util.Arrays; + +public class ArraysDemo +{ + + public static void main(String[] args) + { + String[][] multiDimensionalStrArray = { { "Hello ", " Peter" }, + { "how ", "are you." } }; + + /* + * Returns a string representation of the "deep contents" of + * the specified array. If the array contains other arrays as + * elements, the string representation contains their contents + * and so on. This method is designed for converting + * multidimensional arrays to strings. + * + * Parameters: + * + * a - the array whose string representation to return + * + * Returns: + * + * a string representation of a + */ + String strValue = Arrays.deepToString(multiDimensionalStrArray); + System.out.println(strValue); + } + +} diff --git a/Later/Java_Util_package/Arrays/8_hashcode/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/8_hashcode/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/8_hashcode/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/8_hashcode/ArraysDemo/.project b/Later/Java_Util_package/Arrays/8_hashcode/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/8_hashcode/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/8_hashcode/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/8_hashcode/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/8_hashcode/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/8_hashcode/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/8_hashcode/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..89d2ee294 Binary files /dev/null and b/Later/Java_Util_package/Arrays/8_hashcode/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/8_hashcode/ArraysDemo/src/ArraysDemo.java b/Later/Java_Util_package/Arrays/8_hashcode/ArraysDemo/src/ArraysDemo.java new file mode 100644 index 000000000..d9ad382b2 --- /dev/null +++ b/Later/Java_Util_package/Arrays/8_hashcode/ArraysDemo/src/ArraysDemo.java @@ -0,0 +1,23 @@ +public class ArraysDemo +{ + + public static void main(String[] args) + { + + int[] intArray = new int[] { 1, 15 }; + + /* + * Returns a hash code based on the contents of the specified + * array. + */ + int hashCodeValue = intArray.hashCode(); + System.out.println("intArray hashCodeValue = " + hashCodeValue); + + double[] doubleArray = new double[] { 90.1, 15.6 }; + hashCodeValue = doubleArray.hashCode(); + + System.out.println("doubleArray hashCodeValue = " + hashCodeValue); + + } + +} diff --git a/Later/Java_Util_package/Arrays/8_hashcode/Arrays_hashcode.pptx b/Later/Java_Util_package/Arrays/8_hashcode/Arrays_hashcode.pptx new file mode 100644 index 000000000..3c3c63604 Binary files /dev/null and b/Later/Java_Util_package/Arrays/8_hashcode/Arrays_hashcode.pptx differ diff --git a/Later/Java_Util_package/Arrays/9_stream/1/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/9_stream/1/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/9_stream/1/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/9_stream/1/ArraysDemo/.project b/Later/Java_Util_package/Arrays/9_stream/1/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/9_stream/1/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/9_stream/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/9_stream/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/9_stream/1/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/9_stream/1/ArraysDemo/bin/ArraysDemo.class b/Later/Java_Util_package/Arrays/9_stream/1/ArraysDemo/bin/ArraysDemo.class new file mode 100644 index 000000000..b5eaaa815 Binary files /dev/null and b/Later/Java_Util_package/Arrays/9_stream/1/ArraysDemo/bin/ArraysDemo.class differ diff --git a/Later/Java_Util_package/Arrays/9_stream/1/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/9_stream/1/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..894c1494d Binary files /dev/null and b/Later/Java_Util_package/Arrays/9_stream/1/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/9_stream/1/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/9_stream/1/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..b4d3c95d1 --- /dev/null +++ b/Later/Java_Util_package/Arrays/9_stream/1/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,28 @@ +import java.util.Arrays; +import java.util.stream.IntStream; + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + + int[] intArray = new int[] { 5, 15, 25, 35, 45 }; + + /* + * Returns a sequential IntStream with the specified array as + * its source. + * + * Parameters: + * + * array - the array, assumed to be unmodified during use + * + * Returns: + * + * an IntStream for the array + */ + IntStream intStream = Arrays.stream(intArray); + intStream.forEach(System.out::println); + } + +} diff --git a/Later/Java_Util_package/Arrays/9_stream/1/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/9_stream/1/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..4740d4e20 --- /dev/null +++ b/Later/Java_Util_package/Arrays/9_stream/1/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,33 @@ +import java.util.Arrays; +import java.util.stream.IntStream; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + + int[] intArray = new int[] { 5, 15, 25, 35, 45 }; + + /* + * Returns a sequential IntStream with the specified range of + * the specified array as its source. + * + * Parameters: + * + * array - the array, assumed to be unmodified during use + * + * startInclusive - the first index to cover, inclusive + * + * endExclusive - index immediately past the last index to + * cover + * + * Returns: + * + * an IntStream for the array range + */ + IntStream intStream = Arrays.stream(intArray, 1, 3); + intStream.forEach(System.out::println); + } + +} diff --git a/Later/Java_Util_package/Arrays/9_stream/2/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/9_stream/2/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/9_stream/2/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/9_stream/2/ArraysDemo/.project b/Later/Java_Util_package/Arrays/9_stream/2/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/9_stream/2/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/9_stream/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/9_stream/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/9_stream/2/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/9_stream/2/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/9_stream/2/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..93c718044 Binary files /dev/null and b/Later/Java_Util_package/Arrays/9_stream/2/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/9_stream/2/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/9_stream/2/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..6a1ae2ba2 Binary files /dev/null and b/Later/Java_Util_package/Arrays/9_stream/2/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/9_stream/2/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/9_stream/2/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..33ec8eb60 --- /dev/null +++ b/Later/Java_Util_package/Arrays/9_stream/2/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,28 @@ +import java.util.Arrays; +import java.util.stream.LongStream; + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + + long[] longArray = new long[] { 5, 15, 25, 35, 45 }; + + /* + * Returns a sequential longStream with the specified array as + * its source. + * + * Parameters: + * + * array - the array, assumed to be unmodified during use + * + * Returns: + * + * an longStream for the array + */ + LongStream longStream = Arrays.stream(longArray); + longStream.forEach(System.out::println); + } + +} diff --git a/Later/Java_Util_package/Arrays/9_stream/2/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/9_stream/2/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..aa51ad230 --- /dev/null +++ b/Later/Java_Util_package/Arrays/9_stream/2/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,33 @@ +import java.util.Arrays; +import java.util.stream.LongStream; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + + long[] longArray = new long[] { 5, 15, 25, 35, 45 }; + + /* + * Returns a sequential longStream with the specified range of + * the specified array as its source. + * + * Parameters: + * + * array - the array, assumed to be unmodified during use + * + * startInclusive - the first index to cover, inclusive + * + * endExclusive - index immediately past the last index to + * cover + * + * Returns: + * + * an longStream for the array range + */ + LongStream longStream = Arrays.stream(longArray, 1, 3); + longStream.forEach(System.out::println); + } + +} diff --git a/Later/Java_Util_package/Arrays/9_stream/3/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/9_stream/3/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/9_stream/3/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/9_stream/3/ArraysDemo/.project b/Later/Java_Util_package/Arrays/9_stream/3/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/9_stream/3/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/9_stream/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/9_stream/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/9_stream/3/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/9_stream/3/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/9_stream/3/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..97d6d4c0b Binary files /dev/null and b/Later/Java_Util_package/Arrays/9_stream/3/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/9_stream/3/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/9_stream/3/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..ea4517fdd Binary files /dev/null and b/Later/Java_Util_package/Arrays/9_stream/3/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/9_stream/3/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/9_stream/3/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..f618dc276 --- /dev/null +++ b/Later/Java_Util_package/Arrays/9_stream/3/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,28 @@ +import java.util.Arrays; +import java.util.stream.DoubleStream; + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + + double[] doubleArray = new double[] { 5.6, 15.5, 25.1, 35.3, 45.5 }; + + /* + * Returns a sequential doubleStream with the specified array as + * its source. + * + * Parameters: + * + * array - the array, assumed to be unmodified during use + * + * Returns: + * + * an doubleStream for the array + */ + DoubleStream doubleStream = Arrays.stream(doubleArray); + doubleStream.forEach(System.out::println); + } + +} diff --git a/Later/Java_Util_package/Arrays/9_stream/3/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/9_stream/3/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..c75b69dbf --- /dev/null +++ b/Later/Java_Util_package/Arrays/9_stream/3/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,33 @@ +import java.util.Arrays; +import java.util.stream.DoubleStream; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + + double[] doubleArray = new double[] { 5.6, 15.5, 25.1, 35.3, 45.5 }; + + /* + * Returns a sequential doubleStream with the specified range of + * the specified array as its source. + * + * Parameters: + * + * array - the array, assumed to be unmodified during use + * + * startInclusive - the first index to cover, inclusive + * + * endExclusive - index immediately past the last index to + * cover + * + * Returns: + * + * an doubleStream for the array range + */ + DoubleStream doubleStream = Arrays.stream(doubleArray, 1, 3); + doubleStream.forEach(System.out::println); + } + +} diff --git a/Later/Java_Util_package/Arrays/9_stream/4/ArraysDemo/.classpath b/Later/Java_Util_package/Arrays/9_stream/4/ArraysDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Arrays/9_stream/4/ArraysDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Arrays/9_stream/4/ArraysDemo/.project b/Later/Java_Util_package/Arrays/9_stream/4/ArraysDemo/.project new file mode 100644 index 000000000..697111422 --- /dev/null +++ b/Later/Java_Util_package/Arrays/9_stream/4/ArraysDemo/.project @@ -0,0 +1,17 @@ + + + ArraysDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Arrays/9_stream/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Arrays/9_stream/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Arrays/9_stream/4/ArraysDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Arrays/9_stream/4/ArraysDemo/bin/ArraysDemo1.class b/Later/Java_Util_package/Arrays/9_stream/4/ArraysDemo/bin/ArraysDemo1.class new file mode 100644 index 000000000..b10b3976c Binary files /dev/null and b/Later/Java_Util_package/Arrays/9_stream/4/ArraysDemo/bin/ArraysDemo1.class differ diff --git a/Later/Java_Util_package/Arrays/9_stream/4/ArraysDemo/bin/ArraysDemo2.class b/Later/Java_Util_package/Arrays/9_stream/4/ArraysDemo/bin/ArraysDemo2.class new file mode 100644 index 000000000..0b9c0748a Binary files /dev/null and b/Later/Java_Util_package/Arrays/9_stream/4/ArraysDemo/bin/ArraysDemo2.class differ diff --git a/Later/Java_Util_package/Arrays/9_stream/4/ArraysDemo/src/ArraysDemo1.java b/Later/Java_Util_package/Arrays/9_stream/4/ArraysDemo/src/ArraysDemo1.java new file mode 100644 index 000000000..6028cbd9c --- /dev/null +++ b/Later/Java_Util_package/Arrays/9_stream/4/ArraysDemo/src/ArraysDemo1.java @@ -0,0 +1,25 @@ +import java.util.Arrays; +import java.util.stream.Stream; + +public class ArraysDemo1 +{ + + public static void main(String[] args) + { + + Integer[] integerArray = new Integer[] { 5, 15, 25, 35, 45 }; + + copy + * Parameters: + * + * array - the array, assumed to be unmodified during use + * + * Returns: + * + * an IntegerStream for the array + */ + Stream stream = Arrays.stream(integerArray); + stream.forEach(System.out::println); + } + +} diff --git a/Later/Java_Util_package/Arrays/9_stream/4/ArraysDemo/src/ArraysDemo2.java b/Later/Java_Util_package/Arrays/9_stream/4/ArraysDemo/src/ArraysDemo2.java new file mode 100644 index 000000000..5e8f5e757 --- /dev/null +++ b/Later/Java_Util_package/Arrays/9_stream/4/ArraysDemo/src/ArraysDemo2.java @@ -0,0 +1,33 @@ +import java.util.Arrays; +import java.util.stream.Stream; + +public class ArraysDemo2 +{ + + public static void main(String[] args) + { + + Integer[] integerArray = new Integer[] { 5, 15, 25, 35, 45 }; + + /* + * Returns a sequential IntegerStream with the specified range of + * the specified array as its source. + * + * Parameters: + * + * array - the array, assumed to be unmodified during use + * + * startInclusive - the first index to cover, inclusive + * + * endExclusive - index immediately past the last index to + * cover + * + * Returns: + * + * an IntegerStream for the array range + */ + Stream stream = Arrays.stream(integerArray, 1, 3); + stream.forEach(System.out::println); + } + +} diff --git a/Later/Java_Util_package/EnumMap/1/EnumMap Intro.pptx b/Later/Java_Util_package/EnumMap/1/EnumMap Intro.pptx new file mode 100644 index 000000000..d153ef557 Binary files /dev/null and b/Later/Java_Util_package/EnumMap/1/EnumMap Intro.pptx differ diff --git a/Later/Java_Util_package/EnumMap/1/EnumMapDemo/.classpath b/Later/Java_Util_package/EnumMap/1/EnumMapDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/EnumMap/1/EnumMapDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/EnumMap/1/EnumMapDemo/.project b/Later/Java_Util_package/EnumMap/1/EnumMapDemo/.project new file mode 100644 index 000000000..615eddcb2 --- /dev/null +++ b/Later/Java_Util_package/EnumMap/1/EnumMapDemo/.project @@ -0,0 +1,17 @@ + + + EnumMapDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/EnumMap/1/EnumMapDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/EnumMap/1/EnumMapDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/EnumMap/1/EnumMapDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/EnumMap/1/EnumMapDemo/bin/EnumMapDemo$Month.class b/Later/Java_Util_package/EnumMap/1/EnumMapDemo/bin/EnumMapDemo$Month.class new file mode 100644 index 000000000..0d824f7cd Binary files /dev/null and b/Later/Java_Util_package/EnumMap/1/EnumMapDemo/bin/EnumMapDemo$Month.class differ diff --git a/Later/Java_Util_package/EnumMap/1/EnumMapDemo/bin/EnumMapDemo.class b/Later/Java_Util_package/EnumMap/1/EnumMapDemo/bin/EnumMapDemo.class new file mode 100644 index 000000000..1de0b92b3 Binary files /dev/null and b/Later/Java_Util_package/EnumMap/1/EnumMapDemo/bin/EnumMapDemo.class differ diff --git a/Later/Java_Util_package/EnumMap/1/EnumMapDemo/src/EnumMapDemo.java b/Later/Java_Util_package/EnumMap/1/EnumMapDemo/src/EnumMapDemo.java new file mode 100644 index 000000000..c07ffe3ea --- /dev/null +++ b/Later/Java_Util_package/EnumMap/1/EnumMapDemo/src/EnumMapDemo.java @@ -0,0 +1,38 @@ +import java.util.EnumMap; + +/** + * public EnumMap(Class keyType) + * + * Creates an empty enum map with the specified key type. + * + * Parameters: + * + * keyType - the class object of the key type for this enum map + * + */ + +public class EnumMapDemo +{ + + public enum Month + { + JAN, FEB, MAR, APR, MAY + }; + + public static void main(String[] args) + { + /* + * Creates an empty enum map with the specified key type. + */ + EnumMap enumMap = new EnumMap( + Month.class); + + enumMap.put(Month.JAN, "January month is cool"); + enumMap.put(Month.FEB, "February month is cool"); + enumMap.put(Month.MAR, "March month is less hot"); + enumMap.put(Month.MAY, "May month is hot"); + + System.out.println("enumMap = "+enumMap); + } + +} diff --git a/Later/Java_Util_package/EnumMap/10/EnumMapDemo/.classpath b/Later/Java_Util_package/EnumMap/10/EnumMapDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/EnumMap/10/EnumMapDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/EnumMap/10/EnumMapDemo/.project b/Later/Java_Util_package/EnumMap/10/EnumMapDemo/.project new file mode 100644 index 000000000..615eddcb2 --- /dev/null +++ b/Later/Java_Util_package/EnumMap/10/EnumMapDemo/.project @@ -0,0 +1,17 @@ + + + EnumMapDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/EnumMap/10/EnumMapDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/EnumMap/10/EnumMapDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/EnumMap/10/EnumMapDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/EnumMap/10/EnumMapDemo/bin/EnumMapDemo$Month.class b/Later/Java_Util_package/EnumMap/10/EnumMapDemo/bin/EnumMapDemo$Month.class new file mode 100644 index 000000000..6124882b1 Binary files /dev/null and b/Later/Java_Util_package/EnumMap/10/EnumMapDemo/bin/EnumMapDemo$Month.class differ diff --git a/Later/Java_Util_package/EnumMap/10/EnumMapDemo/bin/EnumMapDemo.class b/Later/Java_Util_package/EnumMap/10/EnumMapDemo/bin/EnumMapDemo.class new file mode 100644 index 000000000..1a9d70c76 Binary files /dev/null and b/Later/Java_Util_package/EnumMap/10/EnumMapDemo/bin/EnumMapDemo.class differ diff --git a/Later/Java_Util_package/EnumMap/10/EnumMapDemo/src/EnumMapDemo.java b/Later/Java_Util_package/EnumMap/10/EnumMapDemo/src/EnumMapDemo.java new file mode 100644 index 000000000..1f7aef84a --- /dev/null +++ b/Later/Java_Util_package/EnumMap/10/EnumMapDemo/src/EnumMapDemo.java @@ -0,0 +1,32 @@ +import java.util.Collection; +import java.util.EnumMap; + +public class EnumMapDemo +{ + + public enum Month + { + JAN, FEB, MAR, APR, MAY + }; + + public static void main(String[] args) + { + EnumMap enumMap = new EnumMap( + Month.class); + + enumMap.put(Month.JAN, "January month is cool"); + enumMap.put(Month.FEB, "February month is cool"); + enumMap.put(Month.MAR, "March month is less hot"); + enumMap.put(Month.MAY, "May month is hot"); + + System.out.println("Before remove, enumMap = " + enumMap); + + /* + * Returns:a collection view of the values contained in this + * map + */ + Collection values = enumMap.values(); + System.out.println(values); + } + +} diff --git a/Later/Java_Util_package/EnumMap/2/EnumMapDemo/.classpath b/Later/Java_Util_package/EnumMap/2/EnumMapDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/EnumMap/2/EnumMapDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/EnumMap/2/EnumMapDemo/.project b/Later/Java_Util_package/EnumMap/2/EnumMapDemo/.project new file mode 100644 index 000000000..615eddcb2 --- /dev/null +++ b/Later/Java_Util_package/EnumMap/2/EnumMapDemo/.project @@ -0,0 +1,17 @@ + + + EnumMapDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/EnumMap/2/EnumMapDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/EnumMap/2/EnumMapDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/EnumMap/2/EnumMapDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/EnumMap/2/EnumMapDemo/bin/EnumMapDemo$Month.class b/Later/Java_Util_package/EnumMap/2/EnumMapDemo/bin/EnumMapDemo$Month.class new file mode 100644 index 000000000..0d824f7cd Binary files /dev/null and b/Later/Java_Util_package/EnumMap/2/EnumMapDemo/bin/EnumMapDemo$Month.class differ diff --git a/Later/Java_Util_package/EnumMap/2/EnumMapDemo/bin/EnumMapDemo.class b/Later/Java_Util_package/EnumMap/2/EnumMapDemo/bin/EnumMapDemo.class new file mode 100644 index 000000000..3360e2a65 Binary files /dev/null and b/Later/Java_Util_package/EnumMap/2/EnumMapDemo/bin/EnumMapDemo.class differ diff --git a/Later/Java_Util_package/EnumMap/2/EnumMapDemo/src/EnumMapDemo.java b/Later/Java_Util_package/EnumMap/2/EnumMapDemo/src/EnumMapDemo.java new file mode 100644 index 000000000..7f76a7461 --- /dev/null +++ b/Later/Java_Util_package/EnumMap/2/EnumMapDemo/src/EnumMapDemo.java @@ -0,0 +1,42 @@ +import java.util.EnumMap; + +/** + * public int size() + * + * Returns the number of key-value mappings in this map + * + * Returns: + * + * the number of key-value mappings in this map + * + */ + +public class EnumMapDemo +{ + + public enum Month + { + JAN, FEB, MAR, APR, MAY + }; + + public static void main(String[] args) + { + EnumMap enumMap = new EnumMap( + Month.class); + + enumMap.put(Month.JAN, "January month is cool"); + enumMap.put(Month.FEB, "February month is cool"); + enumMap.put(Month.MAR, "March month is less hot"); + enumMap.put(Month.MAY, "May month is hot"); + + System.out.println("enumMap = " + enumMap); + + /* + * Returns the number of key-value mappings in this map. + */ + int size = enumMap.size(); + System.out.println("size = " + size); + + } + +} diff --git a/Later/Java_Util_package/EnumMap/3/EnumMapDemo/.classpath b/Later/Java_Util_package/EnumMap/3/EnumMapDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/EnumMap/3/EnumMapDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/EnumMap/3/EnumMapDemo/.project b/Later/Java_Util_package/EnumMap/3/EnumMapDemo/.project new file mode 100644 index 000000000..615eddcb2 --- /dev/null +++ b/Later/Java_Util_package/EnumMap/3/EnumMapDemo/.project @@ -0,0 +1,17 @@ + + + EnumMapDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/EnumMap/3/EnumMapDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/EnumMap/3/EnumMapDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/EnumMap/3/EnumMapDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/EnumMap/3/EnumMapDemo/bin/EnumMapDemo$Month.class b/Later/Java_Util_package/EnumMap/3/EnumMapDemo/bin/EnumMapDemo$Month.class new file mode 100644 index 000000000..aeb3fcc59 Binary files /dev/null and b/Later/Java_Util_package/EnumMap/3/EnumMapDemo/bin/EnumMapDemo$Month.class differ diff --git a/Later/Java_Util_package/EnumMap/3/EnumMapDemo/bin/EnumMapDemo.class b/Later/Java_Util_package/EnumMap/3/EnumMapDemo/bin/EnumMapDemo.class new file mode 100644 index 000000000..aa556d563 Binary files /dev/null and b/Later/Java_Util_package/EnumMap/3/EnumMapDemo/bin/EnumMapDemo.class differ diff --git a/Later/Java_Util_package/EnumMap/3/EnumMapDemo/src/EnumMapDemo.java b/Later/Java_Util_package/EnumMap/3/EnumMapDemo/src/EnumMapDemo.java new file mode 100644 index 000000000..99d926f20 --- /dev/null +++ b/Later/Java_Util_package/EnumMap/3/EnumMapDemo/src/EnumMapDemo.java @@ -0,0 +1,38 @@ +import java.util.EnumMap; + +/** + * public void clear() + * + * Removes all mappings from this map. + * + */ + +public class EnumMapDemo +{ + + public enum Month + { + JAN, FEB, MAR, APR, MAY + }; + + public static void main(String[] args) + { + EnumMap enumMap = new EnumMap( + Month.class); + + enumMap.put(Month.JAN, "January month is cool"); + enumMap.put(Month.FEB, "February month is cool"); + enumMap.put(Month.MAR, "March month is less hot"); + enumMap.put(Month.MAY, "May month is hot"); + + System.out.println("Before clear, enumMap = " + enumMap); + + /* + * Removes all mappings from this map. + */ + enumMap.clear(); + System.out.println("After clear, enumMap = " + enumMap); + + } + +} diff --git a/Later/Java_Util_package/EnumMap/4/EnumMapDemo/.classpath b/Later/Java_Util_package/EnumMap/4/EnumMapDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/EnumMap/4/EnumMapDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/EnumMap/4/EnumMapDemo/.project b/Later/Java_Util_package/EnumMap/4/EnumMapDemo/.project new file mode 100644 index 000000000..615eddcb2 --- /dev/null +++ b/Later/Java_Util_package/EnumMap/4/EnumMapDemo/.project @@ -0,0 +1,17 @@ + + + EnumMapDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/EnumMap/4/EnumMapDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/EnumMap/4/EnumMapDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/EnumMap/4/EnumMapDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/EnumMap/4/EnumMapDemo/bin/EnumMapDemo$Month.class b/Later/Java_Util_package/EnumMap/4/EnumMapDemo/bin/EnumMapDemo$Month.class new file mode 100644 index 000000000..e0eadb236 Binary files /dev/null and b/Later/Java_Util_package/EnumMap/4/EnumMapDemo/bin/EnumMapDemo$Month.class differ diff --git a/Later/Java_Util_package/EnumMap/4/EnumMapDemo/bin/EnumMapDemo.class b/Later/Java_Util_package/EnumMap/4/EnumMapDemo/bin/EnumMapDemo.class new file mode 100644 index 000000000..6689ad7a1 Binary files /dev/null and b/Later/Java_Util_package/EnumMap/4/EnumMapDemo/bin/EnumMapDemo.class differ diff --git a/Later/Java_Util_package/EnumMap/4/EnumMapDemo/src/EnumMapDemo.java b/Later/Java_Util_package/EnumMap/4/EnumMapDemo/src/EnumMapDemo.java new file mode 100644 index 000000000..752fa3fe4 --- /dev/null +++ b/Later/Java_Util_package/EnumMap/4/EnumMapDemo/src/EnumMapDemo.java @@ -0,0 +1,49 @@ +import java.util.EnumMap; + +public class EnumMapDemo +{ + + public enum Month + { + JAN, FEB, MAR, APR, MAY + }; + + public static void main(String[] args) + { + EnumMap enumMap = new EnumMap( + Month.class); + + enumMap.put(Month.JAN, "January month is cool"); + enumMap.put(Month.FEB, "February month is cool"); + enumMap.put(Month.MAR, "March month is less hot"); + enumMap.put(Month.MAY, "May month is hot"); + + System.out.println("enumMap = " + enumMap); + + /* + * Parameters: + * + * key - the key whose presence in this map is to be tested + * + * Returns true if this map contains a mapping for the + * specified key. + */ + boolean isKeyExists = enumMap.containsKey(Month.MAY); + System.out.println("isKeyExists = " + isKeyExists); + + /* + * Parameters: + * + * value - the value whose presence in this map is to be + * tested + * + * Returns true if this map maps one or more keys to the + * specified value. + */ + boolean isValueExists = enumMap + .containsValue("March month is less hot"); + System.out.println("isValueExists = " + isValueExists); + + } + +} diff --git a/Later/Java_Util_package/EnumMap/5/EnumMapDemo/.classpath b/Later/Java_Util_package/EnumMap/5/EnumMapDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/EnumMap/5/EnumMapDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/EnumMap/5/EnumMapDemo/.project b/Later/Java_Util_package/EnumMap/5/EnumMapDemo/.project new file mode 100644 index 000000000..615eddcb2 --- /dev/null +++ b/Later/Java_Util_package/EnumMap/5/EnumMapDemo/.project @@ -0,0 +1,17 @@ + + + EnumMapDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/EnumMap/5/EnumMapDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/EnumMap/5/EnumMapDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/EnumMap/5/EnumMapDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/EnumMap/5/EnumMapDemo/bin/EnumMapDemo$Month.class b/Later/Java_Util_package/EnumMap/5/EnumMapDemo/bin/EnumMapDemo$Month.class new file mode 100644 index 000000000..37df9bf14 Binary files /dev/null and b/Later/Java_Util_package/EnumMap/5/EnumMapDemo/bin/EnumMapDemo$Month.class differ diff --git a/Later/Java_Util_package/EnumMap/5/EnumMapDemo/bin/EnumMapDemo.class b/Later/Java_Util_package/EnumMap/5/EnumMapDemo/bin/EnumMapDemo.class new file mode 100644 index 000000000..43f0d51dd Binary files /dev/null and b/Later/Java_Util_package/EnumMap/5/EnumMapDemo/bin/EnumMapDemo.class differ diff --git a/Later/Java_Util_package/EnumMap/5/EnumMapDemo/src/EnumMapDemo.java b/Later/Java_Util_package/EnumMap/5/EnumMapDemo/src/EnumMapDemo.java new file mode 100644 index 000000000..7bed69f8c --- /dev/null +++ b/Later/Java_Util_package/EnumMap/5/EnumMapDemo/src/EnumMapDemo.java @@ -0,0 +1,34 @@ +import java.util.EnumMap; +import java.util.Map; +import java.util.Set; + +public class EnumMapDemo +{ + + public enum Month + { + JAN, FEB, MAR, APR, MAY + }; + + public static void main(String[] args) + { + EnumMap enumMap = new EnumMap( + Month.class); + + enumMap.put(Month.JAN, "January month is cool"); + enumMap.put(Month.FEB, "February month is cool"); + enumMap.put(Month.MAR, "March month is less hot"); + enumMap.put(Month.MAY, "May month is hot"); + + System.out.println("enumMap = " + enumMap); + + /* + * Returns: a set view of the mappings contained in this + * enummap + */ + Set> set = enumMap.entrySet(); + System.out.println("set = " + set); + + } + +} diff --git a/Later/Java_Util_package/EnumMap/6/EnumMapDemo/.classpath b/Later/Java_Util_package/EnumMap/6/EnumMapDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/EnumMap/6/EnumMapDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/EnumMap/6/EnumMapDemo/.project b/Later/Java_Util_package/EnumMap/6/EnumMapDemo/.project new file mode 100644 index 000000000..615eddcb2 --- /dev/null +++ b/Later/Java_Util_package/EnumMap/6/EnumMapDemo/.project @@ -0,0 +1,17 @@ + + + EnumMapDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/EnumMap/6/EnumMapDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/EnumMap/6/EnumMapDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/EnumMap/6/EnumMapDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/EnumMap/6/EnumMapDemo/bin/EnumMapDemo$Month.class b/Later/Java_Util_package/EnumMap/6/EnumMapDemo/bin/EnumMapDemo$Month.class new file mode 100644 index 000000000..e0eadb236 Binary files /dev/null and b/Later/Java_Util_package/EnumMap/6/EnumMapDemo/bin/EnumMapDemo$Month.class differ diff --git a/Later/Java_Util_package/EnumMap/6/EnumMapDemo/bin/EnumMapDemo.class b/Later/Java_Util_package/EnumMap/6/EnumMapDemo/bin/EnumMapDemo.class new file mode 100644 index 000000000..f547c563b Binary files /dev/null and b/Later/Java_Util_package/EnumMap/6/EnumMapDemo/bin/EnumMapDemo.class differ diff --git a/Later/Java_Util_package/EnumMap/6/EnumMapDemo/src/EnumMapDemo.java b/Later/Java_Util_package/EnumMap/6/EnumMapDemo/src/EnumMapDemo.java new file mode 100644 index 000000000..f09e8d069 --- /dev/null +++ b/Later/Java_Util_package/EnumMap/6/EnumMapDemo/src/EnumMapDemo.java @@ -0,0 +1,36 @@ +import java.util.EnumMap; + +public class EnumMapDemo +{ + + public enum Month + { + JAN, FEB, MAR, APR, MAY + }; + + public static void main(String[] args) + { + EnumMap enumMap = new EnumMap( + Month.class); + + enumMap.put(Month.JAN, "January month is cool"); + enumMap.put(Month.FEB, "February month is cool"); + enumMap.put(Month.MAR, "March month is less hot"); + enumMap.put(Month.MAY, "May month is hot"); + + System.out.println("enumMap = " + enumMap); + + /* + * Parameters: + * + * key - the key whose associated value is to be returned + * + * Returns: the value to which the specified key is mapped, or + * null if this map contains no mapping for the key + */ + String value = enumMap.get(Month.JAN); + System.out.println("value = " + value); + + } + +} diff --git a/Later/Java_Util_package/EnumMap/7/EnumMapDemo/.classpath b/Later/Java_Util_package/EnumMap/7/EnumMapDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/EnumMap/7/EnumMapDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/EnumMap/7/EnumMapDemo/.project b/Later/Java_Util_package/EnumMap/7/EnumMapDemo/.project new file mode 100644 index 000000000..615eddcb2 --- /dev/null +++ b/Later/Java_Util_package/EnumMap/7/EnumMapDemo/.project @@ -0,0 +1,17 @@ + + + EnumMapDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/EnumMap/7/EnumMapDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/EnumMap/7/EnumMapDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/EnumMap/7/EnumMapDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/EnumMap/7/EnumMapDemo/bin/EnumMapDemo$Month.class b/Later/Java_Util_package/EnumMap/7/EnumMapDemo/bin/EnumMapDemo$Month.class new file mode 100644 index 000000000..6124882b1 Binary files /dev/null and b/Later/Java_Util_package/EnumMap/7/EnumMapDemo/bin/EnumMapDemo$Month.class differ diff --git a/Later/Java_Util_package/EnumMap/7/EnumMapDemo/bin/EnumMapDemo.class b/Later/Java_Util_package/EnumMap/7/EnumMapDemo/bin/EnumMapDemo.class new file mode 100644 index 000000000..868e02f7c Binary files /dev/null and b/Later/Java_Util_package/EnumMap/7/EnumMapDemo/bin/EnumMapDemo.class differ diff --git a/Later/Java_Util_package/EnumMap/7/EnumMapDemo/src/EnumMapDemo.java b/Later/Java_Util_package/EnumMap/7/EnumMapDemo/src/EnumMapDemo.java new file mode 100644 index 000000000..bd2be87ab --- /dev/null +++ b/Later/Java_Util_package/EnumMap/7/EnumMapDemo/src/EnumMapDemo.java @@ -0,0 +1,32 @@ +import java.util.EnumMap; +import java.util.Set; + +public class EnumMapDemo +{ + + public enum Month + { + JAN, FEB, MAR, APR, MAY + }; + + public static void main(String[] args) + { + EnumMap enumMap = new EnumMap( + Month.class); + + enumMap.put(Month.JAN, "January month is cool"); + enumMap.put(Month.FEB, "February month is cool"); + enumMap.put(Month.MAR, "March month is less hot"); + enumMap.put(Month.MAY, "May month is hot"); + + System.out.println("enumMap = " + enumMap); + + /* + * Returns a Set view of the keys contained in this map. + */ + Set set = enumMap.keySet(); + System.out.println("set = " + set); + + } + +} diff --git a/Later/Java_Util_package/EnumMap/8/EnumMapDemo/.classpath b/Later/Java_Util_package/EnumMap/8/EnumMapDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/EnumMap/8/EnumMapDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/EnumMap/8/EnumMapDemo/.project b/Later/Java_Util_package/EnumMap/8/EnumMapDemo/.project new file mode 100644 index 000000000..615eddcb2 --- /dev/null +++ b/Later/Java_Util_package/EnumMap/8/EnumMapDemo/.project @@ -0,0 +1,17 @@ + + + EnumMapDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/EnumMap/8/EnumMapDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/EnumMap/8/EnumMapDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/EnumMap/8/EnumMapDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/EnumMap/8/EnumMapDemo/bin/EnumMapDemo$Month.class b/Later/Java_Util_package/EnumMap/8/EnumMapDemo/bin/EnumMapDemo$Month.class new file mode 100644 index 000000000..e0eadb236 Binary files /dev/null and b/Later/Java_Util_package/EnumMap/8/EnumMapDemo/bin/EnumMapDemo$Month.class differ diff --git a/Later/Java_Util_package/EnumMap/8/EnumMapDemo/bin/EnumMapDemo.class b/Later/Java_Util_package/EnumMap/8/EnumMapDemo/bin/EnumMapDemo.class new file mode 100644 index 000000000..03d5b7665 Binary files /dev/null and b/Later/Java_Util_package/EnumMap/8/EnumMapDemo/bin/EnumMapDemo.class differ diff --git a/Later/Java_Util_package/EnumMap/8/EnumMapDemo/src/EnumMapDemo.java b/Later/Java_Util_package/EnumMap/8/EnumMapDemo/src/EnumMapDemo.java new file mode 100644 index 000000000..b4e3a3728 --- /dev/null +++ b/Later/Java_Util_package/EnumMap/8/EnumMapDemo/src/EnumMapDemo.java @@ -0,0 +1,36 @@ +import java.util.EnumMap; + +public class EnumMapDemo +{ + + public enum Month + { + JAN, FEB, MAR, APR, MAY + }; + + public static void main(String[] args) + { + EnumMap enumMap1 = new EnumMap( + Month.class); + + enumMap1.put(Month.JAN, "January month is cool"); + enumMap1.put(Month.FEB, "February month is cool"); + enumMap1.put(Month.MAR, "March month is less hot"); + enumMap1.put(Month.MAY, "May month is hot"); + + System.out.println("enumMap1 = " + enumMap1); + + EnumMap enumMap2 = new EnumMap( + Month.class); + + /* + * Copies all of the mappings from the specified map to this + * map. These mappings will replace any mappings that this map + * had for any of the keys currently in the specified map. + */ + enumMap2.putAll(enumMap1); + System.out.println("\nenumMap2 = " + enumMap2); + + } + +} diff --git a/Later/Java_Util_package/EnumMap/9/EnumMapDemo/.classpath b/Later/Java_Util_package/EnumMap/9/EnumMapDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/EnumMap/9/EnumMapDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/EnumMap/9/EnumMapDemo/.project b/Later/Java_Util_package/EnumMap/9/EnumMapDemo/.project new file mode 100644 index 000000000..615eddcb2 --- /dev/null +++ b/Later/Java_Util_package/EnumMap/9/EnumMapDemo/.project @@ -0,0 +1,17 @@ + + + EnumMapDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/EnumMap/9/EnumMapDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/EnumMap/9/EnumMapDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/EnumMap/9/EnumMapDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/EnumMap/9/EnumMapDemo/bin/EnumMapDemo$Month.class b/Later/Java_Util_package/EnumMap/9/EnumMapDemo/bin/EnumMapDemo$Month.class new file mode 100644 index 000000000..e0eadb236 Binary files /dev/null and b/Later/Java_Util_package/EnumMap/9/EnumMapDemo/bin/EnumMapDemo$Month.class differ diff --git a/Later/Java_Util_package/EnumMap/9/EnumMapDemo/bin/EnumMapDemo.class b/Later/Java_Util_package/EnumMap/9/EnumMapDemo/bin/EnumMapDemo.class new file mode 100644 index 000000000..7b508816e Binary files /dev/null and b/Later/Java_Util_package/EnumMap/9/EnumMapDemo/bin/EnumMapDemo.class differ diff --git a/Later/Java_Util_package/EnumMap/9/EnumMapDemo/src/EnumMapDemo.java b/Later/Java_Util_package/EnumMap/9/EnumMapDemo/src/EnumMapDemo.java new file mode 100644 index 000000000..1c22937c5 --- /dev/null +++ b/Later/Java_Util_package/EnumMap/9/EnumMapDemo/src/EnumMapDemo.java @@ -0,0 +1,40 @@ +import java.util.EnumMap; + +public class EnumMapDemo +{ + + public enum Month + { + JAN, FEB, MAR, APR, MAY + }; + + public static void main(String[] args) + { + EnumMap enumMap = new EnumMap( + Month.class); + + enumMap.put(Month.JAN, "January month is cool"); + enumMap.put(Month.FEB, "February month is cool"); + enumMap.put(Month.MAR, "March month is less hot"); + enumMap.put(Month.MAY, "May month is hot"); + + System.out.println("Before remove, enumMap = " + enumMap); + + /* + * Removes the mapping for this key from this map if present. + * + * Parameters: + * + * key - the key whose mapping is to be removed from the map + * + * Returns: the previous value associated with specified key, + * or null if there was no entry for key. + */ + String valueOfTheRemovedKey = enumMap.remove(Month.MAR); + System.out.println("After remove, enumMap = " + enumMap); + System.out.println( + "valueOfTheRemovedKey = " + valueOfTheRemovedKey); + + } + +} diff --git a/Later/Java_Util_package/EnumSet/1/EnumSet Intro.pptx b/Later/Java_Util_package/EnumSet/1/EnumSet Intro.pptx new file mode 100644 index 000000000..d9fa83414 Binary files /dev/null and b/Later/Java_Util_package/EnumSet/1/EnumSet Intro.pptx differ diff --git a/Later/Java_Util_package/EnumSet/1/EnumSetDemo/.classpath b/Later/Java_Util_package/EnumSet/1/EnumSetDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/EnumSet/1/EnumSetDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/EnumSet/1/EnumSetDemo/.project b/Later/Java_Util_package/EnumSet/1/EnumSetDemo/.project new file mode 100644 index 000000000..035aa4e44 --- /dev/null +++ b/Later/Java_Util_package/EnumSet/1/EnumSetDemo/.project @@ -0,0 +1,17 @@ + + + EnumSetDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/EnumSet/1/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/EnumSet/1/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/EnumSet/1/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/EnumSet/1/EnumSetDemo/bin/EnumSetDemo$Month.class b/Later/Java_Util_package/EnumSet/1/EnumSetDemo/bin/EnumSetDemo$Month.class new file mode 100644 index 000000000..e23e32af0 Binary files /dev/null and b/Later/Java_Util_package/EnumSet/1/EnumSetDemo/bin/EnumSetDemo$Month.class differ diff --git a/Later/Java_Util_package/EnumSet/1/EnumSetDemo/bin/EnumSetDemo.class b/Later/Java_Util_package/EnumSet/1/EnumSetDemo/bin/EnumSetDemo.class new file mode 100644 index 000000000..ce7075db3 Binary files /dev/null and b/Later/Java_Util_package/EnumSet/1/EnumSetDemo/bin/EnumSetDemo.class differ diff --git a/Later/Java_Util_package/EnumSet/1/EnumSetDemo/src/EnumSetDemo.java b/Later/Java_Util_package/EnumSet/1/EnumSetDemo/src/EnumSetDemo.java new file mode 100644 index 000000000..a32eefd1b --- /dev/null +++ b/Later/Java_Util_package/EnumSet/1/EnumSetDemo/src/EnumSetDemo.java @@ -0,0 +1,48 @@ +import java.util.ArrayList; +import java.util.EnumSet; + +/** + * + * public static > EnumSet copyOf(Collection + * c) + * + * Creates an enum set initialized from the specified collection. + * + * Type Parameters: + * + * E - The class of the elements in the collection + * + * Parameters: + * + * c - the collection from which to initialize this enum set + * + * Returns: + * + * An enum set initialized from the given collection. + * + */ + +public class EnumSetDemo +{ + + public enum Month + { + JAN, FEB, MAR, APR, MAY + }; + + public static void main(String[] args) + { + + ArrayList list = new ArrayList(); + list.add(Month.JAN); + list.add(Month.FEB); + list.add(Month.MAR); + + /* + * Returns:An enum set initialized from the given collection. + */ + EnumSet enumSet = EnumSet.copyOf(list); + System.out.println("enumSet = " + enumSet); + } + +} diff --git a/Later/Java_Util_package/EnumSet/10/EnumSetDemo/.classpath b/Later/Java_Util_package/EnumSet/10/EnumSetDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/EnumSet/10/EnumSetDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/EnumSet/10/EnumSetDemo/.project b/Later/Java_Util_package/EnumSet/10/EnumSetDemo/.project new file mode 100644 index 000000000..035aa4e44 --- /dev/null +++ b/Later/Java_Util_package/EnumSet/10/EnumSetDemo/.project @@ -0,0 +1,17 @@ + + + EnumSetDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/EnumSet/10/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/EnumSet/10/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/EnumSet/10/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/EnumSet/10/EnumSetDemo/bin/EnumSetDemo$Month.class b/Later/Java_Util_package/EnumSet/10/EnumSetDemo/bin/EnumSetDemo$Month.class new file mode 100644 index 000000000..de66c6ee9 Binary files /dev/null and b/Later/Java_Util_package/EnumSet/10/EnumSetDemo/bin/EnumSetDemo$Month.class differ diff --git a/Later/Java_Util_package/EnumSet/10/EnumSetDemo/bin/EnumSetDemo.class b/Later/Java_Util_package/EnumSet/10/EnumSetDemo/bin/EnumSetDemo.class new file mode 100644 index 000000000..3dd88d7db Binary files /dev/null and b/Later/Java_Util_package/EnumSet/10/EnumSetDemo/bin/EnumSetDemo.class differ diff --git a/Later/Java_Util_package/EnumSet/10/EnumSetDemo/src/EnumSetDemo.java b/Later/Java_Util_package/EnumSet/10/EnumSetDemo/src/EnumSetDemo.java new file mode 100644 index 000000000..61cdc5b32 --- /dev/null +++ b/Later/Java_Util_package/EnumSet/10/EnumSetDemo/src/EnumSetDemo.java @@ -0,0 +1,45 @@ +import java.util.EnumSet; + +/** + * + * public static > EnumSet + * complementOf(EnumSet s) + * + * Creates an enum set with the same element type as the specified + * enum set, initially containing all the elements of this type that + * are not contained in the specified set. + * + * Type Parameters: E - The class of the elements in the enum set + * + * Parameters: + * + * s - the enum set from whose complement to initialize this enum set + * + * Returns: + * + * The complement of the specified set in this set + * + */ + +public class EnumSetDemo +{ + + public enum Month + { + JAN, FEB, MAR, APR, MAY + }; + + public static void main(String[] args) + { + EnumSet enumSet1 = EnumSet.of(Month.JAN); + System.out.println("enumSet1 = " + enumSet1); + + /* + * Create a enumSet2 which has all elements that enumSet1 + * doesn't have + */ + EnumSet enumSet2 = EnumSet.complementOf(enumSet1); + System.out.println("enumSet2 = " + enumSet2); + } + +} diff --git a/Later/Java_Util_package/EnumSet/11/EnumSetDemo/.classpath b/Later/Java_Util_package/EnumSet/11/EnumSetDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/EnumSet/11/EnumSetDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/EnumSet/11/EnumSetDemo/.project b/Later/Java_Util_package/EnumSet/11/EnumSetDemo/.project new file mode 100644 index 000000000..035aa4e44 --- /dev/null +++ b/Later/Java_Util_package/EnumSet/11/EnumSetDemo/.project @@ -0,0 +1,17 @@ + + + EnumSetDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/EnumSet/11/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/EnumSet/11/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/EnumSet/11/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/EnumSet/11/EnumSetDemo/bin/EnumSetDemo$Month.class b/Later/Java_Util_package/EnumSet/11/EnumSetDemo/bin/EnumSetDemo$Month.class new file mode 100644 index 000000000..de66c6ee9 Binary files /dev/null and b/Later/Java_Util_package/EnumSet/11/EnumSetDemo/bin/EnumSetDemo$Month.class differ diff --git a/Later/Java_Util_package/EnumSet/11/EnumSetDemo/bin/EnumSetDemo.class b/Later/Java_Util_package/EnumSet/11/EnumSetDemo/bin/EnumSetDemo.class new file mode 100644 index 000000000..fc1390d0a Binary files /dev/null and b/Later/Java_Util_package/EnumSet/11/EnumSetDemo/bin/EnumSetDemo.class differ diff --git a/Later/Java_Util_package/EnumSet/11/EnumSetDemo/src/EnumSetDemo.java b/Later/Java_Util_package/EnumSet/11/EnumSetDemo/src/EnumSetDemo.java new file mode 100644 index 000000000..939c152e7 --- /dev/null +++ b/Later/Java_Util_package/EnumSet/11/EnumSetDemo/src/EnumSetDemo.java @@ -0,0 +1,41 @@ +import java.util.EnumSet; + +/** + * public static > EnumSet noneOf(Class + * elementType) + * + * Creates an empty enum set with the specified element type. + * + * Type Parameters: + * + * E - The class of the elements in the set + * + * Parameters: + * + * elementType - the class object of the element type for this enum + * set + * + * Returns: + * + * An empty enum set of the specified type. + * + */ + +public class EnumSetDemo +{ + + public enum Month + { + JAN, FEB, MAR, APR, MAY + }; + + public static void main(String[] args) + { + /* + * Returns: An empty enum set of the specified type. + */ + EnumSet enumSet = EnumSet.noneOf(Month.class); + System.out.println("enumSet = " + enumSet); + } + +} diff --git a/Later/Java_Util_package/EnumSet/2/EnumSetDemo/.classpath b/Later/Java_Util_package/EnumSet/2/EnumSetDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/EnumSet/2/EnumSetDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/EnumSet/2/EnumSetDemo/.project b/Later/Java_Util_package/EnumSet/2/EnumSetDemo/.project new file mode 100644 index 000000000..035aa4e44 --- /dev/null +++ b/Later/Java_Util_package/EnumSet/2/EnumSetDemo/.project @@ -0,0 +1,17 @@ + + + EnumSetDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/EnumSet/2/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/EnumSet/2/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/EnumSet/2/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/EnumSet/2/EnumSetDemo/bin/EnumSetDemo$Month.class b/Later/Java_Util_package/EnumSet/2/EnumSetDemo/bin/EnumSetDemo$Month.class new file mode 100644 index 000000000..de66c6ee9 Binary files /dev/null and b/Later/Java_Util_package/EnumSet/2/EnumSetDemo/bin/EnumSetDemo$Month.class differ diff --git a/Later/Java_Util_package/EnumSet/2/EnumSetDemo/bin/EnumSetDemo.class b/Later/Java_Util_package/EnumSet/2/EnumSetDemo/bin/EnumSetDemo.class new file mode 100644 index 000000000..387694512 Binary files /dev/null and b/Later/Java_Util_package/EnumSet/2/EnumSetDemo/bin/EnumSetDemo.class differ diff --git a/Later/Java_Util_package/EnumSet/2/EnumSetDemo/src/EnumSetDemo.java b/Later/Java_Util_package/EnumSet/2/EnumSetDemo/src/EnumSetDemo.java new file mode 100644 index 000000000..ad7258b4a --- /dev/null +++ b/Later/Java_Util_package/EnumSet/2/EnumSetDemo/src/EnumSetDemo.java @@ -0,0 +1,47 @@ +import java.util.ArrayList; +import java.util.EnumSet; + +/** + * + * public static > EnumSet of(E e) + * + * Creates an enum set initially containing the specified element. + * + * Type Parameters: + * + * E - The class of the specified element and of the set + * + * Parameters: + * + * e - the element that this set is to contain initially + * + * Returns: + * + * an enum set initially containing the specified element + * + */ + +public class EnumSetDemo +{ + + public enum Month + { + JAN, FEB, MAR, APR, MAY + }; + + public static void main(String[] args) + { + + /* + * Returns: an enum set initially containing the specified + * element + */ + + EnumSet enumSet = EnumSet.of(Month.MAR); + System.out.println("enumSet = " + enumSet); + + enumSet = EnumSet.of(Month.FEB); + System.out.println("enumSet = " + enumSet); + } + +} diff --git a/Later/Java_Util_package/EnumSet/3/EnumSetDemo/.classpath b/Later/Java_Util_package/EnumSet/3/EnumSetDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/EnumSet/3/EnumSetDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/EnumSet/3/EnumSetDemo/.project b/Later/Java_Util_package/EnumSet/3/EnumSetDemo/.project new file mode 100644 index 000000000..035aa4e44 --- /dev/null +++ b/Later/Java_Util_package/EnumSet/3/EnumSetDemo/.project @@ -0,0 +1,17 @@ + + + EnumSetDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/EnumSet/3/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/EnumSet/3/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/EnumSet/3/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/EnumSet/3/EnumSetDemo/bin/EnumSetDemo$Month.class b/Later/Java_Util_package/EnumSet/3/EnumSetDemo/bin/EnumSetDemo$Month.class new file mode 100644 index 000000000..e23e32af0 Binary files /dev/null and b/Later/Java_Util_package/EnumSet/3/EnumSetDemo/bin/EnumSetDemo$Month.class differ diff --git a/Later/Java_Util_package/EnumSet/3/EnumSetDemo/bin/EnumSetDemo.class b/Later/Java_Util_package/EnumSet/3/EnumSetDemo/bin/EnumSetDemo.class new file mode 100644 index 000000000..1489b06b6 Binary files /dev/null and b/Later/Java_Util_package/EnumSet/3/EnumSetDemo/bin/EnumSetDemo.class differ diff --git a/Later/Java_Util_package/EnumSet/3/EnumSetDemo/src/EnumSetDemo.java b/Later/Java_Util_package/EnumSet/3/EnumSetDemo/src/EnumSetDemo.java new file mode 100644 index 000000000..27d0b01d3 --- /dev/null +++ b/Later/Java_Util_package/EnumSet/3/EnumSetDemo/src/EnumSetDemo.java @@ -0,0 +1,44 @@ +import java.util.EnumSet; + +/** + * + * public static > EnumSet of(E e1, E e2) + * + * Creates an enum set initially containing the specified elements. + * + * Type Parameters: + * + * E - The class of the specified element and of the set + * + * Parameters: + * + * e1 - an element that this set is to contain initially + * + * e2 - another element that this set is to contain initially + * + * Returns: + * + * an enum set initially containing the specified elements + * + */ + +public class EnumSetDemo +{ + + public enum Month + { + JAN, FEB, MAR, APR, MAY + }; + + public static void main(String[] args) + { + /* + * Returns: an enum set initially containing the specified + * elements + */ + + EnumSet enumSet = EnumSet.of(Month.MAR, Month.JAN); + System.out.println("enumSet = " + enumSet); + } + +} diff --git a/Later/Java_Util_package/EnumSet/4/EnumSetDemo/.classpath b/Later/Java_Util_package/EnumSet/4/EnumSetDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/EnumSet/4/EnumSetDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/EnumSet/4/EnumSetDemo/.project b/Later/Java_Util_package/EnumSet/4/EnumSetDemo/.project new file mode 100644 index 000000000..035aa4e44 --- /dev/null +++ b/Later/Java_Util_package/EnumSet/4/EnumSetDemo/.project @@ -0,0 +1,17 @@ + + + EnumSetDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/EnumSet/4/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/EnumSet/4/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/EnumSet/4/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/EnumSet/4/EnumSetDemo/bin/EnumSetDemo$Month.class b/Later/Java_Util_package/EnumSet/4/EnumSetDemo/bin/EnumSetDemo$Month.class new file mode 100644 index 000000000..684b90e19 Binary files /dev/null and b/Later/Java_Util_package/EnumSet/4/EnumSetDemo/bin/EnumSetDemo$Month.class differ diff --git a/Later/Java_Util_package/EnumSet/4/EnumSetDemo/bin/EnumSetDemo.class b/Later/Java_Util_package/EnumSet/4/EnumSetDemo/bin/EnumSetDemo.class new file mode 100644 index 000000000..494970167 Binary files /dev/null and b/Later/Java_Util_package/EnumSet/4/EnumSetDemo/bin/EnumSetDemo.class differ diff --git a/Later/Java_Util_package/EnumSet/4/EnumSetDemo/src/EnumSetDemo.java b/Later/Java_Util_package/EnumSet/4/EnumSetDemo/src/EnumSetDemo.java new file mode 100644 index 000000000..06988d1a8 --- /dev/null +++ b/Later/Java_Util_package/EnumSet/4/EnumSetDemo/src/EnumSetDemo.java @@ -0,0 +1,47 @@ +import java.util.EnumSet; + +/** + * + * public static > EnumSet of(E e1, E e2, E e3) + * + * Creates an enum set initially containing the specified elements. + * + * Type Parameters: + * + * E - The class of the specified element and of the set + * + * Parameters: + * + * e1 - an element that this set is to contain initially + * + * e2 - another element that this set is to contain initially + * + * e3 - another element that this set is to contain initially + * + * Returns: + * + * an enum set initially containing the specified elements + * + */ + +public class EnumSetDemo +{ + + public enum Month + { + JAN, FEB, MAR, APR, MAY + }; + + public static void main(String[] args) + { + /* + * Returns: an enum set initially containing the specified + * elements + */ + + EnumSet enumSet = EnumSet.of(Month.MAR, Month.JAN, + Month.MAY); + System.out.println("enumSet = " + enumSet); + } + +} diff --git a/Later/Java_Util_package/EnumSet/5/EnumSetDemo/.classpath b/Later/Java_Util_package/EnumSet/5/EnumSetDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/EnumSet/5/EnumSetDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/EnumSet/5/EnumSetDemo/.project b/Later/Java_Util_package/EnumSet/5/EnumSetDemo/.project new file mode 100644 index 000000000..035aa4e44 --- /dev/null +++ b/Later/Java_Util_package/EnumSet/5/EnumSetDemo/.project @@ -0,0 +1,17 @@ + + + EnumSetDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/EnumSet/5/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/EnumSet/5/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/EnumSet/5/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/EnumSet/5/EnumSetDemo/bin/EnumSetDemo$Month.class b/Later/Java_Util_package/EnumSet/5/EnumSetDemo/bin/EnumSetDemo$Month.class new file mode 100644 index 000000000..c45970fee Binary files /dev/null and b/Later/Java_Util_package/EnumSet/5/EnumSetDemo/bin/EnumSetDemo$Month.class differ diff --git a/Later/Java_Util_package/EnumSet/5/EnumSetDemo/bin/EnumSetDemo.class b/Later/Java_Util_package/EnumSet/5/EnumSetDemo/bin/EnumSetDemo.class new file mode 100644 index 000000000..c11f09d23 Binary files /dev/null and b/Later/Java_Util_package/EnumSet/5/EnumSetDemo/bin/EnumSetDemo.class differ diff --git a/Later/Java_Util_package/EnumSet/5/EnumSetDemo/src/EnumSetDemo.java b/Later/Java_Util_package/EnumSet/5/EnumSetDemo/src/EnumSetDemo.java new file mode 100644 index 000000000..5f505c84a --- /dev/null +++ b/Later/Java_Util_package/EnumSet/5/EnumSetDemo/src/EnumSetDemo.java @@ -0,0 +1,50 @@ +import java.util.EnumSet; + +/** + * + * public static > EnumSet of(E e1, E e2, E e3, E + * e4) + * + * Creates an enum set initially containing the specified elements. + * + * Type Parameters: + * + * E - The class of the specified element and of the set + * + * Parameters: + * + * e1 - an element that this set is to contain initially + * + * e2 - another element that this set is to contain initially + * + * e3 - another element that this set is to contain initially + * + * e4 - another element that this set is to contain initially + * + * Returns: + * + * an enum set initially containing the specified elements + * + */ + +public class EnumSetDemo +{ + + public enum Month + { + JAN, FEB, MAR, APR, MAY + }; + + public static void main(String[] args) + { + /* + * Returns: an enum set initially containing the specified + * elements + */ + + EnumSet enumSet = EnumSet.of(Month.MAR, Month.JAN, + Month.MAY, Month.FEB); + System.out.println("enumSet = " + enumSet); + } + +} diff --git a/Later/Java_Util_package/EnumSet/6/EnumSetDemo/.classpath b/Later/Java_Util_package/EnumSet/6/EnumSetDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/EnumSet/6/EnumSetDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/EnumSet/6/EnumSetDemo/.project b/Later/Java_Util_package/EnumSet/6/EnumSetDemo/.project new file mode 100644 index 000000000..035aa4e44 --- /dev/null +++ b/Later/Java_Util_package/EnumSet/6/EnumSetDemo/.project @@ -0,0 +1,17 @@ + + + EnumSetDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/EnumSet/6/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/EnumSet/6/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/EnumSet/6/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/EnumSet/6/EnumSetDemo/bin/EnumSetDemo$Month.class b/Later/Java_Util_package/EnumSet/6/EnumSetDemo/bin/EnumSetDemo$Month.class new file mode 100644 index 000000000..de3330d8d Binary files /dev/null and b/Later/Java_Util_package/EnumSet/6/EnumSetDemo/bin/EnumSetDemo$Month.class differ diff --git a/Later/Java_Util_package/EnumSet/6/EnumSetDemo/bin/EnumSetDemo.class b/Later/Java_Util_package/EnumSet/6/EnumSetDemo/bin/EnumSetDemo.class new file mode 100644 index 000000000..b865981ca Binary files /dev/null and b/Later/Java_Util_package/EnumSet/6/EnumSetDemo/bin/EnumSetDemo.class differ diff --git a/Later/Java_Util_package/EnumSet/6/EnumSetDemo/src/EnumSetDemo.java b/Later/Java_Util_package/EnumSet/6/EnumSetDemo/src/EnumSetDemo.java new file mode 100644 index 000000000..4d68f0d8e --- /dev/null +++ b/Later/Java_Util_package/EnumSet/6/EnumSetDemo/src/EnumSetDemo.java @@ -0,0 +1,52 @@ +import java.util.EnumSet; + +/** + * + * public static > EnumSet of(E e1, E e2, E e3, E + * e4, E e5) + * + * Creates an enum set initially containing the specified elements. + * + * Type Parameters: + * + * E - The class of the specified element and of the set + * + * Parameters: + * + * e1 - an element that this set is to contain initially + * + * e2 - another element that this set is to contain initially + * + * e3 - another element that this set is to contain initially + * + * e4 - another element that this set is to contain initially + * + * e5 - another element that this set is to contain initially + * + * Returns: + * + * an enum set initially containing the specified elements + * + */ + +public class EnumSetDemo +{ + + public enum Month + { + JAN, FEB, MAR, APR, MAY + }; + + public static void main(String[] args) + { + /* + * Returns: an enum set initially containing the specified + * elements + */ + + EnumSet enumSet = EnumSet.of(Month.MAR, Month.JAN, + Month.MAY, Month.FEB,Month.APR); + System.out.println("enumSet = " + enumSet); + } + +} diff --git a/Later/Java_Util_package/EnumSet/7/EnumSetDemo/.classpath b/Later/Java_Util_package/EnumSet/7/EnumSetDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/EnumSet/7/EnumSetDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/EnumSet/7/EnumSetDemo/.project b/Later/Java_Util_package/EnumSet/7/EnumSetDemo/.project new file mode 100644 index 000000000..035aa4e44 --- /dev/null +++ b/Later/Java_Util_package/EnumSet/7/EnumSetDemo/.project @@ -0,0 +1,17 @@ + + + EnumSetDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/EnumSet/7/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/EnumSet/7/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/EnumSet/7/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/EnumSet/7/EnumSetDemo/bin/EnumSetDemo$Month.class b/Later/Java_Util_package/EnumSet/7/EnumSetDemo/bin/EnumSetDemo$Month.class new file mode 100644 index 000000000..f7e290102 Binary files /dev/null and b/Later/Java_Util_package/EnumSet/7/EnumSetDemo/bin/EnumSetDemo$Month.class differ diff --git a/Later/Java_Util_package/EnumSet/7/EnumSetDemo/bin/EnumSetDemo.class b/Later/Java_Util_package/EnumSet/7/EnumSetDemo/bin/EnumSetDemo.class new file mode 100644 index 000000000..8f8f2932c Binary files /dev/null and b/Later/Java_Util_package/EnumSet/7/EnumSetDemo/bin/EnumSetDemo.class differ diff --git a/Later/Java_Util_package/EnumSet/7/EnumSetDemo/src/EnumSetDemo.java b/Later/Java_Util_package/EnumSet/7/EnumSetDemo/src/EnumSetDemo.java new file mode 100644 index 000000000..af47382b4 --- /dev/null +++ b/Later/Java_Util_package/EnumSet/7/EnumSetDemo/src/EnumSetDemo.java @@ -0,0 +1,54 @@ +import java.util.EnumSet; + +/** + * + * public static > EnumSet of(E first, E... rest) + * + * Creates an enum set initially containing the specified elements. + * This factory, whose parameter list uses the varargs feature, may be + * used to create an enum set initially containing an arbitrary number + * of elements, but it is likely to run slower than the overloadings + * that do not use varargs. + * + * Type Parameters: + * + * E - The class of the specified element and of the set + * + * Parameters: + * + * first - an element that the set is to contain initially + * + * rest - the remaining elements the set is to contain initially + * + * Returns: + * + * an enum set initially containing the specified elements + * + */ + +public class EnumSetDemo +{ + + public enum Month + { + JAN, FEB, MAR, APR, MAY + }; + + public static void main(String[] args) + { + // create a fake list that will be used like args + Month[] monthList = { Month.FEB, Month.MAR, Month.APR, + Month.MAY }; + createEnumSet(monthList); + } + + public static void createEnumSet(Month[] varargs) + { + /* + * Returns: an enum set initially containing the specified + * elements + */ + EnumSet enumSet = EnumSet.of(Month.JAN, varargs); + System.out.println("enumSet = " + enumSet); + } +} diff --git a/Later/Java_Util_package/EnumSet/8/EnumSetDemo/.classpath b/Later/Java_Util_package/EnumSet/8/EnumSetDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/EnumSet/8/EnumSetDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/EnumSet/8/EnumSetDemo/.project b/Later/Java_Util_package/EnumSet/8/EnumSetDemo/.project new file mode 100644 index 000000000..035aa4e44 --- /dev/null +++ b/Later/Java_Util_package/EnumSet/8/EnumSetDemo/.project @@ -0,0 +1,17 @@ + + + EnumSetDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/EnumSet/8/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/EnumSet/8/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/EnumSet/8/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/EnumSet/8/EnumSetDemo/bin/EnumSetDemo$Month.class b/Later/Java_Util_package/EnumSet/8/EnumSetDemo/bin/EnumSetDemo$Month.class new file mode 100644 index 000000000..684b90e19 Binary files /dev/null and b/Later/Java_Util_package/EnumSet/8/EnumSetDemo/bin/EnumSetDemo$Month.class differ diff --git a/Later/Java_Util_package/EnumSet/8/EnumSetDemo/bin/EnumSetDemo.class b/Later/Java_Util_package/EnumSet/8/EnumSetDemo/bin/EnumSetDemo.class new file mode 100644 index 000000000..2727ff0b3 Binary files /dev/null and b/Later/Java_Util_package/EnumSet/8/EnumSetDemo/bin/EnumSetDemo.class differ diff --git a/Later/Java_Util_package/EnumSet/8/EnumSetDemo/src/EnumSetDemo.java b/Later/Java_Util_package/EnumSet/8/EnumSetDemo/src/EnumSetDemo.java new file mode 100644 index 000000000..d7f576269 --- /dev/null +++ b/Later/Java_Util_package/EnumSet/8/EnumSetDemo/src/EnumSetDemo.java @@ -0,0 +1,46 @@ +import java.util.EnumSet; + +/** + * + * public static > EnumSet range(E from, E to) + * + * Creates an enum set initially containing all of the elements in the + * range defined by the two specified endpoints. + * + * Type Parameters: + * + * E - The class of the parameter elements and of the set + * + * Parameters: + * + * from - the first element in the range + * + * to - the last element in the range + * + * Returns: + * + * an enum set initially containing all of the elements in the range + * defined by the two specified endpoints + * + */ + +public class EnumSetDemo +{ + + public enum Month + { + JAN, FEB, MAR, APR, MAY + }; + + public static void main(String[] args) + { + /* + * Returns: an enum set initially containing all of the + * elements in the range defined by the two specified + * endpoints + */ + EnumSet enumSet = EnumSet.range(Month.JAN, Month.APR); + System.out.println("enumSet = " + enumSet); + } + +} diff --git a/Later/Java_Util_package/EnumSet/9/EnumSetDemo/.classpath b/Later/Java_Util_package/EnumSet/9/EnumSetDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/EnumSet/9/EnumSetDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/EnumSet/9/EnumSetDemo/.project b/Later/Java_Util_package/EnumSet/9/EnumSetDemo/.project new file mode 100644 index 000000000..035aa4e44 --- /dev/null +++ b/Later/Java_Util_package/EnumSet/9/EnumSetDemo/.project @@ -0,0 +1,17 @@ + + + EnumSetDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/EnumSet/9/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/EnumSet/9/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/EnumSet/9/EnumSetDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/EnumSet/9/EnumSetDemo/bin/EnumSetDemo$Month.class b/Later/Java_Util_package/EnumSet/9/EnumSetDemo/bin/EnumSetDemo$Month.class new file mode 100644 index 000000000..0d56d7283 Binary files /dev/null and b/Later/Java_Util_package/EnumSet/9/EnumSetDemo/bin/EnumSetDemo$Month.class differ diff --git a/Later/Java_Util_package/EnumSet/9/EnumSetDemo/bin/EnumSetDemo.class b/Later/Java_Util_package/EnumSet/9/EnumSetDemo/bin/EnumSetDemo.class new file mode 100644 index 000000000..87963aa40 Binary files /dev/null and b/Later/Java_Util_package/EnumSet/9/EnumSetDemo/bin/EnumSetDemo.class differ diff --git a/Later/Java_Util_package/EnumSet/9/EnumSetDemo/src/EnumSetDemo.java b/Later/Java_Util_package/EnumSet/9/EnumSetDemo/src/EnumSetDemo.java new file mode 100644 index 000000000..e185f40b6 --- /dev/null +++ b/Later/Java_Util_package/EnumSet/9/EnumSetDemo/src/EnumSetDemo.java @@ -0,0 +1,44 @@ +import java.util.EnumSet; + +/** + * + * public static > EnumSet allOf(Class + * elementType) + * + * Creates an enum set containing all of the elements in the specified + * element type. + * + * Type Parameters: + * + * E - The class of the elements in the set + * + * Parameters: + * + * elementType - the class object of the element type for this enum + * set + * + * Returns: + * + * An enum set containing all the elements in the specified type. + * + */ + +public class EnumSetDemo +{ + + public enum Month + { + JAN, FEB, MAR, APR, MAY + }; + + public static void main(String[] args) + { + /* + * Returns: An enum set containing all the elements in the + * specified type. + */ + EnumSet enumSet = EnumSet.allOf(Month.class); + System.out.println("enumSet = " + enumSet); + } + +} diff --git a/Later/Java_Util_package/Internationalization/I18N with Currency/I18N with Currency.pptx b/Later/Java_Util_package/Internationalization/I18N with Currency/I18N with Currency.pptx new file mode 100644 index 000000000..ff1e82343 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/I18N with Currency/I18N with Currency.pptx differ diff --git a/Later/Java_Util_package/Internationalization/I18N with Currency/InternalizationCurrencyDemo/.classpath b/Later/Java_Util_package/Internationalization/I18N with Currency/InternalizationCurrencyDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/I18N with Currency/InternalizationCurrencyDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Internationalization/I18N with Currency/InternalizationCurrencyDemo/.project b/Later/Java_Util_package/Internationalization/I18N with Currency/InternalizationCurrencyDemo/.project new file mode 100644 index 000000000..49550d201 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/I18N with Currency/InternalizationCurrencyDemo/.project @@ -0,0 +1,17 @@ + + + InternalizationCurrencyDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Internationalization/I18N with Currency/InternalizationCurrencyDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Internationalization/I18N with Currency/InternalizationCurrencyDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/I18N with Currency/InternalizationCurrencyDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Internationalization/I18N with Currency/InternalizationCurrencyDemo/bin/InternalizationNumberDemo.class b/Later/Java_Util_package/Internationalization/I18N with Currency/InternalizationCurrencyDemo/bin/InternalizationNumberDemo.class new file mode 100644 index 000000000..338c3af1f Binary files /dev/null and b/Later/Java_Util_package/Internationalization/I18N with Currency/InternalizationCurrencyDemo/bin/InternalizationNumberDemo.class differ diff --git a/Later/Java_Util_package/Internationalization/I18N with Currency/InternalizationCurrencyDemo/src/InternalizationCurrencyDemo.java b/Later/Java_Util_package/Internationalization/I18N with Currency/InternalizationCurrencyDemo/src/InternalizationCurrencyDemo.java new file mode 100644 index 000000000..25579a4ff --- /dev/null +++ b/Later/Java_Util_package/Internationalization/I18N with Currency/InternalizationCurrencyDemo/src/InternalizationCurrencyDemo.java @@ -0,0 +1,38 @@ +import java.text.NumberFormat; +import java.util.Locale; + +/** + * + * Internationalizing Currency (I18N with Currency) + * + */ +public class InternalizationCurrencyDemo +{ + + public static void main(String[] args) + { + displayCurrency(Locale.US); + displayCurrency(Locale.CHINA); + displayCurrency(Locale.FRANCE); + } + + static void displayCurrency(Locale locale) + { + double dbl = 2000.909; + /* + * Returns a currency format for the specified locale. + * + * Parameters: + * + * inLocale - the desired locale + * + * Returns: + * + * the NumberFormat instance for currency formatting + */ + NumberFormat formatter = NumberFormat.getCurrencyInstance(locale); + String currency = formatter.format(dbl); + System.out.println(currency + " for the locale " + locale); + } + +} diff --git a/Later/Java_Util_package/Internationalization/I18N with Date/I18N with Date.pptx b/Later/Java_Util_package/Internationalization/I18N with Date/I18N with Date.pptx new file mode 100644 index 000000000..559c2ed22 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/I18N with Date/I18N with Date.pptx differ diff --git a/Later/Java_Util_package/Internationalization/I18N with Date/InternationalizationDateDemo/.classpath b/Later/Java_Util_package/Internationalization/I18N with Date/InternationalizationDateDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/I18N with Date/InternationalizationDateDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Internationalization/I18N with Date/InternationalizationDateDemo/.project b/Later/Java_Util_package/Internationalization/I18N with Date/InternationalizationDateDemo/.project new file mode 100644 index 000000000..71b746aa5 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/I18N with Date/InternationalizationDateDemo/.project @@ -0,0 +1,17 @@ + + + InternationalizationDateDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Internationalization/I18N with Date/InternationalizationDateDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Internationalization/I18N with Date/InternationalizationDateDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/I18N with Date/InternationalizationDateDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Internationalization/I18N with Date/InternationalizationDateDemo/bin/InternationalizationDateDemo.class b/Later/Java_Util_package/Internationalization/I18N with Date/InternationalizationDateDemo/bin/InternationalizationDateDemo.class new file mode 100644 index 000000000..7109e2d0d Binary files /dev/null and b/Later/Java_Util_package/Internationalization/I18N with Date/InternationalizationDateDemo/bin/InternationalizationDateDemo.class differ diff --git a/Later/Java_Util_package/Internationalization/I18N with Date/InternationalizationDateDemo/src/InternationalizationDateDemo.java b/Later/Java_Util_package/Internationalization/I18N with Date/InternationalizationDateDemo/src/InternationalizationDateDemo.java new file mode 100644 index 000000000..694ae464d --- /dev/null +++ b/Later/Java_Util_package/Internationalization/I18N with Date/InternationalizationDateDemo/src/InternationalizationDateDemo.java @@ -0,0 +1,45 @@ +import java.text.DateFormat; +import java.util.Date; +import java.util.Locale; + +/** + * + * Internationalizing Date (I18N with Date). + * + */ +public class InternationalizationDateDemo +{ + + public static void main(String[] args) + { + displayDate(Locale.US); + displayDate(Locale.FRANCE); + displayDate(Locale.CHINA); + } + + public static void displayDate(Locale locale) + { + /* + * Gets the date formatter with the given formatting style for + * the given locale. + * + * Parameters: + * + * style - the given formatting style. For example, SHORT for + * "M/d/yy" in the US locale. + * + * aLocale - the given locale. Returns: a date formatter. + */ + DateFormat formatter = DateFormat.getDateInstance(DateFormat.DEFAULT, + locale); + Date currentDate = new Date(); + + /* + * Formats a Date into a date/time string. + * + */ + String date = formatter.format(currentDate); + System.out.println("Date value in " + locale + " locale = " + date); + } + +} diff --git a/Later/Java_Util_package/Internationalization/I18N with DateTime/I18N with DateTime.pptx b/Later/Java_Util_package/Internationalization/I18N with DateTime/I18N with DateTime.pptx new file mode 100644 index 000000000..7b38dc00c Binary files /dev/null and b/Later/Java_Util_package/Internationalization/I18N with DateTime/I18N with DateTime.pptx differ diff --git a/Later/Java_Util_package/Internationalization/I18N with DateTime/InternationalizationDateDemo/.classpath b/Later/Java_Util_package/Internationalization/I18N with DateTime/InternationalizationDateDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/I18N with DateTime/InternationalizationDateDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Internationalization/I18N with DateTime/InternationalizationDateDemo/.project b/Later/Java_Util_package/Internationalization/I18N with DateTime/InternationalizationDateDemo/.project new file mode 100644 index 000000000..71b746aa5 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/I18N with DateTime/InternationalizationDateDemo/.project @@ -0,0 +1,17 @@ + + + InternationalizationDateDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Internationalization/I18N with DateTime/InternationalizationDateDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Internationalization/I18N with DateTime/InternationalizationDateDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/I18N with DateTime/InternationalizationDateDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Internationalization/I18N with DateTime/InternationalizationDateDemo/bin/InternationalizationDateTimeDemo.class b/Later/Java_Util_package/Internationalization/I18N with DateTime/InternationalizationDateDemo/bin/InternationalizationDateTimeDemo.class new file mode 100644 index 000000000..e2f543c89 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/I18N with DateTime/InternationalizationDateDemo/bin/InternationalizationDateTimeDemo.class differ diff --git a/Later/Java_Util_package/Internationalization/I18N with DateTime/InternationalizationDateDemo/src/InternationalizationDateTimeDemo.java b/Later/Java_Util_package/Internationalization/I18N with DateTime/InternationalizationDateDemo/src/InternationalizationDateTimeDemo.java new file mode 100644 index 000000000..1093db316 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/I18N with DateTime/InternationalizationDateDemo/src/InternationalizationDateTimeDemo.java @@ -0,0 +1,46 @@ +import java.text.DateFormat; +import java.util.Date; +import java.util.Locale; + +/** + * + * Internationalizing DateTime (I18N with DateTime) + * + */ +public class InternationalizationDateTimeDemo +{ + + public static void main(String[] args) + { + displayDateTime(Locale.US); + displayDateTime(Locale.CHINA); + displayDateTime(Locale.FRANCE); + } + + public static void displayDateTime(Locale locale) + { + /* + * Gets the date/time formatter with the given formatting + * styles for the given locale. + * + * Parameters: + * + * dateStyle - the given date formatting style. + * + * timeStyle - the given time formatting style. + * + * aLocale - the given locale. Returns: a date/time formatter. + */ + DateFormat formatter = DateFormat.getDateTimeInstance( + DateFormat.DEFAULT, DateFormat.DEFAULT, locale); + Date date = new Date(); + + /* + * Formats a Date into a date/time string. + * + */ + String strDate = formatter.format(date); + System.out.println("Time value in " + locale + " locale = " + strDate); + } + +} diff --git a/Later/Java_Util_package/Internationalization/I18N with Number/I18N with Number.pptx b/Later/Java_Util_package/Internationalization/I18N with Number/I18N with Number.pptx new file mode 100644 index 000000000..5b5ed9594 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/I18N with Number/I18N with Number.pptx differ diff --git a/Later/Java_Util_package/Internationalization/I18N with Number/InternalizationNumberDemo/.classpath b/Later/Java_Util_package/Internationalization/I18N with Number/InternalizationNumberDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/I18N with Number/InternalizationNumberDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Internationalization/I18N with Number/InternalizationNumberDemo/.project b/Later/Java_Util_package/Internationalization/I18N with Number/InternalizationNumberDemo/.project new file mode 100644 index 000000000..5e4637bfb --- /dev/null +++ b/Later/Java_Util_package/Internationalization/I18N with Number/InternalizationNumberDemo/.project @@ -0,0 +1,17 @@ + + + InternalizationNumberDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Internationalization/I18N with Number/InternalizationNumberDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Internationalization/I18N with Number/InternalizationNumberDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/I18N with Number/InternalizationNumberDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Internationalization/I18N with Number/InternalizationNumberDemo/bin/InternalizationNumberDemo.class b/Later/Java_Util_package/Internationalization/I18N with Number/InternalizationNumberDemo/bin/InternalizationNumberDemo.class new file mode 100644 index 000000000..9c944a3dc Binary files /dev/null and b/Later/Java_Util_package/Internationalization/I18N with Number/InternalizationNumberDemo/bin/InternalizationNumberDemo.class differ diff --git a/Later/Java_Util_package/Internationalization/I18N with Number/InternalizationNumberDemo/src/InternalizationNumberDemo.java b/Later/Java_Util_package/Internationalization/I18N with Number/InternalizationNumberDemo/src/InternalizationNumberDemo.java new file mode 100644 index 000000000..f28b3ee36 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/I18N with Number/InternalizationNumberDemo/src/InternalizationNumberDemo.java @@ -0,0 +1,38 @@ +import java.text.NumberFormat; +import java.util.Locale; + +/** + * + * Internationalizing Number (I18N with Number) + * + */ +public class InternalizationNumberDemo +{ + + public static void main(String[] args) + { + displayNumber(Locale.US); + displayNumber(Locale.CHINA); + displayNumber(Locale.FRANCE); + } + + static void displayNumber(Locale locale) + { + double dbl = 10000.909; + /* + * Returns a general-purpose number format for the specified + * locale. + * + * Parameters: + * + * inLocale - the desired locale + * + * Returns: the NumberFormat instance for general-purpose + * number formatting + */ + NumberFormat formatter = NumberFormat.getNumberInstance(locale); + String number = formatter.format(dbl); + System.out.println(number + " for the locale " + locale); + } + +} diff --git a/Later/Java_Util_package/Internationalization/I18N with Time/I18N with Time.pptx b/Later/Java_Util_package/Internationalization/I18N with Time/I18N with Time.pptx new file mode 100644 index 000000000..f7dfb436f Binary files /dev/null and b/Later/Java_Util_package/Internationalization/I18N with Time/I18N with Time.pptx differ diff --git a/Later/Java_Util_package/Internationalization/I18N with Time/InternationalizationDateDemo/.classpath b/Later/Java_Util_package/Internationalization/I18N with Time/InternationalizationDateDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/I18N with Time/InternationalizationDateDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Internationalization/I18N with Time/InternationalizationDateDemo/.project b/Later/Java_Util_package/Internationalization/I18N with Time/InternationalizationDateDemo/.project new file mode 100644 index 000000000..71b746aa5 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/I18N with Time/InternationalizationDateDemo/.project @@ -0,0 +1,17 @@ + + + InternationalizationDateDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Internationalization/I18N with Time/InternationalizationDateDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Internationalization/I18N with Time/InternationalizationDateDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/I18N with Time/InternationalizationDateDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Internationalization/I18N with Time/InternationalizationDateDemo/bin/InternationalizationTimeDemo.class b/Later/Java_Util_package/Internationalization/I18N with Time/InternationalizationDateDemo/bin/InternationalizationTimeDemo.class new file mode 100644 index 000000000..267a1b473 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/I18N with Time/InternationalizationDateDemo/bin/InternationalizationTimeDemo.class differ diff --git a/Later/Java_Util_package/Internationalization/I18N with Time/InternationalizationDateDemo/src/InternationalizationTimeDemo.java b/Later/Java_Util_package/Internationalization/I18N with Time/InternationalizationDateDemo/src/InternationalizationTimeDemo.java new file mode 100644 index 000000000..877346ac3 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/I18N with Time/InternationalizationDateDemo/src/InternationalizationTimeDemo.java @@ -0,0 +1,45 @@ +import java.text.DateFormat; +import java.util.Date; +import java.util.Locale; + +/** + * + * Internationalizing Time (I18N with Time) + * + */ +public class InternationalizationTimeDemo +{ + + public static void main(String[] args) + { + displayTime(Locale.US); + displayTime(Locale.CHINA); + displayTime(Locale.FRANCE); + } + + public static void displayTime(Locale locale) + { + /* + * Gets the time formatter with the given formatting style for + * the given locale. + * + * Parameters: + * + * style - the given formatting style. For example, SHORT for + * "h:mm a" in the US locale. + * + * aLocale - the given locale. Returns: a time formatter. + */ + DateFormat formatter = DateFormat.getTimeInstance(DateFormat.DEFAULT, + locale); + Date date = new Date(); + + /* + * Formats a Date into a date/time string. + * + */ + String strDate = formatter.format(date); + System.out.println("Time value in " + locale + " locale = " + strDate); + } + +} diff --git a/Later/Java_Util_package/Internationalization/ListResourceBundle/1/ListResourceBundle.pptx b/Later/Java_Util_package/Internationalization/ListResourceBundle/1/ListResourceBundle.pptx new file mode 100644 index 000000000..39d975431 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/ListResourceBundle/1/ListResourceBundle.pptx differ diff --git a/Later/Java_Util_package/Internationalization/ListResourceBundle/1/ListResourceBundleDemo/.classpath b/Later/Java_Util_package/Internationalization/ListResourceBundle/1/ListResourceBundleDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ListResourceBundle/1/ListResourceBundleDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Internationalization/ListResourceBundle/1/ListResourceBundleDemo/.project b/Later/Java_Util_package/Internationalization/ListResourceBundle/1/ListResourceBundleDemo/.project new file mode 100644 index 000000000..881213492 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ListResourceBundle/1/ListResourceBundleDemo/.project @@ -0,0 +1,17 @@ + + + ListResourceBundleDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Internationalization/ListResourceBundle/1/ListResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Internationalization/ListResourceBundle/1/ListResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ListResourceBundle/1/ListResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Internationalization/ListResourceBundle/1/ListResourceBundleDemo/bin/MessageBundle_en_US.class b/Later/Java_Util_package/Internationalization/ListResourceBundle/1/ListResourceBundleDemo/bin/MessageBundle_en_US.class new file mode 100644 index 000000000..71cb19e41 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/ListResourceBundle/1/ListResourceBundleDemo/bin/MessageBundle_en_US.class differ diff --git a/Later/Java_Util_package/Internationalization/ListResourceBundle/1/ListResourceBundleDemo/bin/MessageBundle_fr_FR.class b/Later/Java_Util_package/Internationalization/ListResourceBundle/1/ListResourceBundleDemo/bin/MessageBundle_fr_FR.class new file mode 100644 index 000000000..ce7ba19c7 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/ListResourceBundle/1/ListResourceBundleDemo/bin/MessageBundle_fr_FR.class differ diff --git a/Later/Java_Util_package/Internationalization/ListResourceBundle/1/ListResourceBundleDemo/bin/ResourceBundleDemo.class b/Later/Java_Util_package/Internationalization/ListResourceBundle/1/ListResourceBundleDemo/bin/ResourceBundleDemo.class new file mode 100644 index 000000000..724e195c4 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/ListResourceBundle/1/ListResourceBundleDemo/bin/ResourceBundleDemo.class differ diff --git a/Later/Java_Util_package/Internationalization/ListResourceBundle/1/ListResourceBundleDemo/src/ListResourceBundleDemo.java b/Later/Java_Util_package/Internationalization/ListResourceBundle/1/ListResourceBundleDemo/src/ListResourceBundleDemo.java new file mode 100644 index 000000000..ada94d90c --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ListResourceBundle/1/ListResourceBundleDemo/src/ListResourceBundleDemo.java @@ -0,0 +1,34 @@ +import java.util.Enumeration; +import java.util.Locale; +import java.util.ResourceBundle; + +public class ListResourceBundleDemo +{ + + public static void main(String[] args) + { + + Locale usLocale = new Locale("en", "US"); + printKeysValues(usLocale); + + System.out.println(); + + Locale frLocale = new Locale("fr", "FR"); + printKeysValues(frLocale); + + } + + private static void printKeysValues(Locale locale) + { + ResourceBundle rb = ResourceBundle.getBundle("MessageBundle", locale); + + Enumeration en = rb.getKeys(); + while (en.hasMoreElements()) + { + String key = en.nextElement(); + System.out + .println(key + " = " + rb.getString(key)); + } + } + +} diff --git a/Later/Java_Util_package/Internationalization/ListResourceBundle/1/ListResourceBundleDemo/src/MessageBundle_en_US.java b/Later/Java_Util_package/Internationalization/ListResourceBundle/1/ListResourceBundleDemo/src/MessageBundle_en_US.java new file mode 100644 index 000000000..23933e8e8 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ListResourceBundle/1/ListResourceBundleDemo/src/MessageBundle_en_US.java @@ -0,0 +1,32 @@ +import java.util.ListResourceBundle; + +/** + * + * Subclasses of ListResourceBundle must override getContents and provide an array, where + * each item in the array is a pair of objects. The first element of + * each pair is the key, which must be a String, and the second + * element is the value associated with that key. + * + */ +public class MessageBundle_en_US extends ListResourceBundle +{ + /* + * Returns an array in which each item is a pair of objects in an + * Object array. The first element of each pair is the key, which + * must be a String, and the second element is the value + * associated with that key. See the class description for + * details. + * + * Returns: + * + * an array of an Object array representing a key-value pair. + */ + + @Override + protected Object[][] getContents() + { + return new Object[][] { { "hello", "Hello Peter" }, + { "welcome", "Welcome Juli" }, }; + } + +} diff --git a/Later/Java_Util_package/Internationalization/ListResourceBundle/1/ListResourceBundleDemo/src/MessageBundle_fr_FR.java b/Later/Java_Util_package/Internationalization/ListResourceBundle/1/ListResourceBundleDemo/src/MessageBundle_fr_FR.java new file mode 100644 index 000000000..dab132489 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ListResourceBundle/1/ListResourceBundleDemo/src/MessageBundle_fr_FR.java @@ -0,0 +1,34 @@ +import java.util.ListResourceBundle; + +/** + * + * Subclasses of ListResourceBundle must override getContents and provide an array, where + * each item in the array is a pair of objects. The first element of + * each pair is the key, which must be a String, and the second + * element is the value associated with that key. + * + */ +public class MessageBundle_fr_FR extends ListResourceBundle +{ + /* + * Returns an array in which each item is a pair of objects in an + * Object array. The first element of each pair is the key, which + * must be a String, and the second element is the value + * associated with that key. See the class description for + * details. + * + * Returns: + * + * an array of an Object array representing a key-value pair. + */ + + @Override + protected Object[][] getContents() + { + return new Object[][] { + { "hello", "Bonjour Peter" }, + { "welcome", "Bienvenue Juli" }, + }; + } + +} diff --git a/Later/Java_Util_package/Internationalization/Locale/1/Internationalization_in_java.pptx b/Later/Java_Util_package/Internationalization/Locale/1/Internationalization_in_java.pptx new file mode 100644 index 000000000..ee9e7c437 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/Locale/1/Internationalization_in_java.pptx differ diff --git a/Later/Java_Util_package/Internationalization/Locale/10/Codes in Locale.pptx b/Later/Java_Util_package/Internationalization/Locale/10/Codes in Locale.pptx new file mode 100644 index 000000000..8c6217696 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/Locale/10/Codes in Locale.pptx differ diff --git a/Later/Java_Util_package/Internationalization/Locale/11/LocaleDemo/.classpath b/Later/Java_Util_package/Internationalization/Locale/11/LocaleDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/11/LocaleDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Internationalization/Locale/11/LocaleDemo/.project b/Later/Java_Util_package/Internationalization/Locale/11/LocaleDemo/.project new file mode 100644 index 000000000..941bf265e --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/11/LocaleDemo/.project @@ -0,0 +1,17 @@ + + + LocaleDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Internationalization/Locale/11/LocaleDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Internationalization/Locale/11/LocaleDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/11/LocaleDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Internationalization/Locale/11/LocaleDemo/bin/LocaleDemo.class b/Later/Java_Util_package/Internationalization/Locale/11/LocaleDemo/bin/LocaleDemo.class new file mode 100644 index 000000000..a482a20ae Binary files /dev/null and b/Later/Java_Util_package/Internationalization/Locale/11/LocaleDemo/bin/LocaleDemo.class differ diff --git a/Later/Java_Util_package/Internationalization/Locale/11/LocaleDemo/src/LocaleDemo.java b/Later/Java_Util_package/Internationalization/Locale/11/LocaleDemo/src/LocaleDemo.java new file mode 100644 index 000000000..0d2f91cee --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/11/LocaleDemo/src/LocaleDemo.java @@ -0,0 +1,26 @@ +import java.util.Locale; + +public class LocaleDemo +{ + + public static void main(String[] args) + { + + /* + * Returns: An array of ISO 3166 two-letter country codes. + */ + String[] countryCodeArray = Locale.getISOCountries(); + + for (String countryCode : countryCodeArray) + { + + Locale obj = new Locale("", countryCode); + + System.out.println("Country Code = " + obj.getCountry() + + ", Country Name = " + obj.getDisplayCountry()); + + } + + } + +} diff --git a/Later/Java_Util_package/Internationalization/Locale/12/LocaleDemo/.classpath b/Later/Java_Util_package/Internationalization/Locale/12/LocaleDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/12/LocaleDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Internationalization/Locale/12/LocaleDemo/.project b/Later/Java_Util_package/Internationalization/Locale/12/LocaleDemo/.project new file mode 100644 index 000000000..941bf265e --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/12/LocaleDemo/.project @@ -0,0 +1,17 @@ + + + LocaleDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Internationalization/Locale/12/LocaleDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Internationalization/Locale/12/LocaleDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/12/LocaleDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Internationalization/Locale/12/LocaleDemo/bin/LocaleDemo.class b/Later/Java_Util_package/Internationalization/Locale/12/LocaleDemo/bin/LocaleDemo.class new file mode 100644 index 000000000..f55c45d9a Binary files /dev/null and b/Later/Java_Util_package/Internationalization/Locale/12/LocaleDemo/bin/LocaleDemo.class differ diff --git a/Later/Java_Util_package/Internationalization/Locale/12/LocaleDemo/src/LocaleDemo.java b/Later/Java_Util_package/Internationalization/Locale/12/LocaleDemo/src/LocaleDemo.java new file mode 100644 index 000000000..0fc8d86be --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/12/LocaleDemo/src/LocaleDemo.java @@ -0,0 +1,29 @@ +import java.util.Locale; + +/** + * + * Get a list of countries, and display the country name in FRENCH. + * + */ +public class LocaleDemo +{ + + public static void main(String[] args) + { + + String[] locales = Locale.getISOCountries(); + + for (String countryCode : locales) + { + + Locale obj = new Locale("", countryCode); + + System.out.println( + "Country Code = " + obj.getCountry() + ", Country Name = " + + obj.getDisplayCountry(Locale.FRENCH)); + + } + + } + +} diff --git a/Later/Java_Util_package/Internationalization/Locale/13/LocaleDemo/.classpath b/Later/Java_Util_package/Internationalization/Locale/13/LocaleDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/13/LocaleDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Internationalization/Locale/13/LocaleDemo/.project b/Later/Java_Util_package/Internationalization/Locale/13/LocaleDemo/.project new file mode 100644 index 000000000..941bf265e --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/13/LocaleDemo/.project @@ -0,0 +1,17 @@ + + + LocaleDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Internationalization/Locale/13/LocaleDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Internationalization/Locale/13/LocaleDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/13/LocaleDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Internationalization/Locale/13/LocaleDemo/bin/LocaleDemo.class b/Later/Java_Util_package/Internationalization/Locale/13/LocaleDemo/bin/LocaleDemo.class new file mode 100644 index 000000000..80b83ad36 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/Locale/13/LocaleDemo/bin/LocaleDemo.class differ diff --git a/Later/Java_Util_package/Internationalization/Locale/13/LocaleDemo/src/LocaleDemo.java b/Later/Java_Util_package/Internationalization/Locale/13/LocaleDemo/src/LocaleDemo.java new file mode 100644 index 000000000..3a469d6d4 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/13/LocaleDemo/src/LocaleDemo.java @@ -0,0 +1,28 @@ +import java.util.Locale; + +/** + * + * Display the country name in own country’s languages. + * + */ +public class LocaleDemo +{ + + public static void main(String[] args) + { + + String[] locales = Locale.getISOCountries(); + + for (String countryCode : locales) + { + + Locale obj = new Locale("", countryCode); + + System.out.println("Country Code = " + obj.getCountry() + + ", Country Name = " + obj.getDisplayCountry()); + + } + + } + +} diff --git a/Later/Java_Util_package/Internationalization/Locale/2.1/LocaleDemo/.classpath b/Later/Java_Util_package/Internationalization/Locale/2.1/LocaleDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/2.1/LocaleDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Internationalization/Locale/2.1/LocaleDemo/.project b/Later/Java_Util_package/Internationalization/Locale/2.1/LocaleDemo/.project new file mode 100644 index 000000000..941bf265e --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/2.1/LocaleDemo/.project @@ -0,0 +1,17 @@ + + + LocaleDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Internationalization/Locale/2.1/LocaleDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Internationalization/Locale/2.1/LocaleDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/2.1/LocaleDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Internationalization/Locale/2.1/LocaleDemo/bin/LocaleDemo.class b/Later/Java_Util_package/Internationalization/Locale/2.1/LocaleDemo/bin/LocaleDemo.class new file mode 100644 index 000000000..e8c851fdd Binary files /dev/null and b/Later/Java_Util_package/Internationalization/Locale/2.1/LocaleDemo/bin/LocaleDemo.class differ diff --git a/Later/Java_Util_package/Internationalization/Locale/2.1/LocaleDemo/src/LocaleDemo.java b/Later/Java_Util_package/Internationalization/Locale/2.1/LocaleDemo/src/LocaleDemo.java new file mode 100644 index 000000000..e27f5ba3b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/2.1/LocaleDemo/src/LocaleDemo.java @@ -0,0 +1,21 @@ +import java.util.Locale; + +public class LocaleDemo +{ + + public static void main(String[] args) + { + /* + * Useful constant for country. + */ + Locale usLocale = Locale.US; + System.out.println(usLocale); + + Locale frenchLocale = Locale.FRENCH; + System.out.println(frenchLocale); + + Locale chineseLocale = Locale.CHINESE; + System.out.println(chineseLocale); + } + +} diff --git a/Later/Java_Util_package/Internationalization/Locale/2.1/Locale_fields.pptx b/Later/Java_Util_package/Internationalization/Locale/2.1/Locale_fields.pptx new file mode 100644 index 000000000..4b8edc67b Binary files /dev/null and b/Later/Java_Util_package/Internationalization/Locale/2.1/Locale_fields.pptx differ diff --git a/Later/Java_Util_package/Internationalization/Locale/2/Locale.pptx b/Later/Java_Util_package/Internationalization/Locale/2/Locale.pptx new file mode 100644 index 000000000..63768bc62 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/Locale/2/Locale.pptx differ diff --git a/Later/Java_Util_package/Internationalization/Locale/2/LocaleDemo/.classpath b/Later/Java_Util_package/Internationalization/Locale/2/LocaleDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/2/LocaleDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Internationalization/Locale/2/LocaleDemo/.project b/Later/Java_Util_package/Internationalization/Locale/2/LocaleDemo/.project new file mode 100644 index 000000000..941bf265e --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/2/LocaleDemo/.project @@ -0,0 +1,17 @@ + + + LocaleDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Internationalization/Locale/2/LocaleDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Internationalization/Locale/2/LocaleDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/2/LocaleDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Internationalization/Locale/2/LocaleDemo/bin/LocaleDemo.class b/Later/Java_Util_package/Internationalization/Locale/2/LocaleDemo/bin/LocaleDemo.class new file mode 100644 index 000000000..dd7387e1b Binary files /dev/null and b/Later/Java_Util_package/Internationalization/Locale/2/LocaleDemo/bin/LocaleDemo.class differ diff --git a/Later/Java_Util_package/Internationalization/Locale/2/LocaleDemo/src/LocaleDemo.java b/Later/Java_Util_package/Internationalization/Locale/2/LocaleDemo/src/LocaleDemo.java new file mode 100644 index 000000000..1599fd2a8 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/2/LocaleDemo/src/LocaleDemo.java @@ -0,0 +1,28 @@ +import java.util.Locale; + +public class LocaleDemo +{ + + public static void main(String[] args) + { + + /* + * Returns: + * + * the default locale for this instance of the Java Virtual + * Machine + */ + Locale locale = Locale.getDefault(); + System.out.println("locale = " + locale); + + System.out.println("DisplayCountry = " + locale.getDisplayCountry()); + System.out.println("DisplayLanguage = " + locale.getDisplayLanguage()); + System.out.println("DisplayName = " + locale.getDisplayName()); + System.out.println("ISO3Country = " + locale.getISO3Country()); + System.out.println("ISO3Language = " + locale.getISO3Language()); + System.out.println("Language = " + locale.getLanguage()); + System.out.println("Country = " + locale.getCountry()); + + } + +} diff --git a/Later/Java_Util_package/Internationalization/Locale/3/LocaleDemo/.classpath b/Later/Java_Util_package/Internationalization/Locale/3/LocaleDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/3/LocaleDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Internationalization/Locale/3/LocaleDemo/.project b/Later/Java_Util_package/Internationalization/Locale/3/LocaleDemo/.project new file mode 100644 index 000000000..941bf265e --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/3/LocaleDemo/.project @@ -0,0 +1,17 @@ + + + LocaleDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Internationalization/Locale/3/LocaleDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Internationalization/Locale/3/LocaleDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/3/LocaleDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Internationalization/Locale/3/LocaleDemo/bin/LocaleDemo1.class b/Later/Java_Util_package/Internationalization/Locale/3/LocaleDemo/bin/LocaleDemo1.class new file mode 100644 index 000000000..bb911f34c Binary files /dev/null and b/Later/Java_Util_package/Internationalization/Locale/3/LocaleDemo/bin/LocaleDemo1.class differ diff --git a/Later/Java_Util_package/Internationalization/Locale/3/LocaleDemo/bin/LocaleDemo2.class b/Later/Java_Util_package/Internationalization/Locale/3/LocaleDemo/bin/LocaleDemo2.class new file mode 100644 index 000000000..01e7477d8 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/Locale/3/LocaleDemo/bin/LocaleDemo2.class differ diff --git a/Later/Java_Util_package/Internationalization/Locale/3/LocaleDemo/src/LocaleDemo1.java b/Later/Java_Util_package/Internationalization/Locale/3/LocaleDemo/src/LocaleDemo1.java new file mode 100644 index 000000000..f23a4f8e1 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/3/LocaleDemo/src/LocaleDemo1.java @@ -0,0 +1,28 @@ +import java.util.Locale; + +public class LocaleDemo1 +{ + + public static void main(String[] args) + { + + /* + * Construct a locale from a language code. This constructor + * normalizes the language value to lowercase. + * + * Parameters: + * + * language - An ISO 639 alpha-2 or alpha-3 language code, or + * a language subtag up to 8 characters in length. See the + * Locale class description about valid language values. + * + */ + Locale enLocale = new Locale("en"); + System.out.println(enLocale); + + Locale frLocale = new Locale("fr"); + System.out.println(frLocale); + + } + +} diff --git a/Later/Java_Util_package/Internationalization/Locale/3/LocaleDemo/src/LocaleDemo2.java b/Later/Java_Util_package/Internationalization/Locale/3/LocaleDemo/src/LocaleDemo2.java new file mode 100644 index 000000000..54f000d37 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/3/LocaleDemo/src/LocaleDemo2.java @@ -0,0 +1,33 @@ +import java.util.Locale; + +public class LocaleDemo2 +{ + + public static void main(String[] args) + { + + /* + * Construct a locale from language and country. This + * constructor normalizes the language value to lowercase and + * the country value to uppercase. + * + * Parameters: + * + * language - An ISO 639 alpha-2 or alpha-3 language code, or + * a language subtag up to 8 characters in length. See the + * Locale class description about valid language values. + * + * country - An ISO 3166 alpha-2 country code or a UN M.49 + * numeric-3 area code. See the Locale class description about + * valid country values. + * + */ + Locale enLocale = new Locale("en", "US"); + System.out.println(enLocale); + + Locale frLocale = new Locale("fr", "FR"); + System.out.println(frLocale); + + } + +} diff --git a/Later/Java_Util_package/Internationalization/Locale/4/LocaleDemo/.classpath b/Later/Java_Util_package/Internationalization/Locale/4/LocaleDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/4/LocaleDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Internationalization/Locale/4/LocaleDemo/.project b/Later/Java_Util_package/Internationalization/Locale/4/LocaleDemo/.project new file mode 100644 index 000000000..941bf265e --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/4/LocaleDemo/.project @@ -0,0 +1,17 @@ + + + LocaleDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Internationalization/Locale/4/LocaleDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Internationalization/Locale/4/LocaleDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/4/LocaleDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Internationalization/Locale/4/LocaleDemo/bin/LocaleDemo1.class b/Later/Java_Util_package/Internationalization/Locale/4/LocaleDemo/bin/LocaleDemo1.class new file mode 100644 index 000000000..bbee4a01e Binary files /dev/null and b/Later/Java_Util_package/Internationalization/Locale/4/LocaleDemo/bin/LocaleDemo1.class differ diff --git a/Later/Java_Util_package/Internationalization/Locale/4/LocaleDemo/bin/LocaleDemo2.class b/Later/Java_Util_package/Internationalization/Locale/4/LocaleDemo/bin/LocaleDemo2.class new file mode 100644 index 000000000..10f5fd61f Binary files /dev/null and b/Later/Java_Util_package/Internationalization/Locale/4/LocaleDemo/bin/LocaleDemo2.class differ diff --git a/Later/Java_Util_package/Internationalization/Locale/4/LocaleDemo/bin/LocaleDemo3.class b/Later/Java_Util_package/Internationalization/Locale/4/LocaleDemo/bin/LocaleDemo3.class new file mode 100644 index 000000000..4364739b8 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/Locale/4/LocaleDemo/bin/LocaleDemo3.class differ diff --git a/Later/Java_Util_package/Internationalization/Locale/4/LocaleDemo/src/LocaleDemo1.java b/Later/Java_Util_package/Internationalization/Locale/4/LocaleDemo/src/LocaleDemo1.java new file mode 100644 index 000000000..b5a2e48e4 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/4/LocaleDemo/src/LocaleDemo1.java @@ -0,0 +1,23 @@ +import java.util.Locale; + +public class LocaleDemo1 +{ + + public static void main(String[] args) + { + /* + * Returns: + * + * An array of installed locales. + */ + + Locale[] localeArray = Locale.getAvailableLocales(); + + for (Locale locale : localeArray) + { + System.out.println(locale); + } + + } + +} diff --git a/Later/Java_Util_package/Internationalization/Locale/4/LocaleDemo/src/LocaleDemo2.java b/Later/Java_Util_package/Internationalization/Locale/4/LocaleDemo/src/LocaleDemo2.java new file mode 100644 index 000000000..7b2dd53ab --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/4/LocaleDemo/src/LocaleDemo2.java @@ -0,0 +1,22 @@ +import java.util.Locale; + +public class LocaleDemo2 +{ + + public static void main(String[] args) + { + /* + * Returns: + * + * An array of ISO 3166 two-letter country codes. + */ + String[] countryCodeArray = Locale.getISOCountries(); + + for (String country : countryCodeArray) + { + System.out.println(country); + } + + } + +} diff --git a/Later/Java_Util_package/Internationalization/Locale/4/LocaleDemo/src/LocaleDemo3.java b/Later/Java_Util_package/Internationalization/Locale/4/LocaleDemo/src/LocaleDemo3.java new file mode 100644 index 000000000..556929759 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/4/LocaleDemo/src/LocaleDemo3.java @@ -0,0 +1,22 @@ +import java.util.Locale; + +public class LocaleDemo3 +{ + + public static void main(String[] args) + { + + /* + * Returns: + * + * An array of ISO 639 two-letter language codes. + */ + String[] languageCodeArray = Locale.getISOLanguages(); + + for (String language : languageCodeArray) + { + System.out.println(language); + } + } + +} diff --git a/Later/Java_Util_package/Internationalization/Locale/5/LocaleDemo/.classpath b/Later/Java_Util_package/Internationalization/Locale/5/LocaleDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/5/LocaleDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Internationalization/Locale/5/LocaleDemo/.project b/Later/Java_Util_package/Internationalization/Locale/5/LocaleDemo/.project new file mode 100644 index 000000000..941bf265e --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/5/LocaleDemo/.project @@ -0,0 +1,17 @@ + + + LocaleDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Internationalization/Locale/5/LocaleDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Internationalization/Locale/5/LocaleDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/5/LocaleDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Internationalization/Locale/5/LocaleDemo/bin/LocaleDemo1.class b/Later/Java_Util_package/Internationalization/Locale/5/LocaleDemo/bin/LocaleDemo1.class new file mode 100644 index 000000000..2c890ce01 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/Locale/5/LocaleDemo/bin/LocaleDemo1.class differ diff --git a/Later/Java_Util_package/Internationalization/Locale/5/LocaleDemo/bin/LocaleDemo2.class b/Later/Java_Util_package/Internationalization/Locale/5/LocaleDemo/bin/LocaleDemo2.class new file mode 100644 index 000000000..10f5fd61f Binary files /dev/null and b/Later/Java_Util_package/Internationalization/Locale/5/LocaleDemo/bin/LocaleDemo2.class differ diff --git a/Later/Java_Util_package/Internationalization/Locale/5/LocaleDemo/bin/LocaleDemo3.class b/Later/Java_Util_package/Internationalization/Locale/5/LocaleDemo/bin/LocaleDemo3.class new file mode 100644 index 000000000..4364739b8 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/Locale/5/LocaleDemo/bin/LocaleDemo3.class differ diff --git a/Later/Java_Util_package/Internationalization/Locale/5/LocaleDemo/src/LocaleDemo.java b/Later/Java_Util_package/Internationalization/Locale/5/LocaleDemo/src/LocaleDemo.java new file mode 100644 index 000000000..722a82ed1 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/5/LocaleDemo/src/LocaleDemo.java @@ -0,0 +1,28 @@ +import java.util.Locale; + +public class LocaleDemo +{ + + public static void main(String[] args) + { + Locale locale = Locale.getDefault(); + + System.out.println("Locale = " + locale); + + Locale frLocale = new Locale("fr", "FR"); + + /* + * Parameters: + * + * newLocale - the new default locale + * + */ + Locale.setDefault(frLocale); + + locale = Locale.getDefault(); + + System.out.println("Locale = " + locale); + + } + +} diff --git a/Later/Java_Util_package/Internationalization/Locale/6/LocaleDemo/.classpath b/Later/Java_Util_package/Internationalization/Locale/6/LocaleDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/6/LocaleDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Internationalization/Locale/6/LocaleDemo/.project b/Later/Java_Util_package/Internationalization/Locale/6/LocaleDemo/.project new file mode 100644 index 000000000..941bf265e --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/6/LocaleDemo/.project @@ -0,0 +1,17 @@ + + + LocaleDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Internationalization/Locale/6/LocaleDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Internationalization/Locale/6/LocaleDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/6/LocaleDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Internationalization/Locale/6/LocaleDemo/bin/LocaleDemo.class b/Later/Java_Util_package/Internationalization/Locale/6/LocaleDemo/bin/LocaleDemo.class new file mode 100644 index 000000000..34a53d776 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/Locale/6/LocaleDemo/bin/LocaleDemo.class differ diff --git a/Later/Java_Util_package/Internationalization/Locale/6/LocaleDemo/src/LocaleDemo.java b/Later/Java_Util_package/Internationalization/Locale/6/LocaleDemo/src/LocaleDemo.java new file mode 100644 index 000000000..62012c4e0 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/6/LocaleDemo/src/LocaleDemo.java @@ -0,0 +1,32 @@ +import java.util.Locale; + +public class LocaleDemo +{ + + public static void main(String[] args) + { + Locale locale = new Locale("en", "US", "WIN"); + + System.out.println("Locale = " + locale); + + /* + * Returns: + * + * The variant code, or the empty string if none is defined. + * + */ + String variant = locale.getVariant(); + System.out.println("variant = " + variant); + + /* + * Returns: + * + * The name of the display variant code appropriate to the + * locale. + */ + String displayVariant = locale.getDisplayVariant(); + System.out.println("displayVariant = " + displayVariant); + + } + +} diff --git a/Later/Java_Util_package/Internationalization/Locale/7/LocaleDemo/.classpath b/Later/Java_Util_package/Internationalization/Locale/7/LocaleDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/7/LocaleDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Internationalization/Locale/7/LocaleDemo/.project b/Later/Java_Util_package/Internationalization/Locale/7/LocaleDemo/.project new file mode 100644 index 000000000..941bf265e --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/7/LocaleDemo/.project @@ -0,0 +1,17 @@ + + + LocaleDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Internationalization/Locale/7/LocaleDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Internationalization/Locale/7/LocaleDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/7/LocaleDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Internationalization/Locale/7/LocaleDemo/bin/LocaleDemo1.class b/Later/Java_Util_package/Internationalization/Locale/7/LocaleDemo/bin/LocaleDemo1.class new file mode 100644 index 000000000..8b4d0af26 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/Locale/7/LocaleDemo/bin/LocaleDemo1.class differ diff --git a/Later/Java_Util_package/Internationalization/Locale/7/LocaleDemo/bin/LocaleDemo2.class b/Later/Java_Util_package/Internationalization/Locale/7/LocaleDemo/bin/LocaleDemo2.class new file mode 100644 index 000000000..45f7b46b6 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/Locale/7/LocaleDemo/bin/LocaleDemo2.class differ diff --git a/Later/Java_Util_package/Internationalization/Locale/7/LocaleDemo/bin/LocaleDemo3.class b/Later/Java_Util_package/Internationalization/Locale/7/LocaleDemo/bin/LocaleDemo3.class new file mode 100644 index 000000000..1f24fd636 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/Locale/7/LocaleDemo/bin/LocaleDemo3.class differ diff --git a/Later/Java_Util_package/Internationalization/Locale/7/LocaleDemo/src/LocaleDemo1.java b/Later/Java_Util_package/Internationalization/Locale/7/LocaleDemo/src/LocaleDemo1.java new file mode 100644 index 000000000..616e0c58f --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/7/LocaleDemo/src/LocaleDemo1.java @@ -0,0 +1,30 @@ +import java.util.Locale; + +public class LocaleDemo1 +{ + + public static void main(String[] args) + { + Locale locale = new Locale("en", "US"); + + String displayName = locale.getDisplayCountry(); + System.out.println("Display Country = " + displayName); + + Locale frLocale = new Locale("fr", "FR"); + + /* + * Parameters: + * + * inLocale - The locale for which to retrieve the display + * country. + * + * Returns: + * + * The name of the country appropriate to the given locale. + */ + displayName = locale.getDisplayCountry(frLocale); + System.out.println("Display Country = " + displayName); + + } + +} diff --git a/Later/Java_Util_package/Internationalization/Locale/7/LocaleDemo/src/LocaleDemo2.java b/Later/Java_Util_package/Internationalization/Locale/7/LocaleDemo/src/LocaleDemo2.java new file mode 100644 index 000000000..c09b8665a --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/7/LocaleDemo/src/LocaleDemo2.java @@ -0,0 +1,32 @@ +import java.util.Locale; + +public class LocaleDemo2 +{ + + public static void main(String[] args) + { + Locale locale = new Locale("en", "US"); + + String displayName = locale.getDisplayLanguage(); + System.out.println("Display Language = " + displayName); + + Locale frLocale = new Locale("fr", "FR"); + + /* + * Parameters: + * + * inLocale - The locale for which to retrieve the display + * language. + * + * Returns: + * + * The name of the display language appropriate to the given + * locale. + * + */ + displayName = locale.getDisplayLanguage(frLocale); + System.out.println("Display Language = " + displayName); + + } + +} diff --git a/Later/Java_Util_package/Internationalization/Locale/7/LocaleDemo/src/LocaleDemo3.java b/Later/Java_Util_package/Internationalization/Locale/7/LocaleDemo/src/LocaleDemo3.java new file mode 100644 index 000000000..02d502e15 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/7/LocaleDemo/src/LocaleDemo3.java @@ -0,0 +1,32 @@ +import java.util.Locale; + +public class LocaleDemo3 +{ + + public static void main(String[] args) + { + Locale locale = new Locale("en", "US"); + + String displayName = locale.getDisplayName(); + System.out.println("Display Name = " + displayName); + + Locale frLocale = new Locale("fr", "FR"); + + /* + * Parameters: + * + * inLocale - The locale for which to retrieve the display + * name. + * + * Returns: + * + * The name of the locale appropriate to display. + * + * + */ + displayName = locale.getDisplayName(frLocale); + System.out.println("Display Name = " + displayName); + + } + +} diff --git a/Later/Java_Util_package/Internationalization/Locale/8/LocaleDemo/.classpath b/Later/Java_Util_package/Internationalization/Locale/8/LocaleDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/8/LocaleDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Internationalization/Locale/8/LocaleDemo/.project b/Later/Java_Util_package/Internationalization/Locale/8/LocaleDemo/.project new file mode 100644 index 000000000..941bf265e --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/8/LocaleDemo/.project @@ -0,0 +1,17 @@ + + + LocaleDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Internationalization/Locale/8/LocaleDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Internationalization/Locale/8/LocaleDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/8/LocaleDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Internationalization/Locale/8/LocaleDemo/bin/LocaleDemo1.class b/Later/Java_Util_package/Internationalization/Locale/8/LocaleDemo/bin/LocaleDemo1.class new file mode 100644 index 000000000..aee0c911d Binary files /dev/null and b/Later/Java_Util_package/Internationalization/Locale/8/LocaleDemo/bin/LocaleDemo1.class differ diff --git a/Later/Java_Util_package/Internationalization/Locale/8/LocaleDemo/src/LocaleDemo.java b/Later/Java_Util_package/Internationalization/Locale/8/LocaleDemo/src/LocaleDemo.java new file mode 100644 index 000000000..a2708e8de --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/8/LocaleDemo/src/LocaleDemo.java @@ -0,0 +1,32 @@ +import java.util.Locale; + +public class LocaleDemo1 +{ + + public static void main(String[] args) + { + Locale locale = new Locale("en", "US", "WIN"); + + String displayVariant = locale.getDisplayVariant(); + System.out.println("Display Variant = " + displayVariant); + + Locale frLocale = new Locale("fr", "FR"); + + /* + * Parameters: + * + * inLocale - The locale for which to retrieve the display + * variant code. + * + * Returns: + * + * The name of the display variant code appropriate to the + * given locale. + * + */ + displayVariant = locale.getDisplayVariant(frLocale); + System.out.println("Display Variant = " + displayVariant); + + } + +} diff --git a/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/.classpath b/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/.project b/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/.project new file mode 100644 index 000000000..941bf265e --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/.project @@ -0,0 +1,17 @@ + + + LocaleDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/bin/LocaleDemo1.class b/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/bin/LocaleDemo1.class new file mode 100644 index 000000000..0685db047 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/bin/LocaleDemo1.class differ diff --git a/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/bin/LocaleDemo2.class b/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/bin/LocaleDemo2.class new file mode 100644 index 000000000..cdaad9bc6 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/bin/LocaleDemo2.class differ diff --git a/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/bin/LocaleDemo3.class b/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/bin/LocaleDemo3.class new file mode 100644 index 000000000..6f7a50750 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/bin/LocaleDemo3.class differ diff --git a/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/bin/LocaleDemo4.class b/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/bin/LocaleDemo4.class new file mode 100644 index 000000000..6840d9a2a Binary files /dev/null and b/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/bin/LocaleDemo4.class differ diff --git a/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/src/LocaleDemo1.java b/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/src/LocaleDemo1.java new file mode 100644 index 000000000..d099883ea --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/src/LocaleDemo1.java @@ -0,0 +1,28 @@ +import java.util.Locale; + +public class LocaleDemo1 +{ + + public static void main(String[] args) + { + + /* + * Creates Locale objects for the English language in the + * United States. + */ + Locale usLocale = new Locale.Builder().setLanguage("en").setRegion("US") + .build(); + + System.out.println(usLocale); + + /* + * Creates Locale objects for the English language in the + * Great Britain: + */ + Locale gbLocale = new Locale.Builder().setLanguage("en").setRegion("GB") + .build(); + + System.out.println(gbLocale); + } + +} diff --git a/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/src/LocaleDemo2.java b/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/src/LocaleDemo2.java new file mode 100644 index 000000000..0acc74dc2 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/src/LocaleDemo2.java @@ -0,0 +1,16 @@ +import java.util.Locale; + +public class LocaleDemo2 +{ + + public static void main(String[] args) + { + + Locale usLocale = new Locale("en", "US"); + System.out.println(usLocale); + + Locale frLocale = new Locale("fr", "FR"); + System.out.println(frLocale); + } + +} diff --git a/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/src/LocaleDemo3.java b/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/src/LocaleDemo3.java new file mode 100644 index 000000000..6e3845321 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/src/LocaleDemo3.java @@ -0,0 +1,15 @@ +import java.util.Locale; + +public class LocaleDemo3 +{ + + public static void main(String[] args) + { + Locale usLocale = Locale.forLanguageTag("en-US"); + System.out.println(usLocale); + + Locale frLocale = Locale.forLanguageTag("fr_FR"); + System.out.println(frLocale); + } + +} diff --git a/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/src/LocaleDemo4.java b/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/src/LocaleDemo4.java new file mode 100644 index 000000000..58eac1aa7 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/Locale/9/LocaleDemo/src/LocaleDemo4.java @@ -0,0 +1,15 @@ +import java.util.Locale; + +public class LocaleDemo4 +{ + + public static void main(String[] args) + { + Locale japanLocale = Locale.JAPAN; + System.out.println(japanLocale); + + Locale canadaFrenchLocale = Locale.CANADA_FRENCH; + System.out.println(canadaFrenchLocale); + } + +} diff --git a/Later/Java_Util_package/Internationalization/Locale/9/Locale_Creation.pptx b/Later/Java_Util_package/Internationalization/Locale/9/Locale_Creation.pptx new file mode 100644 index 000000000..fdd959a72 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/Locale/9/Locale_Creation.pptx differ diff --git a/Later/Java_Util_package/Internationalization/PropertyResourceBundle/1/PropertyResourceBundle.pptx b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/1/PropertyResourceBundle.pptx new file mode 100644 index 000000000..fe068f45c Binary files /dev/null and b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/1/PropertyResourceBundle.pptx differ diff --git a/Later/Java_Util_package/Internationalization/PropertyResourceBundle/1/PropertyResourceBundleDemo/.classpath b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/1/PropertyResourceBundleDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/1/PropertyResourceBundleDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Internationalization/PropertyResourceBundle/1/PropertyResourceBundleDemo/.project b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/1/PropertyResourceBundleDemo/.project new file mode 100644 index 000000000..a1facddf6 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/1/PropertyResourceBundleDemo/.project @@ -0,0 +1,17 @@ + + + PropertyResourceBundleDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Internationalization/PropertyResourceBundle/1/PropertyResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/1/PropertyResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/1/PropertyResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Internationalization/PropertyResourceBundle/1/PropertyResourceBundleDemo/bin/MessageBundle_en_US.properties b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/1/PropertyResourceBundleDemo/bin/MessageBundle_en_US.properties new file mode 100644 index 000000000..1c057abd9 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/1/PropertyResourceBundleDemo/bin/MessageBundle_en_US.properties @@ -0,0 +1,2 @@ +greeting=Hello, how are you? +welcome=Welcome to India. \ No newline at end of file diff --git a/Later/Java_Util_package/Internationalization/PropertyResourceBundle/1/PropertyResourceBundleDemo/bin/PropertyResourceBundleDemo.class b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/1/PropertyResourceBundleDemo/bin/PropertyResourceBundleDemo.class new file mode 100644 index 000000000..efcc51742 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/1/PropertyResourceBundleDemo/bin/PropertyResourceBundleDemo.class differ diff --git a/Later/Java_Util_package/Internationalization/PropertyResourceBundle/1/PropertyResourceBundleDemo/src/MessageBundle_en_US.properties b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/1/PropertyResourceBundleDemo/src/MessageBundle_en_US.properties new file mode 100644 index 000000000..1c057abd9 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/1/PropertyResourceBundleDemo/src/MessageBundle_en_US.properties @@ -0,0 +1,2 @@ +greeting=Hello, how are you? +welcome=Welcome to India. \ No newline at end of file diff --git a/Later/Java_Util_package/Internationalization/PropertyResourceBundle/1/PropertyResourceBundleDemo/src/PropertyResourceBundleDemo.java b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/1/PropertyResourceBundleDemo/src/PropertyResourceBundleDemo.java new file mode 100644 index 000000000..2d8c21254 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/1/PropertyResourceBundleDemo/src/PropertyResourceBundleDemo.java @@ -0,0 +1,44 @@ +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.util.Enumeration; +import java.util.PropertyResourceBundle; + +public class PropertyResourceBundleDemo +{ + + public static void main(String[] args) + { + + File file = new File( + "D:\\eclipse\\workspace\\PropertyResourceBundleDemo\\src\\MessageBundle_en_US.properties"); + + try (InputStream inputStream = new FileInputStream(file)) + { + + PropertyResourceBundle bundle = new PropertyResourceBundle( + inputStream); + + Enumeration keys = bundle.getKeys(); + + while (keys.hasMoreElements()) + { + String key = keys.nextElement(); + String value = bundle.getString(key); + System.out.println(key+" = "+value); + } + } + catch (FileNotFoundException e) + { + e.printStackTrace(); + } + catch (IOException e) + { + e.printStackTrace(); + } + + } + +} diff --git a/Later/Java_Util_package/Internationalization/PropertyResourceBundle/2/PropertyResourceBundleDemo/.classpath b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/2/PropertyResourceBundleDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/2/PropertyResourceBundleDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Internationalization/PropertyResourceBundle/2/PropertyResourceBundleDemo/.project b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/2/PropertyResourceBundleDemo/.project new file mode 100644 index 000000000..a1facddf6 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/2/PropertyResourceBundleDemo/.project @@ -0,0 +1,17 @@ + + + PropertyResourceBundleDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Internationalization/PropertyResourceBundle/2/PropertyResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/2/PropertyResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/2/PropertyResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Internationalization/PropertyResourceBundle/2/PropertyResourceBundleDemo/bin/MessageBundle_en_US.properties b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/2/PropertyResourceBundleDemo/bin/MessageBundle_en_US.properties new file mode 100644 index 000000000..1c057abd9 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/2/PropertyResourceBundleDemo/bin/MessageBundle_en_US.properties @@ -0,0 +1,2 @@ +greeting=Hello, how are you? +welcome=Welcome to India. \ No newline at end of file diff --git a/Later/Java_Util_package/Internationalization/PropertyResourceBundle/2/PropertyResourceBundleDemo/bin/PropertyResourceBundleDemo.class b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/2/PropertyResourceBundleDemo/bin/PropertyResourceBundleDemo.class new file mode 100644 index 000000000..31b43c658 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/2/PropertyResourceBundleDemo/bin/PropertyResourceBundleDemo.class differ diff --git a/Later/Java_Util_package/Internationalization/PropertyResourceBundle/2/PropertyResourceBundleDemo/src/MessageBundle_en_US.properties b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/2/PropertyResourceBundleDemo/src/MessageBundle_en_US.properties new file mode 100644 index 000000000..1c057abd9 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/2/PropertyResourceBundleDemo/src/MessageBundle_en_US.properties @@ -0,0 +1,2 @@ +greeting=Hello, how are you? +welcome=Welcome to India. \ No newline at end of file diff --git a/Later/Java_Util_package/Internationalization/PropertyResourceBundle/2/PropertyResourceBundleDemo/src/PropertyResourceBundleDemo.java b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/2/PropertyResourceBundleDemo/src/PropertyResourceBundleDemo.java new file mode 100644 index 000000000..b4f9826f3 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/2/PropertyResourceBundleDemo/src/PropertyResourceBundleDemo.java @@ -0,0 +1,50 @@ +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.util.PropertyResourceBundle; +import java.util.Set; + +public class PropertyResourceBundleDemo +{ + + public static void main(String[] args) + { + + File file = new File( + "D:\\eclipse\\workspace\\PropertyResourceBundleDemo\\src\\MessageBundle_en_US.properties"); + + try (InputStream inputStream = new FileInputStream(file)) + { + + PropertyResourceBundle bundle = new PropertyResourceBundle( + inputStream); + + /* + * Returns: + * + * a Set of all keys contained in this ResourceBundle and + * its parent bundles. + * + */ + Set keySet = bundle.keySet(); + + for (String key : keySet) + { + String value = bundle.getString(key); + System.out.println(key + " = " + value); + } + } + catch (FileNotFoundException e) + { + e.printStackTrace(); + } + catch (IOException e) + { + e.printStackTrace(); + } + + } + +} diff --git a/Later/Java_Util_package/Internationalization/PropertyResourceBundle/3/PropertyResourceBundleDemo/.classpath b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/3/PropertyResourceBundleDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/3/PropertyResourceBundleDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Internationalization/PropertyResourceBundle/3/PropertyResourceBundleDemo/.project b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/3/PropertyResourceBundleDemo/.project new file mode 100644 index 000000000..a1facddf6 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/3/PropertyResourceBundleDemo/.project @@ -0,0 +1,17 @@ + + + PropertyResourceBundleDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Internationalization/PropertyResourceBundle/3/PropertyResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/3/PropertyResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/3/PropertyResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Internationalization/PropertyResourceBundle/3/PropertyResourceBundleDemo/bin/MessageBundle_en_US.properties b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/3/PropertyResourceBundleDemo/bin/MessageBundle_en_US.properties new file mode 100644 index 000000000..1c057abd9 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/3/PropertyResourceBundleDemo/bin/MessageBundle_en_US.properties @@ -0,0 +1,2 @@ +greeting=Hello, how are you? +welcome=Welcome to India. \ No newline at end of file diff --git a/Later/Java_Util_package/Internationalization/PropertyResourceBundle/3/PropertyResourceBundleDemo/bin/PropertyResourceBundleDemo.class b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/3/PropertyResourceBundleDemo/bin/PropertyResourceBundleDemo.class new file mode 100644 index 000000000..2cd7fba38 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/3/PropertyResourceBundleDemo/bin/PropertyResourceBundleDemo.class differ diff --git a/Later/Java_Util_package/Internationalization/PropertyResourceBundle/3/PropertyResourceBundleDemo/src/MessageBundle_en_US.properties b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/3/PropertyResourceBundleDemo/src/MessageBundle_en_US.properties new file mode 100644 index 000000000..1c057abd9 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/3/PropertyResourceBundleDemo/src/MessageBundle_en_US.properties @@ -0,0 +1,2 @@ +greeting=Hello, how are you? +welcome=Welcome to India. \ No newline at end of file diff --git a/Later/Java_Util_package/Internationalization/PropertyResourceBundle/3/PropertyResourceBundleDemo/src/PropertyResourceBundleDemo.java b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/3/PropertyResourceBundleDemo/src/PropertyResourceBundleDemo.java new file mode 100644 index 000000000..35874d81b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/PropertyResourceBundle/3/PropertyResourceBundleDemo/src/PropertyResourceBundleDemo.java @@ -0,0 +1,50 @@ +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.util.PropertyResourceBundle; +import java.util.Set; + +public class PropertyResourceBundleDemo +{ + + public static void main(String[] args) + { + + File file = new File( + "D:\\eclipse\\workspace\\PropertyResourceBundleDemo\\src\\MessageBundle_en_US.properties"); + + try (InputStream inputStream = new FileInputStream(file)) + { + + PropertyResourceBundle bundle = new PropertyResourceBundle( + inputStream); + /* + * Parameters: + * + * key - the key for the desired object + * + * Returns: + * + * the object for the given key, or null + */ + Object res1 = bundle.handleGetObject("greeting"); + Object res2 = bundle.handleGetObject("welcome"); + + // Print resource contents + System.out.println("[Resource1] " + res1); + System.out.println("[Resource2] " + res2); + } + catch (FileNotFoundException e) + { + e.printStackTrace(); + } + catch (IOException e) + { + e.printStackTrace(); + } + + } + +} diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/1/ResourceBundle.pptx b/Later/Java_Util_package/Internationalization/ResourceBundle/1/ResourceBundle.pptx new file mode 100644 index 000000000..9bf1ceeeb Binary files /dev/null and b/Later/Java_Util_package/Internationalization/ResourceBundle/1/ResourceBundle.pptx differ diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/1/ResourceBundleDemo/.classpath b/Later/Java_Util_package/Internationalization/ResourceBundle/1/ResourceBundleDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/1/ResourceBundleDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/1/ResourceBundleDemo/.project b/Later/Java_Util_package/Internationalization/ResourceBundle/1/ResourceBundleDemo/.project new file mode 100644 index 000000000..1b5459b96 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/1/ResourceBundleDemo/.project @@ -0,0 +1,17 @@ + + + ResourceBundleDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/1/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Internationalization/ResourceBundle/1/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/1/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/1/ResourceBundleDemo/bin/InternationalizationDemo.class b/Later/Java_Util_package/Internationalization/ResourceBundle/1/ResourceBundleDemo/bin/InternationalizationDemo.class new file mode 100644 index 000000000..1cabe36e1 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/ResourceBundle/1/ResourceBundleDemo/bin/InternationalizationDemo.class differ diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/1/ResourceBundleDemo/bin/MessageBundle_en_US.properties b/Later/Java_Util_package/Internationalization/ResourceBundle/1/ResourceBundleDemo/bin/MessageBundle_en_US.properties new file mode 100644 index 000000000..f5504d58a --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/1/ResourceBundleDemo/bin/MessageBundle_en_US.properties @@ -0,0 +1 @@ +greeting=Hello, how are you? \ No newline at end of file diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/1/ResourceBundleDemo/bin/MessageBundle_fr_FR.properties b/Later/Java_Util_package/Internationalization/ResourceBundle/1/ResourceBundleDemo/bin/MessageBundle_fr_FR.properties new file mode 100644 index 000000000..51b9052ed --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/1/ResourceBundleDemo/bin/MessageBundle_fr_FR.properties @@ -0,0 +1 @@ +greeting=Halo, apa kabar? \ No newline at end of file diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/1/ResourceBundleDemo/src/InternationalizationDemo.java b/Later/Java_Util_package/Internationalization/ResourceBundle/1/ResourceBundleDemo/src/InternationalizationDemo.java new file mode 100644 index 000000000..24c617e6c --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/1/ResourceBundleDemo/src/InternationalizationDemo.java @@ -0,0 +1,70 @@ +import java.util.Locale; +import java.util.ResourceBundle; +import java.util.Scanner; + +/** + * If Application supports US Country and English language, then read + * message from MessageBundle_en_US.properties file. + * + * If Application supports France country and French language, then + * read message from MessageBundle_fr_FR.properties file. + */ +public class InternationalizationDemo +{ + + public static void main(String[] args) + { + Scanner sc = new Scanner(System.in); + + System.out.println("Enter Language code:"); + String languageCode = sc.next(); + + System.out.println("Enter Country code:"); + String countryCode = sc.next(); + + sc.close(); + + if (countryCode.equals("US") && languageCode.equals("en")) + { + /* + * Gets a resource bundle using the specified base name + * and locale + * + * Parameters: + * + * baseName - the base name of the resource bundle, a + * fully qualified class name + * + * locale - the locale for which a resource bundle is + * desired + * + * Returns: + * + * a resource bundle for the given base name and locale + * + */ + ResourceBundle bundle = ResourceBundle.getBundle("MessageBundle", + Locale.US); + + System.out.println("Message in " + Locale.US + " = " + + bundle.getString("greeting")); + } + else if (countryCode.equals("FR") && languageCode.equals("fr")) + { + ResourceBundle bundle = ResourceBundle.getBundle("MessageBundle", + Locale.US); + Locale.setDefault(new Locale("fr", "FR")); + + bundle = ResourceBundle.getBundle("MessageBundle"); + System.out.println("Message in " + Locale.getDefault() + " = " + + bundle.getString("greeting")); + } + else + { + System.out.println( + "Please enter proper countryCode and languageCode."); + } + + } + +} diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/1/ResourceBundleDemo/src/MessageBundle_en_US.properties b/Later/Java_Util_package/Internationalization/ResourceBundle/1/ResourceBundleDemo/src/MessageBundle_en_US.properties new file mode 100644 index 000000000..f5504d58a --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/1/ResourceBundleDemo/src/MessageBundle_en_US.properties @@ -0,0 +1 @@ +greeting=Hello, how are you? \ No newline at end of file diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/1/ResourceBundleDemo/src/MessageBundle_fr_FR.properties b/Later/Java_Util_package/Internationalization/ResourceBundle/1/ResourceBundleDemo/src/MessageBundle_fr_FR.properties new file mode 100644 index 000000000..51b9052ed --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/1/ResourceBundleDemo/src/MessageBundle_fr_FR.properties @@ -0,0 +1 @@ +greeting=Halo, apa kabar? \ No newline at end of file diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/10/ResourceBundleDemo/.classpath b/Later/Java_Util_package/Internationalization/ResourceBundle/10/ResourceBundleDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/10/ResourceBundleDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/10/ResourceBundleDemo/.project b/Later/Java_Util_package/Internationalization/ResourceBundle/10/ResourceBundleDemo/.project new file mode 100644 index 000000000..1b5459b96 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/10/ResourceBundleDemo/.project @@ -0,0 +1,17 @@ + + + ResourceBundleDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/10/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Internationalization/ResourceBundle/10/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/10/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/10/ResourceBundleDemo/bin/MessageBundle.class b/Later/Java_Util_package/Internationalization/ResourceBundle/10/ResourceBundleDemo/bin/MessageBundle.class new file mode 100644 index 000000000..17cedc43e Binary files /dev/null and b/Later/Java_Util_package/Internationalization/ResourceBundle/10/ResourceBundleDemo/bin/MessageBundle.class differ diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/10/ResourceBundleDemo/bin/ResourceBundleDemo.class b/Later/Java_Util_package/Internationalization/ResourceBundle/10/ResourceBundleDemo/bin/ResourceBundleDemo.class new file mode 100644 index 000000000..aaa802900 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/ResourceBundle/10/ResourceBundleDemo/bin/ResourceBundleDemo.class differ diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/10/ResourceBundleDemo/src/MessageBundle.java b/Later/Java_Util_package/Internationalization/ResourceBundle/10/ResourceBundleDemo/src/MessageBundle.java new file mode 100644 index 000000000..62316f2e2 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/10/ResourceBundleDemo/src/MessageBundle.java @@ -0,0 +1,43 @@ +import java.util.Enumeration; +import java.util.ResourceBundle; +import java.util.StringTokenizer; + +public class MessageBundle extends ResourceBundle +{ + private String keys = "Hello Goodbye"; + + /* + * Gets an object for the given key from this resource bundle. + * Returns null if this resource bundle does not contain an object + * for the given key. + * + * Parameters: + * + * key - the key for the desired object + * + * Returns: the object for the given key, or null + * + */ + @Override + public Object handleGetObject(String key) + { + if (key.equals("Hello")) + { + return "Hello Peter"; + } + if (key.equals("Goodbye")) + { + return "Goodbye Steve"; + } + + return null; + } + + @Override + public Enumeration getKeys() + { + StringTokenizer keyTokenizer = new StringTokenizer(keys); + + return keyTokenizer; + } +} diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/10/ResourceBundleDemo/src/ResourceBundleDemo.java b/Later/Java_Util_package/Internationalization/ResourceBundle/10/ResourceBundleDemo/src/ResourceBundleDemo.java new file mode 100644 index 000000000..b8e896e17 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/10/ResourceBundleDemo/src/ResourceBundleDemo.java @@ -0,0 +1,29 @@ +import java.util.Enumeration; +import java.util.ResourceBundle; + +public class ResourceBundleDemo +{ + + public static void main(String[] args) + { + + ResourceBundle rb = ResourceBundle.getBundle("MessageBundle"); + + System.out.println(rb.getString("Hello")); + System.out.println(rb.getString("Goodbye")); + + Enumeration enumeration = rb.getKeys(); + + /* + * Print all the keys and corresponding values + */ + while (enumeration.hasMoreElements()) + { + Object key = enumeration.nextElement(); + Object value = rb.getObject(key.toString()); + System.out.println(key+" = "+value); + } + + } + +} diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/11/ResourceBundleDemo/.classpath b/Later/Java_Util_package/Internationalization/ResourceBundle/11/ResourceBundleDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/11/ResourceBundleDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/11/ResourceBundleDemo/.project b/Later/Java_Util_package/Internationalization/ResourceBundle/11/ResourceBundleDemo/.project new file mode 100644 index 000000000..1b5459b96 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/11/ResourceBundleDemo/.project @@ -0,0 +1,17 @@ + + + ResourceBundleDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/11/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Internationalization/ResourceBundle/11/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/11/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/11/ResourceBundleDemo/bin/MessageBundle_en_US.class b/Later/Java_Util_package/Internationalization/ResourceBundle/11/ResourceBundleDemo/bin/MessageBundle_en_US.class new file mode 100644 index 000000000..52a977d18 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/ResourceBundle/11/ResourceBundleDemo/bin/MessageBundle_en_US.class differ diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/11/ResourceBundleDemo/bin/MessageBundle_fr_FR.class b/Later/Java_Util_package/Internationalization/ResourceBundle/11/ResourceBundleDemo/bin/MessageBundle_fr_FR.class new file mode 100644 index 000000000..bb781e635 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/ResourceBundle/11/ResourceBundleDemo/bin/MessageBundle_fr_FR.class differ diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/11/ResourceBundleDemo/bin/ResourceBundleDemo.class b/Later/Java_Util_package/Internationalization/ResourceBundle/11/ResourceBundleDemo/bin/ResourceBundleDemo.class new file mode 100644 index 000000000..3a05fd471 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/ResourceBundle/11/ResourceBundleDemo/bin/ResourceBundleDemo.class differ diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/11/ResourceBundleDemo/src/MessageBundle_en_US.java b/Later/Java_Util_package/Internationalization/ResourceBundle/11/ResourceBundleDemo/src/MessageBundle_en_US.java new file mode 100644 index 000000000..7eb3bb96d --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/11/ResourceBundleDemo/src/MessageBundle_en_US.java @@ -0,0 +1,43 @@ +import java.util.Enumeration; +import java.util.ResourceBundle; +import java.util.StringTokenizer; + +public class MessageBundle_en_US extends ResourceBundle +{ + private String keys = "Hello Goodbye"; + + /* + * Gets an object for the given key from this resource bundle. + * Returns null if this resource bundle does not contain an object + * for the given key. + * + * Parameters: + * + * key - the key for the desired object + * + * Returns: the object for the given key, or null + * + */ + @Override + public Object handleGetObject(String key) + { + if (key.equals("Hello")) + { + return "Hello Peter"; + } + if (key.equals("Goodbye")) + { + return "Goodbye Steve"; + } + + return null; + } + + @Override + public Enumeration getKeys() + { + StringTokenizer keyTokenizer = new StringTokenizer(keys); + + return keyTokenizer; + } +} diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/11/ResourceBundleDemo/src/MessageBundle_fr_FR.java b/Later/Java_Util_package/Internationalization/ResourceBundle/11/ResourceBundleDemo/src/MessageBundle_fr_FR.java new file mode 100644 index 000000000..fa2ea0af0 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/11/ResourceBundleDemo/src/MessageBundle_fr_FR.java @@ -0,0 +1,43 @@ +import java.util.Enumeration; +import java.util.ResourceBundle; +import java.util.StringTokenizer; + +public class MessageBundle_fr_FR extends ResourceBundle +{ + private String keys = "Hello Goodbye"; + + /* + * Gets an object for the given key from this resource bundle. + * Returns null if this resource bundle does not contain an object + * for the given key. + * + * Parameters: + * + * key - the key for the desired object + * + * Returns: the object for the given key, or null + * + */ + @Override + public Object handleGetObject(String key) + { + if (key.equals("Hello")) + { + return "Bonjour Peter"; + } + if (key.equals("Goodbye")) + { + return "Au revoir Steve"; + } + + return null; + } + + @Override + public Enumeration getKeys() + { + StringTokenizer keyTokenizer = new StringTokenizer(keys); + + return keyTokenizer; + } +} diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/11/ResourceBundleDemo/src/ResourceBundleDemo.java b/Later/Java_Util_package/Internationalization/ResourceBundle/11/ResourceBundleDemo/src/ResourceBundleDemo.java new file mode 100644 index 000000000..a53b28a6e --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/11/ResourceBundleDemo/src/ResourceBundleDemo.java @@ -0,0 +1,26 @@ +import java.util.Locale; +import java.util.ResourceBundle; + +public class ResourceBundleDemo +{ + + public static void main(String[] args) + { + + Locale usLocale = new Locale("en", "US"); + ResourceBundle rb = ResourceBundle.getBundle("MessageBundle", usLocale); + + System.out.println(rb.getString("Hello")); + System.out.println(rb.getString("Goodbye")); + + Locale frenchLocale = new Locale("fr", "FR"); + rb = ResourceBundle.getBundle("MessageBundle", frenchLocale); + + System.out.println(); + + System.out.println(rb.getString("Hello")); + System.out.println(rb.getString("Goodbye")); + + } + +} diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/2/ResourceBundleDemo/.classpath b/Later/Java_Util_package/Internationalization/ResourceBundle/2/ResourceBundleDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/2/ResourceBundleDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/2/ResourceBundleDemo/.project b/Later/Java_Util_package/Internationalization/ResourceBundle/2/ResourceBundleDemo/.project new file mode 100644 index 000000000..1b5459b96 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/2/ResourceBundleDemo/.project @@ -0,0 +1,17 @@ + + + ResourceBundleDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/2/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Internationalization/ResourceBundle/2/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/2/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/2/ResourceBundleDemo/bin/MessageBundle_en_US.properties b/Later/Java_Util_package/Internationalization/ResourceBundle/2/ResourceBundleDemo/bin/MessageBundle_en_US.properties new file mode 100644 index 000000000..f5504d58a --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/2/ResourceBundleDemo/bin/MessageBundle_en_US.properties @@ -0,0 +1 @@ +greeting=Hello, how are you? \ No newline at end of file diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/2/ResourceBundleDemo/bin/MessageBundle_fr_FR.properties b/Later/Java_Util_package/Internationalization/ResourceBundle/2/ResourceBundleDemo/bin/MessageBundle_fr_FR.properties new file mode 100644 index 000000000..51b9052ed --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/2/ResourceBundleDemo/bin/MessageBundle_fr_FR.properties @@ -0,0 +1 @@ +greeting=Halo, apa kabar? \ No newline at end of file diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/2/ResourceBundleDemo/bin/ResourceBundleDemo.class b/Later/Java_Util_package/Internationalization/ResourceBundle/2/ResourceBundleDemo/bin/ResourceBundleDemo.class new file mode 100644 index 000000000..63ed3aeee Binary files /dev/null and b/Later/Java_Util_package/Internationalization/ResourceBundle/2/ResourceBundleDemo/bin/ResourceBundleDemo.class differ diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/2/ResourceBundleDemo/src/MessageBundle_en_US.properties b/Later/Java_Util_package/Internationalization/ResourceBundle/2/ResourceBundleDemo/src/MessageBundle_en_US.properties new file mode 100644 index 000000000..f5504d58a --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/2/ResourceBundleDemo/src/MessageBundle_en_US.properties @@ -0,0 +1 @@ +greeting=Hello, how are you? \ No newline at end of file diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/2/ResourceBundleDemo/src/MessageBundle_fr_FR.properties b/Later/Java_Util_package/Internationalization/ResourceBundle/2/ResourceBundleDemo/src/MessageBundle_fr_FR.properties new file mode 100644 index 000000000..51b9052ed --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/2/ResourceBundleDemo/src/MessageBundle_fr_FR.properties @@ -0,0 +1 @@ +greeting=Halo, apa kabar? \ No newline at end of file diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/2/ResourceBundleDemo/src/ResourceBundleDemo.java b/Later/Java_Util_package/Internationalization/ResourceBundle/2/ResourceBundleDemo/src/ResourceBundleDemo.java new file mode 100644 index 000000000..c72ca3da9 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/2/ResourceBundleDemo/src/ResourceBundleDemo.java @@ -0,0 +1,47 @@ +import java.util.Locale; +import java.util.ResourceBundle; + +/** + * If Application supports US Country and English language, then read + * message from MessageBundle_en_US.properties file. + * + * If Application supports France country and French language, then + * read message from MessageBundle_fr_FR.properties file. + */ +public class ResourceBundleDemo +{ + + public static void main(String[] args) + { + + /* + * Gets a resource bundle using the specified base name, the + * default locale. + * + * Parameters: + * + * baseName - the base name of the resource bundle, a fully + * qualified class name + * + * Returns: + * + * a resource bundle for the given base name and the default + * locale + * + */ + System.out.println("Default Locale = " + Locale.getDefault()); + ResourceBundle bundle = ResourceBundle.getBundle("MessageBundle"); + + System.out.println("Message in " + Locale.US + " = " + + bundle.getString("greeting")); + + Locale.setDefault(new Locale("fr", "FR")); + System.out.println("Default Locale = " + Locale.getDefault()); + + bundle = ResourceBundle.getBundle("MessageBundle"); + System.out.println("Message in " + Locale.getDefault() + " = " + + bundle.getString("greeting")); + + } + +} diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/3/ResourceBundleDemo/.classpath b/Later/Java_Util_package/Internationalization/ResourceBundle/3/ResourceBundleDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/3/ResourceBundleDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/3/ResourceBundleDemo/.project b/Later/Java_Util_package/Internationalization/ResourceBundle/3/ResourceBundleDemo/.project new file mode 100644 index 000000000..1b5459b96 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/3/ResourceBundleDemo/.project @@ -0,0 +1,17 @@ + + + ResourceBundleDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/3/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Internationalization/ResourceBundle/3/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/3/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/3/ResourceBundleDemo/bin/MessageBundle_en_US.properties b/Later/Java_Util_package/Internationalization/ResourceBundle/3/ResourceBundleDemo/bin/MessageBundle_en_US.properties new file mode 100644 index 000000000..3d808db8c --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/3/ResourceBundleDemo/bin/MessageBundle_en_US.properties @@ -0,0 +1,3 @@ +greeting=Hello, how are you? +welcome=Welcome to India +meeting=Meeting with Peter \ No newline at end of file diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/3/ResourceBundleDemo/bin/ResourceBundleDemo.class b/Later/Java_Util_package/Internationalization/ResourceBundle/3/ResourceBundleDemo/bin/ResourceBundleDemo.class new file mode 100644 index 000000000..b38fa3ace Binary files /dev/null and b/Later/Java_Util_package/Internationalization/ResourceBundle/3/ResourceBundleDemo/bin/ResourceBundleDemo.class differ diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/3/ResourceBundleDemo/src/MessageBundle_en_US.properties b/Later/Java_Util_package/Internationalization/ResourceBundle/3/ResourceBundleDemo/src/MessageBundle_en_US.properties new file mode 100644 index 000000000..3d808db8c --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/3/ResourceBundleDemo/src/MessageBundle_en_US.properties @@ -0,0 +1,3 @@ +greeting=Hello, how are you? +welcome=Welcome to India +meeting=Meeting with Peter \ No newline at end of file diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/3/ResourceBundleDemo/src/ResourceBundleDemo.java b/Later/Java_Util_package/Internationalization/ResourceBundle/3/ResourceBundleDemo/src/ResourceBundleDemo.java new file mode 100644 index 000000000..edabb4db6 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/3/ResourceBundleDemo/src/ResourceBundleDemo.java @@ -0,0 +1,33 @@ +import java.util.Enumeration; +import java.util.ResourceBundle; + +public class ResourceBundleDemo +{ + + public static void main(String[] args) + { + + ResourceBundle bundle = ResourceBundle.getBundle("MessageBundle"); + + /* + * Returns an enumeration of the keys. + * + * Returns: + * + * an Enumeration of the keys contained in this ResourceBundle + * and its parent bundles. + */ + Enumeration enumeration = bundle.getKeys(); + + /* + * Print all the keys + */ + while (enumeration.hasMoreElements()) + { + String key = enumeration.nextElement(); + System.out.println(key); + } + + } + +} diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/4/ResourceBundleDemo/.classpath b/Later/Java_Util_package/Internationalization/ResourceBundle/4/ResourceBundleDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/4/ResourceBundleDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/4/ResourceBundleDemo/.project b/Later/Java_Util_package/Internationalization/ResourceBundle/4/ResourceBundleDemo/.project new file mode 100644 index 000000000..1b5459b96 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/4/ResourceBundleDemo/.project @@ -0,0 +1,17 @@ + + + ResourceBundleDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/4/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Internationalization/ResourceBundle/4/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/4/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/4/ResourceBundleDemo/bin/MessageBundle_en_US.properties b/Later/Java_Util_package/Internationalization/ResourceBundle/4/ResourceBundleDemo/bin/MessageBundle_en_US.properties new file mode 100644 index 000000000..3d808db8c --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/4/ResourceBundleDemo/bin/MessageBundle_en_US.properties @@ -0,0 +1,3 @@ +greeting=Hello, how are you? +welcome=Welcome to India +meeting=Meeting with Peter \ No newline at end of file diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/4/ResourceBundleDemo/bin/ResourceBundleDemo.class b/Later/Java_Util_package/Internationalization/ResourceBundle/4/ResourceBundleDemo/bin/ResourceBundleDemo.class new file mode 100644 index 000000000..e21d7cfa5 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/ResourceBundle/4/ResourceBundleDemo/bin/ResourceBundleDemo.class differ diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/4/ResourceBundleDemo/src/MessageBundle_en_US.properties b/Later/Java_Util_package/Internationalization/ResourceBundle/4/ResourceBundleDemo/src/MessageBundle_en_US.properties new file mode 100644 index 000000000..3d808db8c --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/4/ResourceBundleDemo/src/MessageBundle_en_US.properties @@ -0,0 +1,3 @@ +greeting=Hello, how are you? +welcome=Welcome to India +meeting=Meeting with Peter \ No newline at end of file diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/4/ResourceBundleDemo/src/ResourceBundleDemo.java b/Later/Java_Util_package/Internationalization/ResourceBundle/4/ResourceBundleDemo/src/ResourceBundleDemo.java new file mode 100644 index 000000000..1bd8948c7 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/4/ResourceBundleDemo/src/ResourceBundleDemo.java @@ -0,0 +1,34 @@ +import java.util.Enumeration; +import java.util.ResourceBundle; + +public class ResourceBundleDemo +{ + + public static void main(String[] args) + { + + ResourceBundle bundle = ResourceBundle.getBundle("MessageBundle"); + + /* + * Returns an enumeration of the keys. + * + * Returns: + * + * an Enumeration of the keys contained in this ResourceBundle + * and its parent bundles. + */ + Enumeration enumeration = bundle.getKeys(); + + /* + * Print all the keys and corresponding values + */ + while (enumeration.hasMoreElements()) + { + String key = enumeration.nextElement(); + String value = bundle.getString(key); + System.out.println(key+" = "+value); + } + + } + +} diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/5/ResourceBundleDemo/.classpath b/Later/Java_Util_package/Internationalization/ResourceBundle/5/ResourceBundleDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/5/ResourceBundleDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/5/ResourceBundleDemo/.project b/Later/Java_Util_package/Internationalization/ResourceBundle/5/ResourceBundleDemo/.project new file mode 100644 index 000000000..1b5459b96 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/5/ResourceBundleDemo/.project @@ -0,0 +1,17 @@ + + + ResourceBundleDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/5/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Internationalization/ResourceBundle/5/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/5/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/5/ResourceBundleDemo/bin/MessageBundle_en_US.properties b/Later/Java_Util_package/Internationalization/ResourceBundle/5/ResourceBundleDemo/bin/MessageBundle_en_US.properties new file mode 100644 index 000000000..3d808db8c --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/5/ResourceBundleDemo/bin/MessageBundle_en_US.properties @@ -0,0 +1,3 @@ +greeting=Hello, how are you? +welcome=Welcome to India +meeting=Meeting with Peter \ No newline at end of file diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/5/ResourceBundleDemo/bin/ResourceBundleDemo.class b/Later/Java_Util_package/Internationalization/ResourceBundle/5/ResourceBundleDemo/bin/ResourceBundleDemo.class new file mode 100644 index 000000000..feb51fc7c Binary files /dev/null and b/Later/Java_Util_package/Internationalization/ResourceBundle/5/ResourceBundleDemo/bin/ResourceBundleDemo.class differ diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/5/ResourceBundleDemo/src/MessageBundle_en_US.properties b/Later/Java_Util_package/Internationalization/ResourceBundle/5/ResourceBundleDemo/src/MessageBundle_en_US.properties new file mode 100644 index 000000000..3d808db8c --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/5/ResourceBundleDemo/src/MessageBundle_en_US.properties @@ -0,0 +1,3 @@ +greeting=Hello, how are you? +welcome=Welcome to India +meeting=Meeting with Peter \ No newline at end of file diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/5/ResourceBundleDemo/src/ResourceBundleDemo.java b/Later/Java_Util_package/Internationalization/ResourceBundle/5/ResourceBundleDemo/src/ResourceBundleDemo.java new file mode 100644 index 000000000..578c6c4e1 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/5/ResourceBundleDemo/src/ResourceBundleDemo.java @@ -0,0 +1,32 @@ +import java.util.ResourceBundle; +import java.util.Set; + +public class ResourceBundleDemo +{ + + public static void main(String[] args) + { + + ResourceBundle bundle = ResourceBundle.getBundle("MessageBundle"); + + /* + * Returns a Set of all keys contained in this ResourceBundle + * and its parent bundles. + * + * Returns: + * + * a Set of all keys contained in this ResourceBundle and its + * parent bundles. + * + */ + Set keySet = bundle.keySet(); + + for (String key : keySet) + { + String value = bundle.getString(key); + System.out.println(key + " = " + value); + } + + } + +} diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/6/ResourceBundleDemo/.classpath b/Later/Java_Util_package/Internationalization/ResourceBundle/6/ResourceBundleDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/6/ResourceBundleDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/6/ResourceBundleDemo/.project b/Later/Java_Util_package/Internationalization/ResourceBundle/6/ResourceBundleDemo/.project new file mode 100644 index 000000000..1b5459b96 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/6/ResourceBundleDemo/.project @@ -0,0 +1,17 @@ + + + ResourceBundleDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/6/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Internationalization/ResourceBundle/6/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/6/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/6/ResourceBundleDemo/bin/MessageBundle_en_US.properties b/Later/Java_Util_package/Internationalization/ResourceBundle/6/ResourceBundleDemo/bin/MessageBundle_en_US.properties new file mode 100644 index 000000000..3d808db8c --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/6/ResourceBundleDemo/bin/MessageBundle_en_US.properties @@ -0,0 +1,3 @@ +greeting=Hello, how are you? +welcome=Welcome to India +meeting=Meeting with Peter \ No newline at end of file diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/6/ResourceBundleDemo/bin/ResourceBundleDemo.class b/Later/Java_Util_package/Internationalization/ResourceBundle/6/ResourceBundleDemo/bin/ResourceBundleDemo.class new file mode 100644 index 000000000..a29ea38a2 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/ResourceBundle/6/ResourceBundleDemo/bin/ResourceBundleDemo.class differ diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/6/ResourceBundleDemo/src/MessageBundle_en_US.properties b/Later/Java_Util_package/Internationalization/ResourceBundle/6/ResourceBundleDemo/src/MessageBundle_en_US.properties new file mode 100644 index 000000000..3d808db8c --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/6/ResourceBundleDemo/src/MessageBundle_en_US.properties @@ -0,0 +1,3 @@ +greeting=Hello, how are you? +welcome=Welcome to India +meeting=Meeting with Peter \ No newline at end of file diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/6/ResourceBundleDemo/src/ResourceBundleDemo.java b/Later/Java_Util_package/Internationalization/ResourceBundle/6/ResourceBundleDemo/src/ResourceBundleDemo.java new file mode 100644 index 000000000..e7bcbcd44 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/6/ResourceBundleDemo/src/ResourceBundleDemo.java @@ -0,0 +1,30 @@ +import java.util.ResourceBundle; + +public class ResourceBundleDemo +{ + + public static void main(String[] args) + { + + ResourceBundle bundle = ResourceBundle.getBundle("MessageBundle"); + + /* + * Determines whether the given key is contained in this + * ResourceBundle or its parent bundles. + * + * Parameters: + * + * key - the resource key + * + * Returns: + * + * true if the given key is contained in this ResourceBundle + * or its parent bundles; false otherwise. + * + */ + boolean result = bundle.containsKey("greeting"); + System.out.println(result); + + } + +} diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/7/ResourceBundleDemo/.classpath b/Later/Java_Util_package/Internationalization/ResourceBundle/7/ResourceBundleDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/7/ResourceBundleDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/7/ResourceBundleDemo/.project b/Later/Java_Util_package/Internationalization/ResourceBundle/7/ResourceBundleDemo/.project new file mode 100644 index 000000000..1b5459b96 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/7/ResourceBundleDemo/.project @@ -0,0 +1,17 @@ + + + ResourceBundleDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/7/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Internationalization/ResourceBundle/7/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/7/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/7/ResourceBundleDemo/bin/MessageBundle_en_US.properties b/Later/Java_Util_package/Internationalization/ResourceBundle/7/ResourceBundleDemo/bin/MessageBundle_en_US.properties new file mode 100644 index 000000000..3d808db8c --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/7/ResourceBundleDemo/bin/MessageBundle_en_US.properties @@ -0,0 +1,3 @@ +greeting=Hello, how are you? +welcome=Welcome to India +meeting=Meeting with Peter \ No newline at end of file diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/7/ResourceBundleDemo/bin/ResourceBundleDemo.class b/Later/Java_Util_package/Internationalization/ResourceBundle/7/ResourceBundleDemo/bin/ResourceBundleDemo.class new file mode 100644 index 000000000..42f18fccb Binary files /dev/null and b/Later/Java_Util_package/Internationalization/ResourceBundle/7/ResourceBundleDemo/bin/ResourceBundleDemo.class differ diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/7/ResourceBundleDemo/src/MessageBundle_en_US.properties b/Later/Java_Util_package/Internationalization/ResourceBundle/7/ResourceBundleDemo/src/MessageBundle_en_US.properties new file mode 100644 index 000000000..3d808db8c --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/7/ResourceBundleDemo/src/MessageBundle_en_US.properties @@ -0,0 +1,3 @@ +greeting=Hello, how are you? +welcome=Welcome to India +meeting=Meeting with Peter \ No newline at end of file diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/7/ResourceBundleDemo/src/ResourceBundleDemo.java b/Later/Java_Util_package/Internationalization/ResourceBundle/7/ResourceBundleDemo/src/ResourceBundleDemo.java new file mode 100644 index 000000000..6a08679ef --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/7/ResourceBundleDemo/src/ResourceBundleDemo.java @@ -0,0 +1,28 @@ +import java.util.Locale; +import java.util.ResourceBundle; + +public class ResourceBundleDemo +{ + + public static void main(String[] args) + { + + ResourceBundle bundle = ResourceBundle.getBundle("MessageBundle"); + + /* + * Returns the locale of this resource bundle. This method can + * be used after a call to getBundle() to determine whether + * the resource bundle returned really corresponds to the + * requested locale or is a fallback. + * + * Returns: + * + * the locale of this resource bundle + * + */ + Locale locale = bundle.getLocale(); + System.out.println(locale); + + } + +} diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/8/ResourceBundleDemo/.classpath b/Later/Java_Util_package/Internationalization/ResourceBundle/8/ResourceBundleDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/8/ResourceBundleDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/8/ResourceBundleDemo/.project b/Later/Java_Util_package/Internationalization/ResourceBundle/8/ResourceBundleDemo/.project new file mode 100644 index 000000000..1b5459b96 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/8/ResourceBundleDemo/.project @@ -0,0 +1,17 @@ + + + ResourceBundleDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/8/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Internationalization/ResourceBundle/8/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/8/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/8/ResourceBundleDemo/bin/MessageBundle_en_US.properties b/Later/Java_Util_package/Internationalization/ResourceBundle/8/ResourceBundleDemo/bin/MessageBundle_en_US.properties new file mode 100644 index 000000000..3d808db8c --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/8/ResourceBundleDemo/bin/MessageBundle_en_US.properties @@ -0,0 +1,3 @@ +greeting=Hello, how are you? +welcome=Welcome to India +meeting=Meeting with Peter \ No newline at end of file diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/8/ResourceBundleDemo/bin/ResourceBundleDemo.class b/Later/Java_Util_package/Internationalization/ResourceBundle/8/ResourceBundleDemo/bin/ResourceBundleDemo.class new file mode 100644 index 000000000..1a224c944 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/ResourceBundle/8/ResourceBundleDemo/bin/ResourceBundleDemo.class differ diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/8/ResourceBundleDemo/src/MessageBundle_en_US.properties b/Later/Java_Util_package/Internationalization/ResourceBundle/8/ResourceBundleDemo/src/MessageBundle_en_US.properties new file mode 100644 index 000000000..3d808db8c --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/8/ResourceBundleDemo/src/MessageBundle_en_US.properties @@ -0,0 +1,3 @@ +greeting=Hello, how are you? +welcome=Welcome to India +meeting=Meeting with Peter \ No newline at end of file diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/8/ResourceBundleDemo/src/ResourceBundleDemo.java b/Later/Java_Util_package/Internationalization/ResourceBundle/8/ResourceBundleDemo/src/ResourceBundleDemo.java new file mode 100644 index 000000000..78086b9e2 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/8/ResourceBundleDemo/src/ResourceBundleDemo.java @@ -0,0 +1,21 @@ +import java.util.Locale; +import java.util.ResourceBundle; + +public class ResourceBundleDemo +{ + + public static void main(String[] args) + { + + ClassLoader cl = ClassLoader.getSystemClassLoader(); + + ResourceBundle bundle = ResourceBundle.getBundle("MessageBundle", + Locale.US, cl); + + String value = bundle.getString("greeting"); + + System.out.println("Message in " + Locale.getDefault() + " = " + value); + + } + +} diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/.classpath b/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/.project b/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/.project new file mode 100644 index 000000000..1b5459b96 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/.project @@ -0,0 +1,17 @@ + + + ResourceBundleDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/bin/MessageBundle_en_US.properties b/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/bin/MessageBundle_en_US.properties new file mode 100644 index 000000000..3d808db8c --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/bin/MessageBundle_en_US.properties @@ -0,0 +1,3 @@ +greeting=Hello, how are you? +welcome=Welcome to India +meeting=Meeting with Peter \ No newline at end of file diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/bin/MessageBundle_fr_FR.properties b/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/bin/MessageBundle_fr_FR.properties new file mode 100644 index 000000000..51b9052ed --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/bin/MessageBundle_fr_FR.properties @@ -0,0 +1 @@ +greeting=Halo, apa kabar? \ No newline at end of file diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/bin/ResourceBundleDemo1.class b/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/bin/ResourceBundleDemo1.class new file mode 100644 index 000000000..37470ba88 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/bin/ResourceBundleDemo1.class differ diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/bin/ResourceBundleDemo2.class b/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/bin/ResourceBundleDemo2.class new file mode 100644 index 000000000..e2e1443f8 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/bin/ResourceBundleDemo2.class differ diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/bin/ResourceBundleDemo3.class b/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/bin/ResourceBundleDemo3.class new file mode 100644 index 000000000..e62b4d497 Binary files /dev/null and b/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/bin/ResourceBundleDemo3.class differ diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/src/MessageBundle_en_US.properties b/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/src/MessageBundle_en_US.properties new file mode 100644 index 000000000..3d808db8c --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/src/MessageBundle_en_US.properties @@ -0,0 +1,3 @@ +greeting=Hello, how are you? +welcome=Welcome to India +meeting=Meeting with Peter \ No newline at end of file diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/src/MessageBundle_fr_FR.properties b/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/src/MessageBundle_fr_FR.properties new file mode 100644 index 000000000..51b9052ed --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/src/MessageBundle_fr_FR.properties @@ -0,0 +1 @@ +greeting=Halo, apa kabar? \ No newline at end of file diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/src/ResourceBundleDemo1.java b/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/src/ResourceBundleDemo1.java new file mode 100644 index 000000000..98a4761b7 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/src/ResourceBundleDemo1.java @@ -0,0 +1,30 @@ +import java.util.Locale; +import java.util.ResourceBundle; +import java.util.ResourceBundle.Control; + +public class ResourceBundleDemo1 +{ + + public static void main(String[] args) + { + + /* + * create a new ResourceBundle.Control with default format + */ + ResourceBundle.Control rbc = ResourceBundle.Control + .getControl(Control.FORMAT_DEFAULT); + + /* + * Returns a resource bundle using the specified base name, + * the default locale and the specified control + */ + ResourceBundle bundle = ResourceBundle.getBundle("MessageBundle", rbc); + + String value = bundle.getString("greeting"); + + System.out.println("Message in " + Locale.getDefault() + " = " + value); + + + } + +} diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/src/ResourceBundleDemo2.java b/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/src/ResourceBundleDemo2.java new file mode 100644 index 000000000..703238813 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/src/ResourceBundleDemo2.java @@ -0,0 +1,30 @@ +import java.util.Locale; +import java.util.ResourceBundle; +import java.util.ResourceBundle.Control; + +public class ResourceBundleDemo2 +{ + + public static void main(String[] args) + { + + /* + * create a new ResourceBundle.Control with default format + */ + ResourceBundle.Control rbc = ResourceBundle.Control + .getControl(Control.FORMAT_DEFAULT); + + /* + * Returns a resource bundle using the specified base name, + * the target locale and the specified control + */ + ResourceBundle bundle = ResourceBundle.getBundle("MessageBundle",Locale.FRANCE, rbc); + + String value = bundle.getString("greeting"); + + System.out.println("Message in " + Locale.getDefault() + " = " + value); + + + } + +} diff --git a/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/src/ResourceBundleDemo3.java b/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/src/ResourceBundleDemo3.java new file mode 100644 index 000000000..3c91c4641 --- /dev/null +++ b/Later/Java_Util_package/Internationalization/ResourceBundle/9/ResourceBundleDemo/src/ResourceBundleDemo3.java @@ -0,0 +1,32 @@ +import java.util.Locale; +import java.util.ResourceBundle; +import java.util.ResourceBundle.Control; + +public class ResourceBundleDemo3 +{ + + public static void main(String[] args) + { + + /* + * create a new ResourceBundle.Control with default format + */ + ResourceBundle.Control rbc = ResourceBundle.Control + .getControl(Control.FORMAT_DEFAULT); + + ClassLoader cl = ClassLoader.getSystemClassLoader(); + + /* + * Returns a resource bundle using the specified base name, + * target locale, class loader and control + */ + ResourceBundle bundle = ResourceBundle.getBundle("MessageBundle", + Locale.US, cl, rbc); + + String value = bundle.getString("greeting"); + + System.out.println("Message in " + Locale.getDefault() + " = " + value); + + } + +} diff --git a/Later/Java_Util_package/Observable/1/Observable.pptx b/Later/Java_Util_package/Observable/1/Observable.pptx new file mode 100644 index 000000000..4312500ca Binary files /dev/null and b/Later/Java_Util_package/Observable/1/Observable.pptx differ diff --git a/Later/Java_Util_package/Observable/1/ObservableDemo/.classpath b/Later/Java_Util_package/Observable/1/ObservableDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Observable/1/ObservableDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Observable/1/ObservableDemo/.project b/Later/Java_Util_package/Observable/1/ObservableDemo/.project new file mode 100644 index 000000000..944ce1591 --- /dev/null +++ b/Later/Java_Util_package/Observable/1/ObservableDemo/.project @@ -0,0 +1,17 @@ + + + ObservableDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Observable/1/ObservableDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Observable/1/ObservableDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Observable/1/ObservableDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Observable/1/ObservableDemo/bin/JohnObserver.class b/Later/Java_Util_package/Observable/1/ObservableDemo/bin/JohnObserver.class new file mode 100644 index 000000000..abab4ad72 Binary files /dev/null and b/Later/Java_Util_package/Observable/1/ObservableDemo/bin/JohnObserver.class differ diff --git a/Later/Java_Util_package/Observable/1/ObservableDemo/bin/NokioMobilePriceObservable.class b/Later/Java_Util_package/Observable/1/ObservableDemo/bin/NokioMobilePriceObservable.class new file mode 100644 index 000000000..ee2e736f3 Binary files /dev/null and b/Later/Java_Util_package/Observable/1/ObservableDemo/bin/NokioMobilePriceObservable.class differ diff --git a/Later/Java_Util_package/Observable/1/ObservableDemo/bin/ObservableDemo.class b/Later/Java_Util_package/Observable/1/ObservableDemo/bin/ObservableDemo.class new file mode 100644 index 000000000..43ec81207 Binary files /dev/null and b/Later/Java_Util_package/Observable/1/ObservableDemo/bin/ObservableDemo.class differ diff --git a/Later/Java_Util_package/Observable/1/ObservableDemo/bin/PeterObserver.class b/Later/Java_Util_package/Observable/1/ObservableDemo/bin/PeterObserver.class new file mode 100644 index 000000000..e23711973 Binary files /dev/null and b/Later/Java_Util_package/Observable/1/ObservableDemo/bin/PeterObserver.class differ diff --git a/Later/Java_Util_package/Observable/1/ObservableDemo/src/JohnObserver.java b/Later/Java_Util_package/Observable/1/ObservableDemo/src/JohnObserver.java new file mode 100644 index 000000000..bb9026996 --- /dev/null +++ b/Later/Java_Util_package/Observable/1/ObservableDemo/src/JohnObserver.java @@ -0,0 +1,14 @@ +import java.util.Observable; +import java.util.Observer; + +public class JohnObserver implements Observer +{ + + @Override + public void update(Observable o, Object arg) + { + System.out.println("JohnObserver is notified, Price changed to " + arg); + + } + +} diff --git a/Later/Java_Util_package/Observable/1/ObservableDemo/src/NokioMobilePriceObservable.java b/Later/Java_Util_package/Observable/1/ObservableDemo/src/NokioMobilePriceObservable.java new file mode 100644 index 000000000..bea0ee526 --- /dev/null +++ b/Later/Java_Util_package/Observable/1/ObservableDemo/src/NokioMobilePriceObservable.java @@ -0,0 +1,48 @@ +import java.util.Observable; + +public class NokioMobilePriceObservable extends Observable +{ + private int price; + + public NokioMobilePriceObservable(int price) + { + this.price = price; + } + + public void setPrice(int newPrice) + { + + /* + * if price has changed notify observers + */ + if (price != newPrice) + { + System.out.println("price changed to new price = " + newPrice); + price = newPrice; + + /* + * Marks this Observable object as having been changed; + * the hasChanged method will now return true. + */ + setChanged(); + + /* + * If this object has changed, as indicated by the + * hasChanged method, then notify all of its observers and + * then call the clearChanged method to indicate that this + * object has no longer changed. + * + * Each observer has its update method called with two + * arguments: this observable object and the arg argument. + * + * Parameters: + * + * arg - any object. + * + */ + notifyObservers(newPrice); + } + + } + +} diff --git a/Later/Java_Util_package/Observable/1/ObservableDemo/src/ObservableDemo.java b/Later/Java_Util_package/Observable/1/ObservableDemo/src/ObservableDemo.java new file mode 100644 index 000000000..0af5b481c --- /dev/null +++ b/Later/Java_Util_package/Observable/1/ObservableDemo/src/ObservableDemo.java @@ -0,0 +1,30 @@ +public class ObservableDemo +{ + + public static void main(String[] args) + { + NokioMobilePriceObservable nokioMobilePriceObservable = new NokioMobilePriceObservable( + 6000); + + PeterObserver peterObserver = new PeterObserver(); + JohnObserver johnObserver = new JohnObserver(); + + /* + * Adds an observer to the set of observers for this object, + * provided that it is not the same as some observer already + * in the set. The order in which notifications will be + * delivered to multiple observers is not specified. + * + * Parameters: + * + * o - an observer to be added. + * + */ + nokioMobilePriceObservable.addObserver(peterObserver); + nokioMobilePriceObservable.addObserver(johnObserver); + + nokioMobilePriceObservable.setPrice(9000); + + } + +} diff --git a/Later/Java_Util_package/Observable/1/ObservableDemo/src/PeterObserver.java b/Later/Java_Util_package/Observable/1/ObservableDemo/src/PeterObserver.java new file mode 100644 index 000000000..1d3c0321b --- /dev/null +++ b/Later/Java_Util_package/Observable/1/ObservableDemo/src/PeterObserver.java @@ -0,0 +1,15 @@ +import java.util.Observable; +import java.util.Observer; + +public class PeterObserver implements Observer +{ + + @Override + public void update(Observable o, Object arg) + { + System.out + .println("PeterObserver is notified, Price changed to " + arg); + + } + +} diff --git a/Later/Java_Util_package/Observable/2/Observable.pptx b/Later/Java_Util_package/Observable/2/Observable.pptx new file mode 100644 index 000000000..28c9b5d78 Binary files /dev/null and b/Later/Java_Util_package/Observable/2/Observable.pptx differ diff --git a/Later/Java_Util_package/Observable/2/ObservableDemo/.classpath b/Later/Java_Util_package/Observable/2/ObservableDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Observable/2/ObservableDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Observable/2/ObservableDemo/.project b/Later/Java_Util_package/Observable/2/ObservableDemo/.project new file mode 100644 index 000000000..944ce1591 --- /dev/null +++ b/Later/Java_Util_package/Observable/2/ObservableDemo/.project @@ -0,0 +1,17 @@ + + + ObservableDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Observable/2/ObservableDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Observable/2/ObservableDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Observable/2/ObservableDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Observable/2/ObservableDemo/Observable.jpg b/Later/Java_Util_package/Observable/2/ObservableDemo/Observable.jpg new file mode 100644 index 000000000..38304e40d Binary files /dev/null and b/Later/Java_Util_package/Observable/2/ObservableDemo/Observable.jpg differ diff --git a/Later/Java_Util_package/Observable/2/ObservableDemo/Observable.mdr b/Later/Java_Util_package/Observable/2/ObservableDemo/Observable.mdr new file mode 100644 index 000000000..3d4716d48 Binary files /dev/null and b/Later/Java_Util_package/Observable/2/ObservableDemo/Observable.mdr differ diff --git a/Later/Java_Util_package/Observable/2/ObservableDemo/Observable.mdr.bak b/Later/Java_Util_package/Observable/2/ObservableDemo/Observable.mdr.bak new file mode 100644 index 000000000..3d4716d48 Binary files /dev/null and b/Later/Java_Util_package/Observable/2/ObservableDemo/Observable.mdr.bak differ diff --git a/Later/Java_Util_package/Observable/2/ObservableDemo/Observable.mdzip b/Later/Java_Util_package/Observable/2/ObservableDemo/Observable.mdzip new file mode 100644 index 000000000..e81aff444 Binary files /dev/null and b/Later/Java_Util_package/Observable/2/ObservableDemo/Observable.mdzip differ diff --git a/Later/Java_Util_package/Observable/2/ObservableDemo/Observable.mdzip.bak b/Later/Java_Util_package/Observable/2/ObservableDemo/Observable.mdzip.bak new file mode 100644 index 000000000..2d739c1cb Binary files /dev/null and b/Later/Java_Util_package/Observable/2/ObservableDemo/Observable.mdzip.bak differ diff --git a/Later/Java_Util_package/Observable/2/ObservableDemo/bin/JohnObserver.class b/Later/Java_Util_package/Observable/2/ObservableDemo/bin/JohnObserver.class new file mode 100644 index 000000000..dcda07e8c Binary files /dev/null and b/Later/Java_Util_package/Observable/2/ObservableDemo/bin/JohnObserver.class differ diff --git a/Later/Java_Util_package/Observable/2/ObservableDemo/bin/NokioMobilePriceObservable.class b/Later/Java_Util_package/Observable/2/ObservableDemo/bin/NokioMobilePriceObservable.class new file mode 100644 index 000000000..952d96871 Binary files /dev/null and b/Later/Java_Util_package/Observable/2/ObservableDemo/bin/NokioMobilePriceObservable.class differ diff --git a/Later/Java_Util_package/Observable/2/ObservableDemo/bin/ObservableDemo.class b/Later/Java_Util_package/Observable/2/ObservableDemo/bin/ObservableDemo.class new file mode 100644 index 000000000..43ec81207 Binary files /dev/null and b/Later/Java_Util_package/Observable/2/ObservableDemo/bin/ObservableDemo.class differ diff --git a/Later/Java_Util_package/Observable/2/ObservableDemo/bin/PeterObserver.class b/Later/Java_Util_package/Observable/2/ObservableDemo/bin/PeterObserver.class new file mode 100644 index 000000000..347a31af8 Binary files /dev/null and b/Later/Java_Util_package/Observable/2/ObservableDemo/bin/PeterObserver.class differ diff --git a/Later/Java_Util_package/Observable/2/ObservableDemo/src/JohnObserver.java b/Later/Java_Util_package/Observable/2/ObservableDemo/src/JohnObserver.java new file mode 100644 index 000000000..9dcdccecd --- /dev/null +++ b/Later/Java_Util_package/Observable/2/ObservableDemo/src/JohnObserver.java @@ -0,0 +1,17 @@ +import java.util.Observable; +import java.util.Observer; + +public class JohnObserver implements Observer +{ + + @Override + public void update(Observable observable, Object arg) + { + NokioMobilePriceObservable nokioMobilePriceObservable = (NokioMobilePriceObservable) observable; + + System.out.println("JohnObserver is notified, Price changed to " + + nokioMobilePriceObservable.getPrice()); + + } + +} diff --git a/Later/Java_Util_package/Observable/2/ObservableDemo/src/NokioMobilePriceObservable.java b/Later/Java_Util_package/Observable/2/ObservableDemo/src/NokioMobilePriceObservable.java new file mode 100644 index 000000000..2e268e971 --- /dev/null +++ b/Later/Java_Util_package/Observable/2/ObservableDemo/src/NokioMobilePriceObservable.java @@ -0,0 +1,51 @@ +import java.util.Observable; + +public class NokioMobilePriceObservable extends Observable +{ + private int price; + + public NokioMobilePriceObservable(int price) + { + this.price = price; + } + + public void setPrice(int newPrice) + { + + /* + * if price has changed notify observers + */ + if (price != newPrice) + { + System.out.println("price changed to new price = " + newPrice); + price = newPrice; + + /* + * Marks this Observable object as having been changed; + * the hasChanged method will now return true. + */ + setChanged(); + + /* + * If this object has changed, as indicated by the + * hasChanged method, then notify all of its observers and + * then call the clearChanged method to indicate that this + * object has no longer changed. Each observer has its + * update method called with two arguments: this + * observable object and null. In other words, this method + * is equivalent to: + * + * notifyObservers(null) + * + */ + notifyObservers(); + } + + } + + public int getPrice() + { + return price; + } + +} diff --git a/Later/Java_Util_package/Observable/2/ObservableDemo/src/ObservableDemo.java b/Later/Java_Util_package/Observable/2/ObservableDemo/src/ObservableDemo.java new file mode 100644 index 000000000..0af5b481c --- /dev/null +++ b/Later/Java_Util_package/Observable/2/ObservableDemo/src/ObservableDemo.java @@ -0,0 +1,30 @@ +public class ObservableDemo +{ + + public static void main(String[] args) + { + NokioMobilePriceObservable nokioMobilePriceObservable = new NokioMobilePriceObservable( + 6000); + + PeterObserver peterObserver = new PeterObserver(); + JohnObserver johnObserver = new JohnObserver(); + + /* + * Adds an observer to the set of observers for this object, + * provided that it is not the same as some observer already + * in the set. The order in which notifications will be + * delivered to multiple observers is not specified. + * + * Parameters: + * + * o - an observer to be added. + * + */ + nokioMobilePriceObservable.addObserver(peterObserver); + nokioMobilePriceObservable.addObserver(johnObserver); + + nokioMobilePriceObservable.setPrice(9000); + + } + +} diff --git a/Later/Java_Util_package/Observable/2/ObservableDemo/src/PeterObserver.java b/Later/Java_Util_package/Observable/2/ObservableDemo/src/PeterObserver.java new file mode 100644 index 000000000..69c3a1b19 --- /dev/null +++ b/Later/Java_Util_package/Observable/2/ObservableDemo/src/PeterObserver.java @@ -0,0 +1,18 @@ +import java.util.Observable; +import java.util.Observer; + +public class PeterObserver implements Observer +{ + + @Override + public void update(Observable observable, Object arg) + { + + NokioMobilePriceObservable nokioMobilePriceObservable = (NokioMobilePriceObservable) observable; + + System.out.println("PeterObserver is notified, Price changed to " + + nokioMobilePriceObservable.getPrice()); + + } + +} diff --git a/Later/Java_Util_package/Observable/3/ObservableDemo/.classpath b/Later/Java_Util_package/Observable/3/ObservableDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Observable/3/ObservableDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Observable/3/ObservableDemo/.project b/Later/Java_Util_package/Observable/3/ObservableDemo/.project new file mode 100644 index 000000000..944ce1591 --- /dev/null +++ b/Later/Java_Util_package/Observable/3/ObservableDemo/.project @@ -0,0 +1,17 @@ + + + ObservableDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Observable/3/ObservableDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Observable/3/ObservableDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Observable/3/ObservableDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Observable/3/ObservableDemo/bin/JohnObserver.class b/Later/Java_Util_package/Observable/3/ObservableDemo/bin/JohnObserver.class new file mode 100644 index 000000000..dcda07e8c Binary files /dev/null and b/Later/Java_Util_package/Observable/3/ObservableDemo/bin/JohnObserver.class differ diff --git a/Later/Java_Util_package/Observable/3/ObservableDemo/bin/NokioMobilePriceObservable.class b/Later/Java_Util_package/Observable/3/ObservableDemo/bin/NokioMobilePriceObservable.class new file mode 100644 index 000000000..e0b40f9bd Binary files /dev/null and b/Later/Java_Util_package/Observable/3/ObservableDemo/bin/NokioMobilePriceObservable.class differ diff --git a/Later/Java_Util_package/Observable/3/ObservableDemo/bin/ObservableDemo.class b/Later/Java_Util_package/Observable/3/ObservableDemo/bin/ObservableDemo.class new file mode 100644 index 000000000..77db1047e Binary files /dev/null and b/Later/Java_Util_package/Observable/3/ObservableDemo/bin/ObservableDemo.class differ diff --git a/Later/Java_Util_package/Observable/3/ObservableDemo/bin/PeterObserver.class b/Later/Java_Util_package/Observable/3/ObservableDemo/bin/PeterObserver.class new file mode 100644 index 000000000..347a31af8 Binary files /dev/null and b/Later/Java_Util_package/Observable/3/ObservableDemo/bin/PeterObserver.class differ diff --git a/Later/Java_Util_package/Observable/3/ObservableDemo/src/JohnObserver.java b/Later/Java_Util_package/Observable/3/ObservableDemo/src/JohnObserver.java new file mode 100644 index 000000000..9dcdccecd --- /dev/null +++ b/Later/Java_Util_package/Observable/3/ObservableDemo/src/JohnObserver.java @@ -0,0 +1,17 @@ +import java.util.Observable; +import java.util.Observer; + +public class JohnObserver implements Observer +{ + + @Override + public void update(Observable observable, Object arg) + { + NokioMobilePriceObservable nokioMobilePriceObservable = (NokioMobilePriceObservable) observable; + + System.out.println("JohnObserver is notified, Price changed to " + + nokioMobilePriceObservable.getPrice()); + + } + +} diff --git a/Later/Java_Util_package/Observable/3/ObservableDemo/src/NokioMobilePriceObservable.java b/Later/Java_Util_package/Observable/3/ObservableDemo/src/NokioMobilePriceObservable.java new file mode 100644 index 000000000..910be38f9 --- /dev/null +++ b/Later/Java_Util_package/Observable/3/ObservableDemo/src/NokioMobilePriceObservable.java @@ -0,0 +1,81 @@ +import java.util.Observable; + +public class NokioMobilePriceObservable extends Observable +{ + private int price; + + public NokioMobilePriceObservable(int price) + { + this.price = price; + } + + public void setPrice(int newPrice) + { + + /* + * if price has changed notify observers + */ + if (price != newPrice) + { + System.out.println("price changed to new price = " + newPrice); + price = newPrice; + + /* + * Marks this Observable object as having been changed; + * the hasChanged method will now return true. + */ + setChanged(); + + System.out.println("Before Notify call hasChanged method"); + + /* + * Returns: + * + * true if and only if the setChanged method has been + * called more recently than the clearChanged method on + * this object; false otherwise. + * + */ + if (this.hasChanged()) + { + System.out.println("Price value changed"); + } + else + { + System.out.println("Price value not changed"); + } + + /* + * If this object has changed, as indicated by the + * hasChanged method, then notify all of its observers and + * then call the clearChanged method to indicate that this + * object has no longer changed. Each observer has its + * update method called with two arguments: this + * observable object and null. In other words, this method + * is equivalent to: + * + * notifyObservers(null) + * + */ + notifyObservers(); + + + System.out.println("After Notify call hasChanged method"); + if (this.hasChanged()) + { + System.out.println("Price value changed"); + } + else + { + System.out.println("Price value not changed"); + } + } + + } + + public int getPrice() + { + return price; + } + +} diff --git a/Later/Java_Util_package/Observable/3/ObservableDemo/src/ObservableDemo.java b/Later/Java_Util_package/Observable/3/ObservableDemo/src/ObservableDemo.java new file mode 100644 index 000000000..a27609bd1 --- /dev/null +++ b/Later/Java_Util_package/Observable/3/ObservableDemo/src/ObservableDemo.java @@ -0,0 +1,70 @@ +public class ObservableDemo +{ + + public static void main(String[] args) + { + NokioMobilePriceObservable nokioMobilePriceObservable = new NokioMobilePriceObservable( + 6000); + + PeterObserver peterObserver = new PeterObserver(); + JohnObserver johnObserver = new JohnObserver(); + + /* + * Adds an observer to the set of observers for this object, + * provided that it is not the same as some observer already + * in the set. The order in which notifications will be + * delivered to multiple observers is not specified. + * + * Parameters: + * + * o - an observer to be added. + * + */ + nokioMobilePriceObservable.addObserver(peterObserver); + nokioMobilePriceObservable.addObserver(johnObserver); + + /* + * Returns the number of observers of this Observable object. + * + * Returns: + * + * the number of observers of this object. + */ + int count = nokioMobilePriceObservable.countObservers(); + System.out.println(count + " observers are listening"); + + nokioMobilePriceObservable.setPrice(9000); + + System.out.println("------------------------------------------"); + + /* + * Deletes an observer from the set of observers of this + * object. + * + * Parameters: + * + * o - the observer to be deleted. + */ + nokioMobilePriceObservable.deleteObserver(peterObserver); + + count = nokioMobilePriceObservable.countObservers(); + System.out.println(count + " observer is listening"); + nokioMobilePriceObservable.setPrice(20000); + + System.out.println("------------------------------------------"); + + /* + * Clears the observer list so that this object no longer has + * any observers. + */ + nokioMobilePriceObservable.deleteObservers(); + count = nokioMobilePriceObservable.countObservers(); + System.out.println(count + " observers are listening"); + + nokioMobilePriceObservable.setPrice(30000); + + + + } + +} diff --git a/Later/Java_Util_package/Observable/3/ObservableDemo/src/PeterObserver.java b/Later/Java_Util_package/Observable/3/ObservableDemo/src/PeterObserver.java new file mode 100644 index 000000000..69c3a1b19 --- /dev/null +++ b/Later/Java_Util_package/Observable/3/ObservableDemo/src/PeterObserver.java @@ -0,0 +1,18 @@ +import java.util.Observable; +import java.util.Observer; + +public class PeterObserver implements Observer +{ + + @Override + public void update(Observable observable, Object arg) + { + + NokioMobilePriceObservable nokioMobilePriceObservable = (NokioMobilePriceObservable) observable; + + System.out.println("PeterObserver is notified, Price changed to " + + nokioMobilePriceObservable.getPrice()); + + } + +} diff --git a/Later/Java_Util_package/Random/1/Random.pptx b/Later/Java_Util_package/Random/1/Random.pptx new file mode 100644 index 000000000..14731f844 Binary files /dev/null and b/Later/Java_Util_package/Random/1/Random.pptx differ diff --git a/Later/Java_Util_package/Random/1/RandomDemo/.classpath b/Later/Java_Util_package/Random/1/RandomDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Random/1/RandomDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Random/1/RandomDemo/.project b/Later/Java_Util_package/Random/1/RandomDemo/.project new file mode 100644 index 000000000..22071f2a6 --- /dev/null +++ b/Later/Java_Util_package/Random/1/RandomDemo/.project @@ -0,0 +1,17 @@ + + + RandomDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Random/1/RandomDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Random/1/RandomDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Random/1/RandomDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Random/1/RandomDemo/bin/RandomDemo.class b/Later/Java_Util_package/Random/1/RandomDemo/bin/RandomDemo.class new file mode 100644 index 000000000..976e7fb8d Binary files /dev/null and b/Later/Java_Util_package/Random/1/RandomDemo/bin/RandomDemo.class differ diff --git a/Later/Java_Util_package/Random/1/RandomDemo/src/RandomDemo.java b/Later/Java_Util_package/Random/1/RandomDemo/src/RandomDemo.java new file mode 100644 index 000000000..0c96b55f9 --- /dev/null +++ b/Later/Java_Util_package/Random/1/RandomDemo/src/RandomDemo.java @@ -0,0 +1,29 @@ +import java.util.Random; + +public class RandomDemo +{ + + public static void main(String[] args) + { + /* + * Creates a new random number generator. + */ + Random random = new Random(); + + int i = 0; + while (i < 5) + { + /* + * Returns: + * + * the next pseudorandom, uniformly distributed int value + * from this random number generator's sequence + */ + int randomNumber = random.nextInt(); + System.out.println("randomNumber = " + randomNumber); + ++i; + } + + } + +} diff --git a/Later/Java_Util_package/Random/10/RandomDemo/.classpath b/Later/Java_Util_package/Random/10/RandomDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Random/10/RandomDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Random/10/RandomDemo/.project b/Later/Java_Util_package/Random/10/RandomDemo/.project new file mode 100644 index 000000000..22071f2a6 --- /dev/null +++ b/Later/Java_Util_package/Random/10/RandomDemo/.project @@ -0,0 +1,17 @@ + + + RandomDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Random/10/RandomDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Random/10/RandomDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Random/10/RandomDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Random/10/RandomDemo/bin/RandomDemo1.class b/Later/Java_Util_package/Random/10/RandomDemo/bin/RandomDemo1.class new file mode 100644 index 000000000..1cea3d0ab Binary files /dev/null and b/Later/Java_Util_package/Random/10/RandomDemo/bin/RandomDemo1.class differ diff --git a/Later/Java_Util_package/Random/10/RandomDemo/bin/RandomDemo2.class b/Later/Java_Util_package/Random/10/RandomDemo/bin/RandomDemo2.class new file mode 100644 index 000000000..3b768b110 Binary files /dev/null and b/Later/Java_Util_package/Random/10/RandomDemo/bin/RandomDemo2.class differ diff --git a/Later/Java_Util_package/Random/10/RandomDemo/src/RandomDemo1.java b/Later/Java_Util_package/Random/10/RandomDemo/src/RandomDemo1.java new file mode 100644 index 000000000..1cff164c6 --- /dev/null +++ b/Later/Java_Util_package/Random/10/RandomDemo/src/RandomDemo1.java @@ -0,0 +1,38 @@ +import java.util.Random; +import java.util.stream.DoubleStream; + +public class RandomDemo1 +{ + + public static void main(String[] args) + { + + Random random = new Random(); + + /* + * Returns an effectively unlimited stream of pseudorandom + * double values, each conforming to the given origin + * (inclusive) and bound (exclusive). + * + * Parameters: + * + * randomNumberOrigin - the origin (inclusive) of each random + * value + * + * randomNumberBound - the bound (exclusive) of each random + * value + * + * Returns: + * + * a stream of pseudorandom double values, each with the given + * origin (inclusive) and bound (exclusive) + * + * + */ + DoubleStream doubleStream = random.doubles(1, 5); + + doubleStream.forEach(System.out::println); + + } + +} diff --git a/Later/Java_Util_package/Random/10/RandomDemo/src/RandomDemo2.java b/Later/Java_Util_package/Random/10/RandomDemo/src/RandomDemo2.java new file mode 100644 index 000000000..a6473e3dd --- /dev/null +++ b/Later/Java_Util_package/Random/10/RandomDemo/src/RandomDemo2.java @@ -0,0 +1,39 @@ +import java.util.Random; +import java.util.stream.DoubleStream; + +public class RandomDemo2 +{ + + public static void main(String[] args) + { + Random random = new Random(); + + /* + * Returns a stream producing the given streamSize number of + * pseudorandom double values, each conforming to the given + * origin (inclusive) and bound (exclusive). + * + * Parameters: + * + * streamSize - the number of values to generate + * + * randomNumberOrigin - the origin (inclusive) of each random + * value + * + * randomNumberBound - the bound (exclusive) of each random + * value + * + * Returns: + * + * a stream of pseudorandom double values, each with the given + * origin (inclusive) and bound (exclusive) + * + * + */ + DoubleStream doubleStream = random.doubles(6, 1, 5); + + doubleStream.forEach(System.out::println); + + } + +} diff --git a/Later/Java_Util_package/Random/11/RandomDemo/.classpath b/Later/Java_Util_package/Random/11/RandomDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Random/11/RandomDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Random/11/RandomDemo/.project b/Later/Java_Util_package/Random/11/RandomDemo/.project new file mode 100644 index 000000000..22071f2a6 --- /dev/null +++ b/Later/Java_Util_package/Random/11/RandomDemo/.project @@ -0,0 +1,17 @@ + + + RandomDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Random/11/RandomDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Random/11/RandomDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Random/11/RandomDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Random/11/RandomDemo/bin/RandomDemo1.class b/Later/Java_Util_package/Random/11/RandomDemo/bin/RandomDemo1.class new file mode 100644 index 000000000..df403ca5e Binary files /dev/null and b/Later/Java_Util_package/Random/11/RandomDemo/bin/RandomDemo1.class differ diff --git a/Later/Java_Util_package/Random/11/RandomDemo/bin/RandomDemo2.class b/Later/Java_Util_package/Random/11/RandomDemo/bin/RandomDemo2.class new file mode 100644 index 000000000..5adc3194b Binary files /dev/null and b/Later/Java_Util_package/Random/11/RandomDemo/bin/RandomDemo2.class differ diff --git a/Later/Java_Util_package/Random/11/RandomDemo/src/RandomDemo1.java b/Later/Java_Util_package/Random/11/RandomDemo/src/RandomDemo1.java new file mode 100644 index 000000000..ab4c73cea --- /dev/null +++ b/Later/Java_Util_package/Random/11/RandomDemo/src/RandomDemo1.java @@ -0,0 +1,23 @@ +import java.util.Random; +import java.util.stream.LongStream; + +public class RandomDemo1 +{ + + public static void main(String[] args) + { + + Random random = new Random(); + + /* + * Returns an effectively unlimited stream of pseudorandom + * long values. + * + */ + LongStream longStream = random.longs(); + + longStream.forEach(System.out::println); + + } + +} diff --git a/Later/Java_Util_package/Random/11/RandomDemo/src/RandomDemo2.java b/Later/Java_Util_package/Random/11/RandomDemo/src/RandomDemo2.java new file mode 100644 index 000000000..4c14dff0b --- /dev/null +++ b/Later/Java_Util_package/Random/11/RandomDemo/src/RandomDemo2.java @@ -0,0 +1,30 @@ +import java.util.Random; +import java.util.stream.LongStream; + +public class RandomDemo2 +{ + + public static void main(String[] args) + { + Random random = new Random(); + + /* + * Returns a stream producing the given streamSize number of + * pseudorandom long values. + * + * Parameters: + * + * streamSize - the number of values to generate + * + * Returns: + * + * a stream of pseudorandom long values + * + */ + LongStream longStream = random.longs(4); + + longStream.forEach(System.out::println); + + } + +} diff --git a/Later/Java_Util_package/Random/12/RandomDemo/.classpath b/Later/Java_Util_package/Random/12/RandomDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Random/12/RandomDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Random/12/RandomDemo/.project b/Later/Java_Util_package/Random/12/RandomDemo/.project new file mode 100644 index 000000000..22071f2a6 --- /dev/null +++ b/Later/Java_Util_package/Random/12/RandomDemo/.project @@ -0,0 +1,17 @@ + + + RandomDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Random/12/RandomDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Random/12/RandomDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Random/12/RandomDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Random/12/RandomDemo/bin/RandomDemo1.class b/Later/Java_Util_package/Random/12/RandomDemo/bin/RandomDemo1.class new file mode 100644 index 000000000..68a36938b Binary files /dev/null and b/Later/Java_Util_package/Random/12/RandomDemo/bin/RandomDemo1.class differ diff --git a/Later/Java_Util_package/Random/12/RandomDemo/bin/RandomDemo2.class b/Later/Java_Util_package/Random/12/RandomDemo/bin/RandomDemo2.class new file mode 100644 index 000000000..5d8f275b0 Binary files /dev/null and b/Later/Java_Util_package/Random/12/RandomDemo/bin/RandomDemo2.class differ diff --git a/Later/Java_Util_package/Random/12/RandomDemo/src/RandomDemo1.java b/Later/Java_Util_package/Random/12/RandomDemo/src/RandomDemo1.java new file mode 100644 index 000000000..370f6b0af --- /dev/null +++ b/Later/Java_Util_package/Random/12/RandomDemo/src/RandomDemo1.java @@ -0,0 +1,35 @@ +import java.util.Random; +import java.util.stream.LongStream; + +public class RandomDemo1 +{ + + public static void main(String[] args) + { + + Random random = new Random(); + + /* + * Returns an effectively unlimited stream of pseudorandom long values, + * each conforming to the given origin (inclusive) and bound + * (exclusive). + * + * Parameters: + * + * randomNumberOrigin - the origin (inclusive) of each random value + * + * randomNumberBound - the bound (exclusive) of each random value + * + * Returns: + * + * a stream of pseudorandom long values, each with the given origin + * (inclusive) and bound (exclusive) + * + */ + LongStream longStream = random.longs(1, 5); + + longStream.forEach(System.out::println); + + } + +} diff --git a/Later/Java_Util_package/Random/12/RandomDemo/src/RandomDemo2.java b/Later/Java_Util_package/Random/12/RandomDemo/src/RandomDemo2.java new file mode 100644 index 000000000..b5b5805e5 --- /dev/null +++ b/Later/Java_Util_package/Random/12/RandomDemo/src/RandomDemo2.java @@ -0,0 +1,36 @@ +import java.util.Random; +import java.util.stream.LongStream; + +public class RandomDemo2 +{ + + public static void main(String[] args) + { + Random random = new Random(); + + /* + * Returns a stream producing the given streamSize number of + * pseudorandom long, each conforming to the given origin (inclusive) + * and bound (exclusive). + * + * Parameters: + * + * streamSize - the number of values to generate + * + * randomNumberOrigin - the origin (inclusive) of each random value + * + * randomNumberBound - the bound (exclusive) of each random value + * + * Returns: + * + * a stream of pseudorandom long values, each with the given origin + * (inclusive) and bound (exclusive) + * + */ + LongStream longStream = random.longs(6, 1, 5); + + longStream.forEach(System.out::println); + + } + +} diff --git a/Later/Java_Util_package/Random/2/RandomDemo/.classpath b/Later/Java_Util_package/Random/2/RandomDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Random/2/RandomDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Random/2/RandomDemo/.project b/Later/Java_Util_package/Random/2/RandomDemo/.project new file mode 100644 index 000000000..22071f2a6 --- /dev/null +++ b/Later/Java_Util_package/Random/2/RandomDemo/.project @@ -0,0 +1,17 @@ + + + RandomDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Random/2/RandomDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Random/2/RandomDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Random/2/RandomDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Random/2/RandomDemo/bin/RandomDemo1.class b/Later/Java_Util_package/Random/2/RandomDemo/bin/RandomDemo1.class new file mode 100644 index 000000000..a1a5d4862 Binary files /dev/null and b/Later/Java_Util_package/Random/2/RandomDemo/bin/RandomDemo1.class differ diff --git a/Later/Java_Util_package/Random/2/RandomDemo/bin/RandomDemo2.class b/Later/Java_Util_package/Random/2/RandomDemo/bin/RandomDemo2.class new file mode 100644 index 000000000..017b4cacb Binary files /dev/null and b/Later/Java_Util_package/Random/2/RandomDemo/bin/RandomDemo2.class differ diff --git a/Later/Java_Util_package/Random/2/RandomDemo/bin/RandomDemo3.class b/Later/Java_Util_package/Random/2/RandomDemo/bin/RandomDemo3.class new file mode 100644 index 000000000..9ee3c0335 Binary files /dev/null and b/Later/Java_Util_package/Random/2/RandomDemo/bin/RandomDemo3.class differ diff --git a/Later/Java_Util_package/Random/2/RandomDemo/bin/RandomDemo4.class b/Later/Java_Util_package/Random/2/RandomDemo/bin/RandomDemo4.class new file mode 100644 index 000000000..82a6b4711 Binary files /dev/null and b/Later/Java_Util_package/Random/2/RandomDemo/bin/RandomDemo4.class differ diff --git a/Later/Java_Util_package/Random/2/RandomDemo/src/RandomDemo1.java b/Later/Java_Util_package/Random/2/RandomDemo/src/RandomDemo1.java new file mode 100644 index 000000000..ee0d92058 --- /dev/null +++ b/Later/Java_Util_package/Random/2/RandomDemo/src/RandomDemo1.java @@ -0,0 +1,26 @@ +import java.util.Random; + +public class RandomDemo1 +{ + + public static void main(String[] args) + { + Random random = new Random(); + + int i = 0; + while (i < 5) + { + /* + * Returns: + * + * the next pseudorandom, uniformly distributed long value + * from this random number generator's sequence + */ + long longValue = random.nextLong(); + System.out.println("longValue = " + longValue); + ++i; + } + + } + +} diff --git a/Later/Java_Util_package/Random/2/RandomDemo/src/RandomDemo2.java b/Later/Java_Util_package/Random/2/RandomDemo/src/RandomDemo2.java new file mode 100644 index 000000000..33c68a0e4 --- /dev/null +++ b/Later/Java_Util_package/Random/2/RandomDemo/src/RandomDemo2.java @@ -0,0 +1,28 @@ +import java.util.Random; + +public class RandomDemo2 +{ + + public static void main(String[] args) + { + + Random random = new Random(); + + int i = 0; + while (i < 5) + { + /* + * Returns: + * + * the next pseudorandom, uniformly distributed float + * value between 0.0 and 1.0 from this random number + * generator's sequence + */ + Float floatValue = random.nextFloat(); + System.out.println("floatValue" + floatValue); + ++i; + } + + } + +} diff --git a/Later/Java_Util_package/Random/2/RandomDemo/src/RandomDemo3.java b/Later/Java_Util_package/Random/2/RandomDemo/src/RandomDemo3.java new file mode 100644 index 000000000..2cc8d71c0 --- /dev/null +++ b/Later/Java_Util_package/Random/2/RandomDemo/src/RandomDemo3.java @@ -0,0 +1,28 @@ +import java.util.Random; + +public class RandomDemo3 +{ + + public static void main(String[] args) + { + + Random random = new Random(); + + int i = 0; + while (i < 5) + { + /* + * Returns: + * + * the next pseudorandom, uniformly distributed double + * value between 0.0 and 1.0 from this random number + * generator's sequence + */ + double doubleValue = random.nextDouble(); + System.out.println("doubleValue = " + doubleValue); + ++i; + } + + } + +} diff --git a/Later/Java_Util_package/Random/2/RandomDemo/src/RandomDemo4.java b/Later/Java_Util_package/Random/2/RandomDemo/src/RandomDemo4.java new file mode 100644 index 000000000..a19147b5f --- /dev/null +++ b/Later/Java_Util_package/Random/2/RandomDemo/src/RandomDemo4.java @@ -0,0 +1,27 @@ +import java.util.Random; + +public class RandomDemo4 +{ + + public static void main(String[] args) + { + + Random random = new Random(); + + int i = 0; + while (i < 5) + { + /* + * Returns: + * + * the next pseudorandom, uniformly distributed boolean + * value from this random number generator's sequence + */ + boolean booleanValue = random.nextBoolean(); + System.out.println("booleanValue = " + booleanValue); + ++i; + } + + } + +} diff --git a/Later/Java_Util_package/Random/3/RandomDemo/.classpath b/Later/Java_Util_package/Random/3/RandomDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Random/3/RandomDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Random/3/RandomDemo/.project b/Later/Java_Util_package/Random/3/RandomDemo/.project new file mode 100644 index 000000000..22071f2a6 --- /dev/null +++ b/Later/Java_Util_package/Random/3/RandomDemo/.project @@ -0,0 +1,17 @@ + + + RandomDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Random/3/RandomDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Random/3/RandomDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Random/3/RandomDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Random/3/RandomDemo/bin/RandomDemo1.class b/Later/Java_Util_package/Random/3/RandomDemo/bin/RandomDemo1.class new file mode 100644 index 000000000..1be120156 Binary files /dev/null and b/Later/Java_Util_package/Random/3/RandomDemo/bin/RandomDemo1.class differ diff --git a/Later/Java_Util_package/Random/3/RandomDemo/bin/RandomDemo2.class b/Later/Java_Util_package/Random/3/RandomDemo/bin/RandomDemo2.class new file mode 100644 index 000000000..edbe30c69 Binary files /dev/null and b/Later/Java_Util_package/Random/3/RandomDemo/bin/RandomDemo2.class differ diff --git a/Later/Java_Util_package/Random/3/RandomDemo/src/RandomDemo1.java b/Later/Java_Util_package/Random/3/RandomDemo/src/RandomDemo1.java new file mode 100644 index 000000000..7d344e06b --- /dev/null +++ b/Later/Java_Util_package/Random/3/RandomDemo/src/RandomDemo1.java @@ -0,0 +1,32 @@ +import java.util.Random; + +public class RandomDemo1 +{ + + public static void main(String[] args) + { + Random random = new Random(); + + int i = 0; + while (i < 5) + { + /* + * Parameters: + * + * bound - the upper bound (exclusive). Must be positive. + * + * Returns: + * + * the next pseudorandom, uniformly distributed int value + * between zero (inclusive) and bound (exclusive) from + * this random number generator's sequence + * + */ + long longValue = random.nextInt(100); + System.out.println("longValue = " + longValue); + ++i; + } + + } + +} diff --git a/Later/Java_Util_package/Random/3/RandomDemo/src/RandomDemo2.java b/Later/Java_Util_package/Random/3/RandomDemo/src/RandomDemo2.java new file mode 100644 index 000000000..6572e34d6 --- /dev/null +++ b/Later/Java_Util_package/Random/3/RandomDemo/src/RandomDemo2.java @@ -0,0 +1,28 @@ +import java.util.Random; + +public class RandomDemo2 +{ + + public static void main(String[] args) + { + + Random random = new Random(); + + int i = 0; + while (i < 5) + { + /* + * Returns: + * + * the next pseudorandom, uniformly distributed float + * value between 0.0 and 1.0 from this random number + * generator's sequence + */ + Double doubleValue = random.nextGaussian(); + System.out.println("doubleValue = " + doubleValue); + ++i; + } + + } + +} diff --git a/Later/Java_Util_package/Random/4/RandomDemo/.classpath b/Later/Java_Util_package/Random/4/RandomDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Random/4/RandomDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Random/4/RandomDemo/.project b/Later/Java_Util_package/Random/4/RandomDemo/.project new file mode 100644 index 000000000..22071f2a6 --- /dev/null +++ b/Later/Java_Util_package/Random/4/RandomDemo/.project @@ -0,0 +1,17 @@ + + + RandomDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Random/4/RandomDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Random/4/RandomDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Random/4/RandomDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Random/4/RandomDemo/bin/RandomDemo1.class b/Later/Java_Util_package/Random/4/RandomDemo/bin/RandomDemo1.class new file mode 100644 index 000000000..c6cf6d6c2 Binary files /dev/null and b/Later/Java_Util_package/Random/4/RandomDemo/bin/RandomDemo1.class differ diff --git a/Later/Java_Util_package/Random/4/RandomDemo/src/RandomDemo.java b/Later/Java_Util_package/Random/4/RandomDemo/src/RandomDemo.java new file mode 100644 index 000000000..222f1a71a --- /dev/null +++ b/Later/Java_Util_package/Random/4/RandomDemo/src/RandomDemo.java @@ -0,0 +1,43 @@ +import java.util.Random; + +public class RandomDemo +{ + + public static void main(String[] args) + { + + Random randomno = new Random(); + + byte[] byteArray = new byte[5]; + + System.out.println( + "------------- Before, nextBytes method is called ------------"); + + for (byte b : byteArray) + { + System.out.println(b); + } + + /* + * Generates random bytes and places them into a user-supplied + * byte array. The number of random bytes produced is equal to + * the length of the byte array. + * + * Parameters: + * + * bytes - the byte array to fill with random bytes + * + */ + randomno.nextBytes(byteArray); + + System.out.println( + "------------- After, nextBytes method is called ------------"); + + for (byte b : byteArray) + { + System.out.println(b); + } + + } + +} diff --git a/Later/Java_Util_package/Random/5/RandomDemo/.classpath b/Later/Java_Util_package/Random/5/RandomDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Random/5/RandomDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Random/5/RandomDemo/.project b/Later/Java_Util_package/Random/5/RandomDemo/.project new file mode 100644 index 000000000..22071f2a6 --- /dev/null +++ b/Later/Java_Util_package/Random/5/RandomDemo/.project @@ -0,0 +1,17 @@ + + + RandomDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Random/5/RandomDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Random/5/RandomDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Random/5/RandomDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Random/5/RandomDemo/bin/RandomDemo1.class b/Later/Java_Util_package/Random/5/RandomDemo/bin/RandomDemo1.class new file mode 100644 index 000000000..85a5bf7fe Binary files /dev/null and b/Later/Java_Util_package/Random/5/RandomDemo/bin/RandomDemo1.class differ diff --git a/Later/Java_Util_package/Random/5/RandomDemo/bin/RandomDemo2.class b/Later/Java_Util_package/Random/5/RandomDemo/bin/RandomDemo2.class new file mode 100644 index 000000000..5e4594ee1 Binary files /dev/null and b/Later/Java_Util_package/Random/5/RandomDemo/bin/RandomDemo2.class differ diff --git a/Later/Java_Util_package/Random/5/RandomDemo/src/RandomDemo1.java b/Later/Java_Util_package/Random/5/RandomDemo/src/RandomDemo1.java new file mode 100644 index 000000000..70d865577 --- /dev/null +++ b/Later/Java_Util_package/Random/5/RandomDemo/src/RandomDemo1.java @@ -0,0 +1,22 @@ +import java.util.Random; +import java.util.stream.DoubleStream; + +public class RandomDemo1 +{ + + public static void main(String[] args) + { + Random random = new Random(); + + /* + * Returns an effectively unlimited stream of pseudorandom + * double values, each between zero (inclusive) and one + * (exclusive). + */ + DoubleStream doubleStream = random.doubles(); + + doubleStream.forEach(System.out::println); + + } + +} diff --git a/Later/Java_Util_package/Random/5/RandomDemo/src/RandomDemo2.java b/Later/Java_Util_package/Random/5/RandomDemo/src/RandomDemo2.java new file mode 100644 index 000000000..fd5fe3951 --- /dev/null +++ b/Later/Java_Util_package/Random/5/RandomDemo/src/RandomDemo2.java @@ -0,0 +1,22 @@ +import java.util.Random; +import java.util.stream.DoubleStream; + +public class RandomDemo2 +{ + + public static void main(String[] args) + { + Random random = new Random(); + + /* + * Returns an effectively unlimited stream of pseudorandom + * double values, each between zero (inclusive) and one + * (exclusive). + */ + DoubleStream doubleStream = random.doubles(); + + doubleStream.limit(5).forEach(System.out::println); + + } + +} diff --git a/Later/Java_Util_package/Random/5/RandomDemo/src/RandomDemo3.java b/Later/Java_Util_package/Random/5/RandomDemo/src/RandomDemo3.java new file mode 100644 index 000000000..cc431a2dd --- /dev/null +++ b/Later/Java_Util_package/Random/5/RandomDemo/src/RandomDemo3.java @@ -0,0 +1,31 @@ +import java.util.Random; +import java.util.stream.DoubleStream; + +public class RandomDemo +{ + + public static void main(String[] args) + { + Random random = new Random(); + + /* + * Returns a stream producing the given streamSize number of + * pseudorandom double values, each between zero (inclusive) + * and one (exclusive). + * + * Parameters: + * + * streamSize - the number of values to generate + * + * Returns: + * + * a stream of double values + * + */ + DoubleStream doubleStream = random.doubles(10); + + doubleStream.forEach(System.out::println); + + } + +} diff --git a/Later/Java_Util_package/Random/6/RandomDemo/.classpath b/Later/Java_Util_package/Random/6/RandomDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Random/6/RandomDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Random/6/RandomDemo/.project b/Later/Java_Util_package/Random/6/RandomDemo/.project new file mode 100644 index 000000000..22071f2a6 --- /dev/null +++ b/Later/Java_Util_package/Random/6/RandomDemo/.project @@ -0,0 +1,17 @@ + + + RandomDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Random/6/RandomDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Random/6/RandomDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Random/6/RandomDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Random/6/RandomDemo/bin/RandomDemo1.class b/Later/Java_Util_package/Random/6/RandomDemo/bin/RandomDemo1.class new file mode 100644 index 000000000..9208264ae Binary files /dev/null and b/Later/Java_Util_package/Random/6/RandomDemo/bin/RandomDemo1.class differ diff --git a/Later/Java_Util_package/Random/6/RandomDemo/bin/RandomDemo2.class b/Later/Java_Util_package/Random/6/RandomDemo/bin/RandomDemo2.class new file mode 100644 index 000000000..9b3d71aaa Binary files /dev/null and b/Later/Java_Util_package/Random/6/RandomDemo/bin/RandomDemo2.class differ diff --git a/Later/Java_Util_package/Random/6/RandomDemo/src/RandomDemo1.java b/Later/Java_Util_package/Random/6/RandomDemo/src/RandomDemo1.java new file mode 100644 index 000000000..04ea505e9 --- /dev/null +++ b/Later/Java_Util_package/Random/6/RandomDemo/src/RandomDemo1.java @@ -0,0 +1,37 @@ +import java.util.Random; +import java.util.stream.DoubleStream; + +public class RandomDemo1 +{ + + public static void main(String[] args) + { + Random random = new Random(); + + /* + * Returns an effectively unlimited stream of pseudorandom + * double values, each conforming to the given origin + * (inclusive) and bound (exclusive). + * + * Parameters: + * + * randomNumberOrigin - the origin (inclusive) of each random + * value + * + * randomNumberBound - the bound (exclusive) of each random + * value + * + * Returns: + * + * a stream of pseudorandom double values, each with the given + * origin (inclusive) and bound (exclusive) + * + * + */ + DoubleStream doubleStream = random.doubles(5, 8); + + doubleStream.forEach(System.out::println); + + } + +} diff --git a/Later/Java_Util_package/Random/6/RandomDemo/src/RandomDemo2.java b/Later/Java_Util_package/Random/6/RandomDemo/src/RandomDemo2.java new file mode 100644 index 000000000..ca933ea43 --- /dev/null +++ b/Later/Java_Util_package/Random/6/RandomDemo/src/RandomDemo2.java @@ -0,0 +1,40 @@ +import java.util.Random; +import java.util.stream.DoubleStream; + +public class RandomDemo2 +{ + + public static void main(String[] args) + { + Random random = new Random(); + + /* + * Returns a stream producing the given streamSize number of + * pseudorandom double values, each conforming to the given + * origin (inclusive) and bound (exclusive). + * + * Parameters: + * + * streamSize - the number of values to generate + * + * + * randomNumberOrigin - the origin (inclusive) of each random + * value + * + * randomNumberBound - the bound (exclusive) of each random + * value + * + * Returns: + * + * a stream of pseudorandom double values, each with the given + * origin (inclusive) and bound (exclusive) + * + * + */ + DoubleStream doubleStream = random.doubles(3, 5, 8); + + doubleStream.forEach(System.out::println); + + } + +} diff --git a/Later/Java_Util_package/Random/7/RandomDemo/.classpath b/Later/Java_Util_package/Random/7/RandomDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Random/7/RandomDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Random/7/RandomDemo/.project b/Later/Java_Util_package/Random/7/RandomDemo/.project new file mode 100644 index 000000000..22071f2a6 --- /dev/null +++ b/Later/Java_Util_package/Random/7/RandomDemo/.project @@ -0,0 +1,17 @@ + + + RandomDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Random/7/RandomDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Random/7/RandomDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Random/7/RandomDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Random/7/RandomDemo/bin/RandomDemo1.class b/Later/Java_Util_package/Random/7/RandomDemo/bin/RandomDemo1.class new file mode 100644 index 000000000..97d0d95e1 Binary files /dev/null and b/Later/Java_Util_package/Random/7/RandomDemo/bin/RandomDemo1.class differ diff --git a/Later/Java_Util_package/Random/7/RandomDemo/bin/RandomDemo2.class b/Later/Java_Util_package/Random/7/RandomDemo/bin/RandomDemo2.class new file mode 100644 index 000000000..18de13eb0 Binary files /dev/null and b/Later/Java_Util_package/Random/7/RandomDemo/bin/RandomDemo2.class differ diff --git a/Later/Java_Util_package/Random/7/RandomDemo/src/RandomDemo1.java b/Later/Java_Util_package/Random/7/RandomDemo/src/RandomDemo1.java new file mode 100644 index 000000000..40f3499d2 --- /dev/null +++ b/Later/Java_Util_package/Random/7/RandomDemo/src/RandomDemo1.java @@ -0,0 +1,21 @@ +import java.util.Random; +import java.util.stream.IntStream; + +public class RandomDemo1 +{ + + public static void main(String[] args) + { + Random random = new Random(); + + /* + * Returns an effectively unlimited stream of pseudorandom int + * values. + */ + IntStream intStream = random.ints(); + + intStream.forEach(System.out::println); + + } + +} diff --git a/Later/Java_Util_package/Random/7/RandomDemo/src/RandomDemo2.java b/Later/Java_Util_package/Random/7/RandomDemo/src/RandomDemo2.java new file mode 100644 index 000000000..f7541e990 --- /dev/null +++ b/Later/Java_Util_package/Random/7/RandomDemo/src/RandomDemo2.java @@ -0,0 +1,30 @@ +import java.util.Random; +import java.util.stream.IntStream; + +public class RandomDemo2 +{ + + public static void main(String[] args) + { + Random random = new Random(); + + /* + * Returns a stream producing the given streamSize number of + * pseudorandom int values. + * + * Parameters: + * + * streamSize - the number of values to generate + * + * Returns: + * + * a stream of pseudorandom int values + * + */ + IntStream intStream = random.ints(5); + + intStream.forEach(System.out::println); + + } + +} diff --git a/Later/Java_Util_package/Random/8/RandomDemo/.classpath b/Later/Java_Util_package/Random/8/RandomDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Random/8/RandomDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Random/8/RandomDemo/.project b/Later/Java_Util_package/Random/8/RandomDemo/.project new file mode 100644 index 000000000..22071f2a6 --- /dev/null +++ b/Later/Java_Util_package/Random/8/RandomDemo/.project @@ -0,0 +1,17 @@ + + + RandomDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Random/8/RandomDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Random/8/RandomDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Random/8/RandomDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Random/8/RandomDemo/bin/RandomDemo1.class b/Later/Java_Util_package/Random/8/RandomDemo/bin/RandomDemo1.class new file mode 100644 index 000000000..de8c5c852 Binary files /dev/null and b/Later/Java_Util_package/Random/8/RandomDemo/bin/RandomDemo1.class differ diff --git a/Later/Java_Util_package/Random/8/RandomDemo/bin/RandomDemo2.class b/Later/Java_Util_package/Random/8/RandomDemo/bin/RandomDemo2.class new file mode 100644 index 000000000..0d5ee8614 Binary files /dev/null and b/Later/Java_Util_package/Random/8/RandomDemo/bin/RandomDemo2.class differ diff --git a/Later/Java_Util_package/Random/8/RandomDemo/src/RandomDemo1.java b/Later/Java_Util_package/Random/8/RandomDemo/src/RandomDemo1.java new file mode 100644 index 000000000..79bc576d0 --- /dev/null +++ b/Later/Java_Util_package/Random/8/RandomDemo/src/RandomDemo1.java @@ -0,0 +1,37 @@ +import java.util.Random; +import java.util.stream.IntStream; + +public class RandomDemo1 +{ + + public static void main(String[] args) + { + Random random = new Random(); + + /* + * Returns an effectively unlimited stream of pseudorandom int + * values, each conforming to the given origin (inclusive) and + * bound (exclusive). + * + * Parameters: + * + * randomNumberOrigin - the origin (inclusive) of each random + * value + * + * randomNumberBound - the bound (exclusive) of each random + * value + * + * Returns: + * + * a stream of pseudorandom int values, each with the given + * origin (inclusive) and bound (exclusive) + * + * + */ + IntStream intStream = random.ints(1, 5); + + intStream.forEach(System.out::println); + + } + +} diff --git a/Later/Java_Util_package/Random/8/RandomDemo/src/RandomDemo2.java b/Later/Java_Util_package/Random/8/RandomDemo/src/RandomDemo2.java new file mode 100644 index 000000000..df79c9ce8 --- /dev/null +++ b/Later/Java_Util_package/Random/8/RandomDemo/src/RandomDemo2.java @@ -0,0 +1,39 @@ +import java.util.Random; +import java.util.stream.IntStream; + +public class RandomDemo2 +{ + + public static void main(String[] args) + { + Random random = new Random(); + + /* + * Returns a stream producing the given streamSize number of + * pseudorandom int values, each conforming to the given + * origin (inclusive) and bound (exclusive). + * + * Parameters: + * + * streamSize - the number of values to generate + * + * randomNumberOrigin - the origin (inclusive) of each random + * value + * + * randomNumberBound - the bound (exclusive) of each random + * value + * + * Returns: + * + * a stream of pseudorandom int values, each with the given + * origin (inclusive) and bound (exclusive) + * + * + */ + IntStream intStream = random.ints(6, 1, 5); + + intStream.forEach(System.out::println); + + } + +} diff --git a/Later/Java_Util_package/Random/9/RandomDemo/.classpath b/Later/Java_Util_package/Random/9/RandomDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/Random/9/RandomDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/Random/9/RandomDemo/.project b/Later/Java_Util_package/Random/9/RandomDemo/.project new file mode 100644 index 000000000..22071f2a6 --- /dev/null +++ b/Later/Java_Util_package/Random/9/RandomDemo/.project @@ -0,0 +1,17 @@ + + + RandomDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/Random/9/RandomDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/Random/9/RandomDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/Random/9/RandomDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/Random/9/RandomDemo/bin/RandomDemo1.class b/Later/Java_Util_package/Random/9/RandomDemo/bin/RandomDemo1.class new file mode 100644 index 000000000..85a5bf7fe Binary files /dev/null and b/Later/Java_Util_package/Random/9/RandomDemo/bin/RandomDemo1.class differ diff --git a/Later/Java_Util_package/Random/9/RandomDemo/bin/RandomDemo2.class b/Later/Java_Util_package/Random/9/RandomDemo/bin/RandomDemo2.class new file mode 100644 index 000000000..bc14011e6 Binary files /dev/null and b/Later/Java_Util_package/Random/9/RandomDemo/bin/RandomDemo2.class differ diff --git a/Later/Java_Util_package/Random/9/RandomDemo/src/RandomDemo1.java b/Later/Java_Util_package/Random/9/RandomDemo/src/RandomDemo1.java new file mode 100644 index 000000000..70d865577 --- /dev/null +++ b/Later/Java_Util_package/Random/9/RandomDemo/src/RandomDemo1.java @@ -0,0 +1,22 @@ +import java.util.Random; +import java.util.stream.DoubleStream; + +public class RandomDemo1 +{ + + public static void main(String[] args) + { + Random random = new Random(); + + /* + * Returns an effectively unlimited stream of pseudorandom + * double values, each between zero (inclusive) and one + * (exclusive). + */ + DoubleStream doubleStream = random.doubles(); + + doubleStream.forEach(System.out::println); + + } + +} diff --git a/Later/Java_Util_package/Random/9/RandomDemo/src/RandomDemo2.java b/Later/Java_Util_package/Random/9/RandomDemo/src/RandomDemo2.java new file mode 100644 index 000000000..83ed0335c --- /dev/null +++ b/Later/Java_Util_package/Random/9/RandomDemo/src/RandomDemo2.java @@ -0,0 +1,31 @@ +import java.util.Random; +import java.util.stream.DoubleStream; + +public class RandomDemo2 +{ + + public static void main(String[] args) + { + Random random = new Random(); + + /* + * Returns a stream producing the given streamSize number of + * pseudorandom double values, each between zero (inclusive) + * and one (exclusive). + * + * Parameters: + * + * streamSize - the number of values to generate + * + * Returns: + * + * a stream of double values + * + */ + DoubleStream doubleStream = random.doubles(5); + + doubleStream.forEach(System.out::println); + + } + +} diff --git a/Later/Java_Util_package/UUID/1/UUID.pptx b/Later/Java_Util_package/UUID/1/UUID.pptx new file mode 100644 index 000000000..c88fa114a Binary files /dev/null and b/Later/Java_Util_package/UUID/1/UUID.pptx differ diff --git a/Later/Java_Util_package/UUID/1/UUIDDemo/.classpath b/Later/Java_Util_package/UUID/1/UUIDDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/UUID/1/UUIDDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/UUID/1/UUIDDemo/.project b/Later/Java_Util_package/UUID/1/UUIDDemo/.project new file mode 100644 index 000000000..babc29192 --- /dev/null +++ b/Later/Java_Util_package/UUID/1/UUIDDemo/.project @@ -0,0 +1,17 @@ + + + UUIDDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/UUID/1/UUIDDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/UUID/1/UUIDDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/UUID/1/UUIDDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/UUID/1/UUIDDemo/bin/UUIDDemo.class b/Later/Java_Util_package/UUID/1/UUIDDemo/bin/UUIDDemo.class new file mode 100644 index 000000000..145be6891 Binary files /dev/null and b/Later/Java_Util_package/UUID/1/UUIDDemo/bin/UUIDDemo.class differ diff --git a/Later/Java_Util_package/UUID/1/UUIDDemo/src/UUIDDemo.java b/Later/Java_Util_package/UUID/1/UUIDDemo/src/UUIDDemo.java new file mode 100644 index 000000000..f6f0ee1aa --- /dev/null +++ b/Later/Java_Util_package/UUID/1/UUIDDemo/src/UUIDDemo.java @@ -0,0 +1,26 @@ +import java.util.UUID; + +public class UUIDDemo +{ + + public static void main(String[] args) + { + + /* + * Constructs a new UUID using the specified data. mostSigBits + * is used for the most significant 64 bits of the UUID and + * leastSigBits becomes the least significant 64 bits of the + * UUID. + * + * Parameters: + * + * mostSigBits - The most significant bits of the UUID + * + * leastSigBits - The least significant bits of the UUID + */ + UUID uuid = new UUID(9999999L, 898989778L); + System.out.println(uuid); + + } + +} diff --git a/Later/Java_Util_package/UUID/2/UUIDDemo/.classpath b/Later/Java_Util_package/UUID/2/UUIDDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/UUID/2/UUIDDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/UUID/2/UUIDDemo/.project b/Later/Java_Util_package/UUID/2/UUIDDemo/.project new file mode 100644 index 000000000..babc29192 --- /dev/null +++ b/Later/Java_Util_package/UUID/2/UUIDDemo/.project @@ -0,0 +1,17 @@ + + + UUIDDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/UUID/2/UUIDDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/UUID/2/UUIDDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/UUID/2/UUIDDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/UUID/2/UUIDDemo/bin/UUIDDemo1.class b/Later/Java_Util_package/UUID/2/UUIDDemo/bin/UUIDDemo1.class new file mode 100644 index 000000000..34eaa583b Binary files /dev/null and b/Later/Java_Util_package/UUID/2/UUIDDemo/bin/UUIDDemo1.class differ diff --git a/Later/Java_Util_package/UUID/2/UUIDDemo/bin/UUIDDemo2.class b/Later/Java_Util_package/UUID/2/UUIDDemo/bin/UUIDDemo2.class new file mode 100644 index 000000000..64fcff78d Binary files /dev/null and b/Later/Java_Util_package/UUID/2/UUIDDemo/bin/UUIDDemo2.class differ diff --git a/Later/Java_Util_package/UUID/2/UUIDDemo/bin/UUIDDemo3.class b/Later/Java_Util_package/UUID/2/UUIDDemo/bin/UUIDDemo3.class new file mode 100644 index 000000000..236f32ef6 Binary files /dev/null and b/Later/Java_Util_package/UUID/2/UUIDDemo/bin/UUIDDemo3.class differ diff --git a/Later/Java_Util_package/UUID/2/UUIDDemo/src/UUIDDemo1.java b/Later/Java_Util_package/UUID/2/UUIDDemo/src/UUIDDemo1.java new file mode 100644 index 000000000..752d839cb --- /dev/null +++ b/Later/Java_Util_package/UUID/2/UUIDDemo/src/UUIDDemo1.java @@ -0,0 +1,27 @@ +import java.util.UUID; + +public class UUIDDemo1 +{ + + public static void main(String[] args) + { + + /* + * Creates a UUID from the string standard representation + * + * Parameters: + * + * name - A string that specifies a UUID + * + * Returns: + * + * A UUID with the specified value + */ + UUID uuid = UUID + .fromString("90400000-8cf0-11bd-b23e-10b96e4ef00d"); + + System.out.println(uuid); + + } + +} diff --git a/Later/Java_Util_package/UUID/2/UUIDDemo/src/UUIDDemo2.java b/Later/Java_Util_package/UUID/2/UUIDDemo/src/UUIDDemo2.java new file mode 100644 index 000000000..8cfe37d8f --- /dev/null +++ b/Later/Java_Util_package/UUID/2/UUIDDemo/src/UUIDDemo2.java @@ -0,0 +1,24 @@ +import java.util.UUID; + +public class UUIDDemo2 +{ + + public static void main(String[] args) + { + + /* + * Static factory to retrieve a type 4 (pseudo randomly + * generated) UUID. The UUID is generated using a + * cryptographically strong pseudo random number generator. + * + * Returns: + * + * A randomly generated UUID + */ + UUID uuid = UUID.randomUUID(); + + System.out.println(uuid); + + } + +} diff --git a/Later/Java_Util_package/UUID/2/UUIDDemo/src/UUIDDemo3.java b/Later/Java_Util_package/UUID/2/UUIDDemo/src/UUIDDemo3.java new file mode 100644 index 000000000..d83ece2f0 --- /dev/null +++ b/Later/Java_Util_package/UUID/2/UUIDDemo/src/UUIDDemo3.java @@ -0,0 +1,30 @@ +import java.util.UUID; + +public class UUIDDemo3 +{ + + public static void main(String[] args) + { + + byte[] byteArray = { 20, 40, 60 }; + + /* + * Static factory to retrieve a type 3 (name based) UUID based + * on the specified byte array. + * + * Parameters: + * + * name - A byte array to be used to construct a UUID + * + * Returns: + * + * A UUID generated from the specified array + */ + UUID uuid = UUID.nameUUIDFromBytes(byteArray); + + // checking UUID value + System.out.println(uuid); + + } + +} diff --git a/Later/Java_Util_package/UUID/3/UUIDDemo/.classpath b/Later/Java_Util_package/UUID/3/UUIDDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/UUID/3/UUIDDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/UUID/3/UUIDDemo/.project b/Later/Java_Util_package/UUID/3/UUIDDemo/.project new file mode 100644 index 000000000..babc29192 --- /dev/null +++ b/Later/Java_Util_package/UUID/3/UUIDDemo/.project @@ -0,0 +1,17 @@ + + + UUIDDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/UUID/3/UUIDDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/UUID/3/UUIDDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/UUID/3/UUIDDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/UUID/3/UUIDDemo/bin/UUIDDemo.class b/Later/Java_Util_package/UUID/3/UUIDDemo/bin/UUIDDemo.class new file mode 100644 index 000000000..7d99fc60c Binary files /dev/null and b/Later/Java_Util_package/UUID/3/UUIDDemo/bin/UUIDDemo.class differ diff --git a/Later/Java_Util_package/UUID/3/UUIDDemo/src/UUIDDemo.java b/Later/Java_Util_package/UUID/3/UUIDDemo/src/UUIDDemo.java new file mode 100644 index 000000000..12119aefd --- /dev/null +++ b/Later/Java_Util_package/UUID/3/UUIDDemo/src/UUIDDemo.java @@ -0,0 +1,30 @@ +import java.util.UUID; + +public class UUIDDemo +{ + + public static void main(String[] args) + { + + UUID uuid = new UUID(9999999L, 898989778L); + + /* + * Returns the most significant 64 bits of this UUID's 128 bit + * value. + */ + long mostSignificantBits = uuid.getMostSignificantBits(); + System.out.println( + "mostSignificantBits = " + mostSignificantBits); + + /* + * Returns the least significant 64 bits of this UUID's 128 + * bit value. + */ + long leastSignificantBits = uuid.getLeastSignificantBits(); + + System.out.println( + "leastSignificantBits = " + leastSignificantBits); + + } + +} diff --git a/Later/Java_Util_package/UUID/4/UUIDDemo/.classpath b/Later/Java_Util_package/UUID/4/UUIDDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/UUID/4/UUIDDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/UUID/4/UUIDDemo/.project b/Later/Java_Util_package/UUID/4/UUIDDemo/.project new file mode 100644 index 000000000..babc29192 --- /dev/null +++ b/Later/Java_Util_package/UUID/4/UUIDDemo/.project @@ -0,0 +1,17 @@ + + + UUIDDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/UUID/4/UUIDDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/UUID/4/UUIDDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/UUID/4/UUIDDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/UUID/4/UUIDDemo/bin/UUIDDemo.class b/Later/Java_Util_package/UUID/4/UUIDDemo/bin/UUIDDemo.class new file mode 100644 index 000000000..dff9dbdf8 Binary files /dev/null and b/Later/Java_Util_package/UUID/4/UUIDDemo/bin/UUIDDemo.class differ diff --git a/Later/Java_Util_package/UUID/4/UUIDDemo/src/UUIDDemo.java b/Later/Java_Util_package/UUID/4/UUIDDemo/src/UUIDDemo.java new file mode 100644 index 000000000..658cb3d2c --- /dev/null +++ b/Later/Java_Util_package/UUID/4/UUIDDemo/src/UUIDDemo.java @@ -0,0 +1,55 @@ +import java.util.UUID; + +public class UUIDDemo +{ + + public static void main(String[] args) + { + + UUID uuid = UUID + .fromString("38400000-8cf0-11bd-b23e-10b96e4ef00d"); + + /* + * The clock sequence value associated with this UUID. + * + * The 14 bit clock sequence value is constructed from the + * clock sequence field of this UUID. The clock sequence field + * is used to guarantee temporal uniqueness in a time-based + * UUID. + * + * The clockSequence value is only meaningful in a time-based + * UUID, which has version type 1. If this UUID is not a + * time-based UUID then this method throws + * UnsupportedOperationException. + * + * + * Returns: + * + * The clock sequence of this UUID + * + */ + int clockSequence = uuid.clockSequence(); + System.out.println("clockSequence = " + clockSequence); + + /* + * The node value associated with this UUID. The 48 bit node + * value is constructed from the node field of this UUID. This + * field is intended to hold the IEEE 802 address of the + * machine that generated this UUID to guarantee spatial + * uniqueness. + * + * The node value is only meaningful in a time-based UUID, + * which has version type 1. If this UUID is not a time-based + * UUID then this method throws UnsupportedOperationException. + * + * Returns: + * + * The clock sequence of this UUID + * + */ + long nodeValue = uuid.node(); + System.out.println("nodeValue = " + nodeValue); + + } + +} diff --git a/Later/Java_Util_package/UUID/5/UUIDDemo/.classpath b/Later/Java_Util_package/UUID/5/UUIDDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/UUID/5/UUIDDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/UUID/5/UUIDDemo/.project b/Later/Java_Util_package/UUID/5/UUIDDemo/.project new file mode 100644 index 000000000..babc29192 --- /dev/null +++ b/Later/Java_Util_package/UUID/5/UUIDDemo/.project @@ -0,0 +1,17 @@ + + + UUIDDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/UUID/5/UUIDDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/UUID/5/UUIDDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/UUID/5/UUIDDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/UUID/5/UUIDDemo/bin/UUIDDemo.class b/Later/Java_Util_package/UUID/5/UUIDDemo/bin/UUIDDemo.class new file mode 100644 index 000000000..b6ebd770e Binary files /dev/null and b/Later/Java_Util_package/UUID/5/UUIDDemo/bin/UUIDDemo.class differ diff --git a/Later/Java_Util_package/UUID/5/UUIDDemo/src/UUIDDemo.java b/Later/Java_Util_package/UUID/5/UUIDDemo/src/UUIDDemo.java new file mode 100644 index 000000000..7bd1adcf4 --- /dev/null +++ b/Later/Java_Util_package/UUID/5/UUIDDemo/src/UUIDDemo.java @@ -0,0 +1,47 @@ +import java.util.UUID; + +public class UUIDDemo +{ + + public static void main(String[] args) + { + + UUID uuid = UUID + .fromString("38400000-8cf0-11bd-b23e-10b96e4ef00d"); + + /* + * The timestamp value associated with this UUID. + * + * The 60 bit timestamp value is constructed from the + * time_low, time_mid, and time_hi fields of this UUID. The + * resulting timestamp is measured in 100-nanosecond units + * since midnight, October 15, 1582 UTC. + * + * The timestamp value is only meaningful in a time-based + * UUID, which has version type 1. If this UUID is not a + * time-based UUID then this method throws + * UnsupportedOperationException. + * + * Returns: + * + * The timestamp of this UUID. + * + */ + long timeStamp = uuid.timestamp(); + System.out.println("timeStamp = " + timeStamp); + + /* + * The variant number associated with this UUID. The variant + * number describes the layout of the UUID. + * + * Returns: + * + * The variant number of this UUID + * + */ + int variant = uuid.variant(); + System.out.println("variant = " + variant); + + } + +} diff --git a/Later/Java_Util_package/UUID/6/UUIDDemo/.classpath b/Later/Java_Util_package/UUID/6/UUIDDemo/.classpath new file mode 100644 index 000000000..fceb4801b --- /dev/null +++ b/Later/Java_Util_package/UUID/6/UUIDDemo/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Later/Java_Util_package/UUID/6/UUIDDemo/.project b/Later/Java_Util_package/UUID/6/UUIDDemo/.project new file mode 100644 index 000000000..babc29192 --- /dev/null +++ b/Later/Java_Util_package/UUID/6/UUIDDemo/.project @@ -0,0 +1,17 @@ + + + UUIDDemo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Later/Java_Util_package/UUID/6/UUIDDemo/.settings/org.eclipse.jdt.core.prefs b/Later/Java_Util_package/UUID/6/UUIDDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/Later/Java_Util_package/UUID/6/UUIDDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Later/Java_Util_package/UUID/6/UUIDDemo/bin/UUIDDemo.class b/Later/Java_Util_package/UUID/6/UUIDDemo/bin/UUIDDemo.class new file mode 100644 index 000000000..7a6770a0e Binary files /dev/null and b/Later/Java_Util_package/UUID/6/UUIDDemo/bin/UUIDDemo.class differ diff --git a/Later/Java_Util_package/UUID/6/UUIDDemo/src/UUIDDemo.java b/Later/Java_Util_package/UUID/6/UUIDDemo/src/UUIDDemo.java new file mode 100644 index 000000000..271c6f64d --- /dev/null +++ b/Later/Java_Util_package/UUID/6/UUIDDemo/src/UUIDDemo.java @@ -0,0 +1,33 @@ +import java.util.UUID; + +public class UUIDDemo +{ + + public static void main(String[] args) + { + + UUID uuid = UUID + .fromString("38400000-8cf0-11bd-b23e-10b96e4ef00d"); + + /* + * The version number associated with this UUID. The version + * number describes how this UUID was generated. The version + * number has the following meaning: + * + * 1. Time-based UUID + * 2. DCE security UUID + * 3. Name-based UUID + * 4. Randomly generated UUID + * + * + * Returns: + * + * The timestamp of this UUID. + * + */ + int version = uuid.version(); + System.out.println("version = " + version); + + } + +} diff --git a/Later/POC/gs-messaging-rabbitmq/.gitignore b/Later/POC/gs-messaging-rabbitmq/.gitignore new file mode 100644 index 000000000..6a08cab17 --- /dev/null +++ b/Later/POC/gs-messaging-rabbitmq/.gitignore @@ -0,0 +1,30 @@ +# Operating System Files + +*.DS_Store +Thumbs.db + +# Build Files # + +bin +target +build/ +.gradle + +# Eclipse Project Files # + +.classpath +.project +.settings + +# IntelliJ IDEA Files # + +*.iml +*.ipr +*.iws +*.idea + +# Spring Bootstrap artifacts + +dependency-reduced-pom.xml +out +README.html diff --git a/Later/POC/gs-messaging-rabbitmq/.travis.yml b/Later/POC/gs-messaging-rabbitmq/.travis.yml new file mode 100644 index 000000000..458d08eaa --- /dev/null +++ b/Later/POC/gs-messaging-rabbitmq/.travis.yml @@ -0,0 +1,11 @@ +sudo: false +language: java +jdk: +- oraclejdk8 +script: +- test/run.sh +services: +- rabbitmq +notifications: + slack: + secure: fYyNAlqkhPGoJXDckeVaoEJAtf8x5c4lBxmC1DJRee77egFlmSFppZ6xVHsR+Jpa44AxA0vHjkUVO3vEJKxDn0bMGu3sQXs0QmJDIGrHK8Pms759eYLKAj46sWHkpVO1Ot++Szo/A+vubxE2XQIX3gBt7g47R5pS/zuDySCCyNk= diff --git a/Later/POC/gs-messaging-rabbitmq/CONTRIBUTING.adoc b/Later/POC/gs-messaging-rabbitmq/CONTRIBUTING.adoc new file mode 100644 index 000000000..a97e428a4 --- /dev/null +++ b/Later/POC/gs-messaging-rabbitmq/CONTRIBUTING.adoc @@ -0,0 +1,2 @@ +If you have not previously done so, please fill out and +submit the https://cla.pivotal.io/sign/spring[Contributor License Agreement]. \ No newline at end of file diff --git a/Later/POC/gs-messaging-rabbitmq/README.adoc b/Later/POC/gs-messaging-rabbitmq/README.adoc new file mode 100644 index 000000000..b9e13d35c --- /dev/null +++ b/Later/POC/gs-messaging-rabbitmq/README.adoc @@ -0,0 +1,147 @@ +--- +tags: [messaging, rabbitmq, stream] +projects: [spring-amqp,spring-cloud-stream] +--- +:spring_boot_version: 1.5.3.RELEASE +:toc: +:icons: font +:source-highlighter: prettify +:project_id: gs-messaging-rabbitmq +This guide walks you through the process of setting up a RabbitMQ AMQP server that publishes and subscribes to messages. + +== What you'll build + +You'll build an application that publishes a message using Spring AMQP's `RabbitTemplate` and subscribes to the message on a link:/understanding/POJO[POJO] using `MessageListenerAdapter`. + +== What you'll need +:java_version: 1.8 +include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/prereq_editor_jdk_buildtools.adoc[] ++ +- RabbitMQ server (installation instructions below) + +include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/how_to_complete_this_guide.adoc[] + + +include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/hide-show-gradle.adoc[] + +include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/hide-show-maven.adoc[] + +include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/hide-show-sts.adoc[] + + +== Set up RabbitMQ broker +Before you can build your messaging application, you need to set up the server that will handle receiving and sending messages. + +RabbitMQ is an AMQP server. The server is freely available at http://www.rabbitmq.com/download.html. You can download it manually, or if you are using a Mac with homebrew: + +---- +brew install rabbitmq +---- + +Unpack the server and launch it with default settings. + +---- +rabbitmq-server +---- + +You should see something like this: + +.... + RabbitMQ 3.1.3. Copyright (C) 2007-2013 VMware, Inc. +## ## Licensed under the MPL. See http://www.rabbitmq.com/ +## ## +########## Logs: /usr/local/var/log/rabbitmq/rabbit@localhost.log +###### ## /usr/local/var/log/rabbitmq/rabbit@localhost-sasl.log +########## + Starting broker... completed with 6 plugins. +.... + +You can also use https://docs.docker.com/compose/[Docker Compose] to quickly launch a RabbitMQ server if you have docker running locally. There is a `docker-compose.yml` in the root of the "complete" project in Github. It is very simple: + +`docker-compose.yml` +[source,yaml] +---- +rabbitmq: + image: rabbitmq:management + ports: + - "5672:5672" + - "15672:15672" +---- + +With this file in the current directory you can run `docker-compose up` to get RabbitMQ running in a container. + +[[initial]] +== Create a RabbitMQ message receiver + +With any messaging-based application, you need to create a receiver that will respond to published messages. + +`src/main/java/hello/Receiver.java` +[source,java] +---- +include::complete/src/main/java/hello/Receiver.java[] +---- + +The `Receiver` is a simple POJO that defines a method for receiving messages. When you register it to receive messages, you can name it anything you want. + +NOTE: For convenience, this POJO also has a `CountDownLatch`. This allows it to signal that the message is received. This is something you are not likely to implement in a production application. + +== Register the listener and send a message + +Spring AMQP's `RabbitTemplate` provides everything you need to send and receive messages with RabbitMQ. Specifically, you need to configure: + +- A message listener container +- Declare the queue, the exchange, and the binding between them +- A component to send some messages to test the listener + +NOTE: Spring Boot automatically creates a connection factory and a RabbitTemplate, reducing the amount of code you have to write. + +You'll use `RabbitTemplate` to send messages, and you will register a `Receiver` with the message listener container to receive messages. The connection factory drives both, allowing them to connect to the RabbitMQ server. + +`src/main/java/hello/Application.java` +[source,java] +---- +include::complete/src/main/java/hello/Application.java[] +---- + +include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/spring-boot-application.adoc[] + +The bean defined in the `listenerAdapter()` method is registered as a message listener in the container defined in `container()`. It will listen for messages on the "spring-boot" queue. Because the `Receiver` class is a POJO, it needs to be wrapped in the `MessageListenerAdapter`, where you specify it to invoke `receiveMessage`. + +NOTE: JMS queues and AMQP queues have different semantics. For example, JMS sends queued messages to only one consumer. While AMQP queues do the same thing, AMQP producers don't send messages directly to queues. Instead, a message is sent to an exchange, which can go to a single queue, or fanout to multiple queues, emulating the concept of JMS topics. For more, see link:/understanding/AMQP[Understanding AMQP]. + +The message listener container and receiver beans are all you need to listen for messages. To send a message, you also need a Rabbit template. + +The `queue()` method creates an AMQP queue. The `exchange()` method creates a topic exchange. The `binding()` method binds these two together, defining the behavior that occurs when RabbitTemplate publishes to an exchange. + +NOTE: Spring AMQP requires that the `Queue`, the `TopicExchange`, and the `Binding` be declared as top level Spring beans in order to be set up properly. + +== Send a Test Message + +Test messages are sent by a `CommandLineRunner`, which also waits for the latch in the receiver and closes the application context: + +`src/main/java/hello/Runner.java` +[source,java] +---- +include::complete/src/main/java/hello/Runner.java[] +---- + +The runner can be mocked out in tests, so that the receiver can be tested in isolation. + +== Run the Application + +The `main()` method starts that process by creating a Spring application context. This starts the message listener container, which will start listening for messages. There is a `Runner` bean which is then automatically executed: it retrieves the `RabbitTemplate` from the application context and sends a "Hello from RabbitMQ!" message on the "spring-boot" queue. Finally, it closes the Spring application context and the application ends. + +include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/build_an_executable_jar_mainhead.adoc[] +include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/build_an_executable_jar_with_both.adoc[] + +You should see the following output: + + Sending message... + Received + +== Summary +Congratulations! You've just developed a simple publish-and-subscribe application with Spring and RabbitMQ. There's http://docs.spring.io/spring-amqp/reference/html/_introduction.html#quick-tour[more you can do with Spring and RabbitMQ] than what is covered here, but this should provide a good start. + + +include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/footer.adoc[] + diff --git a/Later/POC/gs-messaging-rabbitmq/complete/.mvn/wrapper/maven-wrapper.jar b/Later/POC/gs-messaging-rabbitmq/complete/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 000000000..5fd4d5023 Binary files /dev/null and b/Later/POC/gs-messaging-rabbitmq/complete/.mvn/wrapper/maven-wrapper.jar differ diff --git a/Later/POC/gs-messaging-rabbitmq/complete/.mvn/wrapper/maven-wrapper.properties b/Later/POC/gs-messaging-rabbitmq/complete/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 000000000..c954cec91 --- /dev/null +++ b/Later/POC/gs-messaging-rabbitmq/complete/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1 @@ +distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip diff --git a/Later/POC/gs-messaging-rabbitmq/complete/build.gradle b/Later/POC/gs-messaging-rabbitmq/complete/build.gradle new file mode 100644 index 000000000..619f2b2ea --- /dev/null +++ b/Later/POC/gs-messaging-rabbitmq/complete/build.gradle @@ -0,0 +1,31 @@ +buildscript { + repositories { + mavenCentral() + } + dependencies { + classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.3.RELEASE") + } +} + +apply plugin: 'java' +apply plugin: 'eclipse' +apply plugin: 'idea' +apply plugin: 'org.springframework.boot' + +jar { + baseName = 'gs-messaging-rabbitmq' + version = '0.1.0' +} + +repositories { + mavenCentral() +} + +sourceCompatibility = 1.8 +targetCompatibility = 1.8 + +dependencies { + compile("org.springframework.boot:spring-boot-starter-amqp") + testCompile("org.springframework.boot:spring-boot-starter-test") +} + diff --git a/Later/POC/gs-messaging-rabbitmq/complete/docker-compose.yml b/Later/POC/gs-messaging-rabbitmq/complete/docker-compose.yml new file mode 100644 index 000000000..f1b4d67c5 --- /dev/null +++ b/Later/POC/gs-messaging-rabbitmq/complete/docker-compose.yml @@ -0,0 +1,5 @@ +rabbitmq: + host: 192.168.142.83 + ports: + - "w5672:56723" + - "w15672:15672" diff --git a/Later/POC/gs-messaging-rabbitmq/complete/gradle/wrapper/gradle-wrapper.jar b/Later/POC/gs-messaging-rabbitmq/complete/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000..05ef575b0 Binary files /dev/null and b/Later/POC/gs-messaging-rabbitmq/complete/gradle/wrapper/gradle-wrapper.jar differ diff --git a/Later/POC/gs-messaging-rabbitmq/complete/gradle/wrapper/gradle-wrapper.properties b/Later/POC/gs-messaging-rabbitmq/complete/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..c6bff2007 --- /dev/null +++ b/Later/POC/gs-messaging-rabbitmq/complete/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Aug 29 13:07:03 CDT 2016 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip diff --git a/Later/POC/gs-messaging-rabbitmq/complete/gradlew b/Later/POC/gs-messaging-rabbitmq/complete/gradlew new file mode 100644 index 000000000..9d82f7891 --- /dev/null +++ b/Later/POC/gs-messaging-rabbitmq/complete/gradlew @@ -0,0 +1,160 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/Later/POC/gs-messaging-rabbitmq/complete/gradlew.bat b/Later/POC/gs-messaging-rabbitmq/complete/gradlew.bat new file mode 100644 index 000000000..8a0b282aa --- /dev/null +++ b/Later/POC/gs-messaging-rabbitmq/complete/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/Later/POC/gs-messaging-rabbitmq/complete/mvnw b/Later/POC/gs-messaging-rabbitmq/complete/mvnw new file mode 100644 index 000000000..a1ba1bf55 --- /dev/null +++ b/Later/POC/gs-messaging-rabbitmq/complete/mvnw @@ -0,0 +1,233 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven2 Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # + # Look for the Apple JDKs first to preserve the existing behaviour, and then look + # for the new JDKs provided by Oracle. + # + if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then + # + # Apple JDKs + # + export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then + # + # Apple JDKs + # + export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then + # + # Oracle JDKs + # + export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then + # + # Apple JDKs + # + export JAVA_HOME=`/usr/libexec/java_home` + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Migwn, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" + # TODO classpath? +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` +fi + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + local basedir=$(pwd) + local wdir=$(pwd) + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + wdir=$(cd "$wdir/.."; pwd) + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} "$@" diff --git a/Later/POC/gs-messaging-rabbitmq/complete/mvnw.cmd b/Later/POC/gs-messaging-rabbitmq/complete/mvnw.cmd new file mode 100644 index 000000000..2b934e89d --- /dev/null +++ b/Later/POC/gs-messaging-rabbitmq/complete/mvnw.cmd @@ -0,0 +1,145 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +set MAVEN_CMD_LINE_ARGS=%* + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" + +set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar"" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS% +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% \ No newline at end of file diff --git a/Later/POC/gs-messaging-rabbitmq/complete/pom.xml b/Later/POC/gs-messaging-rabbitmq/complete/pom.xml new file mode 100644 index 000000000..5271f2edc --- /dev/null +++ b/Later/POC/gs-messaging-rabbitmq/complete/pom.xml @@ -0,0 +1,42 @@ + + + 4.0.0 + + org.springframework + gs-messaging-rabbitmq + 0.1.0 + + + org.springframework.boot + spring-boot-starter-parent + 1.5.3.RELEASE + + + + 1.8 + + + + + org.springframework.boot + spring-boot-starter-amqp + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/Later/POC/gs-messaging-rabbitmq/complete/src/main/java/hello/Application.java b/Later/POC/gs-messaging-rabbitmq/complete/src/main/java/hello/Application.java new file mode 100644 index 000000000..fbcc228b0 --- /dev/null +++ b/Later/POC/gs-messaging-rabbitmq/complete/src/main/java/hello/Application.java @@ -0,0 +1,82 @@ +package hello; + +import org.springframework.amqp.core.Binding; +import org.springframework.amqp.core.BindingBuilder; +import org.springframework.amqp.core.Queue; +import org.springframework.amqp.core.TopicExchange; +import org.springframework.amqp.rabbit.connection.CachingConnectionFactory; +import org.springframework.amqp.rabbit.connection.Connection; +import org.springframework.amqp.rabbit.connection.ConnectionFactory; +import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; +import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +@SpringBootApplication +public class Application +{ + + final static String queueName = "spring-boot"; + + @Bean + CachingConnectionFactory connectionFactory() + { + + CachingConnectionFactory connectionFactory = new CachingConnectionFactory( + "192.168.142.83"); + connectionFactory.setUsername("guest"); + connectionFactory.setPassword("guest"); + return connectionFactory; + + } + + @Bean + Queue queue() + { + return new Queue(queueName, false); + } + + @Bean + TopicExchange exchange() + { + return new TopicExchange("spring-boot-exchange"); + } + + @Bean + Binding binding(Queue queue, TopicExchange exchange) + { + return BindingBuilder.bind(queue).to(exchange) + .with(queueName); + } + + @Bean + SimpleMessageListenerContainer container( + ConnectionFactory connectionFactory, + MessageListenerAdapter listenerAdapter) + { + SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); + + System.out.println("connectionFactory host = "+ connectionFactory.getHost()); + + System.out.println("connectionFactory port = "+ connectionFactory.getPort()); + + container.setConnectionFactory(connectionFactory); + + container.setQueueNames(queueName); + container.setMessageListener(listenerAdapter); + return container; + } + + @Bean + MessageListenerAdapter listenerAdapter(Receiver receiver) + { + return new MessageListenerAdapter(receiver, "receiveMessage"); + } + + public static void main(String[] args) throws InterruptedException + { + SpringApplication.run(Application.class, args); + } + +} diff --git a/Later/POC/gs-messaging-rabbitmq/complete/src/main/java/hello/Receiver.java b/Later/POC/gs-messaging-rabbitmq/complete/src/main/java/hello/Receiver.java new file mode 100644 index 000000000..e28b646b2 --- /dev/null +++ b/Later/POC/gs-messaging-rabbitmq/complete/src/main/java/hello/Receiver.java @@ -0,0 +1,22 @@ +package hello; + +import java.util.concurrent.CountDownLatch; +import org.springframework.stereotype.Component; + +@Component +public class Receiver { + + private CountDownLatch latch = new CountDownLatch(1); + + public void receiveMessage(String message) { + System.out.println("Received <" + message + ">"); + String str = null; + str.length(); + //latch.countDown(); + } + + public CountDownLatch getLatch() { + return latch; + } + +} diff --git a/Later/POC/gs-messaging-rabbitmq/complete/src/main/java/hello/Runner.java b/Later/POC/gs-messaging-rabbitmq/complete/src/main/java/hello/Runner.java new file mode 100644 index 000000000..b9b065346 --- /dev/null +++ b/Later/POC/gs-messaging-rabbitmq/complete/src/main/java/hello/Runner.java @@ -0,0 +1,32 @@ +package hello; + +import java.util.concurrent.TimeUnit; + +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.boot.CommandLineRunner; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.stereotype.Component; + +@Component +public class Runner implements CommandLineRunner { + + private final RabbitTemplate rabbitTemplate; + private final Receiver receiver; + private final ConfigurableApplicationContext context; + + public Runner(Receiver receiver, RabbitTemplate rabbitTemplate, + ConfigurableApplicationContext context) { + this.receiver = receiver; + this.rabbitTemplate = rabbitTemplate; + this.context = context; + } + + @Override + public void run(String... args) throws Exception { + System.out.println("Sending message..."); + rabbitTemplate.convertAndSend(Application.queueName, "Hello from RabbitMQ!"); + receiver.getLatch().await(10000, TimeUnit.MILLISECONDS); + context.close(); + } + +} diff --git a/Later/POC/gs-messaging-rabbitmq/complete/src/main/resources/application.properties b/Later/POC/gs-messaging-rabbitmq/complete/src/main/resources/application.properties new file mode 100644 index 000000000..2c6c83fea --- /dev/null +++ b/Later/POC/gs-messaging-rabbitmq/complete/src/main/resources/application.properties @@ -0,0 +1 @@ +application.rabbitmq.host.name=192.168.142.83 diff --git a/Later/POC/gs-messaging-rabbitmq/complete/src/main/resources/log4j.properties b/Later/POC/gs-messaging-rabbitmq/complete/src/main/resources/log4j.properties new file mode 100644 index 000000000..40f6292de --- /dev/null +++ b/Later/POC/gs-messaging-rabbitmq/complete/src/main/resources/log4j.properties @@ -0,0 +1,11 @@ +# Set root logger level to DEBUG and its only appender to A1. +log4j.rootLogger=WARN, A1 + +# A1 is set to be a ConsoleAppender. +log4j.appender.A1=org.apache.log4j.ConsoleAppender + +# A1 uses PatternLayout. +log4j.appender.A1.layout=org.apache.log4j.PatternLayout +log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n + +log4j.category.org.springframework=INFO diff --git a/Later/POC/gs-messaging-rabbitmq/complete/src/test/java/hello/ApplicationTest.java b/Later/POC/gs-messaging-rabbitmq/complete/src/test/java/hello/ApplicationTest.java new file mode 100644 index 000000000..51207260e --- /dev/null +++ b/Later/POC/gs-messaging-rabbitmq/complete/src/test/java/hello/ApplicationTest.java @@ -0,0 +1,48 @@ +/* + * Copyright 2012-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package hello; + +import java.util.concurrent.TimeUnit; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class ApplicationTest { + + @MockBean + private Runner runner; + + @Autowired + private RabbitTemplate rabbitTemplate; + + @Autowired + private Receiver receiver; + + @Test + public void test() throws Exception { + rabbitTemplate.convertAndSend(Application.queueName, "Hello from RabbitMQ!"); + receiver.getLatch().await(10000, TimeUnit.MILLISECONDS); + } + +} diff --git a/Later/POC/gs-messaging-rabbitmq/initial/.mvn/wrapper/maven-wrapper.jar b/Later/POC/gs-messaging-rabbitmq/initial/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 000000000..5fd4d5023 Binary files /dev/null and b/Later/POC/gs-messaging-rabbitmq/initial/.mvn/wrapper/maven-wrapper.jar differ diff --git a/Later/POC/gs-messaging-rabbitmq/initial/.mvn/wrapper/maven-wrapper.properties b/Later/POC/gs-messaging-rabbitmq/initial/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 000000000..c954cec91 --- /dev/null +++ b/Later/POC/gs-messaging-rabbitmq/initial/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1 @@ +distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip diff --git a/Later/POC/gs-messaging-rabbitmq/initial/build.gradle b/Later/POC/gs-messaging-rabbitmq/initial/build.gradle new file mode 100644 index 000000000..1828af77a --- /dev/null +++ b/Later/POC/gs-messaging-rabbitmq/initial/build.gradle @@ -0,0 +1,31 @@ +buildscript { + repositories { + mavenCentral() + } + dependencies { + classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.3.RELEASE") + } +} + +apply plugin: 'java' +apply plugin: 'eclipse' +apply plugin: 'idea' +apply plugin: 'org.springframework.boot' + +jar { + baseName = 'gs-messaging-rabbitmq' + version = '0.1.0' +} + +repositories { + mavenCentral() +} + +sourceCompatibility = 1.8 +targetCompatibility = 1.8 + +dependencies { + compile("org.springframework.boot:spring-boot-starter-amqp") + testCompile("junit:junit") +} + diff --git a/Later/POC/gs-messaging-rabbitmq/initial/gradle/wrapper/gradle-wrapper.jar b/Later/POC/gs-messaging-rabbitmq/initial/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000..05ef575b0 Binary files /dev/null and b/Later/POC/gs-messaging-rabbitmq/initial/gradle/wrapper/gradle-wrapper.jar differ diff --git a/Later/POC/gs-messaging-rabbitmq/initial/gradle/wrapper/gradle-wrapper.properties b/Later/POC/gs-messaging-rabbitmq/initial/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..5235101e6 --- /dev/null +++ b/Later/POC/gs-messaging-rabbitmq/initial/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Aug 29 13:07:07 CDT 2016 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip diff --git a/Later/POC/gs-messaging-rabbitmq/initial/gradlew b/Later/POC/gs-messaging-rabbitmq/initial/gradlew new file mode 100644 index 000000000..9d82f7891 --- /dev/null +++ b/Later/POC/gs-messaging-rabbitmq/initial/gradlew @@ -0,0 +1,160 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/Later/POC/gs-messaging-rabbitmq/initial/gradlew.bat b/Later/POC/gs-messaging-rabbitmq/initial/gradlew.bat new file mode 100644 index 000000000..8a0b282aa --- /dev/null +++ b/Later/POC/gs-messaging-rabbitmq/initial/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/Later/POC/gs-messaging-rabbitmq/initial/mvnw b/Later/POC/gs-messaging-rabbitmq/initial/mvnw new file mode 100644 index 000000000..a1ba1bf55 --- /dev/null +++ b/Later/POC/gs-messaging-rabbitmq/initial/mvnw @@ -0,0 +1,233 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven2 Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # + # Look for the Apple JDKs first to preserve the existing behaviour, and then look + # for the new JDKs provided by Oracle. + # + if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then + # + # Apple JDKs + # + export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then + # + # Apple JDKs + # + export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then + # + # Oracle JDKs + # + export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then + # + # Apple JDKs + # + export JAVA_HOME=`/usr/libexec/java_home` + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Migwn, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" + # TODO classpath? +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` +fi + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + local basedir=$(pwd) + local wdir=$(pwd) + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + wdir=$(cd "$wdir/.."; pwd) + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} "$@" diff --git a/Later/POC/gs-messaging-rabbitmq/initial/mvnw.cmd b/Later/POC/gs-messaging-rabbitmq/initial/mvnw.cmd new file mode 100644 index 000000000..2b934e89d --- /dev/null +++ b/Later/POC/gs-messaging-rabbitmq/initial/mvnw.cmd @@ -0,0 +1,145 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +set MAVEN_CMD_LINE_ARGS=%* + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" + +set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar"" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS% +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% \ No newline at end of file diff --git a/Later/POC/gs-messaging-rabbitmq/initial/pom.xml b/Later/POC/gs-messaging-rabbitmq/initial/pom.xml new file mode 100644 index 000000000..70ad5de91 --- /dev/null +++ b/Later/POC/gs-messaging-rabbitmq/initial/pom.xml @@ -0,0 +1,37 @@ + + + 4.0.0 + + org.springframework + gs-messaging-rabbitmq + 0.1.0 + + + org.springframework.boot + spring-boot-starter-parent + 1.5.3.RELEASE + + + + 1.8 + + + + + org.springframework.boot + spring-boot-starter-amqp + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/Later/POC/gs-messaging-rabbitmq/initial/src/main/java/hello/Application.java b/Later/POC/gs-messaging-rabbitmq/initial/src/main/java/hello/Application.java new file mode 100644 index 000000000..5ec3a96b5 --- /dev/null +++ b/Later/POC/gs-messaging-rabbitmq/initial/src/main/java/hello/Application.java @@ -0,0 +1,62 @@ +package hello; + +import org.springframework.amqp.core.Binding; +import org.springframework.amqp.core.BindingBuilder; +import org.springframework.amqp.core.Queue; +import org.springframework.amqp.core.TopicExchange; +import org.springframework.amqp.rabbit.connection.ConnectionFactory; +import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; +import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +@SpringBootApplication +public class Application +{ + + final static String queueName = "spring-boot"; + + @Bean + Queue queue() + { + return new Queue(queueName, false); + } + + @Bean + TopicExchange exchange() + { + return new TopicExchange("spring-boot-exchange"); + } + + @Bean + Binding binding(Queue queue, TopicExchange exchange) + { + return BindingBuilder.bind(queue).to(exchange) + .with(queueName); + } + + @Bean + SimpleMessageListenerContainer container( + ConnectionFactory connectionFactory, + MessageListenerAdapter listenerAdapter) + { + SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); + container.setConnectionFactory(connectionFactory); + container.setQueueNames(queueName); + container.setMessageListener(listenerAdapter); + return container; + } + + @Bean + MessageListenerAdapter listenerAdapter(Receiver receiver) + { + return new MessageListenerAdapter(receiver, "receiveMessage"); + } + + public static void main(String[] args) throws InterruptedException + { + SpringApplication.run(Application.class, args); + } + +} \ No newline at end of file diff --git a/Later/POC/gs-messaging-rabbitmq/initial/src/main/java/hello/Receiver.java b/Later/POC/gs-messaging-rabbitmq/initial/src/main/java/hello/Receiver.java new file mode 100644 index 000000000..9c751208d --- /dev/null +++ b/Later/POC/gs-messaging-rabbitmq/initial/src/main/java/hello/Receiver.java @@ -0,0 +1,22 @@ +package hello; + +import java.util.concurrent.CountDownLatch; +import org.springframework.stereotype.Component; + +@Component +public class Receiver +{ + private CountDownLatch latch = new CountDownLatch(1); + + public void receiveMessage(String message) + { + System.out.println("Received <" + message + ">"); + latch.countDown(); + } + + public CountDownLatch getLatch() + { + return latch; + } + +} diff --git a/Later/POC/gs-messaging-rabbitmq/initial/src/main/resources/log4j.properties b/Later/POC/gs-messaging-rabbitmq/initial/src/main/resources/log4j.properties new file mode 100644 index 000000000..40f6292de --- /dev/null +++ b/Later/POC/gs-messaging-rabbitmq/initial/src/main/resources/log4j.properties @@ -0,0 +1,11 @@ +# Set root logger level to DEBUG and its only appender to A1. +log4j.rootLogger=WARN, A1 + +# A1 is set to be a ConsoleAppender. +log4j.appender.A1=org.apache.log4j.ConsoleAppender + +# A1 uses PatternLayout. +log4j.appender.A1.layout=org.apache.log4j.PatternLayout +log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n + +log4j.category.org.springframework=INFO diff --git a/Later/POC/gs-messaging-rabbitmq/test/run.sh b/Later/POC/gs-messaging-rabbitmq/test/run.sh new file mode 100644 index 000000000..41f69096a --- /dev/null +++ b/Later/POC/gs-messaging-rabbitmq/test/run.sh @@ -0,0 +1,36 @@ +#!/bin/sh +cd $(dirname $0) + +cd ../complete + +mvn clean package +ret=$? +if [ $ret -ne 0 ]; then +exit $ret +fi +rm -rf target + +./gradlew build +ret=$? +if [ $ret -ne 0 ]; then +exit $ret +fi +rm -rf build + +cd ../initial + +mvn clean compile +ret=$? +if [ $ret -ne 0 ]; then +exit $ret +fi +rm -rf target + +./gradlew compileJava +ret=$? +if [ $ret -ne 0 ]; then +exit $ret +fi +rm -rf build + +exit diff --git a/Later/POC/selenium-example-master/.classpath b/Later/POC/selenium-example-master/.classpath new file mode 100644 index 000000000..0a1daddd3 --- /dev/null +++ b/Later/POC/selenium-example-master/.classpath @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Later/POC/selenium-example-master/.gitignore b/Later/POC/selenium-example-master/.gitignore new file mode 100644 index 000000000..a6c754737 --- /dev/null +++ b/Later/POC/selenium-example-master/.gitignore @@ -0,0 +1,16 @@ +*.class + +#maven +target + +#mac +.DS_Store + +# Package Files # +*.jar +*.war +*.ear + +#idea +.idea/ +selenium-chrome-example.iml diff --git a/Later/POC/selenium-example-master/.project b/Later/POC/selenium-example-master/.project new file mode 100644 index 000000000..c28c7d117 --- /dev/null +++ b/Later/POC/selenium-example-master/.project @@ -0,0 +1,23 @@ + + + selenium-example + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/Later/POC/selenium-example-master/.settings/org.eclipse.jdt.core.prefs b/Later/POC/selenium-example-master/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..abec6ca38 --- /dev/null +++ b/Later/POC/selenium-example-master/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/Later/POC/selenium-example-master/.settings/org.eclipse.m2e.core.prefs b/Later/POC/selenium-example-master/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000..f897a7f1c --- /dev/null +++ b/Later/POC/selenium-example-master/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/Later/POC/selenium-example-master/LICENSE b/Later/POC/selenium-example-master/LICENSE new file mode 100644 index 000000000..7494f92b8 --- /dev/null +++ b/Later/POC/selenium-example-master/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Howard.Zuo + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Later/POC/selenium-example-master/README.md b/Later/POC/selenium-example-master/README.md new file mode 100644 index 000000000..3284ff391 --- /dev/null +++ b/Later/POC/selenium-example-master/README.md @@ -0,0 +1,25 @@ +# selenium-example +An example project of selenium using ChromeWebDriver, HtmlUnitDriver, FirefoxFriver + + +## Prerequisites ## + +* Have [java](http://www.oracle.com/technetwork/java/javase/downloads/index.html) installed +* Have [maven](http://maven.apache.org/) installed + + +## Execute automation tests ## + +```bash +mvn clean test +``` + +The result looks as following: + +![](./docs/img/autotests.gif) + + + +## LICENSE ## + +[MIT License](https://raw.githubusercontent.com/leftstick/selenium-example/master/LICENSE) diff --git a/Later/POC/selenium-example-master/docs/img/autotests.gif b/Later/POC/selenium-example-master/docs/img/autotests.gif new file mode 100644 index 000000000..2e24bce4d Binary files /dev/null and b/Later/POC/selenium-example-master/docs/img/autotests.gif differ diff --git a/Later/POC/selenium-example-master/pom.xml b/Later/POC/selenium-example-master/pom.xml new file mode 100644 index 000000000..bc7ab4d49 --- /dev/null +++ b/Later/POC/selenium-example-master/pom.xml @@ -0,0 +1 @@ + 4.0.0 com.movoto.tests selenium-example 1.0-SNAPSHOT junit junit 4.12 test org.hamcrest hamcrest-all 1.3 test org.seleniumhq.selenium selenium-java 3.0.1 org.seleniumhq.selenium selenium-chrome-driver 3.0.1 \ No newline at end of file diff --git a/Later/POC/selenium-example-master/selenium-example.iml b/Later/POC/selenium-example-master/selenium-example.iml new file mode 100644 index 000000000..4c685322e --- /dev/null +++ b/Later/POC/selenium-example-master/selenium-example.iml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Later/POC/selenium-example-master/src/test/java/org/movoto/selenium/example/ChromeDriverTest.java b/Later/POC/selenium-example-master/src/test/java/org/movoto/selenium/example/ChromeDriverTest.java new file mode 100644 index 000000000..032fedda2 --- /dev/null +++ b/Later/POC/selenium-example-master/src/test/java/org/movoto/selenium/example/ChromeDriverTest.java @@ -0,0 +1,87 @@ +package org.movoto.selenium.example; + +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.Dimension; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.chrome.ChromeDriver; +import org.openqa.selenium.firefox.MarionetteDriver; +import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.support.ui.ExpectedCondition; +import org.openqa.selenium.support.ui.WebDriverWait; + +import java.io.IOException; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertTrue; + +/** + * Created by haozuo on 3/22/16. + */ +public class ChromeDriverTest +{ + + private String testUrl; + private WebDriver driver; + + @Before + public void prepare() + { + // setup chromedriver + System.setProperty("webdriver.chrome.driver", + "webdriver/chromedriver"); + + testUrl = "https://leftstick.github.io/"; + + // Create a new instance of the Chrome driver + // Notice that the remainder of the code relies on the + // interface, + // not the implementation. + driver = new ChromeDriver(); + + + // maximize window + driver.manage().window().maximize(); + + // And now use this to visit myBlog + // Alternatively the same thing can be done like this + // driver.navigate().to(testUrl); + driver.get(testUrl); + } + + @Test + public void testTitle() throws IOException + { + + /* // Find elements by attribute lang="READ_MORE_BTN" + List elements = driver.findElements( + By.cssSelector("[lang=\"READ_MORE_BTN\"]")); + + // Click the selected button + elements.get(0).click(); + + assertTrue("The page title should be chagned as expected", + (new WebDriverWait(driver, 5)) + .until(new ExpectedCondition() + { + public Boolean apply(WebDriver d) + { + return d.getTitle().equals( + "我眼中软件工程人员该有的常识"); + } + }));*/ + System.out.println("Ramesh end"); + } + + @After + public void teardown() throws IOException + { + driver.quit(); + } + +} diff --git a/Later/POC/selenium-example-master/webdriver/chromedriver b/Later/POC/selenium-example-master/webdriver/chromedriver new file mode 100644 index 000000000..e7320bc3e Binary files /dev/null and b/Later/POC/selenium-example-master/webdriver/chromedriver differ diff --git a/Later/POC/selenium-example-master/webdriver/chromedriver.exe b/Later/POC/selenium-example-master/webdriver/chromedriver.exe new file mode 100644 index 000000000..4bfff1efb Binary files /dev/null and b/Later/POC/selenium-example-master/webdriver/chromedriver.exe differ diff --git a/Later/POC/selenium-example-master/webdriver/geckodriver b/Later/POC/selenium-example-master/webdriver/geckodriver new file mode 100644 index 000000000..e51f387d0 Binary files /dev/null and b/Later/POC/selenium-example-master/webdriver/geckodriver differ diff --git a/Later/POC/selenium/.classpath b/Later/POC/selenium/.classpath new file mode 100644 index 000000000..9ae7bca0f --- /dev/null +++ b/Later/POC/selenium/.classpath @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Later/POC/selenium/.project b/Later/POC/selenium/.project new file mode 100644 index 000000000..67210f875 --- /dev/null +++ b/Later/POC/selenium/.project @@ -0,0 +1,23 @@ + + + selenium + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/Later/POC/selenium/.settings/org.eclipse.jdt.core.prefs b/Later/POC/selenium/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..abec6ca38 --- /dev/null +++ b/Later/POC/selenium/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/Later/POC/selenium/.settings/org.eclipse.m2e.core.prefs b/Later/POC/selenium/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000..f897a7f1c --- /dev/null +++ b/Later/POC/selenium/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/Later/POC/selenium/pom.xml b/Later/POC/selenium/pom.xml new file mode 100644 index 000000000..0ca8ec161 --- /dev/null +++ b/Later/POC/selenium/pom.xml @@ -0,0 +1,29 @@ + + + 4.0.0 + + ru + parsentev + 1.0-SNAPSHOT + + + + junit + junit + 4.12 + + + org.seleniumhq.selenium + selenium-java + 3.8.1 + + + + org.hamcrest + hamcrest-all + 1.3 + + + + \ No newline at end of file diff --git a/Later/POC/selenium/selenium_command.txt b/Later/POC/selenium/selenium_command.txt new file mode 100644 index 000000000..c0ecb844f --- /dev/null +++ b/Later/POC/selenium/selenium_command.txt @@ -0,0 +1,5 @@ +java -jar selenium-server-standalone-3.8.1.jar -role hub +java -jar -Dwebdriver.chrome.driver=D:/Download/chromedriver.exe selenium-server-standalone-3.8.1.jar -role node -hub http://192.168.140.79:4444/grid/register/ -port 5555 + +java -jar selenium-server-standalone-3.8.1.jar -role hub -host 192.168.140.33 +java -jar -Dwebdriver.chrome.driver=/root/ramesh/selenium/webdriver/chromedriver -Dwebdriver.chrome.bin=/usr/bin/google-chrome selenium-server-standalone-3.8.1.jar -role node -hub http://192.168.140.33:4444/grid/register/ -port 5555 -host 192.168.140.33 diff --git a/Later/POC/selenium/src/test/java/SeleniumStandaloneServerTest.java b/Later/POC/selenium/src/test/java/SeleniumStandaloneServerTest.java new file mode 100644 index 000000000..db0b4c0f4 --- /dev/null +++ b/Later/POC/selenium/src/test/java/SeleniumStandaloneServerTest.java @@ -0,0 +1,54 @@ +import java.net.MalformedURLException; +import java.net.URL; + +import org.junit.Test; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.remote.DesiredCapabilities; +import org.openqa.selenium.remote.RemoteWebDriver; + +/** + * Tests for selenium standalone server. + * + * @author parsentev + * @since 19.11.2015 + */ +public class SeleniumStandaloneServerTest +{ + + /*@Test + public void executeFirefoxDriver() throws MalformedURLException + { + this.execute(DesiredCapabilities.firefox()); + } +*/ + @Test + public void executeChrome() throws MalformedURLException + { + System.setProperty("webdriver.chrome.driver","D:/Download/chromedriver.exe"); + this.execute(DesiredCapabilities.chrome()); + + + } + + private void execute(final DesiredCapabilities capability) + throws MalformedURLException + { + + System.setProperty("webdriver.chrome.driver","./webdriver/chromedriver.exe"); + String URL = "http://www.DemoQA.com"; + String Node = "http://192.168.140.79:4444/wd/hub"; + WebDriver driver = new RemoteWebDriver(new URL(Node), capability); + + driver.navigate().to(URL); + try + { + Thread.sleep(5000); + } + catch (InterruptedException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + driver.quit(); + } +} diff --git a/Later/POC/selenium/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/Later/POC/selenium/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 000000000..e69de29bb diff --git a/Later/POC/selenium/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/Later/POC/selenium/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 000000000..07241addc --- /dev/null +++ b/Later/POC/selenium/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst @@ -0,0 +1 @@ +SeleniumStandaloneServerTest.class diff --git a/Later/POC/selenium/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/Later/POC/selenium/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 000000000..7f4de26de --- /dev/null +++ b/Later/POC/selenium/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst @@ -0,0 +1 @@ +D:\eclipse\workspace\selenium\src\test\java\SeleniumStandaloneServerTest.java diff --git a/Later/POC/selenium/target/surefire-reports/SeleniumStandaloneServerTest.txt b/Later/POC/selenium/target/surefire-reports/SeleniumStandaloneServerTest.txt new file mode 100644 index 000000000..df3666ea1 --- /dev/null +++ b/Later/POC/selenium/target/surefire-reports/SeleniumStandaloneServerTest.txt @@ -0,0 +1,4 @@ +------------------------------------------------------------------------------- +Test set: SeleniumStandaloneServerTest +------------------------------------------------------------------------------- +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 21.621 sec diff --git a/Later/POC/selenium/target/surefire-reports/TEST-SeleniumStandaloneServerTest.xml b/Later/POC/selenium/target/surefire-reports/TEST-SeleniumStandaloneServerTest.xml new file mode 100644 index 000000000..814ed9ad5 --- /dev/null +++ b/Later/POC/selenium/target/surefire-reports/TEST-SeleniumStandaloneServerTest.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Later/POC/selenium/target/test-classes/SeleniumStandaloneServerTest.class b/Later/POC/selenium/target/test-classes/SeleniumStandaloneServerTest.class new file mode 100644 index 000000000..030a87c4e Binary files /dev/null and b/Later/POC/selenium/target/test-classes/SeleniumStandaloneServerTest.class differ diff --git a/Later/POC/selenium/webdriver/chromedriver b/Later/POC/selenium/webdriver/chromedriver new file mode 100644 index 000000000..e7320bc3e Binary files /dev/null and b/Later/POC/selenium/webdriver/chromedriver differ diff --git a/Later/POC/selenium/webdriver/chromedriver.exe b/Later/POC/selenium/webdriver/chromedriver.exe new file mode 100644 index 000000000..4bfff1efb Binary files /dev/null and b/Later/POC/selenium/webdriver/chromedriver.exe differ diff --git a/Later/POC/selenium/webdriver/geckodriver b/Later/POC/selenium/webdriver/geckodriver new file mode 100644 index 000000000..e51f387d0 Binary files /dev/null and b/Later/POC/selenium/webdriver/geckodriver differ diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_34/Java String_endsWith.pptx b/Later/String/Comparing_Strings_and_Portions_of_Strings/String_34/Java String_endsWith.pptx deleted file mode 100644 index de00434ef..000000000 Binary files a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_34/Java String_endsWith.pptx and /dev/null differ diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_34/StringDemo/bin/EndsWithDemo.class b/Later/String/Comparing_Strings_and_Portions_of_Strings/String_34/StringDemo/bin/EndsWithDemo.class deleted file mode 100644 index 0bedd5ed4..000000000 Binary files a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_34/StringDemo/bin/EndsWithDemo.class and /dev/null differ diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_34/StringDemo/src/EndsWithDemo.java b/Later/String/Comparing_Strings_and_Portions_of_Strings/String_34/StringDemo/src/EndsWithDemo.java deleted file mode 100644 index 336579dc1..000000000 --- a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_34/StringDemo/src/EndsWithDemo.java +++ /dev/null @@ -1,27 +0,0 @@ -public class EndsWithDemo -{ - public static void main(String[] args) - { - String str = "Welcome Peter"; - - /* - * public boolean endsWith(String suffix) - * - * Parameters: - * ---------- - * - * suffix - the suffix. - * - * Returns: - * ------- - * - * true if the character sequence represented by the - * argument is a suffix of the character sequence - * represented by this object; false otherwise. - */ - - boolean result = str.endsWith("Peter"); - System.out.println("result = " + result); - - } -} \ No newline at end of file diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_35/Java String_startsWith.pptx b/Later/String/Comparing_Strings_and_Portions_of_Strings/String_35/Java String_startsWith.pptx deleted file mode 100644 index 9dfb6b91f..000000000 Binary files a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_35/Java String_startsWith.pptx and /dev/null differ diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_35/StringDemo/bin/EndsWithDemo.class b/Later/String/Comparing_Strings_and_Portions_of_Strings/String_35/StringDemo/bin/EndsWithDemo.class deleted file mode 100644 index 35c63ec23..000000000 Binary files a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_35/StringDemo/bin/EndsWithDemo.class and /dev/null differ diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_35/StringDemo/src/StartsWithDemo.java b/Later/String/Comparing_Strings_and_Portions_of_Strings/String_35/StringDemo/src/StartsWithDemo.java deleted file mode 100644 index 86c69ade1..000000000 --- a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_35/StringDemo/src/StartsWithDemo.java +++ /dev/null @@ -1,27 +0,0 @@ -public class StartsWithDemo -{ - public static void main(String[] args) - { - String str = "Welcome Peter"; - - /* - * public boolean endsWith(String suffix) - * - * Parameters: - * ---------- - * - * prefix - the prefix. - * - * Returns: - * ------- - * - * true if the character sequence represented by the - * argument is a prefix of the character sequence - * represented by this string; false otherwise. - */ - - boolean result = str.startsWith("Wel"); - System.out.println("result = " + result); - - } -} \ No newline at end of file diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_36/Java String_startsWith-offset.pptx b/Later/String/Comparing_Strings_and_Portions_of_Strings/String_36/Java String_startsWith-offset.pptx deleted file mode 100644 index 54565f44f..000000000 Binary files a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_36/Java String_startsWith-offset.pptx and /dev/null differ diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_36/StringDemo/bin/StartsWithDemo.class b/Later/String/Comparing_Strings_and_Portions_of_Strings/String_36/StringDemo/bin/StartsWithDemo.class deleted file mode 100644 index 62f7bfc1f..000000000 Binary files a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_36/StringDemo/bin/StartsWithDemo.class and /dev/null differ diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_36/StringDemo/src/StartsWithDemo.java b/Later/String/Comparing_Strings_and_Portions_of_Strings/String_36/StringDemo/src/StartsWithDemo.java deleted file mode 100644 index 72820ba7e..000000000 --- a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_36/StringDemo/src/StartsWithDemo.java +++ /dev/null @@ -1,33 +0,0 @@ -public class StartsWithDemo -{ - public static void main(String[] args) - { - String str = "Welcome Peter"; - - /* - * public boolean startsWith(String prefix, int - * offset) - * - * Parameters: - * ---------- - * - * prefix - the prefix. - * - * offset - where to begin looking in this string. - * - * Returns: ------- - * - * true if the character sequence represented by the - * argument is a prefix of the substring of this - * object starting at index offset; false - * otherwise. - */ - - boolean result = str.startsWith("come", 3); - System.out.println("startsWith(\"come\", 3) = " + result); - - result = str.startsWith("come", 0); - System.out.println("startsWith(\"come\", 0) = " + result); - - } -} \ No newline at end of file diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_37/Java String_compareTo.pptx b/Later/String/Comparing_Strings_and_Portions_of_Strings/String_37/Java String_compareTo.pptx deleted file mode 100644 index 90048ce34..000000000 Binary files a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_37/Java String_compareTo.pptx and /dev/null differ diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_37/StringDemo/bin/StartsWithDemo.class b/Later/String/Comparing_Strings_and_Portions_of_Strings/String_37/StringDemo/bin/StartsWithDemo.class deleted file mode 100644 index 8da19ff69..000000000 Binary files a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_37/StringDemo/bin/StartsWithDemo.class and /dev/null differ diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_37/StringDemo/src/StartsWithDemo.java b/Later/String/Comparing_Strings_and_Portions_of_Strings/String_37/StringDemo/src/StartsWithDemo.java deleted file mode 100644 index 311c924b3..000000000 --- a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_37/StringDemo/src/StartsWithDemo.java +++ /dev/null @@ -1,42 +0,0 @@ -public class CompareToDemo -{ - public static void main(String[] args) - { - - /* - * public int compareTo(String anotherString) - * - * Parameters: - * ---------- - * - * anotherString - the String to be compared. - * - * Returns: - * ------- - * - * the value 0 if the argument string is equal to - * this string; - * - * a value less than 0 if this string - * is lexicographically less than the string - * argument; - * - * a value greater than 0 if this - * string is lexicographically greater than the - * string argument. - */ - - int result = "Welcome".compareTo("Welcome"); - System.out.println("\"Welcome\".compareTo(\"Welcome\") = " - + result); - - result = "Hello".compareTo("Welcome"); - System.out.println("\"Hello\".compareTo(\"Welcome\") = " - + result); - - result = "Welcome".compareTo("Apple"); - System.out.println("\"Welcome\".compareTo(\"Apple\") = " - + result); - - } -} \ No newline at end of file diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_38/Java String_compareToIgnoreCase.pptx b/Later/String/Comparing_Strings_and_Portions_of_Strings/String_38/Java String_compareToIgnoreCase.pptx deleted file mode 100644 index c1f720910..000000000 Binary files a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_38/Java String_compareToIgnoreCase.pptx and /dev/null differ diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_38/StringDemo/bin/CompareToIgnoreCaseDemo.class b/Later/String/Comparing_Strings_and_Portions_of_Strings/String_38/StringDemo/bin/CompareToIgnoreCaseDemo.class deleted file mode 100644 index e6f305ca4..000000000 Binary files a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_38/StringDemo/bin/CompareToIgnoreCaseDemo.class and /dev/null differ diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_38/StringDemo/src/CompareToIgnoreCaseDemo.java b/Later/String/Comparing_Strings_and_Portions_of_Strings/String_38/StringDemo/src/CompareToIgnoreCaseDemo.java deleted file mode 100644 index 9791caef4..000000000 --- a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_38/StringDemo/src/CompareToIgnoreCaseDemo.java +++ /dev/null @@ -1,39 +0,0 @@ -public class CompareToIgnoreCaseDemo -{ - public static void main(String[] args) - { - - /* - * public int compareToIgnoreCase(String str) - * - * Parameters: - * ---------- - * - * str - the String to be compared. - * - * Returns: - * ------- - * - * Returns an integer indicating whether this string - * is greater than (result is > 0), equal to (result - * is = 0), or less than (result is < 0) the - * argument. - */ - - int result = "Welcome".compareToIgnoreCase("WELCOME"); - System.out - .println("\"Welcome\".compareToIgnoreCase(\"Welcome\") = " - + result); - - result = "Hello".compareToIgnoreCase("WELCOME"); - System.out - .println("\"Hello\".compareToIgnoreCase(\"Welcome\") = " - + result); - - result = "compareToIgnoreCase".compareToIgnoreCase("Apple"); - System.out - .println("\"Welcome\".compareToIgnoreCase(\"Apple\") = " - + result); - - } -} \ No newline at end of file diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_39/Java String_equals.pptx b/Later/String/Comparing_Strings_and_Portions_of_Strings/String_39/Java String_equals.pptx deleted file mode 100644 index 29f7714bd..000000000 Binary files a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_39/Java String_equals.pptx and /dev/null differ diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_39/StringDemo/src/EqualsDemo.java b/Later/String/Comparing_Strings_and_Portions_of_Strings/String_39/StringDemo/src/EqualsDemo.java deleted file mode 100644 index 109e2affb..000000000 --- a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_39/StringDemo/src/EqualsDemo.java +++ /dev/null @@ -1,45 +0,0 @@ -public class EqualsDemo -{ - public static void main(String[] args) - { - - /* - * public boolean equals(Object anObject) - * ------------------------------------- - * - * Compares this string to the specified object. The - * result is true if and only if the argument is not - * null and is a String object that represents the - * same sequence of characters as this object. - * - * Overrides: - * --------- - * - * equals in class Object - * - * Parameters: - * ---------- - * - * anObject - The object to compare this String - * against - * - * Returns: - * ------- - * - * true if the given object represents a String - * equivalent to this string, false otherwise - */ - - boolean result = "welcome".equals("welcome"); - System.out.println("\"welcome\".equals(\"welcome\") = " - + result); - - result = "welcome".equals("WELCOME"); - System.out.println("\"welcome\".equals(\"WELCOME\") = " - + result); - - result = "welcome".equals("hello"); - System.out.println("\"welcome\".equals(\"hello\") = " - + result); - } -} \ No newline at end of file diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_40/Java String_equalsIgnoreCase.pptx b/Later/String/Comparing_Strings_and_Portions_of_Strings/String_40/Java String_equalsIgnoreCase.pptx deleted file mode 100644 index 73c190f79..000000000 Binary files a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_40/Java String_equalsIgnoreCase.pptx and /dev/null differ diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_40/StringDemo/src/EqualsIgnoreCaseDemo.java b/Later/String/Comparing_Strings_and_Portions_of_Strings/String_40/StringDemo/src/EqualsIgnoreCaseDemo.java deleted file mode 100644 index c29cfb21d..000000000 --- a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_40/StringDemo/src/EqualsIgnoreCaseDemo.java +++ /dev/null @@ -1,30 +0,0 @@ -public class EqualsIgnoreCaseDemo -{ - public static void main(String[] args) - { - - /* - * public boolean equalsIgnoreCase(String - * anotherString) - * - * Parameters: - * ---------- - * - * anotherString - The String to compare this String - * against - * - * Returns: - * ------- - * - * true if the argument is not null and it - * represents an equivalent String ignoring case; - * false otherwise - */ - - boolean result = "welcome".equalsIgnoreCase("WELCOME"); - System.out - .println("\"welcome\".equalsIgnoreCase(\"WELCOME\") = " - + result); - - } -} \ No newline at end of file diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_41/Java String_regionMatches.pptx b/Later/String/Comparing_Strings_and_Portions_of_Strings/String_41/Java String_regionMatches.pptx deleted file mode 100644 index f57419d3a..000000000 Binary files a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_41/Java String_regionMatches.pptx and /dev/null differ diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_41/StringDemo/bin/RegionMatchesDemo.class b/Later/String/Comparing_Strings_and_Portions_of_Strings/String_41/StringDemo/bin/RegionMatchesDemo.class deleted file mode 100644 index 203e20337..000000000 Binary files a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_41/StringDemo/bin/RegionMatchesDemo.class and /dev/null differ diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_41/StringDemo/src/RegionMatchesDemo.java b/Later/String/Comparing_Strings_and_Portions_of_Strings/String_41/StringDemo/src/RegionMatchesDemo.java deleted file mode 100644 index 405a39137..000000000 --- a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_41/StringDemo/src/RegionMatchesDemo.java +++ /dev/null @@ -1,50 +0,0 @@ -public class RegionMatchesDemo -{ - public static void main(String[] args) - { - - String str1 = new String("Welcome to ramj2ee.com"); - String Str2 = new String("ramj2ee"); - String Str3 = new String("RAMJ2EE"); - String Str4 = new String("hello"); - - /* - * public boolean regionMatches(int toffset, - String - * other, int ooffset, int len) - * - * Parameters: - * ---------- - * - * toffset - the starting offset of the subregion in - * this string. - * - * other - the string argument. - * - * ooffset - the starting offset of the subregion in - * the string argument. - * - * len - the number of characters to compare. - * - * Returns: - * ------- - * - * true if the specified subregion of this string - * exactly matches the specified subregion of the - * string argument; false otherwise. - */ - - - System.out - .print("\"Welcome to ramj2ee.com\".regionMatches(11,\"ramj2ee\",0,7) = "); - System.out.println(Str1.regionMatches(11, Str2, 0, 7)); - - System.out - .print("\"Welcome to ramj2ee.com\".regionMatches(11,\"RAMJ2EE\",0,7) = "); - System.out.println(Str1.regionMatches(11, Str3, 0, 7)); - - System.out - .print("\"Welcome to ramj2ee.com\".regionMatches(11,\"hello\",0,7) = "); - System.out.println(Str1.regionMatches(11, Str4, 0, 7)); - } -} \ No newline at end of file diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_42/Java String_regionMatches-ignorecase.pptx b/Later/String/Comparing_Strings_and_Portions_of_Strings/String_42/Java String_regionMatches-ignorecase.pptx deleted file mode 100644 index db058cb49..000000000 Binary files a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_42/Java String_regionMatches-ignorecase.pptx and /dev/null differ diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_42/StringDemo/bin/RegionMatchesDemo.class b/Later/String/Comparing_Strings_and_Portions_of_Strings/String_42/StringDemo/bin/RegionMatchesDemo.class deleted file mode 100644 index 31dd210e7..000000000 Binary files a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_42/StringDemo/bin/RegionMatchesDemo.class and /dev/null differ diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_42/StringDemo/src/RegionMatchesDemo.java b/Later/String/Comparing_Strings_and_Portions_of_Strings/String_42/StringDemo/src/RegionMatchesDemo.java deleted file mode 100644 index 319cea282..000000000 --- a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_42/StringDemo/src/RegionMatchesDemo.java +++ /dev/null @@ -1,49 +0,0 @@ -public class RegionMatchesDemo -{ - public static void main(String[] args) - { - - String str1 = new String("Welcome to ramj2ee.com"); - String Str2 = new String("RAMJ2EE"); - - - /* - * public boolean regionMatches(boolean ignoreCase, - * int toffset, String other, int ooffset, int len) - * - * Parameters: - * ---------- - * - * ignoreCase - if true, ignore case when comparing - * characters. - * - * toffset - the starting offset of the subregion in - * this string. - * - * other - the string argument. - * - * ooffset - the starting offset of the subregion in - * the string argument. - * - * len - the number of characters to compare. - * - * Returns: - * ------- - * - * true if the specified subregion of this string - * matches the specified subregion of the string - * argument; false otherwise. Whether the matching - * is exact or case insensitive depends on the - * ignoreCase argument. - */ - - System.out - .print("\"Welcome to ramj2ee.com\".regionMatches(false,11,\"RAMJ2EE\",0,7) = "); - System.out.println(Str1.regionMatches(false, 11, Str2, 0, 7)); - - System.out - .print("\"Welcome to ramj2ee.com\".regionMatches(true,11,\"RAMJ2EE\",0,7) = "); - System.out.println(Str1.regionMatches(true, 11, Str2, 0, 7)); - - } -} \ No newline at end of file diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_43/Java String_matches.pptx b/Later/String/Comparing_Strings_and_Portions_of_Strings/String_43/Java String_matches.pptx deleted file mode 100644 index 6a9b508e2..000000000 Binary files a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_43/Java String_matches.pptx and /dev/null differ diff --git a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_43/StringDemo/src/MatchesDemo.java b/Later/String/Comparing_Strings_and_Portions_of_Strings/String_43/StringDemo/src/MatchesDemo.java deleted file mode 100644 index 16cbfd0b3..000000000 --- a/Later/String/Comparing_Strings_and_Portions_of_Strings/String_43/StringDemo/src/MatchesDemo.java +++ /dev/null @@ -1,39 +0,0 @@ -public class MatchesDemo -{ - public static void main(String[] args) - { - - String str = new String("Welcome to ramj2ee.com"); - - /* - * public boolean matches(String regex) - * - * Parameters: - * ---------- - * - * regex - the regular expression to which this - * string is to be matched - * - * Returns: - * ------- - * - * true if, and only if, this string matches the - * given regular expression - * - * Throws: - * ------ - * - * PatternSyntaxException - if the regular - * expression's syntax is invalid - */ - - System.out - .print("\"Welcome to ramj2ee.com\".matches(\"Welcome(.*)\") = "); - System.out.println(str.matches("Welcome(.*)")); - - System.out - .print("\"Welcome to ramj2ee.com\".matches(\"(.*)ramj2ee(.*)\") = "); - System.out.println(str.matches("(.*)ramj2ee(.*)")); - - } -} \ No newline at end of file diff --git a/Later/String/Manipulating Characters in a String/String_18/Java String - split.pptx b/Later/String/Manipulating Characters in a String/String_18/Java String - split.pptx deleted file mode 100644 index 2f5dc912b..000000000 Binary files a/Later/String/Manipulating Characters in a String/String_18/Java String - split.pptx and /dev/null differ diff --git a/Later/String/Manipulating Characters in a String/String_18/StringDemo/bin/SplitDemo.class b/Later/String/Manipulating Characters in a String/String_18/StringDemo/bin/SplitDemo.class deleted file mode 100644 index 5422af6f6..000000000 Binary files a/Later/String/Manipulating Characters in a String/String_18/StringDemo/bin/SplitDemo.class and /dev/null differ diff --git a/Later/String/Manipulating Characters in a String/String_18/StringDemo/src/SplitDemo.java b/Later/String/Manipulating Characters in a String/String_18/StringDemo/src/SplitDemo.java deleted file mode 100644 index d3a847a71..000000000 --- a/Later/String/Manipulating Characters in a String/String_18/StringDemo/src/SplitDemo.java +++ /dev/null @@ -1,31 +0,0 @@ -public class SplitDemo -{ - - public static void main(String[] args) - { - String str = "Peter,Welcome,to,India"; - - /* - * public String[] split(String regex) - * - * Parameters: - * ---------- - * - * regex - the delimiting regular expression - * - * Returns: - * ------- - * - * the array of strings computed by splitting this - * string around matches of the given regular - * expression - */ - - String strArray[] = str.split(","); - for (String string : strArray) - { - System.out.println(string); - } - - } -} diff --git a/Later/String/Manipulating Characters in a String/String_19/Java String - split limit.pptx b/Later/String/Manipulating Characters in a String/String_19/Java String - split limit.pptx deleted file mode 100644 index 86a7bf7c7..000000000 Binary files a/Later/String/Manipulating Characters in a String/String_19/Java String - split limit.pptx and /dev/null differ diff --git a/Later/String/Manipulating Characters in a String/String_19/StringDemo/bin/SplitDemo.class b/Later/String/Manipulating Characters in a String/String_19/StringDemo/bin/SplitDemo.class deleted file mode 100644 index 15dad19af..000000000 Binary files a/Later/String/Manipulating Characters in a String/String_19/StringDemo/bin/SplitDemo.class and /dev/null differ diff --git a/Later/String/Manipulating Characters in a String/String_19/StringDemo/src/SplitDemo.java b/Later/String/Manipulating Characters in a String/String_19/StringDemo/src/SplitDemo.java deleted file mode 100644 index 3ae9f1d6d..000000000 --- a/Later/String/Manipulating Characters in a String/String_19/StringDemo/src/SplitDemo.java +++ /dev/null @@ -1,35 +0,0 @@ -public class SplitDemo -{ - - public static void main(String[] args) - { - String str = "Peter,Welcome,to,India"; - - /* - * public String[] split(String regex, int limit) - * - * Parameters: - * ---------- - * - * regex - the delimiting regular expression - * - * limit - limit for the number of strings in array. - * If it is zero, it will returns all the strings - * matching regex. - * - * Returns: - * ------- - * - * the array of strings computed by splitting this - * string around matches of the given regular - * expression - */ - - String strArray[] = str.split(",", 3); - for (String string : strArray) - { - System.out.println(string); - } - - } -} diff --git a/Later/String/Manipulating Characters in a String/String_20/Java String - indexOf-ch.pptx b/Later/String/Manipulating Characters in a String/String_20/Java String - indexOf-ch.pptx deleted file mode 100644 index cfdc2bdb9..000000000 Binary files a/Later/String/Manipulating Characters in a String/String_20/Java String - indexOf-ch.pptx and /dev/null differ diff --git a/Later/String/Manipulating Characters in a String/String_20/StringDemo/bin/SplitDemo.class b/Later/String/Manipulating Characters in a String/String_20/StringDemo/bin/SplitDemo.class deleted file mode 100644 index c744f1b38..000000000 Binary files a/Later/String/Manipulating Characters in a String/String_20/StringDemo/bin/SplitDemo.class and /dev/null differ diff --git a/Later/String/Manipulating Characters in a String/String_20/StringDemo/src/IndexOfDemo.java b/Later/String/Manipulating Characters in a String/String_20/StringDemo/src/IndexOfDemo.java deleted file mode 100644 index ba9ceda97..000000000 --- a/Later/String/Manipulating Characters in a String/String_20/StringDemo/src/IndexOfDemo.java +++ /dev/null @@ -1,32 +0,0 @@ -public class IndexOfDemo -{ - - public static void main(String[] args) - { - String str = "Welcome"; - - /* - * public int indexOf(int ch) - * - * Parameters: - * ---------- - * - * ch - a character (Unicode code point). - * - * - * Returns: - * ------- - * - * Returns the index within this string of the first - * occurrence of the specified character. , or -1 if - * the character does not occur. - */ - - int indexPosition = str.indexOf("e"); - System.out.println("indexOf("e") = " + indexPosition); - - indexPosition = str.indexOf("a"); - System.out.println("indexOf("a") = " + indexPosition); - - } -} diff --git a/Later/String/Manipulating Characters in a String/String_21/Java String - lastIndexOf-ch.pptx b/Later/String/Manipulating Characters in a String/String_21/Java String - lastIndexOf-ch.pptx deleted file mode 100644 index abe5a72f6..000000000 Binary files a/Later/String/Manipulating Characters in a String/String_21/Java String - lastIndexOf-ch.pptx and /dev/null differ diff --git a/Later/String/Manipulating Characters in a String/String_21/StringDemo/src/LastIndexOfDemo.java b/Later/String/Manipulating Characters in a String/String_21/StringDemo/src/LastIndexOfDemo.java deleted file mode 100644 index a0d9bd2a9..000000000 --- a/Later/String/Manipulating Characters in a String/String_21/StringDemo/src/LastIndexOfDemo.java +++ /dev/null @@ -1,32 +0,0 @@ -public class LastIndexDemo -{ - - public static void main(String[] args) - { - String str = "Welcome"; - - /* - * public int lastIndexOf(int ch) - * - * Parameters: - * ---------- - * - * ch - a character (Unicode code point). - * - * - * Returns: - * ------- - * - * Returns the index within this string of the last - * occurrence of the specified character. , or -1 if - * the character does not occur. - */ - - int indexPosition = str.lastIndexOf("e"); - System.out.println("lastIndexOf(\"e\") = " + indexPosition); - - indexPosition = str.lastIndexOf("a"); - System.out.println("lastIndexOf(\"a\") = " + indexPosition); - - } -} diff --git a/Later/String/Manipulating Characters in a String/String_22/Java String - IndexOf-ch-fromIndex.pptx b/Later/String/Manipulating Characters in a String/String_22/Java String - IndexOf-ch-fromIndex.pptx deleted file mode 100644 index 857417eaa..000000000 Binary files a/Later/String/Manipulating Characters in a String/String_22/Java String - IndexOf-ch-fromIndex.pptx and /dev/null differ diff --git a/Later/String/Manipulating Characters in a String/String_22/StringDemo/bin/IndexOfDemo.class b/Later/String/Manipulating Characters in a String/String_22/StringDemo/bin/IndexOfDemo.class deleted file mode 100644 index ff1dc2375..000000000 Binary files a/Later/String/Manipulating Characters in a String/String_22/StringDemo/bin/IndexOfDemo.class and /dev/null differ diff --git a/Later/String/Manipulating Characters in a String/String_22/StringDemo/src/IndexOfDemo.java b/Later/String/Manipulating Characters in a String/String_22/StringDemo/src/IndexOfDemo.java deleted file mode 100644 index 7ce793ba8..000000000 --- a/Later/String/Manipulating Characters in a String/String_22/StringDemo/src/IndexOfDemo.java +++ /dev/null @@ -1,30 +0,0 @@ -public class IndexOfDemo -{ - - public static void main(String[] args) - { - String str = "Welcome"; - - /* - * public int indexOf(int ch, int fromIndex) - * - * Parameters: - * ---------- - * - * ch - a character (Unicode code point). - * fromIndex - the index to start the search from. - * - * Returns: - * ------- - * - * Returns the index within this string of the first - * occurrence of the specified character, starting - * the search at the specified index. , or -1 if the - * character does not occur. - */ - - int indexPosition = str.indexOf("e", 2); - System.out.println("indexOf(\"e\",2) = " + indexPosition); - - } -} diff --git a/Later/String/Manipulating Characters in a String/String_23/Java String - LastIndexOf-ch-fromIndex.pptx b/Later/String/Manipulating Characters in a String/String_23/Java String - LastIndexOf-ch-fromIndex.pptx deleted file mode 100644 index e161b8421..000000000 Binary files a/Later/String/Manipulating Characters in a String/String_23/Java String - LastIndexOf-ch-fromIndex.pptx and /dev/null differ diff --git a/Later/String/Manipulating Characters in a String/String_23/StringDemo/bin/LastIndexOfDemo.class b/Later/String/Manipulating Characters in a String/String_23/StringDemo/bin/LastIndexOfDemo.class deleted file mode 100644 index 12f67e62a..000000000 Binary files a/Later/String/Manipulating Characters in a String/String_23/StringDemo/bin/LastIndexOfDemo.class and /dev/null differ diff --git a/Later/String/Manipulating Characters in a String/String_23/StringDemo/src/LastIndexOfDemo.java b/Later/String/Manipulating Characters in a String/String_23/StringDemo/src/LastIndexOfDemo.java deleted file mode 100644 index bda4f8d11..000000000 --- a/Later/String/Manipulating Characters in a String/String_23/StringDemo/src/LastIndexOfDemo.java +++ /dev/null @@ -1,30 +0,0 @@ -public class LastIndexOfDemo -{ - - public static void main(String[] args) - { - String str = "Welcome"; - - /* - * public int lastIndexOf(int ch, int fromIndex) - * - * Parameters: - * ---------- - * - * ch - a character (Unicode code point). - * fromIndex - the index to start the search from. - * - * Returns: - * ------- - * - * Returns the index within this string of the last - * occurrence of the specified character, starting - * the search at the specified index. , or -1 if the - * character does not occur. - */ - - int indexPosition = str.lastIndexOf("e", 4); - System.out.println("lastIndexOf(\"e\",4) = " + indexPosition); - - } -} diff --git a/Later/String/Manipulating Characters in a String/String_24/Java String - indexOf-String.pptx b/Later/String/Manipulating Characters in a String/String_24/Java String - indexOf-String.pptx deleted file mode 100644 index c5b98b2f8..000000000 Binary files a/Later/String/Manipulating Characters in a String/String_24/Java String - indexOf-String.pptx and /dev/null differ diff --git a/Later/String/Manipulating Characters in a String/String_24/StringDemo/bin/IndexOfDemo.class b/Later/String/Manipulating Characters in a String/String_24/StringDemo/bin/IndexOfDemo.class deleted file mode 100644 index c47c84de2..000000000 Binary files a/Later/String/Manipulating Characters in a String/String_24/StringDemo/bin/IndexOfDemo.class and /dev/null differ diff --git a/Later/String/Manipulating Characters in a String/String_24/StringDemo/src/IndexOfDemo.java b/Later/String/Manipulating Characters in a String/String_24/StringDemo/src/IndexOfDemo.java deleted file mode 100644 index de6538c2b..000000000 --- a/Later/String/Manipulating Characters in a String/String_24/StringDemo/src/IndexOfDemo.java +++ /dev/null @@ -1,31 +0,0 @@ -public class IndexOfDemo -{ - - public static void main(String[] args) - { - String str = "Welcome.com"; - - /* - * public int indexOf(String str) - * - * Parameters: - * ---------- - * - * str - the substring to search for. - * - * Returns: - * ------- - * - * the index of the first occurrence of the - * specified substring, or -1 if there is no such - * occurrence. - */ - - int indexPosition = str.indexOf("com"); - System.out.println("indexOf(\"com\") = " + indexPosition); - - indexPosition = str.indexOf("abc"); - System.out.println("indexOf(\"abc\") = " + indexPosition); - - } -} diff --git a/Later/String/Manipulating Characters in a String/String_25/Java String - indexOf-String-fromindex.pptx b/Later/String/Manipulating Characters in a String/String_25/Java String - indexOf-String-fromindex.pptx deleted file mode 100644 index 6cc888d7e..000000000 Binary files a/Later/String/Manipulating Characters in a String/String_25/Java String - indexOf-String-fromindex.pptx and /dev/null differ diff --git a/Later/String/Manipulating Characters in a String/String_25/StringDemo/bin/IndexOfDemo.class b/Later/String/Manipulating Characters in a String/String_25/StringDemo/bin/IndexOfDemo.class deleted file mode 100644 index ea7c92ba2..000000000 Binary files a/Later/String/Manipulating Characters in a String/String_25/StringDemo/bin/IndexOfDemo.class and /dev/null differ diff --git a/Later/String/Manipulating Characters in a String/String_25/StringDemo/src/IndexOfDemo.java b/Later/String/Manipulating Characters in a String/String_25/StringDemo/src/IndexOfDemo.java deleted file mode 100644 index 388cb7e0c..000000000 --- a/Later/String/Manipulating Characters in a String/String_25/StringDemo/src/IndexOfDemo.java +++ /dev/null @@ -1,33 +0,0 @@ -public class IndexOfDemo -{ - - public static void main(String[] args) - { - String str = "Welcome.com"; - - /* - * public int indexOf(String str, int fromIndex) - * - * Parameters: - * ---------- - * - * str - the substring to search for. - * fromIndex - the index from which to start the - * search. - * - * Returns: - * ------- - * - * the index of the first occurrence of the - * specified substring, starting at the specified - * index, or -1 if there is no such occurrence. - */ - - int indexPosition = str.indexOf("com", 4); - System.out.println("indexOf(\"com\",4) = " + indexPosition); - - indexPosition = str.indexOf("abc",4); - System.out.println("indexOf(\"abc\",4) = " + indexPosition); - - } -} diff --git a/Later/String/Manipulating Characters in a String/String_26/Java String - lastindexOf-String.pptx b/Later/String/Manipulating Characters in a String/String_26/Java String - lastindexOf-String.pptx deleted file mode 100644 index f4fa60eac..000000000 Binary files a/Later/String/Manipulating Characters in a String/String_26/Java String - lastindexOf-String.pptx and /dev/null differ diff --git a/Later/String/Manipulating Characters in a String/String_26/StringDemo/bin/LastIndexOfDemo.class b/Later/String/Manipulating Characters in a String/String_26/StringDemo/bin/LastIndexOfDemo.class deleted file mode 100644 index e79428182..000000000 Binary files a/Later/String/Manipulating Characters in a String/String_26/StringDemo/bin/LastIndexOfDemo.class and /dev/null differ diff --git a/Later/String/Manipulating Characters in a String/String_26/StringDemo/src/LastIndexOfDemo.java b/Later/String/Manipulating Characters in a String/String_26/StringDemo/src/LastIndexOfDemo.java deleted file mode 100644 index 96c39d9d7..000000000 --- a/Later/String/Manipulating Characters in a String/String_26/StringDemo/src/LastIndexOfDemo.java +++ /dev/null @@ -1,30 +0,0 @@ -public class LastIndexOfDemo -{ - - public static void main(String[] args) - { - String str = "Welcome.com"; - - /* - * public int lastIndexOf(String str) - * - * Parameters: - * ---------- - * - * str - the substring to search for. - * - * Returns: - * ------- - * - * the index of the last occurrence of the specified - * substring, or -1 if there is no such occurrence. - */ - - int indexPosition = str.lastIndexOf("com"); - System.out.println("lastIndexOf(\"com\") = " + indexPosition); - - indexPosition = str.indexOf("abc"); - System.out.println("lastIndexOf(\"abc\") = " + indexPosition); - - } -} diff --git a/Later/String/Manipulating Characters in a String/String_27/Java String - lastindexOf-String-fromIndex.pptx b/Later/String/Manipulating Characters in a String/String_27/Java String - lastindexOf-String-fromIndex.pptx deleted file mode 100644 index e25ead06a..000000000 Binary files a/Later/String/Manipulating Characters in a String/String_27/Java String - lastindexOf-String-fromIndex.pptx and /dev/null differ diff --git a/Later/String/Manipulating Characters in a String/String_27/StringDemo/bin/LastIndexOfDemo.class b/Later/String/Manipulating Characters in a String/String_27/StringDemo/bin/LastIndexOfDemo.class deleted file mode 100644 index 0f0a4a05f..000000000 Binary files a/Later/String/Manipulating Characters in a String/String_27/StringDemo/bin/LastIndexOfDemo.class and /dev/null differ diff --git a/Later/String/Manipulating Characters in a String/String_27/StringDemo/src/LastIndexOfDemo.java b/Later/String/Manipulating Characters in a String/String_27/StringDemo/src/LastIndexOfDemo.java deleted file mode 100644 index 071dc62ff..000000000 --- a/Later/String/Manipulating Characters in a String/String_27/StringDemo/src/LastIndexOfDemo.java +++ /dev/null @@ -1,34 +0,0 @@ -public class LastIndexOfDemo -{ - - public static void main(String[] args) - { - String str = "Welcome.com"; - - /* - * public int lastIndexOf(String str, int fromIndex) - * - * Parameters: - * ---------- - * - * str - the substring to search for. - * fromIndex - the index to start the search from. - * - * Returns: - * ------- - * - * the index of the last occurrence of the specified - * substring, searching backward from the specified - * index, or -1 if there is no such occurrence. - */ - - int indexPosition = str.lastIndexOf("com", 7); - System.out.println("lastIndexOf(\"com\",7) = " - + indexPosition); - - indexPosition = str.indexOf("abc", 8); - System.out.println("lastIndexOf(\"abc\",8) = " - + indexPosition); - - } -} diff --git a/Later/String/Manipulating Characters in a String/String_28/Java String_contains.pptx b/Later/String/Manipulating Characters in a String/String_28/Java String_contains.pptx deleted file mode 100644 index 5447b8611..000000000 Binary files a/Later/String/Manipulating Characters in a String/String_28/Java String_contains.pptx and /dev/null differ diff --git a/Later/String/Manipulating Characters in a String/String_28/StringDemo/bin/LastIndexOfDemo.class b/Later/String/Manipulating Characters in a String/String_28/StringDemo/bin/LastIndexOfDemo.class deleted file mode 100644 index 1a17e13a0..000000000 Binary files a/Later/String/Manipulating Characters in a String/String_28/StringDemo/bin/LastIndexOfDemo.class and /dev/null differ diff --git a/Later/String/Manipulating Characters in a String/String_28/StringDemo/src/ContainsDemo.java b/Later/String/Manipulating Characters in a String/String_28/StringDemo/src/ContainsDemo.java deleted file mode 100644 index b674f9a4d..000000000 --- a/Later/String/Manipulating Characters in a String/String_28/StringDemo/src/ContainsDemo.java +++ /dev/null @@ -1,36 +0,0 @@ -public class ContainsDemo -{ - - public static void main(String[] args) - { - String str = "How are you peter?"; - - /* - * public boolean contains(CharSequence s) - * - * Parameters: - * ---------- - * - * s - the sequence to search for. - * - * Returns: - * ------- - * - * Returns true if and only if this string contains - * the specified sequence of char values. - */ - - boolean isExist = str.contains("are"); - System.out.println("contains(\"are\") = " + isExist); - - /* - * CharSequence is an interface that is implemented - * by the String class. Therefore, you can use a - * string as an argument for the contains() method. - */ - - isExist = str.contains("do"); - System.out.println("contains(\"do\") = " + isExist); - - } -} diff --git a/Later/String/Manipulating Characters in a String/String_29/Java String_replace_char.pptx b/Later/String/Manipulating Characters in a String/String_29/Java String_replace_char.pptx deleted file mode 100644 index d818027dc..000000000 Binary files a/Later/String/Manipulating Characters in a String/String_29/Java String_replace_char.pptx and /dev/null differ diff --git a/Later/String/Manipulating Characters in a String/String_29/StringDemo/bin/ContainsDemo.class b/Later/String/Manipulating Characters in a String/String_29/StringDemo/bin/ContainsDemo.class deleted file mode 100644 index 902a6214f..000000000 Binary files a/Later/String/Manipulating Characters in a String/String_29/StringDemo/bin/ContainsDemo.class and /dev/null differ diff --git a/Later/String/Manipulating Characters in a String/String_29/StringDemo/src/ReplaceDemo.java b/Later/String/Manipulating Characters in a String/String_29/StringDemo/src/ReplaceDemo.java deleted file mode 100644 index ff3ccef8b..000000000 --- a/Later/String/Manipulating Characters in a String/String_29/StringDemo/src/ReplaceDemo.java +++ /dev/null @@ -1,29 +0,0 @@ -public class ReplaceDemo -{ - - public static void main(String[] args) - { - String str = "aaabbb"; - - /* - * public String replace(char oldChar, char newChar) - * - * Parameters: - * ---------- - * - * oldChar - the old character. newChar - the new - * character.. - * - * Returns: - * ------- - * - * Returns a string resulting from replacing all - * occurrences of oldChar in this string with - * newChar. - */ - - String replacedStr = str.replace('a', 'z'); - System.out.println("replacedStr = " + replacedStr); - - } -} diff --git a/Later/String/Manipulating Characters in a String/String_30/Java String_replace_CharSequence.pptx b/Later/String/Manipulating Characters in a String/String_30/Java String_replace_CharSequence.pptx deleted file mode 100644 index 013bf64b0..000000000 Binary files a/Later/String/Manipulating Characters in a String/String_30/Java String_replace_CharSequence.pptx and /dev/null differ diff --git a/Later/String/Manipulating Characters in a String/String_30/StringDemo/bin/ReplaceDemo.class b/Later/String/Manipulating Characters in a String/String_30/StringDemo/bin/ReplaceDemo.class deleted file mode 100644 index 9ab49aafb..000000000 Binary files a/Later/String/Manipulating Characters in a String/String_30/StringDemo/bin/ReplaceDemo.class and /dev/null differ diff --git a/Later/String/Manipulating Characters in a String/String_30/StringDemo/src/ReplaceDemo.java b/Later/String/Manipulating Characters in a String/String_30/StringDemo/src/ReplaceDemo.java deleted file mode 100644 index fc40dcb33..000000000 --- a/Later/String/Manipulating Characters in a String/String_30/StringDemo/src/ReplaceDemo.java +++ /dev/null @@ -1,36 +0,0 @@ -public class ReplaceDemo -{ - - public static void main(String[] args) - { - String str = "My name is Peter,her name is Juli"; - System.out.println("str = " + str); - - /* - * public String replace(CharSequence target, - * CharSequence replacement) - * - * Parameters: - * ---------- - * - * target - The sequence of char values to be - * replaced. - * - * replacement - The replacement sequence - * of char values. - * - * Returns: - * ------- - * - * Replaces each substring of this string that - * matches the literal target sequence with the - * specified literal replacement sequence. The - * replacement proceeds from the beginning of the - * string to the end. - */ - - String replacedStr = str.replace("is", "was"); - System.out.println("replacedStr = " + replacedStr); - - } -} diff --git a/Later/String/Manipulating Characters in a String/String_31/Java String_replaceAll.pptx b/Later/String/Manipulating Characters in a String/String_31/Java String_replaceAll.pptx deleted file mode 100644 index e1fe5efe5..000000000 Binary files a/Later/String/Manipulating Characters in a String/String_31/Java String_replaceAll.pptx and /dev/null differ diff --git a/Later/String/Manipulating Characters in a String/String_31/StringDemo/bin/ReplaceAllDemo.class b/Later/String/Manipulating Characters in a String/String_31/StringDemo/bin/ReplaceAllDemo.class deleted file mode 100644 index 7c3a3cad6..000000000 Binary files a/Later/String/Manipulating Characters in a String/String_31/StringDemo/bin/ReplaceAllDemo.class and /dev/null differ diff --git a/Later/String/Manipulating Characters in a String/String_31/StringDemo/src/ReplaceAllDemo.java b/Later/String/Manipulating Characters in a String/String_31/StringDemo/src/ReplaceAllDemo.java deleted file mode 100644 index f386be25e..000000000 --- a/Later/String/Manipulating Characters in a String/String_31/StringDemo/src/ReplaceAllDemo.java +++ /dev/null @@ -1,43 +0,0 @@ -public class ReplaceAllDemo -{ - - public static void main(String[] args) - { - String str = "My name is Peter,her name is Juli"; - System.out.println("str = " + str); - - /* - * public String replaceAll(String regex, String - * replacement) - * - * Parameters: - * ---------- - * - * regex - the regular expression to which this - * string is to be matched. - * - * replacement - the string* to be substituted for - * each match. - * - * Returns: - * ------- - * - * Replaces each substring of this string that - * matches the given regular expression with the - * given replacement. - * - * Throws: - * ------ - * - * PatternSyntaxException - if the - * regular expression's syntax is invalid. - */ - - String replacedStr = str.replaceAll("is", "was"); - System.out.println("replacedStr = " + replacedStr); - - replacedStr = replacedStr.replaceAll("\\s", "_"); - System.out.println("replacedStr = "+replacedStr); - - } -} diff --git a/Later/String/Manipulating Characters in a String/String_32/Java String_replaceFirst.pptx b/Later/String/Manipulating Characters in a String/String_32/Java String_replaceFirst.pptx deleted file mode 100644 index 3b945b88a..000000000 Binary files a/Later/String/Manipulating Characters in a String/String_32/Java String_replaceFirst.pptx and /dev/null differ diff --git a/Later/String/Manipulating Characters in a String/String_32/StringDemo/src/ReplaceFirstDemo.java b/Later/String/Manipulating Characters in a String/String_32/StringDemo/src/ReplaceFirstDemo.java deleted file mode 100644 index 0b35eb374..000000000 --- a/Later/String/Manipulating Characters in a String/String_32/StringDemo/src/ReplaceFirstDemo.java +++ /dev/null @@ -1,40 +0,0 @@ -public class ReplaceFirstDemo -{ - - public static void main(String[] args) - { - String str = "My name is Peter,her name is Juli"; - System.out.println("str = " + str); - - /* - * public String replaceFirst(String regex, String - * replacement) - * - * Parameters: - * ---------- - * - * regex - the regular expression to which this - * string is to be matched. - * - * replacement - the string to be substituted - * for the first match. - * - * Returns: - * ------- - * - * Replaces the first substring of this string that - * matches the given regular expression with the - * given replacement. - * - * Throws: - * ------ - * - * PatternSyntaxException - if the regular - * expression's syntax is invalid. - */ - - String replacedStr = str.replaceFirst("is", "was"); - System.out.println("replacedStr = " + replacedStr); - - } -} diff --git a/Later/String/Manipulating Characters in a String/String_33/Java String_filename.pptx b/Later/String/Manipulating Characters in a String/String_33/Java String_filename.pptx deleted file mode 100644 index 3862eeb28..000000000 Binary files a/Later/String/Manipulating Characters in a String/String_33/Java String_filename.pptx and /dev/null differ diff --git a/Later/String/misc/String Concatenation in Java_62/String Concatenation in Java.pptx b/Later/String/misc/String Concatenation in Java_62/String Concatenation in Java.pptx deleted file mode 100644 index 2950389b1..000000000 Binary files a/Later/String/misc/String Concatenation in Java_62/String Concatenation in Java.pptx and /dev/null differ diff --git a/Later/String/misc/String-Comparison_61/String_61/Java String compare.pptx b/Later/String/misc/String-Comparison_61/String_61/Java String compare.pptx deleted file mode 100644 index ef1e97fc6..000000000 Binary files a/Later/String/misc/String-Comparison_61/String_61/Java String compare.pptx and /dev/null differ diff --git a/Later/String/misc/String_45/Java String_getbytes.pptx b/Later/String/misc/String_45/Java String_getbytes.pptx deleted file mode 100644 index 5ab461d29..000000000 Binary files a/Later/String/misc/String_45/Java String_getbytes.pptx and /dev/null differ diff --git a/Later/String/misc/String_45/StringDemo/bin/GetBytesDemo.class b/Later/String/misc/String_45/StringDemo/bin/GetBytesDemo.class deleted file mode 100644 index 26dd781f2..000000000 Binary files a/Later/String/misc/String_45/StringDemo/bin/GetBytesDemo.class and /dev/null differ diff --git a/Later/String/misc/String_45/StringDemo/src/GetBytesDemo.java b/Later/String/misc/String_45/StringDemo/src/GetBytesDemo.java deleted file mode 100644 index 90261a8b9..000000000 --- a/Later/String/misc/String_45/StringDemo/src/GetBytesDemo.java +++ /dev/null @@ -1,28 +0,0 @@ -public class GetBytesDemo -{ - public static void main(String[] args) - { - String str = "Hi"; - - /* - * public byte[] getBytes() - * - * Encodes this String into a sequence of bytes - * using the platform's default charset, storing the - * result into a new byte array. - * - * Returns: - * ------- - * - * The resultant byte array - */ - - byte[] byteArray = str.getBytes(); - System.out.println("byteArray of \"Hi\" = " + byteArray); - - for (byte b : byteArray) - { - System.out.println(b); - } - } -} \ No newline at end of file diff --git a/Later/String/misc/String_46/Java String_getbytes_charsetName.pptx b/Later/String/misc/String_46/Java String_getbytes_charsetName.pptx deleted file mode 100644 index a1844c963..000000000 Binary files a/Later/String/misc/String_46/Java String_getbytes_charsetName.pptx and /dev/null differ diff --git a/Later/String/misc/String_46/StringDemo/bin/GetBytesDemo.class b/Later/String/misc/String_46/StringDemo/bin/GetBytesDemo.class deleted file mode 100644 index 8197bfd5b..000000000 Binary files a/Later/String/misc/String_46/StringDemo/bin/GetBytesDemo.class and /dev/null differ diff --git a/Later/String/misc/String_46/StringDemo/src/GetBytesDemo.java b/Later/String/misc/String_46/StringDemo/src/GetBytesDemo.java deleted file mode 100644 index 032e3e1c2..000000000 --- a/Later/String/misc/String_46/StringDemo/src/GetBytesDemo.java +++ /dev/null @@ -1,60 +0,0 @@ -import java.io.UnsupportedEncodingException; - -public class GetBytesDemo -{ - public static void main(String[] args) - { - String str = "Hi"; - - /* - * public byte[] getBytes(String charsetName) throws - * UnsupportedEncodingException - * - * Encodes this String into a sequence of bytes - * using the named charset, storing the result into - * a new byte array. - * - * Parameters: - * --------- - * - * charsetName - The name of a supported charset - * - * Returns: - * ------- - * - * The resultant byte array - * - * Throws: - * ------ - * - * UnsupportedEncodingException - If the named - * charset is not supported - */ - - try - { - byte[] byteArray = str.getBytes("UTF-8"); - System.out - .println("byteArray of \"Hi\" with charsetName \"UTF-8\" = " - + byteArray); - for (byte b : byteArray) - { - System.out.println(b); - } - System.out.println("--------------------"); - byteArray = str.getBytes("ISO-8859-1"); - System.out - .println("byteArray of \"Hi\" with charsetName \"ISO-8859-1\" = " - + byteArray); - for (byte b : byteArray) - { - System.out.println(b); - } - } - catch (UnsupportedEncodingException e) - { - e.printStackTrace(); - } - - } -} \ No newline at end of file diff --git a/Later/String/misc/String_47/Java String_getbytes_charset.pptx b/Later/String/misc/String_47/Java String_getbytes_charset.pptx deleted file mode 100644 index b640f07f4..000000000 Binary files a/Later/String/misc/String_47/Java String_getbytes_charset.pptx and /dev/null differ diff --git a/Later/String/misc/String_47/StringDemo/bin/GetBytesDemo.class b/Later/String/misc/String_47/StringDemo/bin/GetBytesDemo.class deleted file mode 100644 index 272be16b4..000000000 Binary files a/Later/String/misc/String_47/StringDemo/bin/GetBytesDemo.class and /dev/null differ diff --git a/Later/String/misc/String_47/StringDemo/src/GetBytesDemo.java b/Later/String/misc/String_47/StringDemo/src/GetBytesDemo.java deleted file mode 100644 index 6fbc5c27e..000000000 --- a/Later/String/misc/String_47/StringDemo/src/GetBytesDemo.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * public byte[] getBytes(Charset charset) - * - * Encodes this String into a sequence of bytes - * using the given charset, storing the result into - * a new byte array. - * - * Parameters: - * ---------- - * - * charset - The Charset to be used to encode the - * String - * - * Returns: - * ------- - * - * The resultant byte array - */ -public class GetBytesDemo -{ - public static void main(String[] args) - { - String str = "Hi"; - - java.nio.charset.Charset charSet = java.nio.charset.Charset - .forName("ASCII"); - byte[] byteArray = str.getBytes(charSet); - System.out - .println("byteArray of \"Hi\" with charsetName \"ASCII\" = " - + byteArray); - for (byte b : byteArray) - { - System.out.println(b); - } - - } -} \ No newline at end of file diff --git a/Later/String/misc/String_48/Java String_isempty.pptx b/Later/String/misc/String_48/Java String_isempty.pptx deleted file mode 100644 index 9406acfa0..000000000 Binary files a/Later/String/misc/String_48/Java String_isempty.pptx and /dev/null differ diff --git a/Later/String/misc/String_49/Java String_intern.pptx b/Later/String/misc/String_49/Java String_intern.pptx deleted file mode 100644 index fee738a49..000000000 Binary files a/Later/String/misc/String_49/Java String_intern.pptx and /dev/null differ diff --git a/Later/String/misc/String_49/StringDemo/bin/InternDemo.class b/Later/String/misc/String_49/StringDemo/bin/InternDemo.class deleted file mode 100644 index bc4f8e599..000000000 Binary files a/Later/String/misc/String_49/StringDemo/bin/InternDemo.class and /dev/null differ diff --git a/Later/String/misc/String_50/Java String_Join.pptx b/Later/String/misc/String_50/Java String_Join.pptx deleted file mode 100644 index c75705ac3..000000000 Binary files a/Later/String/misc/String_50/Java String_Join.pptx and /dev/null differ diff --git a/Later/String/misc/String_50/StringDemo/bin/JoinDemo.class b/Later/String/misc/String_50/StringDemo/bin/JoinDemo.class deleted file mode 100644 index 1b18d4684..000000000 Binary files a/Later/String/misc/String_50/StringDemo/bin/JoinDemo.class and /dev/null differ diff --git a/Later/String/misc/String_50/StringDemo/src/JoinDemo.java b/Later/String/misc/String_50/StringDemo/src/JoinDemo.java deleted file mode 100644 index 1bebf11c6..000000000 --- a/Later/String/misc/String_50/StringDemo/src/JoinDemo.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * public static String join(CharSequence delimiter, - * CharSequence... elements) - * - * Parameters: - * ----------- - * - * delimiter - the delimiter that separates each element - * - * elements - the elements to join together. - * - * Returns: - * -------- - * - * a new String that is composed of the elements - * separated by the delimiter. - * - * Throws: - * ------- - * - * NullPointerException - If delimiter or elements is - * null - */ - -public class JoinDemo -{ - public static void main(String[] args) - { - String str1 = "welcome"; - String str2 = "to"; - String str3 = "India"; - - String joinString = String.join("_", str1, str2, str3); - System.out.println("JoinString = " + joinString); - - } - -} \ No newline at end of file diff --git a/Later/String/misc/String_51/Java String_Join_Iterable.pptx b/Later/String/misc/String_51/Java String_Join_Iterable.pptx deleted file mode 100644 index 0504a156e..000000000 Binary files a/Later/String/misc/String_51/Java String_Join_Iterable.pptx and /dev/null differ diff --git a/Later/String/misc/String_51/StringDemo/bin/JoinDemo.class b/Later/String/misc/String_51/StringDemo/bin/JoinDemo.class deleted file mode 100644 index 718be44b9..000000000 Binary files a/Later/String/misc/String_51/StringDemo/bin/JoinDemo.class and /dev/null differ diff --git a/Later/String/misc/String_51/StringDemo/src/JoinDemo.java b/Later/String/misc/String_51/StringDemo/src/JoinDemo.java deleted file mode 100644 index 2e86f1665..000000000 --- a/Later/String/misc/String_51/StringDemo/src/JoinDemo.java +++ /dev/null @@ -1,55 +0,0 @@ -import java.util.LinkedHashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; - -/* - * public static String join(CharSequence delimiter, - * Iterable elements) - * - * Parameters: - * ----------- - * - * delimiter - a sequence of characters that is used - * to separate each of the elements in the resulting - * String elements - an Iterable that will have its - * elements joined together. - * - * Returns: - * -------- - * - * a new String that is composed from the elements - * argument - * - * Throws: - * ------- - * - * NullPointerException - If delimiter or elements - * is null - */ - -public class JoinDemo -{ - public static void main(String[] args) - { - List listOfStrings = new LinkedList<>(); - listOfStrings.add("Java"); - listOfStrings.add("is"); - listOfStrings.add("cool"); - - // message returned is: "Java|is|cool" - String message = String.join("|", listOfStrings); - System.out.println(message); - - Set setOfStrings = new LinkedHashSet<>(); - setOfStrings.add("Java"); - setOfStrings.add("is"); - setOfStrings.add("very"); - setOfStrings.add("cool"); - - // message returned is: "Java-is-very-cool" - message = String.join("-", setOfStrings); - System.out.println(message); - } - -} \ No newline at end of file diff --git a/Later/String/misc/String_52/Java String_toCharArray.pptx b/Later/String/misc/String_52/Java String_toCharArray.pptx deleted file mode 100644 index 7ac045dfe..000000000 Binary files a/Later/String/misc/String_52/Java String_toCharArray.pptx and /dev/null differ diff --git a/Later/String/misc/String_52/StringDemo/bin/JoinDemo.class b/Later/String/misc/String_52/StringDemo/bin/JoinDemo.class deleted file mode 100644 index 63273ddc1..000000000 Binary files a/Later/String/misc/String_52/StringDemo/bin/JoinDemo.class and /dev/null differ diff --git a/Later/String/misc/String_52/StringDemo/src/toCharArrayDemo.java b/Later/String/misc/String_52/StringDemo/src/toCharArrayDemo.java deleted file mode 100644 index 716efd27e..000000000 --- a/Later/String/misc/String_52/StringDemo/src/toCharArrayDemo.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * public char[] toCharArray() - * - * - * Returns: - * -------- - * - * a newly allocated character array whose length is the - * length of this string and whose contents are - * initialized to contain the character sequence - * represented by this string. - */ -public class toCharArrayDemo -{ - - public static void main(String[] args) - { - String str = "Welcome"; - char[] charArray = str.toCharArray(); - for (char c : charArray) - { - System.out.println(c); - } - } - -} \ No newline at end of file diff --git a/Later/String/misc/String_53/Java String_valueOf.pptx b/Later/String/misc/String_53/Java String_valueOf.pptx deleted file mode 100644 index 1b8c878aa..000000000 Binary files a/Later/String/misc/String_53/Java String_valueOf.pptx and /dev/null differ diff --git a/Later/String/misc/String_53/StringDemo/src/valueOfDemo.java b/Later/String/misc/String_53/StringDemo/src/valueOfDemo.java deleted file mode 100644 index 00c617cb7..000000000 --- a/Later/String/misc/String_53/StringDemo/src/valueOfDemo.java +++ /dev/null @@ -1,23 +0,0 @@ -public class valueOfDemo -{ - - public static void main(String[] args) - { - int intValue=30; - String str1=String.valueOf(intValue); - System.out.println(str1); - - double doubleValue=30; - str1=String.valueOf(doubleValue); - System.out.println(str1); - - char[] charArray ={'H','i'};; - str1=String.valueOf(charArray); - System.out.println(str1); - - boolean value = true; - str1=String.valueOf(value); - System.out.println(str1); - } - -} \ No newline at end of file diff --git a/Later/String/misc/String_54/Java String_contentEquals-ChSeq.pptx b/Later/String/misc/String_54/Java String_contentEquals-ChSeq.pptx deleted file mode 100644 index 207665b41..000000000 Binary files a/Later/String/misc/String_54/Java String_contentEquals-ChSeq.pptx and /dev/null differ diff --git a/Later/String/misc/String_54/StringDemo/bin/ContentEqualsDemo.class b/Later/String/misc/String_54/StringDemo/bin/ContentEqualsDemo.class deleted file mode 100644 index d7db108ac..000000000 Binary files a/Later/String/misc/String_54/StringDemo/bin/ContentEqualsDemo.class and /dev/null differ diff --git a/Later/String/misc/String_54/StringDemo/src/ContentEqualsDemo.java b/Later/String/misc/String_54/StringDemo/src/ContentEqualsDemo.java deleted file mode 100644 index 597acac28..000000000 --- a/Later/String/misc/String_54/StringDemo/src/ContentEqualsDemo.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * public boolean contentEquals(CharSequence cs) - * - * Parameters: - * ---------- - * - * cs - The sequence to compare this String against - * - * Returns: - * ------- - * - * true if this String represents the same sequence of - * char values as the specified sequence, false - * otherwise - */ - -public class ContentEqualsDemo -{ - - public static void main(String[] args) - { - String str1 = "Welcome Peter"; - String str2 = "Hi"; - String str3 = "Welcome Peter"; - - boolean result = str1.contentEquals(str2); - System.out.println("str1.contentEquals(str2) = " + result); - result = str1.contentEquals(str3); - System.out.println("str1.contentEquals(str3) = " + result); - - } - -} \ No newline at end of file diff --git a/Later/String/misc/String_55/Java String_contentEquals-sb.pptx b/Later/String/misc/String_55/Java String_contentEquals-sb.pptx deleted file mode 100644 index b0a970430..000000000 Binary files a/Later/String/misc/String_55/Java String_contentEquals-sb.pptx and /dev/null differ diff --git a/Later/String/misc/String_55/StringDemo/bin/ContentEqualsDemo.class b/Later/String/misc/String_55/StringDemo/bin/ContentEqualsDemo.class deleted file mode 100644 index 54b7e908e..000000000 Binary files a/Later/String/misc/String_55/StringDemo/bin/ContentEqualsDemo.class and /dev/null differ diff --git a/Later/String/misc/String_55/StringDemo/src/ContentEqualsDemo.java b/Later/String/misc/String_55/StringDemo/src/ContentEqualsDemo.java deleted file mode 100644 index 69825262c..000000000 --- a/Later/String/misc/String_55/StringDemo/src/ContentEqualsDemo.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * public boolean contentEquals(StringBuffer sb) - * - * Parameters: - * ---------- - * - * sb - The StringBuffer to compare this String against - * - * Returns: - * ------- - * - * true if this String represents the same sequence of - * characters as the specified StringBuffer, false - * otherwise - */ -public class ContentEqualsDemo -{ - - public static void main(String[] args) - { - String str1 = "Welcome Peter"; - StringBuffer sb1 = new StringBuffer("Welcome Peter"); - StringBuffer sb2 = new StringBuffer("Hello"); - - boolean result = str1.contentEquals(sb1); - System.out.println("str1.contentEquals(sb1) = " + result); - result = str1.contentEquals(sb2); - System.out.println("str1.contentEquals(sb2) = " + result); - - } - -} \ No newline at end of file diff --git a/Later/String/misc/String_56/Java String_copyValueOf.pptx b/Later/String/misc/String_56/Java String_copyValueOf.pptx deleted file mode 100644 index 6e5adf031..000000000 Binary files a/Later/String/misc/String_56/Java String_copyValueOf.pptx and /dev/null differ diff --git a/Later/String/misc/String_56/StringDemo/bin/CopyValueOfDemo.class b/Later/String/misc/String_56/StringDemo/bin/CopyValueOfDemo.class deleted file mode 100644 index 0af3f19a8..000000000 Binary files a/Later/String/misc/String_56/StringDemo/bin/CopyValueOfDemo.class and /dev/null differ diff --git a/Later/String/misc/String_56/StringDemo/src/CopyValueOfDemo.java b/Later/String/misc/String_56/StringDemo/src/CopyValueOfDemo.java deleted file mode 100644 index 585f05e12..000000000 --- a/Later/String/misc/String_56/StringDemo/src/CopyValueOfDemo.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * public static String copyValueOf(char[] data) - * - * Equivalent to valueOf(char[]). - * - * Parameters: - * ---------- - * - * data - the character array. - * - * Returns: - * ------- - * - * a String that contains the - * characters of the character array. - */ -public class CopyValueOfDemo -{ - - public static void main(String[] args) - { - char[] charArray = - { 'H', 'i' }; - - String str = String.copyValueOf(charArray); - System.out.println(str); - - } - -} \ No newline at end of file diff --git a/Later/String/misc/String_57/Java String_copyValueOf-offset.pptx b/Later/String/misc/String_57/Java String_copyValueOf-offset.pptx deleted file mode 100644 index 8b72ff87f..000000000 Binary files a/Later/String/misc/String_57/Java String_copyValueOf-offset.pptx and /dev/null differ diff --git a/Later/String/misc/String_57/StringDemo/bin/CopyValueOfDemo.class b/Later/String/misc/String_57/StringDemo/bin/CopyValueOfDemo.class deleted file mode 100644 index 4a6dc35c9..000000000 Binary files a/Later/String/misc/String_57/StringDemo/bin/CopyValueOfDemo.class and /dev/null differ diff --git a/Later/String/misc/String_57/StringDemo/src/CopyValueOfDemo.java b/Later/String/misc/String_57/StringDemo/src/CopyValueOfDemo.java deleted file mode 100644 index 7ec38b6da..000000000 --- a/Later/String/misc/String_57/StringDemo/src/CopyValueOfDemo.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * public static String copyValueOf(char[] data, - * int offset, int count) - * - * Equivalent to valueOf(char[], int, int). - * - * Parameters: - * ---------- - * - * data - the character array. - * - * offset - initial offset of the subarray. - * - * count - length of the subarray. - * - * Returns: - * ------- - * - * a String that contains the characters of the - * specified subarray of the character array. - * - * Throws: - * ------ - * - * IndexOutOfBoundsException - if offset is negative, or - * count is negative, or offset+count is larger than - * data.length. - */ - -public class CopyValueOfDemo -{ - - public static void main(String[] args) - { - char[] charArray = - { 'H', 'i', ' ', 'W', 'e', 'l', 'c', 'o', 'm', 'e' }; - - String str = String.copyValueOf(charArray, 6, 3); - System.out.println(str); - - } - -} \ No newline at end of file diff --git a/Later/String/misc/String_58/Java String_codePointAt.pptx b/Later/String/misc/String_58/Java String_codePointAt.pptx deleted file mode 100644 index 97c2e2276..000000000 Binary files a/Later/String/misc/String_58/Java String_codePointAt.pptx and /dev/null differ diff --git a/Later/String/misc/String_58/StringDemo/bin/CodePointAtDemo.class b/Later/String/misc/String_58/StringDemo/bin/CodePointAtDemo.class deleted file mode 100644 index 4780e771d..000000000 Binary files a/Later/String/misc/String_58/StringDemo/bin/CodePointAtDemo.class and /dev/null differ diff --git a/Later/String/misc/String_58/StringDemo/src/CodePointAtDemo.java b/Later/String/misc/String_58/StringDemo/src/CodePointAtDemo.java deleted file mode 100644 index 979ab3679..000000000 --- a/Later/String/misc/String_58/StringDemo/src/CodePointAtDemo.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * public int codePointAt(int index) - * - * Parameters: - * ---------- - * - * index - the index to the char values - * - * Returns: - * ------- - * - * the code point value of the character at the index - * - * Throws: - * ------ - * - * IndexOutOfBoundsException - if the index argument is - * negative or not less than the length of this string. - */ - -public class CodePointAtDemo -{ - - public static void main(String[] args) - { - String str = "JAVA"; - System.out.println("String = " + str); - - int retval = str.codePointAt(1); - System.out.println("Character(unicode point) = " + retval); - - } - -} \ No newline at end of file diff --git a/Later/String/misc/String_59/Java String_codePointAt-before.pptx b/Later/String/misc/String_59/Java String_codePointAt-before.pptx deleted file mode 100644 index be24a7636..000000000 Binary files a/Later/String/misc/String_59/Java String_codePointAt-before.pptx and /dev/null differ diff --git a/Later/String/misc/String_59/StringDemo/bin/CodePointBeforeDemo.class b/Later/String/misc/String_59/StringDemo/bin/CodePointBeforeDemo.class deleted file mode 100644 index 4a28eb71c..000000000 Binary files a/Later/String/misc/String_59/StringDemo/bin/CodePointBeforeDemo.class and /dev/null differ diff --git a/Later/String/misc/String_59/StringDemo/src/CodePointBeforeDemo.java b/Later/String/misc/String_59/StringDemo/src/CodePointBeforeDemo.java deleted file mode 100644 index 22b2b1849..000000000 --- a/Later/String/misc/String_59/StringDemo/src/CodePointBeforeDemo.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * public int codePointBefore(int index) - * - * Parameters: - * ---------- - * - * index - the index following the code point that - * should be returned - * - * Returns: - * ------- - * - * the Unicode code point value before the given index. - * - * Throws: - * ------ - * - * IndexOutOfBoundsException - if the index argument is - * less than 1 or greater than the length of this - * string. - */ -public class CodePointBeforeDemo -{ - - public static void main(String[] args) - { - String str = "JAVA"; - System.out.println("String = " + str); - - // codepoint before index 1 i.e J - int retval = str.codePointBefore(1); - - // prints character before index1 in string - System.out.println("Character(unicode point) = " + retval); - - } - -} \ No newline at end of file diff --git a/Later/String/misc/String_60/Java String_codePointCount.pptx b/Later/String/misc/String_60/Java String_codePointCount.pptx deleted file mode 100644 index 51ef863db..000000000 Binary files a/Later/String/misc/String_60/Java String_codePointCount.pptx and /dev/null differ diff --git a/Later/String/misc/String_60/StringDemo/bin/CodePointBeforeDemo.class b/Later/String/misc/String_60/StringDemo/bin/CodePointBeforeDemo.class deleted file mode 100644 index e9d027710..000000000 Binary files a/Later/String/misc/String_60/StringDemo/bin/CodePointBeforeDemo.class and /dev/null differ diff --git a/Later/String/misc/String_60/StringDemo/src/CodePointCountDemo.java b/Later/String/misc/String_60/StringDemo/src/CodePointCountDemo.java deleted file mode 100644 index dd5690502..000000000 --- a/Later/String/misc/String_60/StringDemo/src/CodePointCountDemo.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * public int codePointCount(int beginIndex, int - * endIndex) - * - * Parameters: - * ---------- - * - * beginIndex - the index to the first char of the text - * range. - * - * endIndex - the index after the last char of - * the text range. - * - * Returns: - * ------- - * - * the number of Unicode code points in the specified - * text range - * - * Throws: - * ------ - * - * IndexOutOfBoundsException - if the beginIndex is - * negative, or endIndex is larger than the length of - * this String, or beginIndex is larger than endIndex. - */ - -public class CodePointCount -{ - - public static void main(String[] args) - { - String str = "JAVA programming language"; - System.out.println("String = " + str); - - int retval = str.codePointCount(1, 8); - - System.out.println("Codepoint count = " + retval); - - } - -} \ No newline at end of file diff --git a/Later/StringBuffer/StringBuffer_1/String Buffer_Intro.pptx b/Later/StringBuffer/StringBuffer_1/String Buffer_Intro.pptx deleted file mode 100644 index 59bcd4ace..000000000 Binary files a/Later/StringBuffer/StringBuffer_1/String Buffer_Intro.pptx and /dev/null differ diff --git a/Later/StringBuffer/StringBuffer_2/StringBufferDemo/bin/StringBufferDemo.class b/Later/StringBuffer/StringBuffer_2/StringBufferDemo/bin/StringBufferDemo.class deleted file mode 100644 index dec09d15e..000000000 Binary files a/Later/StringBuffer/StringBuffer_2/StringBufferDemo/bin/StringBufferDemo.class and /dev/null differ diff --git a/Later/StringBuffer/StringBuffer_2/StringBufferDemo/src/StringBufferDemo.java b/Later/StringBuffer/StringBuffer_2/StringBufferDemo/src/StringBufferDemo.java deleted file mode 100644 index 648d9504f..000000000 --- a/Later/StringBuffer/StringBuffer_2/StringBufferDemo/src/StringBufferDemo.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * public StringBuffer append(String str) - * - * Appends the specified string to this character sequence. - * - * Parameters: - * ---------- - * - * str - a string. - * - * Returns: - * ------- - * - * a reference to this object. - */ - -public class StringBufferDemo -{ - - public static void main(String[] args) - { - StringBuffer sb = new StringBuffer("Hello "); - sb.append("Java"); - System.out.println(sb); - } -} diff --git a/Later/StringBuffer/StringBuffer_4/String Buffer_append.pptx b/Later/StringBuffer/StringBuffer_4/String Buffer_append.pptx deleted file mode 100644 index 92d2f3559..000000000 Binary files a/Later/StringBuffer/StringBuffer_4/String Buffer_append.pptx and /dev/null differ diff --git a/Later/StringBuffer/StringBuffer_4/StringBufferDemo/bin/StringBufferDemo.class b/Later/StringBuffer/StringBuffer_4/StringBufferDemo/bin/StringBufferDemo.class deleted file mode 100644 index 065781255..000000000 Binary files a/Later/StringBuffer/StringBuffer_4/StringBufferDemo/bin/StringBufferDemo.class and /dev/null differ diff --git a/Later/StringBuffer/StringBuffer_4/StringBufferDemo/src/StringBufferDemo.java b/Later/StringBuffer/StringBuffer_4/StringBufferDemo/src/StringBufferDemo.java deleted file mode 100644 index d1dbb1f79..000000000 --- a/Later/StringBuffer/StringBuffer_4/StringBufferDemo/src/StringBufferDemo.java +++ /dev/null @@ -1,13 +0,0 @@ -public class StringBufferDemo -{ - - public static void main(String[] args) - { - StringBuffer sb1 = new StringBuffer("Hello "); - int i = 20; - sb1.append(i); - double d = 500.4; - sb1.append(d); - System.out.println(sb1); - } -} diff --git a/Later/StringBuffer/StringBuffer_5/StringBufferDemo/bin/StringBufferDemo.class b/Later/StringBuffer/StringBuffer_5/StringBufferDemo/bin/StringBufferDemo.class deleted file mode 100644 index 228a497a0..000000000 Binary files a/Later/StringBuffer/StringBuffer_5/StringBufferDemo/bin/StringBufferDemo.class and /dev/null differ diff --git a/Later/StringBuffer/StringBuffer_5/StringBufferDemo/src/StringBufferDemo.java b/Later/StringBuffer/StringBuffer_5/StringBufferDemo/src/StringBufferDemo.java deleted file mode 100644 index dad81c8f0..000000000 --- a/Later/StringBuffer/StringBuffer_5/StringBufferDemo/src/StringBufferDemo.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * public StringBuffer insert(int offset, String str) - * - * Inserts the string into this character sequence. - * - * Parameters: - * ---------- - * offset - the offset. - * str - a string. - * - * Returns: - * ------- - * a reference to this object. - */ -public class StringBufferDemo -{ - - public static void main(String[] args) - { - StringBuffer sb = new StringBuffer("Hello World"); - String str = "My "; - sb.insert(6, str); - System.out.println(sb); - - } -} diff --git a/Later/StringBuffer/StringBuffer_6/String Buffer_insert.pptx b/Later/StringBuffer/StringBuffer_6/String Buffer_insert.pptx deleted file mode 100644 index 9336e6a46..000000000 Binary files a/Later/StringBuffer/StringBuffer_6/String Buffer_insert.pptx and /dev/null differ diff --git a/Later/StringBuffer/StringBuffer_6/StringBufferDemo/bin/StringBufferDemo.class b/Later/StringBuffer/StringBuffer_6/StringBufferDemo/bin/StringBufferDemo.class deleted file mode 100644 index fc28474d7..000000000 Binary files a/Later/StringBuffer/StringBuffer_6/StringBufferDemo/bin/StringBufferDemo.class and /dev/null differ diff --git a/Later/StringBuffer/StringBuffer_6/StringBufferDemo/src/StringBufferDemo.java b/Later/StringBuffer/StringBuffer_6/StringBufferDemo/src/StringBufferDemo.java deleted file mode 100644 index c84124d7e..000000000 --- a/Later/StringBuffer/StringBuffer_6/StringBufferDemo/src/StringBufferDemo.java +++ /dev/null @@ -1,11 +0,0 @@ -public class StringBufferDemo -{ - - public static void main(String[] args) - { - StringBuffer sb = new StringBuffer("Hello World"); - int i = 100; - sb.insert(6, i); - System.out.println(sb); - } -} diff --git a/servlets/URLRewritingDemoApp/URLRewritingDemo.war b/servlets/URLRewritingDemoApp/URLRewritingDemo.war new file mode 100644 index 000000000..80d17deac Binary files /dev/null and b/servlets/URLRewritingDemoApp/URLRewritingDemo.war differ diff --git a/servlets/URLRewritingDemoApp/URLRewritingDemo/.classpath b/servlets/URLRewritingDemoApp/URLRewritingDemo/.classpath new file mode 100644 index 000000000..b42037dde --- /dev/null +++ b/servlets/URLRewritingDemoApp/URLRewritingDemo/.classpath @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/servlets/URLRewritingDemoApp/URLRewritingDemo/.project b/servlets/URLRewritingDemoApp/URLRewritingDemo/.project new file mode 100644 index 000000000..53ae64417 --- /dev/null +++ b/servlets/URLRewritingDemoApp/URLRewritingDemo/.project @@ -0,0 +1,36 @@ + + + URLRewritingDemo + + + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.jdt.core.javanature + org.eclipse.wst.jsdt.core.jsNature + + diff --git a/servlets/URLRewritingDemoApp/URLRewritingDemo/.settings/.jsdtscope b/servlets/URLRewritingDemoApp/URLRewritingDemo/.settings/.jsdtscope new file mode 100644 index 000000000..3a28de0c7 --- /dev/null +++ b/servlets/URLRewritingDemoApp/URLRewritingDemo/.settings/.jsdtscope @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/servlets/URLRewritingDemoApp/URLRewritingDemo/.settings/org.eclipse.jdt.core.prefs b/servlets/URLRewritingDemoApp/URLRewritingDemo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..c537b6306 --- /dev/null +++ b/servlets/URLRewritingDemoApp/URLRewritingDemo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/servlets/URLRewritingDemoApp/URLRewritingDemo/.settings/org.eclipse.wst.common.component b/servlets/URLRewritingDemoApp/URLRewritingDemo/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000..2b2a231f9 --- /dev/null +++ b/servlets/URLRewritingDemoApp/URLRewritingDemo/.settings/org.eclipse.wst.common.component @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/servlets/URLRewritingDemoApp/URLRewritingDemo/.settings/org.eclipse.wst.common.project.facet.core.xml b/servlets/URLRewritingDemoApp/URLRewritingDemo/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000..0d3d10e2b --- /dev/null +++ b/servlets/URLRewritingDemoApp/URLRewritingDemo/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/servlets/URLRewritingDemoApp/URLRewritingDemo/.settings/org.eclipse.wst.jsdt.ui.superType.container b/servlets/URLRewritingDemoApp/URLRewritingDemo/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 000000000..3bd5d0a48 --- /dev/null +++ b/servlets/URLRewritingDemoApp/URLRewritingDemo/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/servlets/URLRewritingDemoApp/URLRewritingDemo/.settings/org.eclipse.wst.jsdt.ui.superType.name b/servlets/URLRewritingDemoApp/URLRewritingDemo/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 000000000..05bd71b6e --- /dev/null +++ b/servlets/URLRewritingDemoApp/URLRewritingDemo/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/servlets/URLRewritingDemoApp/URLRewritingDemo/WebContent/META-INF/MANIFEST.MF b/servlets/URLRewritingDemoApp/URLRewritingDemo/WebContent/META-INF/MANIFEST.MF new file mode 100644 index 000000000..254272e1c --- /dev/null +++ b/servlets/URLRewritingDemoApp/URLRewritingDemo/WebContent/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/servlets/URLRewritingDemoApp/URLRewritingDemo/WebContent/WEB-INF/lib/javax.servlet.jar b/servlets/URLRewritingDemoApp/URLRewritingDemo/WebContent/WEB-INF/lib/javax.servlet.jar new file mode 100644 index 000000000..ab2ab3c0e Binary files /dev/null and b/servlets/URLRewritingDemoApp/URLRewritingDemo/WebContent/WEB-INF/lib/javax.servlet.jar differ diff --git a/servlets/URLRewritingDemoApp/URLRewritingDemo/WebContent/WEB-INF/web.xml b/servlets/URLRewritingDemoApp/URLRewritingDemo/WebContent/WEB-INF/web.xml new file mode 100644 index 000000000..074041fed --- /dev/null +++ b/servlets/URLRewritingDemoApp/URLRewritingDemo/WebContent/WEB-INF/web.xml @@ -0,0 +1,27 @@ + + + URLRewritingDemo + + This is a simple web application with a source code organization + based on the recommendations of the Application Developer's Guide. + + + s1 + FirstServlet + + + s2 + SecondServlet + + + s1 + /servlet1 + + + s2 + /servlet2 + + \ No newline at end of file diff --git a/servlets/URLRewritingDemoApp/URLRewritingDemo/WebContent/index.html b/servlets/URLRewritingDemoApp/URLRewritingDemo/WebContent/index.html new file mode 100644 index 000000000..25e5a2315 --- /dev/null +++ b/servlets/URLRewritingDemoApp/URLRewritingDemo/WebContent/index.html @@ -0,0 +1,8 @@ + + +
+ Name:
+ +
+ + diff --git a/servlets/URLRewritingDemoApp/URLRewritingDemo/build/classes/FirstServlet.class b/servlets/URLRewritingDemoApp/URLRewritingDemo/build/classes/FirstServlet.class new file mode 100644 index 000000000..836b7ccbe Binary files /dev/null and b/servlets/URLRewritingDemoApp/URLRewritingDemo/build/classes/FirstServlet.class differ diff --git a/servlets/URLRewritingDemoApp/URLRewritingDemo/build/classes/SecondServlet.class b/servlets/URLRewritingDemoApp/URLRewritingDemo/build/classes/SecondServlet.class new file mode 100644 index 000000000..40b599f9c Binary files /dev/null and b/servlets/URLRewritingDemoApp/URLRewritingDemo/build/classes/SecondServlet.class differ diff --git a/servlets/URLRewritingDemoApp/URLRewritingDemo/src/FirstServlet.java b/servlets/URLRewritingDemoApp/URLRewritingDemo/src/FirstServlet.java new file mode 100644 index 000000000..225e0a4d1 --- /dev/null +++ b/servlets/URLRewritingDemoApp/URLRewritingDemo/src/FirstServlet.java @@ -0,0 +1,44 @@ +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class FirstServlet extends HttpServlet +{ + private static final long serialVersionUID = 1L; + + public void init() throws ServletException + { + System.out.println("-----------------------------------------"); + System.out.println(" Init method is called in " + + this.getClass().getName()); + System.out.println("--------------------------------------"); + } + + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException + { + response.setContentType("text/html"); + PrintWriter out = response.getWriter(); + + String userName = request.getParameter("userName"); + out.print("Welcome " + userName); + + // appending the username in the query string + out.print(" : visit"); + + out.close(); + } + + public void destroy() + { + System.out.println("-----------------------------------------"); + System.out.println(" destroy method is called in " + + this.getClass().getName()); + System.out.println("-----------------------------------------"); + } + +} \ No newline at end of file diff --git a/servlets/URLRewritingDemoApp/URLRewritingDemo/src/SecondServlet.java b/servlets/URLRewritingDemoApp/URLRewritingDemo/src/SecondServlet.java new file mode 100644 index 000000000..765bde83d --- /dev/null +++ b/servlets/URLRewritingDemoApp/URLRewritingDemo/src/SecondServlet.java @@ -0,0 +1,43 @@ +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class SecondServlet extends HttpServlet +{ + private static final long serialVersionUID = 1L; + + public void init() throws ServletException + { + System.out.println("-----------------------------------------"); + System.out.println(" Init method is called in " + + this.getClass().getName()); + System.out.println("--------------------------------------"); + } + + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException + { + response.setContentType("text/html"); + PrintWriter out = response.getWriter(); + + // getting value from the query string + String userName = request.getParameter("uname"); + out.print("Hello " + userName); + + out.close(); + + } + + public void destroy() + { + System.out.println("-----------------------------------------"); + System.out.println(" destroy method is called in " + + this.getClass().getName()); + System.out.println("-----------------------------------------"); + } + +} \ No newline at end of file