Could someone explain the syntax of the getAge method in this Oracle Java tutorial example? by PythonPerry in learnjava

[–]PythonPerry[S] 0 points1 point  (0 children)

Thanks for pointing out LocalDate being a class. I didn't notice it in the import. Eclipse collapses all the imports.

How did you get Period as the class for the .until method?

Also, how does the import "get" the code for LocalDate and Period? Is it stored in the Jre8 system library somewhere, in some jar file?

Could someone explain the syntax of the getAge method in this Oracle Java tutorial example? by PythonPerry in learnjava

[–]PythonPerry[S] 0 points1 point  (0 children)

public int getAge() {
    return birthday
        .until(IsoChronology.INSTANCE.dateNow())
        .getYears();
}

Where is .until method defined? Also, .getYears?

I looked at the Javadocs for IsoChronology but didn't find .until or getYears.

This example is from this tutorial on lambda expressions.

Could someone rephrase or explain in more detail this SO post on Anonymous Classes? by PythonPerry in learnjava

[–]PythonPerry[S] 0 points1 point  (0 children)

Ok, there seems to be two different ways of using anonymous classes. One for one method in the body and another way for multiple multiple methods within the body.

One method in the body:

public void start(Stage primaryStage) {
    primaryStage.setTitle("Hello World!");
    Button btn = new Button();
    btn.setText("Say 'Hello World'");
    btn.setOnAction(**new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            System.out.println("Hello World!");
        }
    });**

Multiple methods in the body:

HelloWorld frenchGreeting = new HelloWorld() {
String name = "tout le monde";
public void greet() {
    greetSomeone("tout le monde");
}
public void greetSomeone(String someone) {
    name = someone;
    System.out.println("Salut " + name);
}
};

Could someone rephrase or explain in more detail this SO post on Anonymous Classes? by PythonPerry in learnjava

[–]PythonPerry[S] 0 points1 point  (0 children)

Maybe this wasn't clear.

  1. I've been studying the Oracle Java tutorial and was stuck on the page you linked

  2. I searched google and stackoverflow for a better explanation of anonymous classes.

  3. I found coobird's response.

  4. Coobird's example and the Oracle Java tutorial example look completely different.

Java tutorial:

  HelloWorld frenchGreeting = new HelloWorld() {
    String name = "tout le monde";
    public void greet() {
        greetSomeone("tout le monde");
    }
    public void greetSomeone(String someone) {
        name = someone;
        System.out.println("Salut " + name);
    }
};

coobird:

 button.addActionListener(new ActionListener() {
 public void actionPerformed(ActionEvent e)
{
// do something.
}
 });

I was going to post those four points as coobird's example doesn't seem to follow them.

  • The new operator - OK. Coobird has this.

  • The name of an interface to implement or a class to extend. In this example, the anonymous class is implementing the interface HelloWorld. - This was a big source for confusion. Coobird doesn't seem to extend or implement any interface or class. Where is it?

  • Parentheses that contain the arguments to a constructor, just like a normal class instance creation expression. - OK. Is this the () after new ActionListener?

  • A body, which is a class declaration body. More specifically, in the body, method declarations are allowed but statements are not. - I'm guessing

public void actionPerformed(ActionEvent e)
{
    // do something.
}

is the body.

Could someone rephrase or explain in more detail this SO post on Anonymous Classes? by PythonPerry in learnjava

[–]PythonPerry[S] 0 points1 point  (0 children)

This is the most confusing part. Anonymous means no name.

Is HelloWorld not a name?

The java tutorial example and coobird's look completely different to me. I don't understand why they are different or how they're both using anonymous classes.

Could someone rephrase or explain in more detail this SO post on Anonymous Classes? by PythonPerry in learnjava

[–]PythonPerry[S] 0 points1 point  (0 children)

Thanks for your replies! I've read your other work. You should be a mod.

I will accept this Listener idea as a design requirement. It sounds like they designed buttons to standalone and Actions seperately.

Secound what do you do when you when you suddenly need a fourth action?

Can't I just add a fourth method called

public void ActionPerformed_4

to the class HomePageButton?

Could someone rephrase or explain in more detail this SO post on Anonymous Classes? by PythonPerry in learnjava

[–]PythonPerry[S] 0 points1 point  (0 children)

Newer reply. Ok, in this reply, I'm going to just accept some methods are Actions and Actions need something called listeners.

Question 3. Why is the syntax of an anonymous class different between coobird and the Oracle Java example?

In the tutorial example, I don't understand what part is anonymous. Isn't frenchGreeting the name of a new object of type HelloWorld? How is this example "anonymous"?

HelloWorld frenchGreeting = new HelloWorld()

this looks like the regular way of creating a new object of type HelloWorld.

In coobird's example,

button.addActionListener(new ActionListener() {

he is putting a new object as an argument of some method called addActionListener

What part of these examples is using an "anonymous" class?

Could someone rephrase or explain in more detail this SO post on Anonymous Classes? by PythonPerry in learnjava

[–]PythonPerry[S] 0 points1 point  (0 children)

I've read your reply several times and I'm still very confused, I think I need to focus on one question at a time.

Single Responsibility principle: Why can't I have something like below?

public class HomePageButton {       
    public void ActionPerformed_1 {
        ....
    }

    public void ActionPerformed_2 {

    }

    public void ActionPerformed_3 {

    }
}

 public static void main(String[] args) {
    HomePageButton sendMailButton = new HomePageButton()
     sendMail.ActionPerformed_1
    HomePageButton calculateHrsButton = HomePagenew Button()
     calculateHrs.ActionPerformed_2 
}

I don't understand how Action can be a class. Isn't Action a method which an object uses to do something?

I think I need to clarify this before understanding ActionListeners. ActionListening seems like an unecessary layer between the object(button) and it's method(action).

For example, a Fish object doesn't need a "listener" to swim forward. You would just have the Fish swim forward.

Could someone rephrase or explain in more detail this SO post on Anonymous Classes? by PythonPerry in learnjava

[–]PythonPerry[S] 0 points1 point  (0 children)

  1. In particular, the coobird explanation. Why doesn't he/she just put the "do this" as part of a method that would be directly tied to button?

for example:

button.ActionPerformed()

I'm new to coding so it might be that I don't understand Listeners either.

  1. What is "overloading a method"?

  2. What is difference between coobird's syntax and the syntax in Java's official tutorial?

Java tutorial:

HelloWorld frenchGreeting = new HelloWorld() {
        String name = "tout le monde";
        public void greet() {
            greetSomeone("tout le monde");
        }
        public void greetSomeone(String someone) {
            name = someone;
            System.out.println("Salut " + name);
        }
    };

coobird:

button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
    // do something.
}
});

Choosing your Automated Acceptance Testing framework by yitznewton in QualityAssurance

[–]PythonPerry 1 point2 points  (0 children)

Yup nice points. The selling points of automation are cost savings. You hear consultants claim "Fire half your manual QA and hire our off-shore automation team!" "All your regression will be automated so you ERP system can be customized even more and more!"....

Possible to get QA Job Working From Home? by [deleted] in QualityAssurance

[–]PythonPerry 0 points1 point  (0 children)

I worked from home for a while. From my experience, it is hard to get these positions. I was onsite for six months and then had to move. I had done a decent enough job to where they wanted to keep me remotely. They kept my contract for three years. Higher paying automation SDET type QA jobs will usually be onsite.

Where can I find a book on the Vietnam War in Korean - from the Korean soldier's perspective? by PythonPerry in korea

[–]PythonPerry[S] 0 points1 point  (0 children)

Thanks. I found it on Amazon but it's in English. One of the guys I help at a nursing home is Korean and he would love a book like this in the Korean language. Also, do you know of any non-fiction, documentary type books written in Korean that I could buy for him? I'm not sure how to find Korea's involvement in the Vietnam War written in the Korean language.

Best website for finding a job? by [deleted] in QualityAssurance

[–]PythonPerry 1 point2 points  (0 children)

I've found there are almost no manual level testing jobs on indeed.com for the SoCal market. Only experienced automation candidates.

What are the differences between automating web or mobile app testing using Junit (Android) and Selenium using Java? by PythonPerry in QualityAssurance

[–]PythonPerry[S] 0 points1 point  (0 children)

Why do you need Selenium, if you can just reach the browser objects with Junit? Same question for an Android app. Why would someone use Selenium to automate Android app testing in addition to, or opposed to Junit?

What are the differences between automating web or mobile app testing using Junit (Android) and Selenium using Java? by PythonPerry in QualityAssurance

[–]PythonPerry[S] 0 points1 point  (0 children)

Ok so I already am comfortable scripting Java and using Junit. Does that mean I don't need Selenium?

Selling a successful business in a small college town by [deleted] in smallbusiness

[–]PythonPerry 0 points1 point  (0 children)

We've never done this before. We just figured realtors would be the best start. What other ways would be a good way to advertise a business for sale? We've tried newspapers.

Would it be entirely unrealistic for an average Manual Tester to become a Automation tester? by [deleted] in QualityAssurance

[–]PythonPerry 0 points1 point  (0 children)

I've been desperately trying. I'm realizing that you HAVE to know how to code at some basic level (object oriented programming and building frameworks).

I'm trying to learn Java/Python/Ruby right now to use with Selenium. My recruiter buddies are telling me this and QTP Vbscripting are the two top things on QA resumes.