Basic Java Examples

72 Comments

    • easy to learn ,follows object oriented programming concepts,code is similar to c and c++,pointers concept is avoided in java due to security purposes ,pointer points out the content at particular location in memory,so with the help of pointer we can hack the memory and we will do whatever we want that is the reason in java pointer concept is avoided and after internet world is arrived the devolopers felt that devoloping a website or networking through conventional programming languages like c++ is somewhat cumbersome takes lot of effort so there is required a new language such that we will devolop websites ,not only websites or network related products we can also write rich set of application softwares
      using java,and java programs are portable means platform independent(robust),we can develop rich set of applications using java in quicker time

    • java is cross platform programming language, it means you can write your program in windows, linux, mac or any other operating system and it will also runs in any OS as long as you do have JDK. java is cover almost all application in computer from web, application, games and many more.

    • Java is used for web designing purpose,computer animation,games, it reduces the development cost and time consuming, easy to find the errors.

    • java programming uses oops concept. The main advantage is that it can be reused and flexible . Distributed networks is achieved through java. Java is platform independent. That is it can create and run on any computer.

    • java based on the opps concept,its platform independent.adv of java is simple, secure,obj oriented, portable,robust and multithread

    • java is object oriented programming(OOPS) language.
      OOPS again can be described as follows-we create a class with various fields and functions(for eg , a tree with attribute leaf color, height and function grow()). When we instantiate it (for eg,mango tree /pine tree we instantiate the fields ie leaf color= green and make use of function.)

      Advantage of java-In most of the pgmg languages the conversion is to machine language (that computer understands) specific to machine we are working on. However, in java we translate pgmg lang instruction into an intermediate lang which can be run on any machine.

    • 1.Copy the code from website
      2.paste in word
      3.Select all and right click – select bullet as None and also Numbering as None
      4.Copy to notpad
      5.Code is ready.

  • can anyone help me with this program:
    Atm simulations
    transaction
    A.Pin verification
    B.Balance inquiry
    C.Withdrawal
    D.Deposit
    E.EXit
    Class
    Runner account transactions
    name display balance()
    account # withdraw()
    pin = 1234 deposit()
    balance =
    Instractions
    1.assume an initial balance of 10,000
    2.assume only account (pin=1234)
    3.transactions starts when user enters correct pin
    options will be displayed
    Balance Inquiry
    Withdrawal
    Deposit
    Exit
    4.Balance Inquiry displays current balance
    5.withdrawal
    5.1 values entered must be positive multiples of 100 and less than or equal to current balace
    5.2update balabnce upon execution
    6.Deposit
    6.1 valuse entered must be positive and multiple of 100
    6.2 update balance upon execution
    7.Exit

  • Thanks a lot for this website because i have learned more on what are the basics Java programming output. I’m a Computer Science College Student. Joefhel U. Bagares.

    • use java.lang.Math.max(a,b) and find the maximum of first 2 numbers

      then call again this method for maximum result and third number

  • i dont know much about it,i studied only little basics…can u help me out by explaining the java programs

    • Salam Dear. I am DeeN Muhammad Khan. I need basic information of java. and i want to do certification of SUN M. Soft. Please reply me. How can i get certification of java. My ID is [email protected] and at facebook DeeNkhan saqi.

  • hi, can you plz help me to code this program.

    Create a program that will compute for the speed of two cars. The distance traveled (in km) by these cars within 2.5 hours should be inputted by the user. After computing for their speed, determine which is the fastest car.

    Formula for speed:

    speed = distance / time

  • can anyone help me to make this program in java
    create 3 check box,one of music,one of reading n 3rd one is select all.
    if we check select all the other 2 be selected automatically.if we uncheck the 3rd one then other be unchecked…….& if we select music & reading by checking the check box the should be select….:)
    reply fast….:)

  • Can anyone help with this program PLEASE…, I’m new here and I’m also a beginners

    Write a JAVA program that will input Employee Name, Rate per hour, No. of hours worked and will compute the daily wage of an employee. If the number of hours worked exceeds eight hours add 30% to each excess hours as overtime rate.

    Formula: Daily Wage = Rate per hour * No. of hours worked + OT pay

  • i want a program to count no of lines(to display no of lines) for the current
    program of which we have written?
    please help me…….

  • Assume the following variable declaration exists in a program .write that uses System .out.printtf to display the value of the number variable formatted as shown in front of each one:

    double number = 1234567.456; 1,234,567,46

    string number =”james “; in a field that is 20 spaces wide.

    int number = 123456; field that is 10 spaces wide, withcomma separators.

    double number = 123456.789; in a field that is 20 spates wide, rounded to two

    decimal places.

  • HELP!!!! I need to Write a program that prompts the user to input three numbers. This
    program should then output the numbers in nondescending order

    • Make sure to import the scanner class by putting “import java.util.Scanner” at the top of your code, inside the class. Also, what do you mean by nondescending? For now, here is the basic code to simply display the numbers that were entered.

      Scanner userInput = new Scanner(System.in);

      System.out.println(“Enter a number: “);
      int firstNum = userInput.nextInt();

      System.out.println(“Enter a second number: “);
      int secondNum = userInput.nextInt();

      System.out.println(“Enter a third number: “);
      int thirdNum = userInput.nextInt();

      System.out.println(“The numbers you entered are:” + firstNum + secondNum + thirdNum);

  • Hi everyone! Can you please help me with this problem?

    Negotiating a consumer loan is not always straightforward. One form of loan is the discount installment loan, which works as follows. Suppose a loan has a face value of 1000 pesos, the interest rate is 15 percent, and the duration is 18 months. The interest is computed by multiplying the face value of 1000 pesos by 0.15 to yield 150 pesos. The figure is then multiplied by the loan period for 1.5 years to yield 225 pesos as the total interest owed. The amount is immediately deducted from the face value, leaving the consumer with only 775 pesos. Repayment is made in equal monthly installments based on the face value. Thus, the monthly loan payment will be 1000 pesos divided by 18, of 55.56 pesos. This method of calculation may not be too bad of the consumer needs 775 pesos, but the calculation is a bit more complicated if the consumer needs 1000 pesos. Write a program that will take three inputs: the amount the consumer needs to receive, the interest rate, and the duration of the loan in months. The program should then calculate the face value required in order for the consumer to receive the amount needed and should also calculate the monthly payment.

    help me with this please?

  • can any one please solve for me this question;

    ( Write a method to find a given number from a given sorted integer array. The array and the number to search for are received as parameters.)

  • also this excises: •

    Develop a method to count the number of vowels in a given array of characters. The array is received as a parameter.

  • Armstrong Number Program without using % and / operators

    import java.util.*;
    class Number1
    {
    public static void main(String[] args)
    {
    Scanner sc = new Scanner(System.in);
    System.out.print(“Enter the number = “);
    String s = sc.next();
    int l=s.length();
    int n3=0,sum=0;

    for(int i=0;i<l;i++) {=”” int=”” n2=”Integer.parseInt(String.valueOf(s.charAt(i)));” n3=”n2;” for(int=”” j=”1;j&lt;l;j++)” {=”” n2=”n2*n3;” }=”” sum+=”n2;” system.out.println(“len=”+sum);
    }

    }

    }”>

Sponsors

Facebook Fans