1 / 10

Understanding Java Basics: Variables, Operators, and Expressions

This lecture notes cover the foundational elements of the Java programming language. Learn about variables, which store data of specific types, such as integers, booleans, doubles, and strings. Discover operators for performing calculations, including arithmetic and comparison operators. Explore the concept of assignment shortcuts and arithmetic expressions. Additionally, understand Unicode formatting and the importance of comments for effective code documentation. For more resources and lectures, visit www.basicsofprogramming.wordpress.com.

Download Presentation

Understanding Java Basics: Variables, Operators, and Expressions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Basic Elements Of Java Language for more lectures and notes visit www.basicsofprogramming.wordpress.com

  2. Variables • Storage name of particular data type having specific value. • They declares under specific daa type it may be • Integer (example 0,1,2 or- 47 etc ) • Boolean (example may be true or false) • Double (10.2, 1.1 or -2.1 etc) • String (shows text format e.g “JAVA", Pakistan etc they are strings) for more lectures and notes visit www.basicsofprogramming.wordpress.com

  3. Operators • Those symbols perform simple calculation. • Addition + • Subtraction - • Multiplication * • Division / • && (and) e.g (1 < x) && (x < 100) • || (or) e.g(lightsOn) || (isDayTime) • ! (not) e.g!(isStopped) for more lectures and notes visit www.basicsofprogramming.wordpress.com

  4. Shortcut Assignment operators Operator Example Equivalent += i+=8 i = i+8 -= f-=8.0 f = f-8.0 *= i*=8 i = i*8 /= i/=8 i = i/8 %= i%=8 i = i%8 for more lectures and notes visit www.basicsofprogramming.wordpress.com

  5. Arithmetic Expressions 3+4x _ 10(y-5) (a+b+c) + 9 4 9+x 5 x x y In code It well be translated like: (3+4*x)/5 – 10*(y-5)*(a+b+c)/x + 9*(4/x + (9+x)/y) for more lectures and notes visit www.basicsofprogramming.wordpress.com

  6. Unicode Format • Description Escape Sequence Unicode • Backspace \b \u0008 • Tab \t \u0009 • Linefeed \n \u000a • Carriage return \r \u000d for more lectures and notes visit www.basicsofprogramming.wordpress.com

  7. Comparison Operators • Operator Name • < less than • <= less than or equal to • > greater than • >= greater than or equal to • == equal to • != not equal to for more lectures and notes visit www.basicsofprogramming.wordpress.com

  8. Commenting • Single Line • We need forward slashes // for single line commenting. • for example // this is a single line comment • Multiple Line • We use /* in first line and at the end line */ • For example /* this is multiple line comment Second line Third line And last one */ for more lectures and notes visit www.basicsofprogramming.wordpress.com

  9. Try First Program Import acm.graphics.*; Import acm.program.*; Public class FirestProgram extends GraphicsProgram { Public void run() { Add{ new GLabel {“My First Program”,100,75}}; } } for more lectures and notes visit www.basicsofprogramming.wordpress.com

  10. END LECTURE # 3 Thanks For next lecture (online, ppt or doc file)visit our website www.basicsofprogramming.wordpress.com for more lectures and notes visit www.basicsofprogramming.wordpress.com

More Related