Skip to main content

Posts

Showing posts with the label JAVA english version

Examples of Simple Programs 1 & 2 Dimensional Array in Java

Previously you must have understood what it is to understand the array of variables easier. So, like this simple example: When you want to store a data that an instance name, of course, you need to declare a variable to be able to store data such name. Unfortunately you do not always deal with one data, now you imagine if you want to list the names of students in your class. Please note: a regular variable can only store one value. Then, if you will create a variable name1, name2, name3, and so on? Of course not, this is why you need an array data type.  Because of the array allows you to store a lot of data in a variable. Below is a simple example of the use of java for an array of one-dimensional and two-dimensional array number specified by input. Example 1 dimensional array java program: import java.util. *; class input_Array1 { public static void main (String [] xxx) { try { int arr [] = new int [4]; String array [] = new String [4]; Scan...

Examples Problem Java Programming and Code

1.)  Program determine type Triangle with Java  Flat Triangle is bounded by three sides and has three vertices.  Triangle has some kind of like an isosceles triangle, equilateral triangle, the triangle is arbitrary, etc.  By using java, we can create a program to determine the type of triangle side lengths just by entering the triangle side. Examples of the coding like this: import java.util.Scanner; public class DeterminingTriangle { public static void main (String [] args) { Scanner scanner = new Scanner (System.in); int a, b, c; System.out.print ("Enter number 1:"); a = scanner.nextInt (); System.out.print ("Enter number 2:"); b = scanner.nextInt (); System.out.print ("Enter number 3:"); c = scanner.nextInt (); if(a==b&&b!=c&&a!=c||b==c&&b!=a&&a!=c||a==c&&b!=a&&b!=c) { // if only two numbers have the same value then print an isosceles triangle System.out.print ("input results make:...

Object, Class, Message and Method JAVA

Object, Class, Message and Method In object-oriented programming, a class is a template for structure definition and object creation.  So the object of an instance of a class, that class is a collection of plans that specify how to build an object. Object and Class Information-related information and describes an object called object attributes (object attribute).  This attribute allows an object has a value attribute that stands alone.  Besides object attributes also have an action called by the method.  So the method is a set of operations on an object in the form of code instructions. General syntax format-making class is as follows: class classname { // declare instance variables var1 type; var2 type; // ... type varN; // declare methods type method1 (parameters) { // body of method } type method2 (parameters) { // body of method } // ... type methodN (parameters) { // body of method } } Defining Class Consider the example of a class definiti...