DNE Does not exists!
Sunday, February 22, 2026
Tuesday, February 3, 2026
Java program to convert Decimal to Binary
import java.util.Scanner;
class D2B
{
public static void main(String[] args)
{
System.out.print("Enter a decimal number :");
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
String binary = "";
while(num > 0)
{
binary = num%2 + binary;
num = num/2;
}
System.out.print(binary);
}
}
Output:
java string value + int is a string or not?
When a Java
String value is concatenated with an int value using the + operator, the result is a String. This behavior is due to Java's rules for the
+ operator: - If either operand is a
String, the other operand is automatically converted to its string representation (e.g., the integer10becomes"10"). - The operator then performs string concatenation.
Example:
String value = "The answer is: ";
int number = 42;
String result = value + number;
// The value of 'result' will be the string "The answer is: 42"
Subscribe to:
Comments (Atom)
-
//The HTML index page <!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change ...
-
Here are some links to online work sites https://www.upwork.com/ https://www.guru.com/ https://studio.envato.com/freelance-switch/ htt...
-
Acronym Full Form AJAX Asynchronous JavaScript and XML API Application Programming Interface APK Android Application Package ASP Activ...
.png)
.png)
.png)