The right way to use JAVA classes ?!
Разница между en1 и en2, 73 символ(ов) изменены
I have a library of data structures I commonly use, however I find it difficult to use them on codeforces because it requires one pubic class only. There are other editors however that support multiple classes.↵

This my programme structure:

  ↵
~~~~~  

class Digraph {}
  
class Bag {} // Bag is used by Digraph
  
public class {
  
    static digraph
  
    // declare other static variables
  
    static recursivefunction () // operates on digraph
  
    static solution () // computes and prints solution and calls recursive function, instantiate digraph
  
    static void main() // calls solution
  
}
  ↵
~~~~~    

The problem came up because codeforces judge would accept only one public class↵

So i tried this:

  ↵
~~~~~   

public class {↵
    class Digraph {}
  
    class Bag {} // Bag is used by Digraph
  
    static digraph
  
    // declare other static variables
  
    static recursivefunction () // operates on digraph
  
    static solution () // computes and prints solution and calls recursive function, instantiate digraph
  
    static void main() // calls solution
  
}
  ↵
~~~~~  

This gives an error that when declaring digraph because Main.this.Digraph cannot be accessed from a static context.↵

So, how do i use classes in a conflict free manner. Your answer would be of great help.↵



История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский twitu 2018-06-21 21:49:56 73 Tiny change: 'ution \n}\n~~~~~ ' -> 'ution \n} \n~~~~~ '
en1 Английский twitu 2018-06-21 21:45:25 1287 Initial revision (published)