Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Exercise 1
- * Define a class named Node with the appopriate fields and constructors. Write a Java application
- * to construct TWO(2) object nodes with integer values of 4 and 7. Print the values and memory
- * addresses of the nodes
- *
- * @author MUHAMMAD AZRI BIN JASNI @ ABDUL RANI
- * @version 10 OCTOBER 2012
- */
- import java.util.*;//Scanner
- public class exercise1
- {
- public static void main (String [] args)
- {
- Scanner sc = new Scanner(System.in);
- Node objNode1 = new Node();
- Node objNode2 = new Node();
- int input;
- System.out.print("Enter object node 1: ");
- input = sc.nextInt();
- objNode1 = new Node(input);
- System.out.print("Enter object node 2: ");
- input = sc.nextInt();
- objNode2 = new Node(input,objNode1);
- //display
- System.out.println("Data objNode1: "+ objNode1.getData() +"\nLink objNode1: "+objNode1.getLink());
- System.out.println("Data objNode2: "+ objNode2.getData() +"\nLink objNode2: "+objNode2.getLink());
- sc.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement