Beginners - 1 Basics

Here are some little things you should keep in mind after first installing Eclipse and making your first file.


In your code, you must have seen a lot of bold colored words(for ex: public static void main). Those words (like public, class, static, etc.) are called 'Identifiers'. Basically, they are Java's vocab words which you cannot use as your own or in different ways.


Let's say that the only reason why you are making this Lincoln file is to show display the sentence 'A quote by Abe Lincoln: I am Abraham Lincoln'. You never write code without a purpose/requirement/function. So, to make sure you remember why we're writing this file, type the following:
 //display something about Abe 

And press enter. Did you notice that the color has changed? This is called a comment. We use comments to "explain the purpose of the program and describe processing steps". They don't effect our code so we can write as many comments as we want as long as we always start them off with a // for each line of code.
An alternative is to type to close it off. Try it out for yourself
 /* and write as many lines as you want (or just one)
 and then type */ 

White Space

When coding, Java doesn't give a shit about the white space or new lines you have in your code. Meaning, you can put hundreds of spaces and tabs between System.out.println("bla"); (i.e. System   .  out.println (   "bla"   );), and Java will interpret this the same as System.out.println("bla"). The only time a space will make a difference is when it's inside the ""  of the println("') statement. But, even though spaces mean nothing, you should always try to limit your spaces and maintain the same tabs that Java automatically generates (such as between { }) so that your code is readable and not annoying to the people who didn't write it.

More to come soon...
Read More

Compiling a arithmetic code in C Using Registers

Problem: The compiler has a bug inside and it is not working. You have to its job to associate program variables with registers:

f = (g + h) - (i + j)
add $t0, $s1, $s2 #gets g + h
add $t1 ,$s3, $s4 #gets i + j
sub $s0, $t0 , $t1 # gets (g + h) - (i +j)
Read More

Convert this C code into Assembly (MIPS)

Problem: Hello there, I am an old guy who understands only low level languages and my son showed me this C code: f = (g + h) - (i + j);
Would you help convert this to assembly?

#Remember that arithmetic operations can have at most three operands.
sum x, g, h #Puts the addition of g and h in x
sum y, i, j #Puts the addition of i and j in y
sub f, x, y #Puts the subtraction of x and y into f
Read More

Put the sum of variables b, c, d, and e into variable a in assembly (MIPS)

Problem: Create an assembly sequence (or code) that places the sum of variables b, c, d, and e into variable a.


add a, b, c #Puts the sum of b and c into variable a
add a, a, d #Puts the sum of a and d into a new variable a
add a, a, e #Puts the sum of a and e into a new variable a

#Now you have the sum of b, c, d and e into a.
Read More

Regular Expressions: Match a or b (a|b) example


Make a regular expression that matches I love cats and I love dogs but not I love logs.



I love (cats|dogs)
Read More

Follow Me

If you like our content, feel free to follow me to stay updated.


Enter your email address:

We hate spam as much as you do.

Upload Material

Got an exam, project, tutorial video, exercise, solutions, unsolved problem, question, solution manual? We are open to any coding material. Why not upload?


Copyright © 2012 - 2014 Java Problems  --  About  --  Attribution  --  Privacy Policy  --  Terms of Use  --  Contact