Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package datatypes;
- import java.io.IOException;
- import java.util.*;
- /**
- *
- * @author fmi
- */
- public class DataTypes {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) throws IOException {
- // TODO code application logic here
- byte myByte = 22;
- short myShort = 257;
- int myInt = -123;
- long myLong = 123L; // 077 0x077
- float myFloat = 2.34F;
- double myDouble = 2.34; //
- char myChar = 'c'; //'\u0000'
- boolean myBoolean = false; // true
- // -------------------- Referent -----
- String myName = "Stoyan\\ "; // \n
- Object myOtherByte = 3;
- System.out.print(myName);
- System.out.println(myName);
- // int ch;
- // 1.
- // ch = System.in.read();
- // System.out.print((char) ch);
- // while ((ch = System.in.read()) != '\n') {
- // System.out.print((char) ch);
- // }
- // 2.
- Scanner input = new Scanner(System.in);
- System.out.print("Please enter your first name: ");
- String firstName = input.nextLine();
- System.out.println(firstName);
- double number1 = 3.14;
- double number2 = 2.71;
- System.out.println(number1 + number2);
- System.out.printf("%.3f \n", number1 + number2);
- /* Old way for reading symbols
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- String firstString = br.readLine();
- String lastString = br.readLine();
- System.out.printf("Hello, %s %s!\n", firstString, lastString);
- */
- for(int i = 0; i < 10; i++)
- {
- for (int j = 0; j < i; j ++)
- {
- System.out.print('*');
- }
- System.out.print("\n");
- }
- Operations(2.32, 45.6);
- }
- static void Operations(double par1, double par2)
- {
- System.out.printf("%.2f + %.2f = %.2f", par1, par2, par1 + par2);
- }
- }
- /*
- import java.util.*;
- public class ReadingStringsNewStyle {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- System.out.print("Please enter your first name: ");
- String firstName = input.nextLine();
- System.out.print("Please enter your last name: ");
- String lastName = input.nextLine();
- System.out.printf("Hello, %s %s!\n", firstName, lastName);
- // input.close(); - Don't close Scanner reading System.in!
- }
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement