0:07 [Music]
0:10 Welcome back to CodeChef. Did you know
0:12 that every value in your Java program
0:14 has a literal representation? Today,
0:17 we'll explore Java literal. The way you
0:19 write numbers, characters, text, and
0:21 special values directly in your code to
0:24 represent data. Think of literal like
0:27 labels on ingredients in a recipe. When
0:29 you see two cups of flour or 1 teaspoon
0:32 of salt, those numbers and measurements
0:33 are fixed values you don't need to calculate.
0:35 calculate.
0:37 Similarly, literals are the fixed values
0:40 you type directly into your program,
0:44 like the number 42 or the word hello. In
0:46 Java, a literal is a fixed value written
0:49 directly in the code. Examples include
0:52 integers like 10, floatingoint numbers
0:55 like 3.14, characters like a, strings
0:58 like Java rocks, and the special null
1:01 literal indicating no value. Here's a
1:03 simple Java example.
1:05 Each value on the right side is a
1:08 literal, a fixed direct representation
1:11 of data. When we run this program, the
1:13 output will be quick facts about
1:16 literals. Integer literal are written
1:19 without quotes like 100. Floating point
1:25 literal use an f or f suffix eg 3.14f.
1:27 Character literal are enclosed in single
1:30 quotes eg z. String literal are in
1:35 double quotes eg hello. The null lit
1:37 indicates an empty reference. Now it's
1:40 your turn. Try this beginnerfriendly
1:43 problem on code chef using literal.
1:45 Write a program that declares variables
1:48 using int, float, char, string, and null
1:51 literal and prints their values.
1:53 Today you learned literal are fixed
1:56 values directly written in your code.
2:01 Java supports int, float, char, string,
2:04 and null literal. Use correct syntax,
2:07 quotes for chars and strings, fsuffix
2:11 for floats, and null for no value. Code
2:13 debug repeat build mastery with code chef.