Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

This file looks weird, but it compiles

 
Joe Allen
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import java.io.*;

abstract interface Veloz { void metodo(String x); }
public class A {
private abstract interface Veloz{ Number metodo(int x); }
abstract static class B{
private abstract static interface Veloz{void metodo(long x) throws Exception;}
public void metodo(){
class Opa implements Veloz{
public void metodo(long x) throws IOException { }
}
}
}
public void test(){
class Opa2 implements Veloz{
public Integer metodo(int x) throws RuntimeException {
return (Integer)(int) .5f;
}
}
}
}
===========================
private abstract static interface?
abstract static class?
I don't understand. Hopefully I don't get all confused and messed up before taking the exam.
 
Zhenyi Luo
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe Allen wrote:import java.io.*;

abstract interface Veloz { void metodo(String x); }
public class A {
private abstract interface Veloz{ Number metodo(int x); }
abstract static class B{
private abstract static interface Veloz{void metodo(long x) throws Exception;}
public void metodo(){
class Opa implements Veloz{
public void metodo(long x) throws IOException { }
}
}
}
public void test(){
class Opa2 implements Veloz{
public Integer metodo(int x) throws RuntimeException {
return (Integer)(int) .5f;
}
}
}
}
===========================
private abstract static interface?
abstract static class?
I don't understand. Hopefully I don't get all confused and messed up before taking the exam.


Interfaces can be members of class definitions and can be declared private or protected there. Inner class is similar.
 
Robert Kristofic
Greenhorn
Posts: 1
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
class in class which is static is static nested class (not static is inner class).

Nested classes
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic