Single logo
  • Courses
  • Blog
  • About
Join on SkoolJoin on Skool

In this topic

Java
  • Install Java 25 (JDK) and IntelliJ IDEA, Then Run Your First Program
  • Use Claude Agent, Copilot or Junie Inside IntelliJ IDEA
  • Java Hello World with Maven: What the JDK Does and What Maven Adds
  • Java Variables, Keywords and Naming Rules
  • Maven in IntelliJ: pom.xml, Dependencies and the Build Lifecycle
  • Java Primitive Types and Memory: What int x = 5 Really Does
  • Java Strings and Text Blocks: Quotes, Concatenation and parseInt
  • Java Operators: Arithmetic, a++ vs ++a, Precedence, && || and the Ternary
  • Java Type Casting: Widening, Narrowing and Converting Text to Numbers
  • Java Practice Lab: A Cafe Bill with Variables, Operators and Casting
  • Java if, else and switch: Braces, Else-If Ladders and the Modern Switch
  • Java Loops: for, while, do-while and for-each
  • Java break, continue and Nested Loops
  • What's New in Java 21 to 25: Compact Source Files and Sequenced Collections
  • Java Arrays: Indexes, Default Values, Loops and 2D Grids
  • Java Methods and Overloading: Parameters, return and Pass-by-Value
  • Java Scope, Code Blocks and the Call Stack
  • Read User Input in Java with Scanner (and the Leftover Enter Trap)
  • Java Practice Lab: A Gym Weekly Tracker with Loops, Arrays and Methods
  • Debugging Java in IntelliJ: Stack Traces, Breakpoints and a Better AI Prompt
  • Java var: Let Java Infer the Type
  • Push and Pull in IntelliJ: Two Developers, One GitHub Repository, a Rejected Push and a Conflict
  • Java Classes and Objects: One Blueprint, Many Cars
  • Java Constructors and the this Keyword
  • Java Instance Methods, Getters, Setters and toString
  • Java static: Fields, Methods and Blocks Shared by the Whole Class
  • Java Packages and Imports: Every Class Has an Address
  • Java Access Modifiers and Encapsulation: Private Data, Public Methods
  • Java final and Immutable Objects: Assign Once, Share Safely
  • Java Strings as Objects: The String Pool, == vs equals, StringBuilder and printf
  • Java Practice Lab: A Library Book Catalogue with final Fields and StringBuilder
  • Java Inheritance: extends, super and the Order Objects Are Built
  • Java Method Overriding, @Override and the Object Class
  • Java Polymorphism: Upcasting, Dynamic Dispatch and Downcasting
  • Java Composition: Has-A vs Is-A
  • Java Abstract Classes: A Parent That Leaves One Blank
  • Java Interfaces: Contracts and Multiple Inheritance
  • Java Nested, Inner and Anonymous Classes
  • Java Enums with Fields, Methods and switch
  • Java Practice Lab: Payment Processing with an Interface, an Abstract Class and an Enum
  • Java Records: A Whole Data Class in One Line
  • Java Sealed Classes and Interfaces
  • Java Pattern Matching with instanceof and switch
  • Java Record Patterns: Unpacking a Record
  • Java equals and hashCode: Why a HashSet Needs Both
  • From Arrays to Collections: The Java Collections Framework Map
  • Java Wrapper Classes and Autoboxing
  • Java ArrayList: The Stretchy Array
  • Java LinkedList vs ArrayList: Nodes or an Array
  • Java Sets: HashSet, LinkedHashSet and TreeSet
  • Java Sorting with Comparable and Comparator
  • Java Maps: HashMap, LinkedHashMap and TreeMap
  • Java Stacks, Queues and Deques: ArrayDeque and PriorityQueue
  • Choosing a Java Collection: Immutable and Sequenced Collections
  • Java Exception Handling: try, catch and finally
  • Java throw, throws, Checked vs Unchecked and Custom Exceptions
  • Java try-with-resources and Clean Error Handling
  • Java Generics: Type-Safe Containers
  • Java Generic Methods, Bounded Types and Wildcards
  • Java Lambdas and Functional Interfaces
  • Java Built-in Functional Interfaces: Predicate, Function, Consumer, Supplier
  • Java Optional: Saying Maybe Without null
  • Java Streams I: filter, map and reduce
  • Java Streams II: Collectors, groupingBy and flatMap
  • Why Concurrency: Processes, Threads and the Main Thread in Java
  • Creating Threads in Java: Thread, Runnable and Lambdas
  • Java Thread Lifecycle: sleep, join and interrupt
  • Java Race Conditions and synchronized
  • Java volatile and Atomic Variables
  • Java ExecutorService and Thread Pools
  • Java Callable, Future and CompletableFuture
  • Java Locks, Deadlock and tryLock
  • Java Concurrent Collections and Virtual Threads
  • Why Slow Work Belongs off the Request Thread: 202 Accepted and a Job Id in Spring Boot
  • Virtual Threads in Spring Boot: One Property, and the Connection Pool Trap
  • @Async, Named TaskExecutors and Structured Concurrency in Spring Boot
  • Java Files and Directories with NIO.2: Path and Files
  • Reading and Writing Text Files in Java
  • Java Structured Data: Reading and Writing JSON and CSV
  1. Blog
  2. /
  3. Java
  4. /
  5. Basics

Java Strings and Text Blocks: Quotes, Concatenation and parseInt

A String is a row of characters in double quotes; a char is one character in single quotes. Why "1" + "2" is 12, how Integer.parseInt turns "100" into a number, and multi-line text with triple-quote text blocks.

Chaand Sheikh

·27 November 2026·Updated 28 November 2026Basics

What you will learn

  • Tell a char in single quotes from a String in double quotes
  • Predict what + does with text, numbers and a mix of both
  • Turn text into a number with Integer.parseInt
  • Write multi-line text with a text block

Before you start

  • Java primitive types and memory

A String is a sequence of characters: messages, names, file paths, any text at all. You'll use one in nearly every program you write.

The String "StudyEasy" is a row of nine characters S, t, u, d, y, E, a, s, y in double quotes. The char 'A' is a single character in single quotes. Study Easy A String course = "StudyEasy"; char grade = 'A'; a row of characters, double quotes one character, single quotes String has a capital S: it's a class, not a primitive.
Double quotes make a String (many characters); single quotes make a char (exactly one).

One character, or many

package org.studyeasy.s02l05;

public class Ex01_CharAndString {
    public static void main(String[] args) {
        char grade = 'A';
        String course = "StudyEasy";
        System.out.println(grade);
        System.out.println(course);
    }
}
A
StudyEasy

char holds one character in single quotes. String holds text in double quotes. Write char grade = "A"; and javac says a String cannot be converted to char. The quotes matter.

The plus sign has two jobs

+ is an overloaded operator: it does different work depending on what's on each side. Numbers on both sides, it adds. Text on either side, it joins.

package org.studyeasy.s02l05;

public class Ex02_Concat {
    public static void main(String[] args) {
        String brand = "study" + "easy";
        System.out.println(brand);
        System.out.println("Score: " + 87);
        System.out.println(1 + 2);
        System.out.println("1" + "2");
    }
}
studyeasy
Score: 87
3
12
  • "study" + "easy" joins into studyeasy.
  • "Score: " + 87: text plus a number gives text. The 87 is joined on.
  • 1 + 2 is maths: 3.
  • "1" + "2" is text: 12.

Only + works this way. "study" - "easy" doesn't compile: the operator - isn't defined for String.

Turn text into a number

package org.studyeasy.s02l05;

public class Ex03_ParseInt {
    public static void main(String[] args) {
        int quantity = Integer.parseInt("100");
        System.out.println(quantity + 20);
        System.out.println("100" + 20);
    }
}
120
10020

Integer.parseInt("100") takes the text "100" and gives back the number 100, so quantity + 20 is 120. Without parseInt, "100" is still text, and + 20 just sticks 20 on the end: 10020.

Parse something that isn't a number, like "one hundred", and the program stops with a NumberFormatException. That's the situation you'll handle later with try and catch.

The quotes tell Java what you mean

You writeTypeMeaning
'A'charone character
"A"Stringtext that happens to be one character
"100"Stringtext, not a number yet
100inta real number you can do maths with

Multi-line text with a text block

package org.studyeasy.s02l05;

public class Ex04_TextBlock {
    public static void main(String[] args) {
        String oldWay = "Hi Emma,\n" + "Your order is ready.\n" + "Thanks, Jack";

        String message = """
                Hi Emma,
                Your order is ready.
                Thanks, Jack""";

        System.out.println(message);
        System.out.println(oldWay.equals(message));
    }
}
Hi Emma,
Your order is ready.
Thanks, Jack
true

The old way needs a \n (new line) and a + on every line, and it gets messy fast. A text block opens with triple double quotes, and you type the text as it should look. It keeps your lines. equals prints true: both strings hold exactly the same text; the text block is just easier to write.

One detail: here the closing """ sits right after Thanks, Jack. Put it on its own line and the text gains a trailing new line, so equals prints false.

Common mistakes

  • char c = "A";: double quotes make a String.
  • Expecting "100" + 20 to be 120. Parse first.
  • Parsing text that isn't a number: NumberFormatException.
  • Writing string with a small s. The class is String.

Recap

IdeaExampleResult
char'A'one character
String"StudyEasy"a row of characters
Join text"1" + "2"12
Add numbers1 + 23
Text to numberInteger.parseInt("100")100
Text block""" ... """multi-line text as typed

Strings have more to them: the string pool, StringBuilder and formatting are covered in Java strings as objects.

Keep going in Java · 7 of 79

Previous
Java Primitive Types and Memory: What int x = 5 Really Does
Next post
Java Operators: Arithmetic, a++ vs ++a, Precedence, && || and the Ternary
Community · Free to join
Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

Related course on Udemy

FULL STACK JAVA : JAVA + JSP + SPRING BOOT AI + REACT + VIBE

Java 25, JSP, Hibernate, Spring Boot 4, REST APIs, React and Spring AI.View on Udemy ↗: FULL STACK JAVA : JAVA + JSP + SPRING BOOT AI + REACT + VIBE (paid course, opens in a new tab)

Related posts

Install Java 25 (JDK) and IntelliJ IDEA, Then Run Your First Program

Install JDK 25 (Microsoft Build of OpenJDK) with JAVA_HOME, install IntelliJ IDEA, then point a run configuration at the JDK and the main class and run Hello World.

Use Claude Agent, Copilot or Junie Inside IntelliJ IDEA

Open IntelliJ's AI Chat, pick Claude Agent (the agent behind Claude Code) or Copilot and a model, ask in plain words for Main.java to print the date and time, review the change, and run it.

Java Hello World with Maven: What the JDK Does and What Maven Adds

javac compiles HelloWorld.java into bytecode and java runs it on the JVM. Maven adds one pom.xml, the same folders in every project and one build command. Then a real Maven Hello World in IntelliJ.

Java Variables, Keywords and Naming Rules

A variable is a labelled jar that holds one value at a time. Four small programs show declaring, reassigning, the names Java accepts, the keywords it reserves, and why daysUntilLaunch beats d.

On this page

  • One character, or many
  • The plus sign has two jobs
  • Turn text into a number
  • The quotes tell Java what you mean
  • Multi-line text with a text block
  • Common mistakes
  • Recap
Community · Free to join
Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

Related course on Udemy

FULL STACK JAVA : JAVA + JSP + SPRING BOOT AI + REACT + VIBE

Java 25, JSP, Hibernate, Spring Boot 4, REST APIs, React and Spring AI.View on Udemy ↗: FULL STACK JAVA : JAVA + JSP + SPRING BOOT AI + REACT + VIBE (paid course, opens in a new tab)

Single logo

Empowering Education, One Course at a Time

About
About usContact us
Legal
Terms of UsePrivacy Policy

© 2026 StudyEasy Organization. All rights reserved.