URL-Shortener

URL Shortener – Java Console Application

📌 Project Description

A Java-based URL Shortener application that converts long URLs into short URLs and retrieves the original URLs efficiently. The project uses HashMap for constant-time lookups and includes input validation, duplicate handling, and a menu-driven console interface.

This project demonstrates strong fundamentals in Data Structures, Java, and problem-solvings.


✨ Features


🛠 Technologies Used


⚙️ How It Works

  1. User selects an option from the menu.
  2. For URL shortening:
    • The input URL is validated.
    • A unique 6-character alphanumeric code is generated.
    • The short URL is stored using HashMap.
  3. For retrieving original URL:
    • The short URL is validated.
    • The original URL is fetched using the short code.
  4. All operations run in constant time on average.

📦 Data Structures Used


⏱ Time & Space Complexity


🧪 Sample Output

***** MENU *****
1. Shorten URL
2. Get Original URL
3. Exit
Enter your choice :
1
Enter the URL to shorten :
https://www.google.com
Short URL : http://short.ly/DMni3a

***** MENU *****
1. Shorten URL
2. Get Original URL
3. Exit
Enter your choice :
2
Enter short URL :
http://short.ly/DMni3a
Original URL : https://www.google.com

***** MENU *****
1. Shorten URL
2. Get Original URL
3. Exit
Enter your choice :
3
Thank you for using URL Shortener!


▶️ How to Run

  1. Clone the repository:git clone
  2. Compile the Java files:javac Main.java
  3. Run the application:java Main
  4. Use the menu to shorten and retrieve URLs.

📘 Key Learnings


🌍 Real-World Use Cases