/JavaSE/ExempleLogging |
Property changes:
Added: svn:ignore
## -0,0 +1 ##
+build
Index: JavaSE/ExempleOOP/nbproject/private/private.properties
===================================================================
--- JavaSE/ExempleOOP/nbproject/private/private.properties (revision 38)
+++ JavaSE/ExempleOOP/nbproject/private/private.properties (revision 39)
@@ -1,2 +1,2 @@
compile.on.save=true
-user.properties.file=C:\\Users\\evo2\\AppData\\Roaming\\NetBeans\\8.0.1\\build.properties
+user.properties.file=C:\\Users\\evo\\AppData\\Roaming\\NetBeans\\8.0.2\\build.properties
Index: JavaSE/ExempleOOP/src/inroducere/java/arrays/ArrayDemo.java
===================================================================
--- JavaSE/ExempleOOP/src/inroducere/java/arrays/ArrayDemo.java (revision 38)
+++ JavaSE/ExempleOOP/src/inroducere/java/arrays/ArrayDemo.java (revision 39)
@@ -1,32 +0,0 @@
-package inroducere.java.arrays;
-
-
-class ArrayDemo {
- public static void main(String[] args) {
- int[] anArray; // declares an array of integers
-
- anArray = new int[10]; // allocates memory for 10 integers
-
- anArray[0] = 100; // initialize first element
- anArray[1] = 200; // initialize second element
- anArray[2] = 300; // etc.
- anArray[3] = 400;
- anArray[4] = 500;
- anArray[5] = 600;
- anArray[6] = 700;
- anArray[7] = 800;
- anArray[8] = 900;
- anArray[9] = 1000;
-
- System.out.println("Element at index 0: " + anArray[0]);
- System.out.println("Element at index 1: " + anArray[1]);
- System.out.println("Element at index 2: " + anArray[2]);
- System.out.println("Element at index 3: " + anArray[3]);
- System.out.println("Element at index 4: " + anArray[4]);
- System.out.println("Element at index 5: " + anArray[5]);
- System.out.println("Element at index 6: " + anArray[6]);
- System.out.println("Element at index 7: " + anArray[7]);
- System.out.println("Element at index 8: " + anArray[8]);
- System.out.println("Element at index 9: " + anArray[9]);
- }
-}
\ No newline at end of file
Index: JavaSE/ExempleOOP/src/inroducere/java/arrays/MultiDimArrayDemo.java
===================================================================
--- JavaSE/ExempleOOP/src/inroducere/java/arrays/MultiDimArrayDemo.java (revision 38)
+++ JavaSE/ExempleOOP/src/inroducere/java/arrays/MultiDimArrayDemo.java (revision 39)
@@ -1,11 +0,0 @@
-package inroducere.java.arrays;
-
-
-class MultiDimArrayDemo {
- public static void main(String[] args) {
- String[][] names = {{"Mr. ", "Mrs. ", "Ms. "},
- {"Smith", "Jones"}};
- System.out.println(names[0][0] + names[1][0]); //Mr. Smith
- System.out.println(names[0][2] + names[1][1]); //Ms. Jones
- }
-}
\ No newline at end of file
Index: JavaSE/ExempleOOP/src/inroducere/java/arrays/ArrayCopyDemo.java
===================================================================
--- JavaSE/ExempleOOP/src/inroducere/java/arrays/ArrayCopyDemo.java (revision 38)
+++ JavaSE/ExempleOOP/src/inroducere/java/arrays/ArrayCopyDemo.java (revision 39)
@@ -1,13 +0,0 @@
-package inroducere.java.arrays;
-
-
-class ArrayCopyDemo {
- public static void main(String[] args) {
- char[] copyFrom = { 'd', 'e', 'c', 'a', 'f', 'f', 'e',
- 'i', 'n', 'a', 't', 'e', 'd' };
- char[] copyTo = new char[7];
-
- System.arraycopy(copyFrom, 2, copyTo, 0, 7);
- System.out.println(new String(copyTo));
- }
-}
\ No newline at end of file
Index: JavaSE/ExempleOOP/src/inroducere/java/controlflow/SwitchStructure.java
===================================================================
--- JavaSE/ExempleOOP/src/inroducere/java/controlflow/SwitchStructure.java (revision 38)
+++ JavaSE/ExempleOOP/src/inroducere/java/controlflow/SwitchStructure.java (revision 39)
@@ -1,33 +0,0 @@
-package inroducere.java.controlflow;
-
-
-public class SwitchStructure {
-
- static int countVowel(String word){
- int vcount=0;
- int ccount=0;
- for(int i=0;i<word.length();i++){
- char c = word.charAt(i);
-
- switch(c) {
- case 'a': vcount++;break;
- case 'e': vcount++;break;
- case 'i': vcount++;break;
- case 'o': vcount++;break;
- case 'u': vcount++;break;
- default : ccount++;
- }
- }
- return vcount;
- }
-
-
- public static void main(String[] args) {
- String testword="java";
- System.out.println("Count vowel in word:"+testword+" = "+countVowel(testword));
-
- testword="expression";
- System.out.println("Count vowel in word:"+testword+" = "+countVowel(testword));
-
- }
-}
Index: JavaSE/ExempleOOP/src/inroducere/java/controlflow/ForStructure.java
===================================================================
--- JavaSE/ExempleOOP/src/inroducere/java/controlflow/ForStructure.java (revision 38)
+++ JavaSE/ExempleOOP/src/inroducere/java/controlflow/ForStructure.java (revision 39)
@@ -1,36 +0,0 @@
-package inroducere.java.controlflow;
-
-
-public class ForStructure {
-
- /**
- * Generate an array of random int numbers.
- * @return
- */
- static int[] generateArray(){
- int size = (int)Math.round(Math.random()*15);
- int[] a = new int[size];
- for(int i=0;i<a.length;i++){
- a[i] = (int)Math.round(Math.random()*100);
- }
- return a;
- }
-
- /**
- * Display the content of an array.
- * @param a
- */
- static void displayArray(int[] a){
- for (int i = a.length; --i>=0; )
- {
- System.out.print("a["+i+"]="+a[i]+" ");
- }
- System.out.println();
- }
-
- public static void main(String[] args) {
- int a[];
- a = generateArray();
- displayArray(a);
- }
-}
Index: JavaSE/ExempleOOP/src/inroducere/java/controlflow/IfElse.java
===================================================================
--- JavaSE/ExempleOOP/src/inroducere/java/controlflow/IfElse.java (revision 38)
+++ JavaSE/ExempleOOP/src/inroducere/java/controlflow/IfElse.java (revision 39)
@@ -1,47 +0,0 @@
-package inroducere.java.controlflow;
-
-/**
- * Exemplify if-else structures
- */
-public class IfElse {
-
- static int getMaxValue(int a, int b){
- int tmp;
- if(a>=b)
- return a;
- else
- return b;
- }
-
- static int getMaxValue2(int a, int b){
- int tmp;
- if(a>=b)
- tmp = a;
- else
- tmp = b;
- return tmp;
- }
-
- static void testTemperature(int temp){
- if(temp<5)
- System.out.println("Low temperature");
- else if(temp>=5&&temp<24)
- System.out.println("Normal temperature");
- else
- System.out.println("High temperature");
- }
-
- public static void main(String[] args) {
-
- int x = 10, y=34;
- System.err.println("Compare "+x+" with "+y+" .Max value is "+getMaxValue(x,y));
-
- x = x*10;
- y = x-y;
- System.err.println("Compare "+x+" with "+y+" .Max value is "+getMaxValue2(x,y));
-
-
- int temperature = 34;
- testTemperature(temperature);
- }
-}
Index: JavaSE/ExempleOOP/src/inroducere/java/controlflow/WhileStructure.java
===================================================================
--- JavaSE/ExempleOOP/src/inroducere/java/controlflow/WhileStructure.java (revision 38)
+++ JavaSE/ExempleOOP/src/inroducere/java/controlflow/WhileStructure.java (revision 39)
@@ -1,22 +0,0 @@
-package inroducere.java.controlflow;
-
-/**
- * Exemplify while and do-while structures.
- */
-public class WhileStructure {
-
- public static void main(String[] args) {
- int count = 1;
- while (count < 11) {
- System.out.println("xCount is: " + count);
- count++;
- }
-
- //reset counter and start againg
- count = 1;
- do {
- System.out.println("xxCount is: " + count);
- count++;
- } while (count <= 11);
- }
-}
Index: JavaSE/ExempleOOP/src/inroducere/java/operator/ComparisonDemo.java
===================================================================
--- JavaSE/ExempleOOP/src/inroducere/java/operator/ComparisonDemo.java (revision 38)
+++ JavaSE/ExempleOOP/src/inroducere/java/operator/ComparisonDemo.java (revision 39)
@@ -1,20 +0,0 @@
-package inroducere.java.operator;
-
-/*
- * The equality and relational operators determine if one operand is greater than,
- * less than, equal to, or not equal to another operand.
- * Keep in mind that you must use "==", not "=", when testing
- * if two primitive values are equal.
- */
-class ComparisonDemo {
-
- public static void main(String[] args){
- int value1 = 1;
- int value2 = 2;
- if(value1 == value2) System.out.println("value1 == value2");
- if(value1 != value2) System.out.println("value1 != value2");
- if(value1 > value2) System.out.println("value1 > value2");
- if(value1 < value2) System.out.println("value1 < value2");
- if(value1 <= value2) System.out.println("value1 <= value2");
- }
-}
\ No newline at end of file
Index: JavaSE/ExempleOOP/src/inroducere/java/operator/UnaryDemo.java
===================================================================
--- JavaSE/ExempleOOP/src/inroducere/java/operator/UnaryDemo.java (revision 38)
+++ JavaSE/ExempleOOP/src/inroducere/java/operator/UnaryDemo.java (revision 39)
@@ -1,22 +0,0 @@
-package inroducere.java.operator;
-
-/**
- * The following program exemplify the use of unary operators.
- *
- */
-class UnaryDemo {
-
- public static void main(String[] args){
- int result = +1; // result is now 1
- System.out.println(result);
- result--; // result is now 0
- System.out.println(result);
- result++; // result is now 1
- System.out.println(result);
- result = -result; // result is now -1
- System.out.println(result);
- boolean success = false;
- System.out.println(success); // false
- System.out.println(!success); // true
- }
-}
Index: JavaSE/ExempleOOP/src/inroducere/java/operator/ConditionalDemo.java
===================================================================
--- JavaSE/ExempleOOP/src/inroducere/java/operator/ConditionalDemo.java (revision 38)
+++ JavaSE/ExempleOOP/src/inroducere/java/operator/ConditionalDemo.java (revision 39)
@@ -1,18 +0,0 @@
-package inroducere.java.operator;
-
-
-/**
- *The && and || operators perform Conditional-AND and Conditional-OR operations on
- *two boolean expressions. These operators exhibit "short-circuiting" behavior, which
- * means that the second operand is evaluated only if needed.
- */
-class ConditionalDemo1 {
-
- public static void main(String[] args){
- int value1 = 1;
- int value2 = 2;
- if((value1 == 1) && (value2 == 2)) System.out.println("value1 is 1 AND value2 is 2");
- if((value1 == 1) || (value2 == 1)) System.out.println("value1 is 1 OR value2 is 1");
-
- }
-}
\ No newline at end of file
Index: JavaSE/ExempleOOP/src/inroducere/java/operator/ConcatDemo.java
===================================================================
--- JavaSE/ExempleOOP/src/inroducere/java/operator/ConcatDemo.java (revision 38)
+++ JavaSE/ExempleOOP/src/inroducere/java/operator/ConcatDemo.java (revision 39)
@@ -1,15 +0,0 @@
-package inroducere.java.operator;
-
-/**
- * The + operator can also be used for concatenating (joining) two
- * strings together, as shown in the following ConcatDemo.
- */
-
-class ConcatDemo {
- public static void main(String[] args){
- String firstString = "This is";
- String secondString = " a concatenated string.";
- String thirdString = firstString+secondString;
- System.out.println(thirdString);
- }
-}
Index: JavaSE/ExempleOOP/src/inroducere/java/operator/ArithmeticDemo.java
===================================================================
--- JavaSE/ExempleOOP/src/inroducere/java/operator/ArithmeticDemo.java (revision 38)
+++ JavaSE/ExempleOOP/src/inroducere/java/operator/ArithmeticDemo.java (revision 39)
@@ -1,27 +0,0 @@
-package inroducere.java.operator;
-
-/**
- * The following program, ArithmeticDemo, tests the arithmetic operators.
- */
-class ArithmeticDemo {
-
- public static void main (String[] args){
-
- int result = 1 + 2; // result is now 3
- System.out.println(result);
-
- result = result - 1; // result is now 2
- System.out.println(result);
-
- result = result * 2; // result is now 4
- System.out.println(result);
-
- result = result / 2; // result is now 2
- System.out.println(result);
-
- result = result + 8; // result is now 10
- result = result % 7; // result is now 3
- System.out.println(result);
-
- }
-}
Index: JavaSE/ExempleOOP/src/inroducere/java/operator/InstanceofDemo.java
===================================================================
--- JavaSE/ExempleOOP/src/inroducere/java/operator/InstanceofDemo.java (revision 38)
+++ JavaSE/ExempleOOP/src/inroducere/java/operator/InstanceofDemo.java (revision 39)
@@ -1,30 +0,0 @@
-package inroducere.java.operator;
-
-/**
- * The instanceof operator compares an object to a specified type.
- * You can use it to test if an object is an instance of a class,
- * an instance of a subclass, or an instance of a class that implements a
- * particular interface.The following program, InstanceofDemo, defines a parent
- * class (named Parent), a simple interface (named MyInterface), and a child class
- * (named Child) that inherits from the parent and implements the interface.
- */
-public class InstanceofDemo {
- public static void main(String[] args) {
-
- Parent obj1 = new Parent();
- Parent obj2 = new Child();
-
- System.out.println("obj1 instanceof Parent: " + (obj1 instanceof Parent));
- System.out.println("obj1 instanceof Child: " + (obj1 instanceof Child));
- System.out.println("obj1 instanceof MyInterface: " + (obj1 instanceof MyInterface));
- System.out.println("obj2 instanceof Parent: " + (obj2 instanceof Parent));
- System.out.println("obj2 instanceof Child: " + (obj2 instanceof Child));
- System.out.println("obj2 instanceof MyInterface: " + (obj2 instanceof MyInterface));
- }
- }
-
-class Parent{}
-
-class Child extends Parent implements MyInterface{}
-
-interface MyInterface{}
\ No newline at end of file
Index: JavaSE/ExempleOOP/src/inroducere/java/breackcontinue/BreakDemo.java
===================================================================
--- JavaSE/ExempleOOP/src/inroducere/java/breackcontinue/BreakDemo.java (revision 38)
+++ JavaSE/ExempleOOP/src/inroducere/java/breackcontinue/BreakDemo.java (revision 39)
@@ -1,32 +0,0 @@
-package inroducere.java.breackcontinue;
-
-/**
- * Exemplify break statement which can be used to terminate a
- * for, while, or do-while loop.
- */
-class BreakDemo {
- public static void main(String[] args) {
-
- int[] arrayOfInts = { 32, 87, 3, 589, 12, 1076,
- 2000, 8, 622, 127 };
- int searchfor = 12;
-
- int i;
- boolean foundIt = false;
-
- for (i = 0; i < arrayOfInts.length; i++) {
- if (arrayOfInts[i] == searchfor) {
- foundIt = true;
- break;
- }
- }
-
- if (foundIt) {
- System.out.println("Found " + searchfor
- + " at index " + i);
- } else {
- System.out.println(searchfor
- + " not in the array");
- }
- }
-}
\ No newline at end of file
Index: JavaSE/ExempleOOP/src/inroducere/java/breackcontinue/ContinueDemo.java
===================================================================
--- JavaSE/ExempleOOP/src/inroducere/java/breackcontinue/ContinueDemo.java (revision 38)
+++ JavaSE/ExempleOOP/src/inroducere/java/breackcontinue/ContinueDemo.java (revision 39)
@@ -1,24 +0,0 @@
-package inroducere.java.breackcontinue;
-
-/**
- * Exemplify the use of the continue statement. This can be used to skip the current
- * iteration of a for, while , or do-while loop.
- */
-class ContinueDemo {
- public static void main(String[] args) {
-
- String searchMe = "peter piper picked a peck of pickled peppers";
- int max = searchMe.length();
- int numPs = 0;
-
- for (int i = 0; i < max; i++) {
- //interested only in p's
- if (searchMe.charAt(i) != 'p')
- continue;
-
- //process p's
- numPs++;
- }
- System.out.println("Found " + numPs + " p's in the string.");
- }
-}
\ No newline at end of file
Index: JavaSE/ExempleOOP/src/introducere/java/arrays/ArrayDemo.java
===================================================================
--- JavaSE/ExempleOOP/src/introducere/java/arrays/ArrayDemo.java (revision 0)
+++ JavaSE/ExempleOOP/src/introducere/java/arrays/ArrayDemo.java (revision 39)
@@ -0,0 +1,32 @@
+package introducere.java.arrays;
+
+
+class ArrayDemo {
+ public static void main(String[] args) {
+ int[] anArray; // declares an array of integers
+
+ anArray = new int[10]; // allocates memory for 10 integers
+
+ anArray[0] = 100; // initialize first element
+ anArray[1] = 200; // initialize second element
+ anArray[2] = 300; // etc.
+ anArray[3] = 400;
+ anArray[4] = 500;
+ anArray[5] = 600;
+ anArray[6] = 700;
+ anArray[7] = 800;
+ anArray[8] = 900;
+ anArray[9] = 1000;
+
+ System.out.println("Element at index 0: " + anArray[0]);
+ System.out.println("Element at index 1: " + anArray[1]);
+ System.out.println("Element at index 2: " + anArray[2]);
+ System.out.println("Element at index 3: " + anArray[3]);
+ System.out.println("Element at index 4: " + anArray[4]);
+ System.out.println("Element at index 5: " + anArray[5]);
+ System.out.println("Element at index 6: " + anArray[6]);
+ System.out.println("Element at index 7: " + anArray[7]);
+ System.out.println("Element at index 8: " + anArray[8]);
+ System.out.println("Element at index 9: " + anArray[9]);
+ }
+}
\ No newline at end of file
Index: JavaSE/ExempleOOP/src/introducere/java/arrays/MultiDimArrayDemo.java
===================================================================
--- JavaSE/ExempleOOP/src/introducere/java/arrays/MultiDimArrayDemo.java (revision 0)
+++ JavaSE/ExempleOOP/src/introducere/java/arrays/MultiDimArrayDemo.java (revision 39)
@@ -0,0 +1,11 @@
+package introducere.java.arrays;
+
+
+class MultiDimArrayDemo {
+ public static void main(String[] args) {
+ String[][] names = {{"Mr. ", "Mrs. ", "Ms. "},
+ {"Smith", "Jones"}};
+ System.out.println(names[0][0] + names[1][0]); //Mr. Smith
+ System.out.println(names[0][2] + names[1][1]); //Ms. Jones
+ }
+}
\ No newline at end of file
Index: JavaSE/ExempleOOP/src/introducere/java/arrays/ArrayCopyDemo.java
===================================================================
--- JavaSE/ExempleOOP/src/introducere/java/arrays/ArrayCopyDemo.java (revision 0)
+++ JavaSE/ExempleOOP/src/introducere/java/arrays/ArrayCopyDemo.java (revision 39)
@@ -0,0 +1,13 @@
+package introducere.java.arrays;
+
+
+class ArrayCopyDemo {
+ public static void main(String[] args) {
+ char[] copyFrom = { 'd', 'e', 'c', 'a', 'f', 'f', 'e',
+ 'i', 'n', 'a', 't', 'e', 'd' };
+ char[] copyTo = new char[7];
+
+ System.arraycopy(copyFrom, 2, copyTo, 0, 7);
+ System.out.println(new String(copyTo));
+ }
+}
\ No newline at end of file
Index: JavaSE/ExempleOOP/src/introducere/java/controlflow/SwitchStructure.java
===================================================================
--- JavaSE/ExempleOOP/src/introducere/java/controlflow/SwitchStructure.java (revision 0)
+++ JavaSE/ExempleOOP/src/introducere/java/controlflow/SwitchStructure.java (revision 39)
@@ -0,0 +1,33 @@
+package introducere.java.controlflow;
+
+
+public class SwitchStructure {
+
+ static int countVowel(String word){
+ int vcount=0;
+ int ccount=0;
+ for(int i=0;i<word.length();i++){
+ char c = word.charAt(i);
+
+ switch(c) {
+ case 'a': vcount++;break;
+ case 'e': vcount++;break;
+ case 'i': vcount++;break;
+ case 'o': vcount++;break;
+ case 'u': vcount++;break;
+ default : ccount++;
+ }
+ }
+ return vcount;
+ }
+
+
+ public static void main(String[] args) {
+ String testword="java";
+ System.out.println("Count vowel in word:"+testword+" = "+countVowel(testword));
+
+ testword="expression";
+ System.out.println("Count vowel in word:"+testword+" = "+countVowel(testword));
+
+ }
+}
Index: JavaSE/ExempleOOP/src/introducere/java/controlflow/ForStructure.java
===================================================================
--- JavaSE/ExempleOOP/src/introducere/java/controlflow/ForStructure.java (revision 0)
+++ JavaSE/ExempleOOP/src/introducere/java/controlflow/ForStructure.java (revision 39)
@@ -0,0 +1,36 @@
+package introducere.java.controlflow;
+
+
+public class ForStructure {
+
+ /**
+ * Generate an array of random int numbers.
+ * @return
+ */
+ static int[] generateArray(){
+ int size = (int)Math.round(Math.random()*15);
+ int[] a = new int[size];
+ for(int i=0;i<a.length;i++){
+ a[i] = (int)Math.round(Math.random()*100);
+ }
+ return a;
+ }
+
+ /**
+ * Display the content of an array.
+ * @param a
+ */
+ static void displayArray(int[] a){
+ for (int i = a.length; --i>=0; )
+ {
+ System.out.print("a["+i+"]="+a[i]+" ");
+ }
+ System.out.println();
+ }
+
+ public static void main(String[] args) {
+ int a[];
+ a = generateArray();
+ displayArray(a);
+ }
+}
Index: JavaSE/ExempleOOP/src/introducere/java/controlflow/IfElse.java
===================================================================
--- JavaSE/ExempleOOP/src/introducere/java/controlflow/IfElse.java (revision 0)
+++ JavaSE/ExempleOOP/src/introducere/java/controlflow/IfElse.java (revision 39)
@@ -0,0 +1,47 @@
+package introducere.java.controlflow;
+
+/**
+ * Exemplify if-else structures
+ */
+public class IfElse {
+
+ static int getMaxValue(int a, int b){
+ int tmp;
+ if(a>=b)
+ return a;
+ else
+ return b;
+ }
+
+ static int getMaxValue2(int a, int b){
+ int tmp;
+ if(a>=b)
+ tmp = a;
+ else
+ tmp = b;
+ return tmp;
+ }
+
+ static void testTemperature(int temp){
+ if(temp<5)
+ System.out.println("Low temperature");
+ else if(temp>=5&&temp<24)
+ System.out.println("Normal temperature");
+ else
+ System.out.println("High temperature");
+ }
+
+ public static void main(String[] args) {
+
+ int x = 10, y=34;
+ System.err.println("Compare "+x+" with "+y+" .Max value is "+getMaxValue(x,y));
+
+ x = x*10;
+ y = x-y;
+ System.err.println("Compare "+x+" with "+y+" .Max value is "+getMaxValue2(x,y));
+
+
+ int temperature = 34;
+ testTemperature(temperature);
+ }
+}
Index: JavaSE/ExempleOOP/src/introducere/java/controlflow/WhileStructure.java
===================================================================
--- JavaSE/ExempleOOP/src/introducere/java/controlflow/WhileStructure.java (revision 0)
+++ JavaSE/ExempleOOP/src/introducere/java/controlflow/WhileStructure.java (revision 39)
@@ -0,0 +1,22 @@
+package introducere.java.controlflow;
+
+/**
+ * Exemplify while and do-while structures.
+ */
+public class WhileStructure {
+
+ public static void main(String[] args) {
+ int count = 1;
+ while (count < 11) {
+ System.out.println("xCount is: " + count);
+ count++;
+ }
+
+ //reset counter and start againg
+ count = 1;
+ do {
+ System.out.println("xxCount is: " + count);
+ count++;
+ } while (count <= 11);
+ }
+}
Index: JavaSE/ExempleOOP/src/introducere/java/operator/ComparisonDemo.java
===================================================================
--- JavaSE/ExempleOOP/src/introducere/java/operator/ComparisonDemo.java (revision 0)
+++ JavaSE/ExempleOOP/src/introducere/java/operator/ComparisonDemo.java (revision 39)
@@ -0,0 +1,20 @@
+package introducere.java.operator;
+
+/*
+ * The equality and relational operators determine if one operand is greater than,
+ * less than, equal to, or not equal to another operand.
+ * Keep in mind that you must use "==", not "=", when testing
+ * if two primitive values are equal.
+ */
+class ComparisonDemo {
+
+ public static void main(String[] args){
+ int value1 = 1;
+ int value2 = 2;
+ if(value1 == value2) System.out.println("value1 == value2");
+ if(value1 != value2) System.out.println("value1 != value2");
+ if(value1 > value2) System.out.println("value1 > value2");
+ if(value1 < value2) System.out.println("value1 < value2");
+ if(value1 <= value2) System.out.println("value1 <= value2");
+ }
+}
\ No newline at end of file
Index: JavaSE/ExempleOOP/src/introducere/java/operator/UnaryDemo.java
===================================================================
--- JavaSE/ExempleOOP/src/introducere/java/operator/UnaryDemo.java (revision 0)
+++ JavaSE/ExempleOOP/src/introducere/java/operator/UnaryDemo.java (revision 39)
@@ -0,0 +1,22 @@
+package introducere.java.operator;
+
+/**
+ * The following program exemplify the use of unary operators.
+ *
+ */
+class UnaryDemo {
+
+ public static void main(String[] args){
+ int result = +1; // result is now 1
+ System.out.println(result);
+ result--; // result is now 0
+ System.out.println(result);
+ result++; // result is now 1
+ System.out.println(result);
+ result = -result; // result is now -1
+ System.out.println(result);
+ boolean success = false;
+ System.out.println(success); // false
+ System.out.println(!success); // true
+ }
+}
Index: JavaSE/ExempleOOP/src/introducere/java/operator/ConditionalDemo.java
===================================================================
--- JavaSE/ExempleOOP/src/introducere/java/operator/ConditionalDemo.java (revision 0)
+++ JavaSE/ExempleOOP/src/introducere/java/operator/ConditionalDemo.java (revision 39)
@@ -0,0 +1,18 @@
+package introducere.java.operator;
+
+
+/**
+ *The && and || operators perform Conditional-AND and Conditional-OR operations on
+ *two boolean expressions. These operators exhibit "short-circuiting" behavior, which
+ * means that the second operand is evaluated only if needed.
+ */
+class ConditionalDemo1 {
+
+ public static void main(String[] args){
+ int value1 = 1;
+ int value2 = 2;
+ if((value1 == 1) && (value2 == 2)) System.out.println("value1 is 1 AND value2 is 2");
+ if((value1 == 1) || (value2 == 1)) System.out.println("value1 is 1 OR value2 is 1");
+
+ }
+}
\ No newline at end of file
Index: JavaSE/ExempleOOP/src/introducere/java/operator/ConcatDemo.java
===================================================================
--- JavaSE/ExempleOOP/src/introducere/java/operator/ConcatDemo.java (revision 0)
+++ JavaSE/ExempleOOP/src/introducere/java/operator/ConcatDemo.java (revision 39)
@@ -0,0 +1,15 @@
+package introducere.java.operator;
+
+/**
+ * The + operator can also be used for concatenating (joining) two
+ * strings together, as shown in the following ConcatDemo.
+ */
+
+class ConcatDemo {
+ public static void main(String[] args){
+ String firstString = "This is";
+ String secondString = " a concatenated string.";
+ String thirdString = firstString+secondString;
+ System.out.println(thirdString);
+ }
+}
Index: JavaSE/ExempleOOP/src/introducere/java/operator/ArithmeticDemo.java
===================================================================
--- JavaSE/ExempleOOP/src/introducere/java/operator/ArithmeticDemo.java (revision 0)
+++ JavaSE/ExempleOOP/src/introducere/java/operator/ArithmeticDemo.java (revision 39)
@@ -0,0 +1,27 @@
+package introducere.java.operator;
+
+/**
+ * The following program, ArithmeticDemo, tests the arithmetic operators.
+ */
+class ArithmeticDemo {
+
+ public static void main (String[] args){
+
+ int result = 1 + 2; // result is now 3
+ System.out.println(result);
+
+ result = result - 1; // result is now 2
+ System.out.println(result);
+
+ result = result * 2; // result is now 4
+ System.out.println(result);
+
+ result = result / 2; // result is now 2
+ System.out.println(result);
+
+ result = result + 8; // result is now 10
+ result = result % 7; // result is now 3
+ System.out.println(result);
+
+ }
+}
Index: JavaSE/ExempleOOP/src/introducere/java/operator/InstanceofDemo.java
===================================================================
--- JavaSE/ExempleOOP/src/introducere/java/operator/InstanceofDemo.java (revision 0)
+++ JavaSE/ExempleOOP/src/introducere/java/operator/InstanceofDemo.java (revision 39)
@@ -0,0 +1,30 @@
+package introducere.java.operator;
+
+/**
+ * The instanceof operator compares an object to a specified type.
+ * You can use it to test if an object is an instance of a class,
+ * an instance of a subclass, or an instance of a class that implements a
+ * particular interface.The following program, InstanceofDemo, defines a parent
+ * class (named Parent), a simple interface (named MyInterface), and a child class
+ * (named Child) that inherits from the parent and implements the interface.
+ */
+public class InstanceofDemo {
+ public static void main(String[] args) {
+
+ Parent obj1 = new Parent();
+ Parent obj2 = new Child();
+
+ System.out.println("obj1 instanceof Parent: " + (obj1 instanceof Parent));
+ System.out.println("obj1 instanceof Child: " + (obj1 instanceof Child));
+ System.out.println("obj1 instanceof MyInterface: " + (obj1 instanceof MyInterface));
+ System.out.println("obj2 instanceof Parent: " + (obj2 instanceof Parent));
+ System.out.println("obj2 instanceof Child: " + (obj2 instanceof Child));
+ System.out.println("obj2 instanceof MyInterface: " + (obj2 instanceof MyInterface));
+ }
+ }
+
+class Parent{}
+
+class Child extends Parent implements MyInterface{}
+
+interface MyInterface{}
\ No newline at end of file
Index: JavaSE/ExempleOOP/src/introducere/java/breackcontinue/BreakDemo.java
===================================================================
--- JavaSE/ExempleOOP/src/introducere/java/breackcontinue/BreakDemo.java (revision 0)
+++ JavaSE/ExempleOOP/src/introducere/java/breackcontinue/BreakDemo.java (revision 39)
@@ -0,0 +1,32 @@
+package introducere.java.breackcontinue;
+
+/**
+ * Exemplify break statement which can be used to terminate a
+ * for, while, or do-while loop.
+ */
+class BreakDemo {
+ public static void main(String[] args) {
+
+ int[] arrayOfInts = { 32, 87, 3, 589, 12, 1076,
+ 2000, 8, 622, 127 };
+ int searchfor = 12;
+
+ int i;
+ boolean foundIt = false;
+
+ for (i = 0; i < arrayOfInts.length; i++) {
+ if (arrayOfInts[i] == searchfor) {
+ foundIt = true;
+ break;
+ }
+ }
+
+ if (foundIt) {
+ System.out.println("Found " + searchfor
+ + " at index " + i);
+ } else {
+ System.out.println(searchfor
+ + " not in the array");
+ }
+ }
+}
\ No newline at end of file
Index: JavaSE/ExempleOOP/src/introducere/java/breackcontinue/ContinueDemo.java
===================================================================
--- JavaSE/ExempleOOP/src/introducere/java/breackcontinue/ContinueDemo.java (revision 0)
+++ JavaSE/ExempleOOP/src/introducere/java/breackcontinue/ContinueDemo.java (revision 39)
@@ -0,0 +1,24 @@
+package introducere.java.breackcontinue;
+
+/**
+ * Exemplify the use of the continue statement. This can be used to skip the current
+ * iteration of a for, while , or do-while loop.
+ */
+class ContinueDemo {
+ public static void main(String[] args) {
+
+ String searchMe = "peter piper picked a peck of pickled peppers";
+ int max = searchMe.length();
+ int numPs = 0;
+
+ for (int i = 0; i < max; i++) {
+ //interested only in p's
+ if (searchMe.charAt(i) != 'p')
+ continue;
+
+ //process p's
+ numPs++;
+ }
+ System.out.println("Found " + numPs + " p's in the string.");
+ }
+}
\ No newline at end of file
Index: JavaSE/ExempleOOP
===================================================================
--- JavaSE/ExempleOOP (revision 38)
+++ JavaSE/ExempleOOP (revision 39)