0% found this document useful (0 votes)
2 views4 pages

Experiment 1

experiment 1

Uploaded by

Navpreet Kaur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

Experiment 1

experiment 1

Uploaded by

Navpreet Kaur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

INTRODUCTION:

Install Java Development Kit (JDK):


To develop Java applications, you need to have the Java Development Kit (JDK)
installed on your machine. You can download the JDK from Oracle or use an
open-source JDK like AdoptOpenJDK.

Install Visual Studio Code:


Visual Studio Code (VS Code) is a popular and highly extensible code editor that
can be used for Java development with the help of extensions and plugins.If
you haven't already, you need to install Visual Studio Code on your system. You
can download it from the official website: Visual Studio Code.

Install Java Extension Pack:


To enable Java development in VS Code, you can use the "Java Extension Pack"
by Microsoft. You can install it by going to the Extensions view (Ctrl+Shift+X),
searching for "Java Extension Pack," and clicking "Install."

Create a Java Project:


You can create a new Java project or open an existing one. VS Code provides
various project templates and options for managing Java projects.

Configure Java Runtime:


Make sure that you have configured the appropriate Java runtime for your
project. You can do this by clicking on the gear icon in the lower-left corner and
selecting "Java Projects." You can then configure the JDK for your project.

Writing Java Code:


You can create Java source files (.java) in your project's source folder. VS Code
provides features like code highlighting, autocompletion, and error checking for
Java code.
Running and Debugging:
You can run and debug your Java applications from within VS Code. Create a
run configuration for your project and use the debugging features to
troubleshoot issues.

Extensions and Plugins:


VS Code has a rich ecosystem of extensions and plugins. You can explore and
install additional extensions that enhance your Java development experience.
For example, you might want to consider extensions for build tools like Maven
or Gradle.

Documentation:
For detailed information on using Visual Studio Code for Java development, you
can refer to the official documentation and resources. Here are some helpful
resources:
Visual Studio Code Java documentation
Java Extension Pack

Hello word program


public class hello {
public static void main(String args[]) {
System.out.println("hello! how are you");
System.out.println("navpreet kaur");
}
}
EXPERIMENT 1: Handling various data types
CODE:
public class hello {
public static void main(String args[]) {
/**
* Data types in java
*/
//Integers
byte b = 127;
short s = 12345;
int i = 1234567;
long l = 12345678L;

//Floating
float f = 10.0f;
double d = 20.0;

// Non-numeric
char c = 'a';
System.out.println("b(byte) = "+b);
System.out.println("s(short) = "+s);
System.out.println("i(int) = "+i);
System.out.println("l(long) = "+l);
System.out.println("f(float) = "+f);
System.out.println("d(double) = "+d);
System.out.println("c(char) = "+i);
}
}
EXPERIMENT 2: Type casting

->Implicit type conversion


public class second {
public static void main(String args[]) {
//implicit conversion(type casting)
int a=55;
long c = a;
System.out.println("value of c is"+c);
char ch='A';
int i=ch;
System.out.println("value of i is "+i);
}
}

->explicit type conversion


public class second {
public static void main(String args[]) {
//explicit conversion(type casting)
long c = 55;
int d = (int) c;
System.out.println("Value of d is "+d);
float e= 4.99f;
int a= (int)e;
System.out.println("value of a is "+a);
}
}

You might also like