In: Computer Science
in bluej java Writing Classes and Methods, Modulo operator, Integer Division, if-statements, Iteration
I am assuming that you are asking of how to perform these actions in the BlueJ IDE.
To create a class, click the New Class button and specify the class name which is on the project tool bar. The name has to be a valid java identifier as well. After creating the class, the type (interface, abstract, or applet) is indicated in the class icon.
Writing a method in blueJ is same as in other IDE's which you will be able to understand by the example below
public class Main {
public static void foo() {
// Do something here
}
}
Modulo operator does not differs from IDE to IDE it depends on the language so, it's the same as in other editors.
If you are having trouble understanding what it is then -
There's one important arithmetical
operator you may not be familiar with, %
, also known
as the modulus or remainder operator. The %
operator
returns the remainder of two numbers. For instance 10 %
3
is 1 because 10 divided by 3 leaves a remainder of 1.
Dividing integer a
by
integer b
you get how many times b
fits
into a
. Also a % b
will give you a
remainder of a division. So (a / b ) * b + a % b =
a.
Java does autoconvert types:
It autoconverts ints to doubles. It autoconverts shorts and bytes to ints even when no ints are involved, requiring constant annoying casts when you want to do short or byte arithmetic. It autoconverts primitives to wrappers and vice versa for boxing and autoboxing.
If statements are type of conditional statements used for running some part of code when the condition written in "if" return True. If it's False then the 'if' block won't run and the compiler would skip ahead.
Iterations means the repetition of a function, method or a process in a computer program which is same for most of the programming languages and it doesn't depends on the IDE as well.
Iterations in Java are performed by