Note that there are some explanatory texts on larger screens.

plurals
  1. POprintf, saying, getName setName
    primarykey
    data
    text
    <p>I just watched a youtube tutorial called "many methods and instances". He made a program in which you enter something and it says "your first gf was <em>_</em>". But it was way too overcomplicated. First is the main class:</p> <pre><code>import java.util.Scanner; public class MethodsInstances2 { public static void main(String args[]) { Scanner input = new Scanner(System.in); MethodsInstances object = new MethodsInstances(); System.out.println("Enter name of first gf here: "); String temp = input.nextLine(); object.setName(temp); object.saying(); } } </code></pre> <p>Next is the class it makes an object from:</p> <pre><code>public class MethodsInstances { private String girlName; public void setName (String name){ girlName=name; } public String getName (){ return girlName; } public void saying(){ System.out.printf("Your first gf was %s", getName()); } } </code></pre> <p>It seemed WAY too overcomplicated, and the title is all of the stuff i didn't understand, considering I'm still a newbie at Java. Here's what I typed which took 4 times faster:</p> <pre><code>import java.util.Scanner; public class programtest { public static void main(String args[]){ Scanner test = new Scanner(System.in); String name; System.out.println("Enter the name of your first girfriend: "); name = test.next(); System.out.println("Your first girlfriend was " + name); } } </code></pre> <p>Can someone tell me the point of doing what the tut said to do, and what the title words mean?</p> <p>Thanks a lot, Dan</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload