कंप्यूटर प्रोग्रामिंग/वेरिएबल/जावा
दिखावट
variables.java
[सम्पादन | स्रोत सम्पादित करें]import java.util.Scanner;
class variables {
public static void main(String[] args) {
System.out.println("Hello world!");
System.out.println("Variables and Data Types");
int i = 1234567890;
float f = 1.2345678f;
double d = 1.234567890123456;
String s = "string";
System.out.println("int: " + i);
System.out.println("float: " + f);
System.out.println("double: " + d);
System.out.println("String: " + s);
System.out.println("");
System.out.println("Constants");
final double PI = 3.14159;
final String C = "Constant";
System.out.println(PI + " " + C);
System.out.println("");
System.out.println("Arithmetic Operators");
int a = 3;
int b = 2;
System.out.println("a = " + a);
System.out.println("b = " + b);
System.out.println("a + b = " + (a + b));
System.out.println("a - b = " + (a - b));
System.out.println("a * b = " + (a * b));
System.out.println("a / b = " + (a / b));
System.out.println("");
System.out.println("Assignment Operators");
a += b;
System.out.println("a += b is " + a);
a -= b;
System.out.println("a -= b is " + a);
a *= b;
System.out.println("a *= b is " + a);
a /= b;
System.out.println("a /= b is " + a);
System.out.println("");
System.out.println("User Input");
System.out.print("What is your name? ");
Scanner scanner = new Scanner(System.in);
String username = "";
username = scanner.nextLine();
System.out.println("Hello " + username + "!");
}
}
कोशिश करो
[सम्पादन | स्रोत सम्पादित करें]निम्न कोड मुफ्त ऑनलाइन विकास के वातावरण में से एक में ऊपर कॉपी और पेस्ट करो या अपने खुद के जावा कम्पाइलर/इंटरप्रेटर/आईडीई का उपयोग करें।