MeshWorld India LogoMeshWorld.
JAVAProgram1 min read

Program to mixup characters of 2 strings in JAVA

Listen to ArticleAI Speech
~1 min read narration
100%
Program to mixup characters of 2 strings in JAVA

In this article we’ll see a program to mixup characters of 2 string in JAVA.

Input

Consider a two strings as Good and Day.

Code

public class StringMixup
{
  public static void main(String[] args)
  {
    String str1 = "Good", str2 = "Day";
    int i = 0, str1Length = str1.length(), str2Length = str2.length();
    String output = "";

    while(i < str1Length || i < str2Length)
    {
      output += i < str1Length ? str1.charAt(i) : "";
      output += i < str2Length ? str2.charAt(i) : "";
      i++;
    }

    System.out.println("String1: " + str1);
    System.out.println("String2: " + str2);
    System.out.println("Output: " + output);
  }
}

Output

String1: Good
String2: Day
Output: GDoaoyd

Happy 😄 coding

Reader Quality Feedback

Did this technical guide help solve your problem?

Suggest Errata ($0)
Vishnu
Primary Author

Vishnu

Founder & Principal Architect at MeshWorld. Senior engineer and instructor specializing in AI agent systems, scalable web architecture, and modern development workflows.

Explore Author Archive
Compute Fuel & Open Testbed
100% Independent & Verified

Fuel High-Density, Zero-Fluff Engineering Deep-Dives

Every guide on MeshWorld is validated on physical Linux nodes and reproducible testbeds. If this article saved you hours of debugging or unblocked production, consider funding our next cluster run.

Weekly Dispatch

Join MeshWorld Dispatch

Get practical tutorials, system blueprints, and curated AI engineering notes straight to your inbox. No fluff, zero spam.

Zero spam. 1-click unsubscribe anytime.Prefer RSS?
Curated Continuations

Up Next in This Domain.

Browse Full Archive