Actually Foo() is a contructor of class Foo. Its a special type of method which has no return type and its name is same as class name. In
java a constructor is required to instantiate any class. If i don't declare any constructor in the class then a default constructor is always there like in your case, a default constructor is there
Foo(){
}
Now if we declare any customized constructor which takes parameters or so then the default constructor vanishes we create the object using our own defined constructor.
Now to create the object of class Foo you will write the code
Foo any_obj_name = new Foo();
and to call any method of this object just use dot operator and method name.
any_obj_name.login();
In you example these 2 steps are performed in one. Made a new object without any name and then call method on that object.
new Foo().login();
I suggest you to read about constructors and other Object Oriented Concepts.