AI May 15, 2023 โ€ข 5 min read

Module 15: Strings

BR

Bhargava Ram Pantina

Web Developer & AI Enthusiast

๐Ÿงต What is a String?

A String in Java is an object that represents a sequence of characters. Strings are immutable, which means once created, they cannot be changed.

๐Ÿ“ Creating Strings

                    String s1 = "Hello"; // using string literal
                    String s2 = new String("World"); // using new keyword
                    

๐Ÿ”ง Common String Methods

                    String s = "Java Programming";
                    s.length(); // 16
                    s.toUpperCase(); // "JAVA PROGRAMMING"
                    s.toLowerCase(); // "java programming"
                    s.charAt(2); // 'v'
                    s.contains("Pro"); // true
                    s.indexOf("a"); // 1
                    s.substring(5); // "Programming"
                    

๐Ÿ” String Comparison

                    String a = "Java";
                    String b = "Java";
                    String c = new String("Java");
                    
                    System.out.println(a == b); // true (same reference)
                    System.out.println(a == c); // false (different reference)
                    System.out.println(a.equals(c)); // true (same content)
                    
Artificial Intelligence Web Development Technology Trends Machine Learning UX Design

Share this article

About the Author

BR

Bhargava Ram Pantina

Bhargava Ram is a web developer and AI enthusiast with over 8 years of experience in the tech industry. He specializes in creating innovative web solutions that leverage the latest technologies to solve real-world problems.

Related Articles

AI Mar 15, 2023

Implementing ChatGPT in Your Web Application: A Step-by-Step Tutorial

Learn how to integrate OpenAI's ChatGPT into your web application to create intelligent chatbots and enhance user interactions.

Read More โ†’
Web Development Apr 22, 2023

Building Accessible Web Forms: A Complete Guide

Learn how to create web forms that are accessible to all users, including those with disabilities. This comprehensive guide covers ARIA attributes, keyboard navigation, and more.

Read More โ†’

Subscribe to My Newsletter

Get the latest articles and resources delivered straight to your inbox.

No spam, just valuable content. Unsubscribe anytime.