Jump to content

Kara

Frost
  • Posts

    1
  • Joined

  • Last visited

About Kara

  • Birthday 07/11/2001

Profile Information

  • Version
    4.1.18.2

Contact Methods

Recent Profile Visitors

1,104 profile views

Kara's Achievements

Newbie

Newbie (1/14)

  • First Post
  • Week One Done
  • One Month Later
  • One Year In
  • Reacting Well

Recent Badges

0

Reputation

  1. Hi! I just wanted to share my basic knowledge on the simple basics of Java. Java is a widely used (the #1 used coding language in the world) language that powers a lot of the things we see today. Java is a very powerful coding language, as it is used almost everywhere. So, after learning basic Java from school, I would like to introduce you all to some of the basic commands in Java. Some basics: int = number. String = word/letter. double = inaccurate/changing decimal. float = stationary decimal. Let's start with the easy stuff, creating our first class. class Hello { system.out.println("Hello world!"); } This is a very simple class, and when you compile and run it, all it would do is return with "Hello world!". If you are familiar with other coding languages, you will see that the way the code works is similar, it's just the syntax that is different. Let's make something a little bit harder. Constructors. This is a very simple constructor, it has no parameters. In the next example, there will be parameters. class Demo{ public Demo(){ System.out.println("This is a default constructor"); } } Constructor with parameters: class Demo{ public Demo(int num, String str){ System.out.println("This is a parameterized constructor"); } } Basically, you can use constructors to define variables, and you can use those variables to run commands. I will now show you simple commands used in the language. This is using a for loop to print out numbers in ascending order. class ForDemo { public static void main(String[] args){ for(int i=1; i<11; i++){ System.out.println("Count is: " + i); } } } When you do i<11, it prints out the indexes from 0-10. The output of that code is; Count is: 1 Count is: 2 Count is: 3 Count is: 4 Count is: 5 Count is: 6 Count is: 7 Count is: 8 Count is: 9 Count is: 10 You may have noticed a weird line of code in there. public static void main(String[] args){ This is a command that allows the class to run. This is recommended to be put when using sorts, searches, fors, ifs, and more. Read more on StackOverflow. These are very basic things in Java, if you want to learn more, I suggest you take a Java class at your nearest High School/College. (I learned my java from AP Computer Science B) I will be posting more about Java soon. I just wanted to get my foot in the door and see if it would be something people would be interested in! Comment/like if I should continue these posts. I will post as many as once a day if wanted. Thanks! ~Kara
×
×
  • Create New...