Presentation is loading. Please wait.

Presentation is loading. Please wait.

S517 Web Programming Assistant Professor Xiaozhong Liu

Similar presentations


Presentation on theme: "S517 Web Programming Assistant Professor Xiaozhong Liu"— Presentation transcript:

1 S517 Web Programming Assistant Professor Xiaozhong Liu http://scholarwiki.indiana.edu/S517/S517.html

2 Stay with S517 if… You are interested in programming, but don’t have a lot experience… You have basic HTML knowledge, but don’t have web programming experience… You are interested in Object-Oriented Programming (OOP) and JAVA… You may want drop S517 if… You have a lot experience in JAVA, C++, C, C#, VB.net… (you can learn java and C# web programming by yourself) You have NO interest to find a tech-related job!

3

4

5 What is programming?

6 JAVA Java is a general-purpose, concurrent, class-based, object-oriented computer programming language that is specifically designed to have as few implementation dependencies as possible. It is intended to let application developers "write once, run anywhere" (WORA), meaning that code that runs on one platform does not need to be recompiled to run on another. Java applications are typically compiled to bytecode (class file) that can run on any Java virtual machine (JVM) regardless of computer architecture. Java is, as of 2012, one of the most popular programming languages in use, particularly for client-server web applications, with a reported 10 million users. [Wikipedia]

7

8 Information problem… Input Output

9 Information problem… Input ProgrammerSource File Compiler Library Java fileClass fileJar file Virtual Machine interpreter

10 Dynamic Page!!!

11 Web

12 Java Servlet API – HTTP protocol request respond dynamic

13 request respond

14 request respond Retrieval algorithm PageRank algorithm Ranking algorithm Result Presentation Personalization ……

15 Command line Or GUI Compute result Command line Or GUI Compute result Java Numeric Text File Internet … Numeric Text File Internet …

16 What is programming? Real WorldProgramming A student Public Class Student I am a student Student a_student = new Student( ) My name is Xiaozhong String name; name = “Xiaozhong” I was born in 1979 Int birth_year; birth_year = 1979 How old? Int age; age = 2013 – birth_year Use computer + programming to solve real-world problem…

17 A java example Real world problem: how to describe a student? 1. Define student public class student { String name; int age; } 2. Describe a student static void main public static void main(String[] args) { student stud_A = new student( ); stud_A.name = “Xiaozhong Liu” stud_A.age = 32; }

18 A java example Real world problem: add two numbers static void main public static void main(String[] args) { //input int number_1 = 20; int number_2 = 30; int sum; //process sum = number_1 + number_2; //output System.out.println(sum); }

19 Some Java Basics – Class name and file name should be the same ABC.java -> public class ABC { } – Source extension.java Compiled file extension.class – The compile process creates a.class file from the.java file Example: Project folder\src\MyProgram.java -> Project folder\build\MyProgram.class – Java is case sensitive

20 Output Information problem… Input Variable double price, pricewithtax; price = 65.20 price = price*1.0825 pricewithtax = price

21 VariableString String name = “Obama”; String name = “Obama”; int int age = 30; int age = 30; double double price = 15.25; double price = 15.25; boolean boolean dataplan = true; (or false) boolean dataplan = true; (or false) Variable type Variable name (no space, start With alphabet, case sensitive) Variable value

22 Memory Model Values in the process are stored in memory. – View memory as a sequence of slots that can hold values of different types Variables name the slots, sometimes called locations of memory Assignment can put values in variables

23 Memory int number_1 = 20; int number_2 = 30; int sum; sum = number_1 + number_2; System.out.println(sum); 1 1 2 2 3 3 4 4 5 5 2G …..

24 Memory int number_1 = 20; int number_2 = 30; int sum; sum = number_1 + number_2; System.out.println(sum); 1 1 2 2 3 3 4 4 5 5 2G ….. number_1 20

25 Memory int number_1 = 20; int number_2 = 30; int sum; sum = number_1 + number_2; System.out.println(sum); 1 1 2 2 3 3 4 4 5 5 2G ….. number_1 20 number_2 30

26 Memory int number_1 = 20; int number_2 = 30; int sum; sum = number_1 + number_2; System.out.println(sum); 1 1 2 2 3 3 4 4 5 5 2G ….. number_1 20 number_2 30 sum

27 Memory int number_1 = 20; int number_2 = 30; int sum; sum = number_1 + number_2; System.out.println(sum); 1 1 2 2 3 3 4 4 5 5 2G ….. number_1 20 number_2 30 sum 50 JAVA MOV AX, 20 ADD AX, 30 ……

28 Memory int number_1 = 20; int number_2 = 30; int sum; sum = number_1 + number_2; System.out.println(sum); 1 1 2 2 3 3 4 4 5 5 2G ….. number_2 30 sum??? java.lang.OutOfMemoryError

29 Standard arithmetic Java supports basic arithmetic operators: +, -, *, /, and %. Add two numbers? int number1, number2, result; numbers1 = 18; number2 = 9; result =number1 + number2; System.out.println(result);

30 double x, y; x = 7.486; y = x+15*x-7/x*x; (?????????) System,out.println(y);

31 Exercise: To convert from meters to feet, multiply the number of meters by 3.28084 1.71 meter = ???? Feet 5.68 feet = ???? meter

32 Exercise: Implement the following expression:

33 int number1 = 5; String number2 = “10”; int result; result = number1 + number2; What is the result??? Variable type conversion

34 double number; String str = “10.735”; number = Double.parseDouble(str) StringStringintint str = Integer.toString(num) num = Integer.parseInt(str); StringStringdoubledouble str = Double.toString(num) num = Double.parseDouble(str); Two questions: 1.What is “Double” and “Integer”??? 2. Why we need type conversion???

35 int number1, number2, sum; number1 = Integer.parseInt (jTextField1.getText()); number2 = Integer.parseInt (jTextField2.getText()); sum = number1 + number2; jLabel3.setText(Integer.toString(sum)); jTextField jTextField1.getText( ); jLabel jLabel3.setText (?????);

36 1.What is variable? 2.What is expression? 3.What is Standard arithmetic? 4.What is type conversion? 5.What is Web? What is Servlet? Homework: Install Eclipse + Tomcat in your PC or Mac

37 Final Project: Option 1: Find your data, create a web service… with Java Servlet + MySQL Database + JDBC Option 2: Build your “mini-Google” with Java Servlet + Lucene + Information Retrieval algorithms (Large Textual Dataset)


Download ppt "S517 Web Programming Assistant Professor Xiaozhong Liu"

Similar presentations


Ads by Google