Java for Complete Beginners (Video), Part 13: Classes and Objects

A basic tutorial on classes and objects in Java. What is a class? How do you create objects and classes and how do you use them?

When the video is running, click the maximize button in the lower-right-hand corner to make it full screen.

Code for this tutorial:


class Person {
	
	// Instance variables (data or "state")
	String name;
	int age;
	
	
	// Classes can contain
	
	// 1. Data
	// 2. Subroutines (methods)
}


public class App {

	public static void main(String[] args) {
		
		
		// Create a Person object using the Person class
		Person person1 = new Person();	
		person1.name = "Joe Bloggs";
		person1.age = 37;
		
		// Create a second Person object
		Person person2 = new Person();
		person2.name = "Sarah Smith";
		person2.age = 20;
		
		System.out.println(person1.name);
		
	}

}

Joe Bloggs

 

Learn to program Java Swing with my complete video course – desktop programming and applets. Includes 7 free videos. Click here for details.

All pages on this site are copyright © 2013 John W. Purcell

2 Responses to Java for Complete Beginners (Video), Part 13: Classes and Objects

  1. Kafil says:

    Your tutorial on Multithreading rocks!!! Easy to understand and very helpful. I feel like a detailed topic on Collection Framework in Java will be very helpful for many people. Can you please work on such tutorial and upload here?

    • Squiffy says:

      Thanks Kafil, that is a really good idea actually. Popular topic. I’ll try to create some videos on collections in the near future.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Posted in Java, Java Video Tutorials (Beginners) | Tagged , , |