diff --git a/VivekGautam/JavaFundamental sourcecode b/VivekGautam/JavaFundamental sourcecode new file mode 100644 index 0000000..7cc46c8 --- /dev/null +++ b/VivekGautam/JavaFundamental sourcecode @@ -0,0 +1,292 @@ +// Video lecture 1 and 2 source code + + +import java util.*; +class VivekGautam +{ + public static void main(String [] args) + { + + Scanner sc = new Scanner(system.in); //we use this syntax for taking a new input + + + System.out.print("My name is Vivek"); //for printing some thing + } +} + + + +//Variables and data type +public class A +{ + static int m=100;//static variable + void method() + { + int n=90;//local variable + } + public static void main(String args[]) + { + int data=50;//instance variable + } +} + + +//video lecture-3 + +public class Solution { + + public static void main(String[] args) { + int i=1,j=1; + while(i<=10) { + while(j<=5) { + System.out.print("*"); + j++; + + } + System.out.println(""); + i++; + j=1; + + } + + } + +} + + +//video lecture-4 + +// Abstract class +package Abstract; + +abstract class AbstractClass { + public void Mymothod(){ + System.out.println("Hello"); + + } + abstract public void anotherMar(); + +} + + +package Abstract; +public class Demo extends AbstractClass { + public void anotherMar() { + System.out.println("another"); + } + + public static void main(String[] args) { + + AbstractClass obj=new Demo(); + obj.anotherMar(); + obj.Mymothod(); + + } + +} + +//STRING AND CHARACTER + +public class Stringoperator { + + public static void main(String[] args) { + + char a='A'; + String b="Vivek Gautam"; // String is nothing but its a group of character + String c="java devloper"; + System.out.println(b.length()); + + System.out.println(c.charAt(0)); + System.out.println(c.compareTo(b)); + System.out.println(b.strip()); + + + System.out.println(c.toUpperCase());//convert in to upper case + System.out.println(c.toLowerCase());//convert in to lower case + System.out.println(c.substring(1,3));//return substring from position 1to position 3-1 + System.out.println(c.substring(3)); + } + +} + + +//VIDEO LECTURE 5 ARRAY IN JAVA + + +import java.util.*; +import java.lang.*; +import java.io.*; + +/* Name of the class has to be "Main" only if the class is public. */ +class Demo +{ + //data member + String name; + int rollno; + int age; + + public void info() //member function + { + System.out.println("Name: "+name); + System.out.println("Roll Number: "+rollno); + System.out.println("Age: "+age); + } +} +class Gautam +{ + public static void main (String[] args) throws java.lang.Exception + { + // your code goes here + Demo student = new Demo(); + //class_name object_name = new class_name() + //Accesing and property value + + student.name = "Vivek"; + student.rollno=362; + student.age=21; + + //calling method + student.info(); + + } +} + + + +import java.util.*; +import java.lang.*; +import java.io.*; + +/* Name of the class has to be "Main" only if the class is public. */ +class Vivek +{ + public static void main (String[] args) throws java.lang.Exception + { + int[] arrayOfInts = {32,87,3,589,1076,12,2000,8,622,127}; + // datatype array_name == elemnts in array + + int serchfor = 12; + int i; + boolean foundIt = false; + for(i=0;i