Stats: 3,189,270 members, 7,936,844 topics. Date: Sunday, 01 September 2024 at 03:24 AM |
Nairaland Forum / Jas80's Profile / Jas80's Posts
(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (of 11 pages)
![]() |
ARITHMETIC OPERATORS I guessed you all already know what an operator is. Arithmetic operators refers to our usual mathematics operators. They include +,-,*,/,%. We use this operators in our programs to perform operations on our variables. Let's take a look at the program below. public class Add{ public static void main (String [] args){ int a =4; int b= 6; int c =a + b; System.out.println(c); } } The output of the program will be 10, because we added two operands a and b,.....hope you dig? 2 Likes |
![]() |
Good afternoon everyone, so lets continue from were we stop. LETS TALK ABOUT VARIABLES IN JAVA Now, when developing an app, there are things known as variables. Variables refer to the name we give to something in our app, which will hold a value. Lets take for example, a bucket, a bucket holds water, which we can use to bath, drink, or wash e.t.c. This bucket helps us to store our water, so we can use it anytime we choose to. The same thing goes with variables, they help us to store data, or information we would like to use in our app. Lets take for example. int a=50; int b=20; int c=a+b; In the above, we have given the value 50 to the variable a to hold for us. So whenever we need the value 50 in our program, we can ask a to provide it for us. Same goes with the variable b which holds 20 for us, and c which gives us the sum of a and b. You will understand more as we go on. JAVA DATA TYPES In computer, we all know what data is. In programming, there are several types of data. Data can be a decimal number, a whole number, a character, a word, or even group of words. As you can see in our java variable example, before declaring our variable, there is a word "int" before our variables. Now "int" is a data type used for declaring whole numbers. Note that all our variables must be assigned a data type. The data type we assign depends on the value of our variables. There are 2 types of data types namely: 1. Primitive data types: This is the basic data types, they include int, double, Boolean,char, short, long, float, 2. Non-primitive data types: These data types are more complex than the primitive data types. They include Strings, classes, interfaces and arrays. We will learn about only the primitive data types for now. Primitive data type We have about 8 primitive data types. As listed earlier, they include • Int data type • Double • Short • Long • Float • Byte • Char • Boolean As beginners, let us just know the basics of the aforementioned data types. Int data type: We use this data type when we are working with whole numbers like 1,20,5,6, e,t.c. Double data type: We use this data type when we are working with decimal numbers Float data type: This data type is just like the double data type You will understand the other data types as we go on 3 Likes |
![]() |
Hello everyone, due to the message I got from 2 or 3 persons following dis thread, I have decided to continue with it..... So, if u know u haven't try the codes above, try them and gv me ur feedbacks 1 Like |
![]() |
Xcecutive: Thanks bro.....was thinking of stopping the tutorial since there are no followings.....have things to do 1 Like |
![]() |
Good evening all, hope u had a nice day, down to business. Explanation of the example Every line of code that runs in Java must be inside a class. In our example, we named the class HelloJava. A class should always start with an uppercase first letter(I already told you). The name of every java file you are saving must match the class name. When saving the file, save it using the class name and add ".java" to the end of the filename. The main Method The main() method is required in every program you are going to write, you will see as we go on: public static void main(String[] args)-----------this is what is known as a method, so it will be present in all our programs. Any code inside the main() method will be executed. You don't have to understand the keywords before and after main. You will understand them as we go on. System.out.println()-------------this is another method We use this method, to print text in our programs. A method is a set of code which is referred to by name and can be called (invoked) at any point in a program simply by utilizing the method's name. Think of a method as a small program inside our main program. Each method has its own name. When that name is encountered in a program, the execution of the program branches to the body of that method. When the method is finished, execution returns to the area of the program code from which it was called, and the program continues on to the next line of code. Methods can be built in or user defined. So, the main method and the System.out.println method are built in method. You will understand as we go on. Note: The curly braces {} marks the beginning and the end of a block of code. Note: Each code statement must end with a semicolon. 3 Likes |
![]() |
![]() |
Xcecutive: That's d spirit....have u installed Java on ur system 1 Like |
![]() |
Happy Sunday everyone, so let me talk about coding apps,.....when I was in school I really wanted to code apps(I studied computer science). I can remember d first day my Java lecturer came to class, I was really so happy, I thought to myself "finally I am going to code application". So, my lecturer went to the board and wrote a code to print hello world. I couldn't run d code because I wasn't with my laptop. So, I rush home type d code and compiled it, only to see "hello world" displayed on my cmd. I was so disappointed. Cos I was expecting an application. My lecturer didn't explain things clearly to me. So, I carried out my research and understand what he did. He was simply showing us the syntax of java. You see, java have different API(Application programming interface), the type of API you use depends on the type of application u want to create. In other to use these API to build ur application, u need to learn the basics of the programming language. This is were basic programs like hello world are useful. So don't be disappointed with output of the codes for now. After learning these basics, will introduce you to the AWT and Swing API..........ask anything, am here 2 Likes |
![]() |
Good evening everyone, so our tutorial is starting today. lets begin.... INTRODUCTION Java is the most popular language used by programmers. Luckily for you, that's the language you are learning today. First, of all i believe, you all know what a compiler is, for those of you who don't know, a compiler is a program, we use in compiling our codes, so that the computer can get what we are telling it to code. As beginners, we are going to we our going to write out codes(what we want the computer to do) using notepad and we are going to compile our codes using command prompt. GETTING STARTED Before we can starting running java programs on our system, we need to install it first. So, visit www.java.com to download it(That is if you don't have java on your machine). After installing it, open your Notepad and type this code on it: public class HelloJava{ public static void main (String [] args){ System.out.println( "I am learning java" ); } } Then save the file name as HelloJava.java. Next thing is you open your command prompt, and go to the directory you save the file. For example if you saved the file on your documents, you simply type cd documents on your command prompt then press enter. Then type javac.Hellojava.java and press enter, type java HelloJava and press enter. Your output will be : I am learning java You may get this error when you are compiling your program “javac’ is not recognized as an internal or external command, operable program or batch file“. This error occurs when the java path is not set in your system. If you get this error then you first need to set the path before compilation. Set Path in Windows:(I believe you are all using windows ![]() Step 1: Go to Computer properties Step 2:Click on advance System settings Step 3:Click on environment variables Step 4:Click on new tab of user variables Step 5: Assign value PATH to variable name Step 6: Copy the path of the bin folder( go to the directory were your java is, and copy the address of the java bin folder) Step 7: Paste path of the bin folder in variable value Step 8: Click OK button Step 9:Click OK button NOTE that java is case sensitive, so type everything the way u see it(public,static,main, void, args, all begin with lowercase, while System and String begins with uppercase). Also note that the file name should be same as the class name, and should begin with an uppercase, each word making up the class name should begin with an uppercase. FEEL FREE TO ASK ANY QUESTION 1 Like |
![]() |
Follow my Java tutorials starting today 1 Like |
![]() |
You can follow up my Java tutorial on this forum, am starting this night |
![]() |
First of all, a happy new year to everyone out there, wishing you a prosperous year in all you do. Actually am a new member here, literally, I just opened my account this morning, but I have been a guest on this forum for 5-6 years now.....by the way, you can call me Jas. I am opening up this trend for any individual out there who wants to learn programming, so each and everyone of you is welcomed. If you want to learn programming, be it Android app development, game development, web design, then you are in the right place. For all the aforementioned programming concept, Java is a front runner. Maybe that is the reason why it is the most popular programming language ![]() You can use Java for almost anything, ranging from game development to web design. So,if you know you have been thinking of learning programming, this is the perfect time for it. So just type "I am in", to lemme know if u really serious about this. Happy New year once again, let us start it with productivity ![]() 1 Like |
![]() |
What can you do with c#, or better still, which app have you created |
(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (of 11 pages)
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 49 |