Software Development Using Java - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

Software Development Using Java

Description:

variables, data types, sequence, selection, iteration, methods (functions) ... but drag-and-drop IDEs are available for Java. Borland JBuilder, Together, NetBeans ... – PowerPoint PPT presentation

Number of Views:90
Avg rating:3.0/5.0
Slides: 18
Provided by: socSta
Category:

less

Transcript and Presenter's Notes

Title: Software Development Using Java


1
Software Development Using Java
  • Surgery
  • Peter King
  • Cathy French

2
Timetables
  • make sure you are attending
  • 2 lecture slots
  • 2 tutorial slots
  • 1 surgery (this one)

3
For discussion
  • What programming language(s) have you studied
    before?
  • What differences have you noticed so far?

4
Java vs. Visual Basic .NET
  • both are programming languages
  • with standard programming language features
  • variables, data types, sequence, selection,
    iteration, methods (functions)
  • both are object-oriented
  • all code belongs to a class
  • large applications will have many classes
  • usually we construct objects of these classes
  • easier to manage large programs
  • each form in Visual Basic .NET is a different
    class
  • can also write classes for non-GUI objects
  • Spike

5
Java vs. Visual Basic .NET
  • both compile to platform-neutral code
  • Java byte-code
  • .NET - Microsoft Intermediate Language
  • C and J also compile to MSIL
  • both are executed using an interpreter
  • Java Virtual Machine
  • .NET Common Language Runtime
  • need a different interpreter for each platform
  • Window, Linux, Solaris SPARC, Solaris x86 etc.

6
Java vs. Visual Basic .NET
  • extensive and easy to use class libraries
  • Java Application Programming Interface (Java API)
  • .NET Framework Class libraries
  • web applications
  • networking sockets
  • graphical user interfaces
  • mobile devices
  • data structures
  • database connections
  • already written
  • programmer has to learn how to use them

7
Java vs. Visual Basic .NET
  • both support rich Graphical User Interfaces
  • Visual Basic commonly takes GUI-first approach
  • use Visual Studio Integrated Development
    Environment (IDE)
  • drag and drop GUI components
  • autogenerate code skeleton
  • type in method bodies by hand
  • type in non-GUI classes
  • in this module we will take a code-first approach
  • type in most code by hand
  • so we can understand it
  • but drag-and-drop IDEs are available for Java
  • Borland JBuilder, Together, NetBeans

8
Why study Java?
  • to learn another language
  • widely used, especially in networked applications
  • build on and reinforce the programming
    fundamentals you learnt in study of Visual Basic
  • same ideas expressed in different syntax
  • keywords, use of brackets, comments
  • use of different libraries
  • GUI components, String handling

9
A first Java program
  • / A first Java program /
  • public class HelloApp
  • public static void main(String args)
  • String name
  • // declares a variable called name of type String
  • name "Cathy"
  • System.out.println("Hello, " name)

10
HelloApp in detail
  • all Java code must belong to a class
  • each application (program) must contain at least
    one class
  • this application has only one class called
    HelloApp
  • the code for each class is stored in a file with
    the same name
  • with the extension .java
  • our file is called HelloApp.java

11
Declaring the class
  • start with a class declaration
  • public class HelloApp
  • body (content) of the class follows within curly
    brackets
  • indent body for readability
  • public and class are Java keywords
  • have specific meaning
  • reserved by Java
  • dont use them for your own variable, attribute
    or method names!

12
The main method
  • all Java programs must have a main method
  • program execution starts here
  • statements in main method are executed
    sequentially until closing is reached
  • Visual Basic programs also have an Main procedure
  • generated automatically when you create a project
  • usually loads the first form
  • main method always has the same signature
  • public static void main(String args)

13
Java statements
  • each statement
  • represents an action
  • ends with a semicolon
  • String name
  • declares a variable of type String called name
  • name "Cathy"
  • stores the value "Cathy" in name
  • System.out.println("Hello, " name)
  • prints the text in brackets in the console window

14
Outputting text
  • Java provides methods to output text to the
    console window in the class System.out
  • this is a library class that is part of the Java
    language
  • System.out.println(name)
  • prints out the String stored in the variable name
  • then goes to a new line
  • System.out.print(name)
  • prints out what is stored in name
  • but does not start a new line

15
Outputting text
  • System.out.print("Hello")
  • prints the word "Hello"
  • can print more than one item by putting between
    them
  • System.out.println("Hello, " name)
  • use escape sequences for formatting
  • /n new line
  • /t tab
  • /" double quote mark
  • System.out.println("Hello \n Welcome")
  • System.out.println("\tYou must be \"Cathy\"")

16
Comments
  • ignored by compiler
  • can write whatever you want
  • // single line (or end of line)
  • / multiple line comments go here
  • everything between the marks
  • is ignored /
  • important for documentation!!!!
  • useful to comment out suspect code
  • don't delete it
  • put / / around it

17
Typical program structure
  • // any import statements
  • public class TypicalApp
  • public static void main(String args)
  • // declare variables
  • // assign variable values
  • // (perhaps with input from user)
  • // do processing / calculations
  • // output results
Write a Comment
User Comments (0)
About PowerShow.com