Client and Server Model – how to establish connection to the server – how to send messages to the server – how to receive messages from the server Socket chatSocket = new Socket(“196.164.1.103”,5000); 196.164.1.103 address of the sever 5000 is the port number server / TCP port numbers ftp/20 telnet/23 smtp/25 time/37 https/443 pop3/110 http/80 […]
Tag: software
JAVA Beginners part 17
How to save data in a Java program. a) use serialization if the programs that use the saved data are Java b) write a plain text file Steps to save an object through serialization. FileOutputStream filestream = new FileOutputStream(“mygame.ser”); this will create a file ObjectOutputStream os = new ObjectOutputStream(filestream); this lets you to create objects, […]
JAVA Beginners part 16
Most of these are event sources meaning the Swing components. Java Swing ———- javax.swing.JComponent All the components are capable of nesting. You can stick anything to anything. Replay 4 steps to make a gui 1) make a frame 2) make a button 3) add the button to frame 4) display interactive components button check box […]
JAVA Beginners part 15
Java Sound ——— 1)get a sequencer sequencer player = midisystem.getsequencer(); 2)make a new sequence sequence seq = new sequence(timing,4); 3)get a new track track t = seq.createTrack(); 4)fill in the track with midievents t.add(mymidievent1); player.setsequence(seq); the actual instructions of a song is held in the message. setmessage(144,1,44,100) 144 says the message type, on or off […]
JAVA Beginners part 14
To convert a number to String couple of ways to do it. a) use concatenation. ‘+’ operator is overloaded in Java as String concatenator. Anything added to String using ‘+’ will be a string. double d = 42.5; String doubles = “”+d; b) use the tostring method from the class Double. double d = 42.5; […]
JAVA Beginners part 13
Static Methods Math Class has lot of static methods. These methods can be used without a need to create an object of math class. There is no Object needed, no heap space spent. The methods can be called any number of times. They do no use instance variables. int x = Math.round(42.2); int y = […]
JAVA Beginners part 12
Java has two memory areas which are Heap and Stack ————————————————– Objects live in Heap ( Garbage collectible Heap) Variables and methods live in Stack Instance variables the variables declared in a class and are associated with an Object.They live on Heap. Local variables are the one declared in a method which include the method […]
JAVA Beginners part 11
The compiler decides whether you can call a method based on the reference type, not the actual object type. Any object that you create is more than a simple Object. It has access to all of the methods of the Class Object. All these stories are useful for this concept. If there is a Dog […]
JAVA Beginners part 10
A class cannot be marked private. In case you dont want a class to be sub classed/inherited you can mark it as Final.More on Final later. Override = The method name , parameters and return type must be same in child and parent class. Vs Overload = The method name is same but the parameters […]
JAVA Beginners part 9
Code Magnet Inheritance. It is a way to reuse a code and make go away the redundant ones. This is one of the pillars of Object Oriented programming. Stand out feature of Java. Much easier to learn through example. Let say, there are three shapes. Triangle, Rectangle. You want all to calculate area of the […]