{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

9_9%20Java%20Style%2c%20Type%20Conversion%2c%20Literals

9_9%20Java%20Style%2c%20Type%20Conversion%2c%20Literals -...

Info icon This preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
COP 3330
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Homework 1 Due Monday 11:55PM Class names must start with uppercase - Collatz.java Factors.java - Reverse.java Cipher.java Read from a file called <ProblemName>.in - Scanner fin = new Scanner(new File(“Collatz.in”)) Output to standard output (the screen) - System.out.println(“Sample answer”)
Image of page 2
Topics Java Basics: Comments, type conversion, literals
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Comments Comments are ignored by the compiler Line comments - // This is a line comment Eclipse/Javadoc Comments - /** Eclipse comment here */ Block comments - /* This is a block comment */
Image of page 4
Comments Why comment? - For others - For yourself When to comment? - Before a class definition Describe the purpose of the class and important things to know about it
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Comments When to comment? - Before a method definition Describe the purpose of the method, the meaning of the formal parameters, and the meaning of the return value - Before variable declarations Describe the purpose of your variables - Mixed in with code Explain what your code is doing and why
Image of page 6
Comments Write comments that give a good feeling for what is actually happening and why Consider: for(i = 0; i < n; i++) score[i] -= minValue; - Okay comment: // Re-scale the scores - Bad comment: // Loop from 0 to n - Really bad comment: // Sort the array
Image of page 7

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Comments Choose descriptive variable names - Good: int numberOfVertices; - Good: double angularVelocity; - Bad: int foo; - Bad: String bar;
Image of page 8
Naming Conventions Class names should begin with an uppercase
Image of page 9

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern