Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CSE110 Lecture 03

CSE110 Lecture 03

Principles of Programming with Java
Classes, methods, and variables
(202205)

More Decks by Javier Gonzalez-Sanchez

Other Decks in Programming

Transcript

  1. CSE110 Principles of Programming with Java Lecture 03: Classes, methods,

    and variables Javier Gonzalez-Sanchez [email protected] javiergs.engineering.asu.edu | javiergs.com Office Hours: By appointment
  2. Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 24 Java

    Program Structure • A program is made up of one or more classes • A class contains one or more methods • A method contains program statements
  3. Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 25 Java

    Program Structure • program statements can be: • Variables – places to store information • Instructions – actions to be done
  4. Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 26 Previously…

    and static public class TheClassName { } public static void theFirstMethodName() { } public static void secondMethodName(){ } // instructions go here // instructions go here // variables go here // variables go here // variables go here public static void main( ) { } // instructions go here // variables go here
  5. Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 28 main()

    method • All programs should have one and only one main() method. • Trying to execute a class without a main() method generates a compilation error
  6. Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 31 Template

    public class TheClassName { } public static void theFirstMethodName() { } public static void secondMethodName(){ } // instructions go here // instructions go here // variables go here // variables go here // variables go here public static void main( ) { } // instructions go here // variables go here
  7. CSE110 - Principles of Programming Javier Gonzalez-Sanchez [email protected] Summer 2022

    Disclaimer. These slides can only be used as study material for the class CSE110 at ASU. They cannot be distributed or used for another purpose.