0
could anyone help me with this?
This is the given problem: The given program declares a variable that holds all the letters of the English alphabet. Task: Complete the program to output the value of the variable. This is my attempt: public class Program { public static void main(String[] args) { String alphabet = "abcdefghijklmnopqrstuvwxyz"; System.out.printIn(alphabet); } } ** I viewed the solution to this problem and it was pretty much similar to my attempt so I don't know why my attempt won't produce an output.
8 Réponses
+ 3
The problem is in "System.out..." line.
To print a value, we use "System.out.println()" but I see you have used:
I <= uppercase (capital) i
Where it should be:
l <= lowercase (small) L
System.out.println()
^
Replace the capital i with small L to make it work.
Since they look similar, be careful with such keywords. They need to be exactly same to work.
+ 2
println stands for "PRINT LINE" because it adds a new line at the end.
You can also use System.out.print() and you will only notice a difference if you use multiple print statements after one another... Normal print will just add more characters in the same line, without line break.
+ 1
thanks for this info.
+ 1
To output the value of the alphabet variable, you can simply replace printIn with println. Here is the corrected version of the program:
public class Program {
public static void main(String[] args) {
String alphabet = "abcdefghijklmnopqrstuvwxyz";
System.out.println(alphabet);
}
}
+ 1
public class Program {
public static void main(String[] args) {
String alphabet = "abcdefghijklmnopqrstuvwxyz";
}
}
0
ohh okay thank you
0
I want to display the output alphabet
0
i think theres a bug same here