diff --git a/CCVT_Code_Distribute/Lecture Files/Lecture 1.pdf b/CCVT_Code_Distribute/Lecture Files/Lecture 1.pdf new file mode 100644 index 0000000..104eeb7 Binary files /dev/null and b/CCVT_Code_Distribute/Lecture Files/Lecture 1.pdf differ diff --git a/CCVT_Code_Distribute/Lecture Files/Lecture 2.pdf b/CCVT_Code_Distribute/Lecture Files/Lecture 2.pdf new file mode 100644 index 0000000..7c3719d Binary files /dev/null and b/CCVT_Code_Distribute/Lecture Files/Lecture 2.pdf differ diff --git a/CCVT_Code_Distribute/Lecture Files/Lecture 5 (Exception).pdf b/CCVT_Code_Distribute/Lecture Files/Lecture 5 (Exception).pdf new file mode 100644 index 0000000..3477bad Binary files /dev/null and b/CCVT_Code_Distribute/Lecture Files/Lecture 5 (Exception).pdf differ diff --git a/CCVT_Code_Distribute/Lecture Files/Lecture 7Cloning Theory.txt b/CCVT_Code_Distribute/Lecture Files/Lecture 7Cloning Theory.txt new file mode 100644 index 0000000..e69de29 diff --git a/CCVT_Code_Distribute/Lecture Files/Lecture 8(String & Wrapper).pdf b/CCVT_Code_Distribute/Lecture Files/Lecture 8(String & Wrapper).pdf new file mode 100644 index 0000000..bc8d9b6 Binary files /dev/null and b/CCVT_Code_Distribute/Lecture Files/Lecture 8(String & Wrapper).pdf differ diff --git a/CCVT_Code_Distribute/Lecture Files/Lecture 9 (Strings).ppt b/CCVT_Code_Distribute/Lecture Files/Lecture 9 (Strings).ppt new file mode 100644 index 0000000..fe2ac34 Binary files /dev/null and b/CCVT_Code_Distribute/Lecture Files/Lecture 9 (Strings).ppt differ diff --git a/CCVT_Code_Distribute/Lecture Files/Lecture3.pdf b/CCVT_Code_Distribute/Lecture Files/Lecture3.pdf new file mode 100644 index 0000000..e3f293f Binary files /dev/null and b/CCVT_Code_Distribute/Lecture Files/Lecture3.pdf differ diff --git a/CCVT_Code_Distribute/Lecture Files/Lecture4.pdf b/CCVT_Code_Distribute/Lecture Files/Lecture4.pdf new file mode 100644 index 0000000..e9dc7a9 Binary files /dev/null and b/CCVT_Code_Distribute/Lecture Files/Lecture4.pdf differ diff --git a/CCVT_Code_Distribute/Lecture Files/Lecture6 (inheritance and Interface) .pdf b/CCVT_Code_Distribute/Lecture Files/Lecture6 (inheritance and Interface) .pdf new file mode 100644 index 0000000..8a2eb2e Binary files /dev/null and b/CCVT_Code_Distribute/Lecture Files/Lecture6 (inheritance and Interface) .pdf differ diff --git a/CCVT_Code_Distribute/Lecture Files/References b/CCVT_Code_Distribute/Lecture Files/References new file mode 100644 index 0000000..7ca4ca1 --- /dev/null +++ b/CCVT_Code_Distribute/Lecture Files/References @@ -0,0 +1 @@ +Most of the data taken from Oracle Java Docs, For further Reading visit : https://docs.oracle.com/javase/tutorial/ diff --git a/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Employee.java b/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Employee.java new file mode 100644 index 0000000..880f3a8 --- /dev/null +++ b/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Employee.java @@ -0,0 +1,22 @@ +package com.rt.exceptionexamples; + +public class Employee { + + + int id; + String name; + public Employee(int id, String name) { + super(); + this.id = id; + this.name = name; + } + + @Override + public String toString() { + // TODO Auto-generated method stub + return "Employee Id"+id+" Employee Name:"+name; + } + + + +} diff --git a/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception10.java b/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception10.java new file mode 100644 index 0000000..c533650 --- /dev/null +++ b/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception10.java @@ -0,0 +1,39 @@ +package com.rt.exceptionexamples; + +class Exception10 { +// Through an exception out of the method. +static void procA() { +try { +System.out.println("inside procA"); +throw new RuntimeException("demo"); +} finally { +System.out.println("procA's finally"); +} +} +// Return from within a try block. +static void procB() { +try { +System.out.println("inside procB"); +return ; +} finally { +System.out.println("procB's finally"); +} +} +static void procC() { +try { +System.out.println("inside procC"); +System.exit(0); +} finally { +System.out.println("procC's finally"); +} +} +public static void main(String args[]) { +try { +procA(); +} catch (Exception e) { +System.out.println("Exception caught"); +} +procB(); +procC(); +} +} \ No newline at end of file diff --git a/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception11.java b/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception11.java new file mode 100644 index 0000000..97d0144 --- /dev/null +++ b/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception11.java @@ -0,0 +1,24 @@ +package com.rt.exceptionexamples; + +class MyException extends RuntimeException { +private int detail; +MyException(int a) { +detail = a; +} +public String toString() { +return "MyException[" + detail + "]should be less than 10"; +} +} +class Exception11 { +static void compute(int a) { +System.out.println("Called compute(" + a + ")"); +if(a > 10) +throw new MyException(a); +System.out.println("Normal exit"); +} +public static void main(String args[]) { + +compute(1); +compute(20); +} +} \ No newline at end of file diff --git a/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception2.java b/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception2.java new file mode 100644 index 0000000..926a17a --- /dev/null +++ b/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception2.java @@ -0,0 +1,29 @@ +package com.rt.exceptionexamples; + +class Exception2 { +public static void main(String args[]) { +int d, a; + +try { // monitor a block of code. +d = 1; +a = 42 / d; +int a1[]=new int[10]; +a1[11]=21; +System.out.println("This will not be printed."); +//throw new IllegalAccessException(); +} catch (ArithmeticException e) { // catch divide-by-zero error +System.out.println("Division by zero."); +} +catch(ArrayIndexOutOfBoundsException e) +{ + System.out.println("Array error"); +} + +catch(Exception o) +{ + System.out.println("Super Exception"); +} + +System.out.println("After catch statement."); +} +} \ No newline at end of file diff --git a/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception3.java b/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception3.java new file mode 100644 index 0000000..df55f56 --- /dev/null +++ b/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception3.java @@ -0,0 +1,20 @@ +package com.rt.exceptionexamples; + +class Exception3 { +public static void main(String args[]) { +try { +int a = args.length; +System.out.println("a = " + a); +int b = 42 / a; +int c[] = { 1 }; +c[42] = 99; +} catch(ArithmeticException e) { +//System.out.println("Divide by 0: " + e.toStri); + e.printStackTrace(); + +} catch(ArrayIndexOutOfBoundsException e) { +System.out.println("Array index oob: " + e); +} +System.out.println("After try/catch blocks."); +} +} \ No newline at end of file diff --git a/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception4.java b/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception4.java new file mode 100644 index 0000000..9e33fe2 --- /dev/null +++ b/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception4.java @@ -0,0 +1,16 @@ +package com.rt.exceptionexamples; + +class Exception4 { +public static void main(String args[]) { +try { +int a = 0; +int b = 42 / a; +} catch(ArithmeticException e) { // ERROR - unreachable + System.out.println("This is never reached."); + } +catch(Exception e) { +System.out.println("Generic Exception catch."); +} + +} +} \ No newline at end of file diff --git a/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception5.java b/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception5.java new file mode 100644 index 0000000..cdea353 --- /dev/null +++ b/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception5.java @@ -0,0 +1,21 @@ +package com.rt.exceptionexamples; + +class Exception5 { +public static void main(String args[]) { +try { +int a = args.length; + +int b = 42 / a; +System.out.println("a = " + a); + +if(a==1) a = a/(a-a); +if(a==2) { +int c[] = { 1 }; +c[42] = 99; +} +} catch(Exception e) { +System.out.println("Array index Out-of-bounds: " + e); + +} +} +} \ No newline at end of file diff --git a/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception6.java b/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception6.java new file mode 100644 index 0000000..f788e2f --- /dev/null +++ b/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception6.java @@ -0,0 +1,25 @@ +package com.rt.exceptionexamples; + +class Exception6 { +static void nesttry(int a) { +try { +if(a==1) a = a/(a-a); +if(a==2) { +int c[] = { 1 }; +c[42] = 99; +} +} catch(ArrayIndexOutOfBoundsException e) { +System.out.println("Array index out-of-bounds: " + e); +} +} +public static void main(String args[]) { +try { +int a = 2; +int b = 42 / a; +System.out.println("a = " + a); +nesttry(a); +} catch(ArithmeticException e) { +System.out.println("Divide by 0: " + e); +} +} +} \ No newline at end of file diff --git a/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception7.java b/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception7.java new file mode 100644 index 0000000..6e71309 --- /dev/null +++ b/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception7.java @@ -0,0 +1,16 @@ +package com.rt.exceptionexamples; + +import java.io.IOException; + +class Exception7 { +static void demoproc() throws IOException { +throw new IOException();//("demo"); + +} + +public static void main(String args[]) throws IOException { + +demoproc(); + +} +} \ No newline at end of file diff --git a/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception8.java b/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception8.java new file mode 100644 index 0000000..1f924bc --- /dev/null +++ b/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception8.java @@ -0,0 +1,17 @@ +package com.rt.exceptionexamples; + +class Exception8 { +static void throwOne() throws IllegalAccessException { +System.out.println("Inside throwOne."); +throw new IllegalAccessException("demo"); +//throw new ArithmeticException(); +} +public static void main(String args[]) { +try { + throwOne(); +} catch (IllegalAccessException e) { + // TODO Auto-generated catch block + System.out.println("Got it"+e.getMessage()); +} +} +} \ No newline at end of file diff --git a/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception9.java b/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception9.java new file mode 100644 index 0000000..10e398c --- /dev/null +++ b/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Exception9.java @@ -0,0 +1,17 @@ +package com.rt.exceptionexamples; + +class Exception9 { +static void throwOne() { +System.out.println("Inside throwOne."); +try { + throw new IllegalAccessException("demo"); +} catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); +} +} +public static void main(String args[]) { + +throwOne(); + +}} \ No newline at end of file diff --git a/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Test.java b/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Test.java new file mode 100644 index 0000000..4926b7b --- /dev/null +++ b/CCVT_Code_Distribute/src/com/rt/exceptionexamples/Test.java @@ -0,0 +1,16 @@ +package com.rt.exceptionexamples; + +public class Test { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + Employee e1=new Employee(1, "Ram"); + System.out.println(e1.toString()); + +// System.out.println(e1.getClass()); +// System.out.println(e1.hashCode()); + + } + +} diff --git a/CCVT_Code_Distribute/src/com/rt/string/forStrings.java b/CCVT_Code_Distribute/src/com/rt/string/forStrings.java new file mode 100644 index 0000000..dffed12 --- /dev/null +++ b/CCVT_Code_Distribute/src/com/rt/string/forStrings.java @@ -0,0 +1,156 @@ +package com.rt.string; +import java.util.StringTokenizer; + +import com.rt.cloning.Employee; + + +public class forStrings { + + /** + * @param args + */ + public static void main(String[] args) { + char ch[]={'h','e','l','l','o'}; + + System.out.println(ch); + + String str=new String(ch); + System.out.println(str); + + System.out.println(str.equals(ch)); + + + String s1="Example of being immutable"; + String s2="Example of being immutable";// + System.out.println("Checking s1 & s2 "+(s1==s2)); + + String s3=new String("Example of being immutable");// + System.out.println("checking s1 & s3 "+(s1==s3)); + System.out.println("Checking s1 & s2"+s1.equals(s2)+"\nchecking s1 & s3"+s1.equals(s3)); + + System.out.println(s1.compareTo(s2)); + System.out.println(s1.compareTo(s3)); + + + s3=s3.intern(); + System.out.println("checking s1 & s3 "+(s1==s3)); + + String s41="abc"; + String s51="abc"; + String s61="abcdef"; + System.out.println(s41==s51);//true + String s71=new String("abc"); + s71=s71+"def"; + System.out.println(s71);//abcdef + System.out.println(s61);//abcdef +// s71=s71.intern(); + System.out.println(s61==s71);//false + //s51.concat("def");System.out.println("hghgj"+s51); + StringBuffer tt=new StringBuffer("abc"); + tt.append("defssss"); + + System.out.println(tt); + + + + + + + //String s1="Example of being immutable"; + System.out.println(s1.charAt(2)); + System.out.println(s1.length()); + System.out.println(s1.format("Hey there %d and %d results in %d", 2,3,5)); + System.out.println(s1.substring(4)); + System.out.println(s1.substring(4, 9)); + System.out.println(s2.substring(0, 1));//start index end index + System.out.println(s1.contains("bein")); + System.out.println(s1.isEmpty()); + + String s4="Hi this is"; + String s5="CCVT at UPES"; + String s6=s4+s5;// String s6=(new StringBuilder()).append(s4).append(s5).toString(); + System.out.println(s6); + s4.concat(s5);//being immutable + System.out.println(s4); + s4=s4.concat(s5); + System.out.println(s4); + + s1.replace('o', 'q'); + System.out.println(s1); + + s1=s1.replace("being", "not"); + System.out.println(s1); + String s7=" after 5 space"; + System.out.println(s7); + System.out.println(s7.trim()); + + System.out.println(s1.toLowerCase()); + System.out.println(s1.toUpperCase()); + + System.out.println(s1.startsWith("Ex")); + System.out.println(s1.endsWith("le")); + + int a=10; + String s8=String.valueOf(a); + + System.out.println(s8+12); + + + ////******************STRING BUFFER + /* + */ + System.out.println("****************STRING BUFFER NOW***************"); + StringBuffer sf1=new StringBuffer();//can be passed with int or string +//sf1.append("aaaaaaaaaaaaaaaaa"); + System.out.println(sf1.capacity()+""+sf1); + sf1.append("few string to append"); + System.out.println(sf1); + sf1.insert(0, "see more appended "); + System.out.println(sf1); + sf1.replace(0, 8, "deleted"); + System.out.println(sf1); + sf1.delete(0, 7); + System.out.println(sf1); + sf1.reverse(); + System.out.println(sf1); +// sf1.ensureCapacity(50); + System.out.println(sf1.capacity()); + + StringBuilder sb1=new StringBuilder();//can be passed with int or string + + sb1.reverse(); + System.out.println(sb1.capacity()+""+sb1); + sb1.append("few string to append"); + System.out.println(sb1); + sb1.insert(0, "see more appended "); + System.out.println(sb1); + sb1.replace(0, 8, "deleted"); + System.out.println(sb1); + sb1.delete(0, 7); + System.out.println(sb1); + sb1.reverse(); + System.out.println(sb1); +// sb1.ensureCapacity(500); + System.out.println(sb1.capacity()); + + + // toString method tgo be explained + String s9="This, string, will, be, tokenized"; + StringTokenizer stk=new StringTokenizer(s9,"s"); + while(stk.hasMoreTokens()) + { + System.out.println(stk.nextToken()); + } + + String s10[]=s9.split(","); + System.out.println(s10.length); + System.out.println(s10[0]+" XX"+s10[1]+" XX"+s10[2]); + + + + + // TODO Auto-generated method stub + + } + +} diff --git a/README.md b/README.md index 1b08940..e2c2771 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,7 @@ -# Java_Programming_CCVT -This is for distribution of Lecture code to my students... +## Welcome to My Repository + +Hey There! This is **Ravi Tomar**, An **E**ngineer, An **A**cadmecian & a **H**elping hand, Working under capacity of Assistant Professor at University of Petroleum & Energy Studies, Dehradun + +### Use this Repository to learn basics of Java language + + diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..c419263 --- /dev/null +++ b/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-cayman \ No newline at end of file