Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.71 KB | None | 0 0
  1. class MyProgram
  2. {
  3. int count = 0;
  4. public static void main(String[] args)
  5. {
  6. System.out.println(count);
  7. }
  8. }
  9.  
  10. Main.java:6: error: non-static variable count cannot be referenced from a static context
  11. System.out.println(count);
  12. ^
  13.  
  14. public static void main (String[] args)
  15. {
  16. try
  17. {
  18. MyProgram7 obj = new MyProgram7 ();
  19. obj.run (args);
  20. }
  21. catch (Exception e)
  22. {
  23. e.printStackTrace ();
  24. }
  25. }
  26.  
  27. // instance variables here
  28.  
  29. public void run (String[] args) throws Exception
  30. {
  31. // put your code here
  32. }
  33.  
  34. class Programm {
  35.  
  36. public static void main(String[] args) {
  37. Programm programm = new Programm();
  38. programm.start();
  39. }
  40.  
  41. public void start() {
  42. // can now access non-static fields
  43. }
  44. }
  45.  
  46. import java.io.*;
  47.  
  48. class HelloWorld {
  49. int myInt; // this is a class variable that is unique to each object
  50. static int myInt2; // this is a class variable shared by all objects of this class
  51.  
  52. static void main (String [] args) {
  53. // this is the main entry point for this Java application
  54. System.out.println ("Hello, Worldn");
  55. myInt2 = 14; // able to access the static int
  56. HelloWorld myWorld = new HelloWorld();
  57. myWorld.myInt = 32; // able to access non-static through an object
  58. }
  59. }
  60.  
  61. public class MyProgram7 {
  62. static Scanner scan = new Scanner(System.in);
  63. static int compareCount = 0;
  64. static int low = 0;
  65. static int high = 0;
  66. static int mid = 0;
  67. static int key = 0;
  68. static Scanner temp;
  69. static int[]list;
  70. static String menu, outputString;
  71. static int option = 1;
  72. static boolean found = false;
  73.  
  74. public static void main (String[]args) throws IOException {
  75. ...
  76.  
  77. public class Myprogram7 {
  78.  
  79. Scanner scan;
  80. int compareCount = 0;
  81. int low = 0;
  82. int high = 0;
  83. int mid = 0;
  84. int key = 0;
  85. Scanner temp;
  86. int[]list;
  87. String menu, outputString;
  88. int option = 1;
  89. boolean found = false;
  90.  
  91. private void readLine() {
  92.  
  93. }
  94.  
  95. private void findkey() {
  96.  
  97. }
  98.  
  99. private void printCount() {
  100.  
  101. }
  102. public static void main(String[] args){
  103.  
  104. Myprogram7 myprg=new Myprogram7();
  105. myprg.readLine();
  106. myprg.findkey();
  107. myprg.printCount();
  108. }
  109. }
  110.  
  111. NamCls.NamFnc();
  112.  
  113. System.out.println();
  114.  
  115. NamCls NamObjVar = new NamCls();
  116. NamObjVar.NamFnc();
  117.  
  118. public class NamCls
  119. {
  120. public static void main(String[] args)
  121. {
  122. PlsPrnFnc("Tst Txt");
  123.  
  124. NamCls NamObjVar = new NamCls();
  125. NamObjVar.PrnFnc("Tst Txt");
  126. }
  127.  
  128. static void PlsPrnFnc(String SrgPsgVal)
  129. {
  130. System.out.println(SrgPsgVal);
  131. }
  132.  
  133. void PrnFnc(String SrgPsgVal)
  134. {
  135. System.out.println(SrgPsgVal);
  136. }
  137. }
  138.  
  139. public class NamCls
  140. {
  141. public static void main(String[] args)
  142. {
  143. NamTicCls NamTicVaj = new NamTicCls();
  144. NamTicVaj.PrnFnc("Tst Txt");
  145.  
  146. NamCls NamObjVar = new NamCls();
  147. NamNicCls NamNicVar = NamObjVar.new NamNicCls();
  148. NamNicVar.PrnFnc("Tst Txt");
  149. }
  150.  
  151. static class NamTicCls
  152. {
  153. void PrnFnc(String SrgPsgVal)
  154. {
  155. System.out.println(SrgPsgVal);
  156. }
  157. }
  158.  
  159. class NamNicCls
  160. {
  161. void PrnFnc(String SrgPsgVal)
  162. {
  163. System.out.println(SrgPsgVal);
  164. }
  165. }
  166. }
  167.  
  168. class StaticTest {
  169.  
  170. static int a;
  171. int b;
  172. int c;
  173. }
  174.  
  175. class StaticTest {
  176.  
  177. public void display() {
  178. System.out.println("Static Test");
  179. }
  180.  
  181.  
  182. public static void main(String []cmd) {
  183.  
  184. display();
  185. }
  186.  
  187. }
  188.  
  189. class StaticTest {
  190.  
  191. public static void main(String []cmd) {
  192.  
  193. display();
  194. }
  195.  
  196. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement