140 likes | 267 Views
Java Kickstart Session. Academic Liaison Cell 16 th Management Committee. Agenda. Warming up to programming in UNIX Introduction to Java Object Oriented Programming Exception(s) & maybe error message API – what is this?. Disclaimer. This is not a replacement for the module CS1020
E N D
Java KickstartSession Academic Liaison Cell 16th Management Committee
Agenda • Warming up to programming in UNIX • Introduction to Java • Object Oriented Programming • Exception(s) & maybe error message • API – what is this?
Disclaimer • This is not a replacement for the module CS1020 • You will not guarantee an A+ if you attend this module • This session does not cover everything about Java.
UNIX Programming • Useful Commands: • pwd: print working directory (aka wru?) • mkdir: make directory (aka make folder) • rm: remove or delete • ls: list all files/folders • cp: copy. • Vim Editor • Different Modes • gg=G (aka. Go to top of doc. and indent to bottom) • :wq / :w / :q / :q! [Shift + Z + Z]
Introduction to Java • Java is just another programming language • Difference lies in the JVM / Java Virtual Machine. • Variables: int/double/char/boolean/etc… • Method(s) / Function(s): • public static void main (String[] args) {…} • static: • a keyword to imply that this exists once and only once • void: • A keyword to imply that the return datatype is void • Basically it is saying it won’t return anything • public: access modifier
Introduction to Java if (condition) {…} if (condition) {…} else {…} if (condition) {…} else { if (condition) {…} else {…} } for(initialization; termination; increment) {…} for( ; ; ) {…} // Infinite loop for(int number: numbers) {…} // foreach loop while(condition) {…} do {…} while(condition); switch(primitive variable) { case n:break; default:break; }
Object Oriented • Java is an OOP based language. • In English, that means you are forced to create an object/template or something close to one in order to program in Java. Sample code: public class JavaKickstartSession { public static void main(String[] args) { System.out.println(“Hello Class!”); } }
Objects • They have • Name(s) • Characteristics • Interaction with other objects Example: Computer Lab has a Name/identification, It also has a computers in it (how many?) People interact with it (they use the computers)
Inheritance • Idea to reuse code – imagine inheriting something that is already in existence. Example public abstract class Animal {…} public class Cat extends Animal {…} public class Kitten extends Cat {…}
Interface • Idea to agree on a certain way to do something public interface WarmBlooded {…} public class Cat extends Animal implements WarmBlooded {…}
Encapsulation • In English: whatever it is interested in or related, can and may be tagged/defined together. Doing otherwise is violation of this “Encapsulation”
Exception(s) • Error messages, but if you know where will go wrong, what is stopping you from preventing it from going wrong? try {…} catch (Exception error) {…} finally {…}
API • Application Programming Interface • Google “Java API” Common Classes Scanner String ArrayList/Vector DecimalFormat Exceptions: NullPointerException, ArithmeticException, IllegalArgumentException, IndexOutOfBoundsException, NumberFormatException
The End • Actually it is just the beginning. • Practice helps. • Clarify when in doubt • Google Inc is still an awesome teacher