So I have looked at numerous posts on classes, references and methods, set and get for a couple days now. I can't seem to comprehend how it all works.
Disclaimer yes this is for classwork, the poor example below is an attempt to illustrate. I would appreciate your help.
I already have a working (albeit very rudimentary and inefficient program). However everything I have is in my main method of my Primary class and I need to put part of it in a separate class and have it all still work.
With the main method the user inputs a clear text password (clearText) wherein a provided snippet of code hashes the password into (hashText). Which is then used for other things.
What I wish to accomplish is to separate the snippet of code that hashes the password out of the main method of my primary class, into a separate secondary class.
What I cannot figure out is how to do that. How to import clearText into secondary class, then output hashText back to the main method in the primary class.
Thank you.
import java.util.*;
import java.io.*;
public class Primary {
public static void main(String[] args) throws Exception {
String clearText = ("");
System.out.print("Type Text");
clearText = scnr.next();
//Somehow export clearText to the secondary class
//Somehow import hashText into the main method for further use
System.out.println(hashText);
}
}
public class Secondary {
String hashText = ("");
//Somehow import clearText value inputted but the user
//here is where clearText gets hashed(I have that)
//Somehow export hashText for use in the main method
}