answersLogoWhite

0


Best Answer

This is called "concatenation", and pretty much just smashes the two Strings together. For example:

import java.util.*;

public class Example

{

public static void main(String[] args)

{

Scanner in = new Scanner(System.in);

System.out.println("Please enter a string: ");

String input = in.next();

System.out.println("Please enter another string: ");

String input2 = in.next();

String together = input + input2;

System.out.println("The strings concatenated yields: " + together);

}

}

OUTPUT:

Please enter a string:

Hello

Please enter another string:

Goodbye

The strings concatenated yields: HelloGoodbye

As well, you can use String.nextLine() to get more than one word per string:

import java.util.*;

public class Example

{

public static void main(String[] args)

{

Scanner in = new Scanner(System.in);

System.out.println("Please enter a string: ");

String input = in.nextLine();

System.out.println("Please enter another string: ");

String input2 = in.nextLine();

String together = input + input2;

System.out.println("The strings concatenated yields: " + together);

}

}

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What happens when one string is appended to the end of another in Java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What are some example for string formatting in Java?

There are lots of examples of string formatting in Java. It can be difficult at times. Some of these examples are, but are not limited to; align, string, format, and JAVA.


How can you prove the given string by user is array or not in java?

Strings and Arrays are two totally different data types in Java and they will not match with one another.


What does it mean to have a string split in java?

To have a string split in Java means that a string array, containing substrings (can be delimited by elements of a specified string or Unicode character array), is returned.


In computer terms what does the phrase 'java string replace' mean?

When referring to computer terms, the phrase "java string replace" means that a string in the line of code that Java uses, is being replaced, or needs to be replaced.


How does the string trim work in Java?

The string trim works in Java by trimming white space from the beginning and end of a string. It cleans up the string and makes makes it neater for the users of the program.


What are the different between'a' and ''a in java string methods?

The difference between 'a' and "a" anywhere in Java is that 'a' is a primitive char type, while "a" is a String object.


Is String in java a class or object?

String is a pre-defined class in Java. For example: String s = new String("This is a string"); the variable s is now a String object since it was declared and initialized in the String class.


Where could someone find an example of Java string comparisons?

There are many sites to find examples of Java string comparisons. Java Revisited, Java Coffee Break, Alvin Alexander, Stack Overflow and Lee Point are a few to start with.


What is string args?

String[] args means an array of sequence of characters (Strings) that are passed to the "main" function. This happens when a program is executed. Example when you execute a Java program via the command line: java MyProgram This is just a test. Therefore, the array will store: ["This", "is", "just", "a", "test"] To learn more about data science please visit- Learnbay.co


What do you mean by string in java programming?

A "string" in any programming language is a line of text.


Concat a string without using any inbuilt function in java?

Use "+". Example: String string = "does this answer " + "your question?";


What is string class features in java?

String class is useful to accept inputs from commands prompt as string arguments