Skip to content

YuriiJavaDev/JavaBasics_Task_6

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

String Manipulation & Immutability (JavaBasics_Task_6)

📌 Description

This project demonstrates how Java handles String variables and references. It explores the concept of object assignment and string immutability by creating a copy of a variable and modifying it independently.

🚀 Task Requirements

Create a copy of the project name to make changes to it.

  1. Declare a String variable projectName with the value "Java".
  2. Declare another String variable newProjectName and assign it the value of projectName.
  3. Change the value of newProjectName to "Java Programming".
  4. Output both variables to verify if the original projectName remains unchanged.

🛠 Technical Insight: Immutability

In Java, String objects are immutable.

  • When newProjectName is assigned the value of projectName, both variables point to the same object in the String Pool.
  • However, when newProjectName is updated to "Java Programming", Java creates a new String object.
  • The original projectName variable continues to point to the original "Java" object, ensuring data integrity.

💻 Code Example

🛠 Technical Stack

  • Language: Java 23
  • IDE: IntelliJ IDEA
  • Concepts: String Pool, Immutability, Variable References.

⌨️ Practical Implementation

The code follows Java naming conventions and clean code principles:

package com.yurii.pavlenko;

public class Task_6_App {
   public static void main(String[] args) {
      String projectName = "Java";
      String newProjectName = projectName;

      newProjectName = "Java Programming";

      System.out.println("Original Project Name: " + projectName);
      System.out.println("New Project Name: " + newProjectName);
   }
}

⚖️ License

This project is licensed under the MIT License.

Copyright (c) 2026 Yurii Pavlenko

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files...

License: MIT

About

Educational project. JavaBasics_Task_6 String manipulation and project naming logic. 140126_1508

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages