Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now

Learn operators Java (2011)


Java Essential Training (2011)

with David Gassner

Video: Learn operators Java (2011)

Operators are characters or sets of characters that execute operations. Since Java is a C-style language, it is able to utilize the same type of identifiers that most other programming languages use. This tutorial will get you started on the basics of understanding operators, and will also show how they are used in Java.
Expand all | Collapse all
  1. 10m 8s
    1. Welcome
      1m 3s
    2. Is this course for you?
      5m 35s
    3. Using the exercise files
      3m 30s
  2. 31m 25s
    1. The history of Java
      5m 19s
    2. Understanding the principles of Java
      8m 28s
    3. Java compilation and syntax
      8m 55s
    4. Choosing a development environment
      8m 43s
  3. 19m 52s
    1. Installing Java on Windows
      6m 42s
    2. Installing Eclipse on Windows
      3m 19s
    3. Exploring Java on Mac OS X Leopard and Snow Leopard
      2m 27s
    4. Installing Java on Mac OS X Lion
      4m 14s
    5. Installing Eclipse on Mac OS X
      3m 10s
  4. 46m 10s
    1. Creating a Hello World application
      11m 7s
    2. Exploring the Eclipse IDE
      8m 55s
    3. Compiling and running from the command line
      8m 2s
    4. Passing arguments to the application
      8m 17s
    5. Using the Java API documentation
      4m 5s
    6. Memory management and garbage collection
      5m 44s
  5. 58m 57s
    1. Everything is an object
      5m 59s
    2. Declaring and initializing variables
      9m 15s
    3. Working with numbers
      8m 32s
    4. Converting numeric values
      6m 40s
    5. Understanding operators
      7m 58s
    6. Working with character values
      5m 14s
    7. Working with boolean values
      5m 13s
    8. Outputting primitive values as strings
      5m 33s
    9. Creating a simple calculator application
      4m 33s
  6. 53m 41s
    1. Writing conditional code
      5m 35s
    2. Using the switch statement
      8m 50s
    3. Repeating code blocks with loops
      7m 35s
    4. Creating reusable code with methods
      6m 31s
    5. Declaring methods with arguments
      5m 42s
    6. Overloading method names with different signatures
      5m 53s
    7. Passing arguments by reference or by value
      5m 35s
    8. Creating a more complex calculator application
      8m 0s
  7. 20m 31s
    1. Using the String class
      5m 44s
    2. Building strings with StringBuilder
      3m 34s
    3. Parsing string values
      3m 20s
    4. Working with date values
      7m 53s
  8. 20m 44s
    1. Understanding compile-time vs. runtime errors
      4m 5s
    2. Handling exceptions with try/catch
      4m 55s
    3. Throwing exceptions in methods
      2m 50s
    4. Using the debugger
      8m 54s
  9. 32m 22s
    1. Using simple arrays
      4m 47s
    2. Using two-dimensional arrays
      6m 17s
    3. Managing resizable arrays with ArrayList
      7m 14s
    4. Managing unordered data with HashMap
      6m 5s
    5. Looping through collections with iterators
      7m 59s
  10. 52m 3s
    1. Understanding encapsulation
      5m 59s
    2. Creating and instantiating custom classes
      8m 8s
    3. Organizing classes with packages
      6m 47s
    4. Creating and using instance methods
      6m 52s
    5. Storing data in instance variables
      6m 56s
    6. Using constructor methods
      5m 40s
    7. Managing instance data with getter and setter methods
      8m 26s
    8. Using class variables and Enum classes
      3m 15s
  11. 41m 15s
    1. Understanding inheritance and polymorphism
      9m 12s
    2. Extending custom classes
      9m 1s
    3. Overriding superclass methods
      3m 8s
    4. Casting subclass objects
      5m 3s
    5. Understanding interfaces and implementing classes
      4m 2s
    6. Creating your own interfaces
      4m 14s
    7. Using abstract classes and methods
      6m 35s
  12. 32m 17s
    1. Managing files with the core class library
      7m 46s
    2. Managing files with Apache Commons FileUtils
      7m 32s
    3. Reading a text file from a networked resource
      7m 52s
    4. Parsing an XML file with DOM
      9m 7s
  13. 17m 39s
    1. Creating your own JAR files
      4m 54s
    2. Understanding the classpath
      5m 2s
    3. Documenting code with Javadoc
      7m 43s
  14. 47s
    1. Goodbye

please wait ...
Understanding operators
Video Duration: 7m 58s7h 17m Beginner Dec 14, 2011

Viewers: in countries Watching now:

Operators are characters or sets of characters that execute operations. Since Java is a C-style language, it is able to utilize the same type of identifiers that most other programming languages use. This tutorial will get you started on the basics of understanding operators, and will also show how they are used in Java.

View Course Description

Join author David Gassner as he explores Java SE (Standard Edition), the language used to build mobile apps for Android devices, enterprise server applications, and more. This course demonstrates how to install both Java and the Eclipse IDE and dives into the particulars of programming. The course also explains the fundamentals of Java, from creating simple variables, assigning values, and declaring methods to working with strings, arrays, and subclasses; reading and writing to text files; and implementing object oriented programming concepts.

Topics include:
  • Understanding the history and principles of Java
  • Installing Eclipse and Java
  • Compiling and running from the command line
  • Managing memory and performing garbage collection
  • Declaring and initializing variables
  • Writing conditional code
  • Building and parsing strings
  • Debugging and exception handling
  • Using simple arrays
  • Creating custom classes
  • Working with encapsulation, inheritance, and polymorphism
  • Managing files
  • Documenting code with Javadocs
Android Java Eclipse
David Gassner

Understanding operators

Every programming language supports operators, characters or sets of characters that execute particular operation. Java remember is C-style language and it uses the same set of operators as most such languages. If you already know JavaScript or ActionScript you will find that the operators in Java are almost identical. Here are some of the types of operators I'll discuss in this video. Assignment operators let you set values. There is a Simple Assignment Operator and then there were more Complex Assignment Operators that let you assignment and math in a single statement.

There are equality and relational operators that let you compare values to each other. There are mathematical operators that let you execute common mathematical process, Conditional operators that let you define complex conditional processes, and the ternary operator which is a special operator I'll describe in a later video when I discuss conditional processing. The most common operator that you'll find yourself using is the Assignment operator. The single equals character is the assignment operator. You put the variable you're assigning to on the left and the value on the right.

You can assign a literal value or a value return from a method or a reference to a complex object. Regardless of what you're assigning the single equals operator always is used. The simple math operators are the same as in JavaScript and ActionScript, the plus operators is used for math. So if I start with the value of 10 and I increment it by 5 with the + operator I get a value of 15, the - character is the traditional minus operator, the asterisk is used for multiplication and the forward slash is division.

There is another single character operator worth knowing about the modulus or remainder operator. Java uses the % character for this. If you take a value of 10 and you take the modulus of 5 that returns a reminder of 0. So those are the five primary math operators. You can combine these math operators with assignment too. Once again starting with an initial value of 10, let's take look at how you can increment and decrement values. The ++; operator means add one, so adding 1 to 10 gives you 11, the - -; operator goes in the other direction decrementing by one and that would give you a result of 9.

Here is how you can combine math operators with assignment, += means take the current value of this variable and add whatever is on the right side. So intValue +=5; would be 15. intValue -=5; would be 5, *= 5; equals 50 and /= 5; would result an intValue having a value of 2. Be aware that when you use the /= you need to make sure that you're assigning a value that matches the data type of the original variable.

When you use the increment and decrement operators you can place them either before or after the variable name, the operational result will be a little bit different depending on the position of the operator. Once again starting with the value of 10, a Postfix operator looks like this intValue ++, when you place the ++ operator after the variable you're saying first evaluate the variable and then execute the mathematical operation, because I've wrapped this inside a print line command I'm going to be outputting a value and changing it's value, but you need to know that with this Postfix syntax the evaluation happens first and only after that does the math happen.

The result would be an output of 10, but then after the statement is complete the new value of the variable would be 11. If you move the ++ operator before the variable name that's called a Prefix or a Unary operation, this would mean do the math then evaluate the variable. And in this case the output and the new value would be the same. Java's relational operators, that is the operators as you used to compare values to each other look exactly as you would expect. You have >, <, >= and <= values.

There is also a special operator called instanceof it's all lower case and all one word. You use the isntanceof operator to determine whether a variable is a member of particular class. Here is an example I declare a variable with a data type of String and I set it to some value. Now, I want to test that variable and ask whether it's an instance of a particular class. Typically when you use the instanceof operator you refer to the class by its fully qualified strength, its package, and its class name.

The String class is a member of the java.lang package, so the complete evaluation of (s instanceof java.lang. String) means is s a String and if so then I would output the String that's in the middle of if clause. One very important thing to know about comparisons is that you can't use the traditional comparison or relational operators when you're working with Strings. Let's take a look at this code, there are two Strings named s1 and s2, they have identical values of "Hello"; and now I put in some conditional code, I ask the question if (s1 ==s2) then output ("They match"); and otherwise output ("No match!);.

In some languages such as JavaScript you would get a match because in those languages they're comparing the values of the Strings, but in Java a String is a complex object and with complex objects the double equal operator is comparing whether they're the same object, not whether they have the same value and so this evaluation would result in the output No match!. If you want to compare two Strings you instead need to use a special method or function of the String class. Here is the correct example, once again I'm declaring two Strings named s1 and s2, now I'm going to use the equals function or method of the String class and I'm asking whether the values of these two variables match, not whether there the same object and this time the output is They match! With primitive variables you can use that double equal operator and you'll be able to match the values to each other, but with complex objects like the String you frequently have to use a method of the class to determine whether the values match.

Speaking of equality, here is how you compare values when you're working with primitives. The equality operator is double equal sign. Be sure you're using double equals not single equals, if you use single equals you'll be assigning the value and not comparing it. The inequality operator is an exclamation mark and the equal sign. So this syntax is asking if this value is not equal to that. And finally you can also use the exclamation mark on it's own to reverse the value of a Boolean Expression. A Boolean Expression evaluates to either true or false, when you apply the exclamation mark before it that reverses the value.

If it's started as true it becomes false and if it started as false it becomes true. You'll hear some developers refer to the exclamation mark as the bang character B-A-N-G. And so if they were reading this code it would be if bang this then do something regardless of what you call it bang or the exclamation it reverses the logic, changing a Boolean value from true to false or vice versa. Here are some conditional operators that you can use in complex logical operators.

The double ampersand is Conditional AND. In this code the output would only happen if both this and that are true. You can also do a Conditional OR using the double pipe character, in this code the output is going to happen if either of those variables equates to true. I'll show you more about how to combine these conditional operators with various types of conditional expressions in later videos, but you should now have a good sense of the kinds of operators that are available in Java and how similar they are to other C-style languages.

Find answers to the most frequently asked questions about Java Essential Training (2011) .

Expand all | Collapse all
please wait ...
Q: Can I safely use Java 8 with this tutorial or do I have to be using Java 6 specifically?
A: Yes, you can use Java 8 with this course.
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.

Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now Already a member? Log in

* Estimated file size

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.

Mark all as unwatched Cancel


You have completed Java Essential Training (2011).

Return to your organization's learning portal to continue training, or close this page.


Upgrade to View Courses Offline


With our new Desktop App, Annual Premium Members can download courses for Internet-free viewing.

Upgrade Now

After upgrading, download Desktop App Here.

Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Start your FREE 10-day trial

Begin learning software, business, and creative skills—anytime,
anywhere—with video instruction from recognized industry experts. provides
Unlimited access to over 4,000 courses—more than 100,000 video tutorials
Expert-led instruction
On-the-go learning. Watch from your computer, tablet, or mobile device. Switch back and forth as you choose.
Start Your FREE Trial Now

A trusted source for knowledge.


We provide training to more than 4 million people, and our members tell us that helps them stay ahead of software updates, pick up brand-new skills, switch careers, land promotions, and explore new hobbies. What can we help you do?

Thanks for signing up.

We’ll send you a confirmation email shortly.

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.