- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What happens when you add a double value to a String in java?
The “+” operator with a String acts as a concatenation operator.
Whenever you add a String value to a double using the “+” operator, both values are concatenated resulting a String object.
In-fact adding a double value to String is the easiest way to convert a double value to Strings.
Example
import java.util.Scanner; public class StringsExample { public static void main(String args[]){ Scanner sc = new Scanner(System.in); System.out.println("Enter a double value: "); double d = sc.nextDouble(); System.out.println("Enter a String value: "); String str = sc.next(); //Adding double and String String result = str+d; System.out.println("Result of the addition "+result); } } }
Output
Enter a double value: 245.5474 Enter a String value: test Result of the addition test245.5474
- Related Articles
- What happens when we try to add a number to undefined value?
- What happens when you declare a method/constructor final in Java?
- How to convert a double value to String in Java?
- Can you cast a Byte object to a double value in java?
- What happens when we try to add a duplicate key into a HashMap object in java?
- Convert double value to string in Java
- What happens when you download a Fake App?
- What Happens When You Quit Smoking?
- What happens when you do not declare a variable in JavaScript?
- What Happens to You When You Don’t Sleep for Days?
- How to convert a double value into a Java String using format method?
- How to convert a double value into a Java String using append method?
- What happens when buffer is set to a value "none" in JSP?
- What happens when you mix a strong acid with gold ?
- What happens when you control your mind?

Advertisements