GoConqr has a new look! Let us know what you think.

Notes

java intro

Mohamed Amireddine Ghezala English 5 pages

Content of the notes (5)

Page 1

chapter 1:

access modifiers:

default:The data members, class or methods which are not declared using any access modifiers i.e. having default access modifier are accessible only within the same package.

private:The methods or data members declared as private are accessible only within the class in which they are declared.

if u have two packages u need to import the one that you gonna use its classes in the other one. import p1.*;

protected:The methods or data members declared as protected are accessible within same package or sub classes in different package.

public:Classes, methods or data members which are declared as public are accessible from every where in the program. There is no restriction on the scope of a public data members.

static: When a member is declared static, it can be accessed before any objects of its class are created, and without reference to any object.

a program is defined by one or more classes.

The Java interpreter executes the application by invoking (calling) the main method.

In Java, every method must be part of some class which is different from languages like C, C++ and Python.

Page 2

chapter 2:

int newNum = 10 *++i; // increment i first then use it;

int newNum = 10 i++; // use i then incrment it.

widening in casting is implicit; up to down byte->short->int->long->float->double.

narrowing is explicit. down to up

when assigning a charecter to integer , its implicit casting;

when u assign a integer to charecter its an explicit casting.

import java.util.*; to use Scanner class.

ex to know the number of tokens:

StringTokenizer st = new StringTokenizer("amir nossa");

// counting tokens

System.out.println("Total tokens : " + st.countTokens());

FileInputStream and FileOutputStream are io package classes .

Output files

• PrintWriter • FileOutputStream

Input files •

BufferReader • FileReader

visit google doc to see how to read and how to write to a file

PrintWriter outputStream = new PrintWriter(new FileOutputStream("out.txt")); ////short way

FileOutputStream s = new FileOutputStream("out.txt"); ///long way

PrintWriter outputStream = new PrintWriter(s);

Page 3

Questions and things to revise back:

-list of reserved words.

-float vs double https://www.geeksforgeeks.org/comparision-double-float-primitive-types-java/

- number literals

- create and intialize d array

- class variables, instance variabesm, object refrence, refrnce variab;les.

- check (this) in the last slide of chap 9

- memorize the file creating, writing.

- memorize the string functions chap 8

-memorize the delimeters

- memorize2d array

-at 11 inheritance,polymorphism,abstract, interface

Page 4

chapter 5

Int [] newArray = Arrays.copyOf(oldArray, newArray.length);///copy newarry into oldarray

Arrays.sort(arr); /// sort the array

Arrays.toString(arr)) print the array [1,2]

how to creae and initialize a 2d array:

int matrix[][] = new int[10][10];

for (int i=0; i

Page 5

Information

Description
Note on java intro, created by Mohamed Amireddine Ghezala on 12/10/2018.
Created by
Mohamed Amireddine Ghezala · Oct 2018
Updated
Oct 21, 2018
Views
0
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?