Skip to content

YuriiJavaDev/JavaBasics_Task_15

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

String data cleaning and manipulation (JavaBasics_Task_15)

📌 Description

This project focuses on data normalization using the String class. It simulates a real-world scenario where user-provided data (like a city name) contains unnecessary spaces and needs to be formatted.

🚀 Task Requirements

  1. Create a String variable cityName with the value " Minsk " (including leading/trailing spaces).
  2. Display the string length before and after using the trim() method.
  3. Display the city name in UPPER CASE and lower case.

📋 Expected Output

Length before trim: 9
Length after trim: 5
Upper case: MINSK
Lower case: minsk

🛠 Technical Stack

  • Language: Java 23
  • IDE: IntelliJ IDEA
  • Concepts: String methods (trim(), length(), toUpperCase(), toLowerCase()), Immutability, Object types.

⌨️ Practical Implementation

The project demonstrates that String objects are immutable. Methods like trim() or toUpperCase() do not modify the original data but return a new object with the modified byte sequence.

💻 Code Example

package com.yurii.pavlenko;

/**
 * Task 15: String manipulation.
 * Cleaning up user input and changing case.
 */

public class Task_15_App {
    public static void main(String[] args) {
        // Initializing with leading and trailing spaces
        String cityName = "  Minsk  ";

        // 1. Length before trimming
        System.out.println("Length before trim: " + cityName.length());

        // 2. Trimming and checking length again
        String trimmedCity = cityName.trim();
        System.out.println("Length after trim: " + trimmedCity.length());

        // 3. Changing case
        System.out.println("Upper case: " + trimmedCity.toUpperCase());
        System.out.println("Lower case: " + trimmedCity.toLowerCase());
    }
}

⚖️ 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

This is a learning project. JavaBasics_Task_15 Implementing line trimming (removing extra spaces to the left and right of text) and case normalization. 160126_1244

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages