Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Day09B {
- public static void main(String[] args) {
- //testing multiple class is one file
- PrintWords callPrint = new PrintWords();
- callPrint.printHello();
- callPrint.callText1();
- callPrint.txt1 = "I am changed here at Day09B";
- callPrint.callText1();
- callPrint.useActionWord("running");
- }
- }
- // only one public class
- class PrintWords {
- public String txt1 = "MNG B8";
- void printHello() {
- System.out.println("Welcome to Jurassic Park");
- }
- void callText1(){
- System.out.println("text 1 value: " + txt1);
- }
- void useActionWord(String verb) {
- System.out.println("The cat is " + verb);
- }
- }
- //----DIFFERENT FILE-------------------------------------------------
- package week2;
- public class Day09C {
- public static void main(String[] args) {
- D9MoreSamples callSample01 = new D9MoreSamples();
- D9MoreSamples callSample02 = new D9MoreSamples();
- D9MoreSamples callSample03 = new D9MoreSamples();
- //to edit an static variable:
- D9MoreSamples.section = "JAVA-B5-2023";
- callSample01.printProfile();
- callSample02.name = "Gelai";
- callSample02.addr = "Bagumbayan Street, Iloilo city, 5700 Antique";
- callSample02.printProfile();
- callSample03.name = "Blooms";
- callSample03.addr = "Hamtic Pob. 5 Antique";
- callSample03.printProfile();
- }
- }
- class D9MoreSamples {
- String name="Juan dela Cruz";
- String addr="San Jose, Antique";
- static String section = "Java B8 2023";
- void printProfile() {
- System.out.println("He/She is " + name + " from " + addr
- + " and is a trainee of MNG TVI on the section of " + section);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment