How to print the letter J with dashes in Java
How to print the letter J with dashes in java
Taking the step to print out anything (in this case the letter J) using dashes (or any other single symbol for that manner) is a great baby step in many programming languages.
I've seen wonderful examples of fairly sophisticated art (i.e. simpsons art) created using a single symbol. The road there includes some of the simplest trial and error. You can quickly move from creating the letter J to creating another letter, or perhaps your name initials, and then even to complete words.
This is another baby step that is worthy of practicing, by following, and then by aiming to complete more and more without referencing, and then completely by memory, and to practice often.
So let's do it, and discuss it, just a bit ...
Here's the code:
1 public class PrintJ {
2 public static void main (String argv[]) {
3 System.out.println("----------");
4 System.out.println(" -- ");
5 System.out.println(" -- ");
6 System.out.println(" -- ");
7 System.out.println(" - -- ");
8 System.out.println(" ----- ");
9 }
10 }
Here's what we used when building this code:
* java 8
* vim editor (note: we have much love for intellij and other editors too!)
* code was placed in a file named PrintJ.java
Here's what we did to run the code:
* javac PrintJ.java
* java PrintJ
Here's what you'll see when you run it:
----------
--
--
--
- --
-----
Here's a bit of description about the code and concepts used:
- the public class name of PrintJ is the same as the filename, and that's important in order for the file class to compile
- The syntax System.out.println is used for printing lines of content, and the content that you want to be printed belongs between the quotes
- The typical public static void main function is added and is the entry point to the application
- The dash character (-) is used to enable content to be printed on each line, working together to form the letter J
Another baby step completed, nice job!
Want to know how to do something in java or have any questions? Let me know by commenting, and we'll consider getting there as we continue to take baby steps!
Copyright © 2024 correlateencourage - All Rights Reserved.
..............................
Practicing baby steps is one of the things we believe correlates with success, and keeping track of your practice experience is another. It's one of the many things you can track with our correlateencourage app, available here at the apple store: https://apps.apple.com/us/app/correlateencourage/id6504427387


Comments
Post a Comment