Click here to Skip to main content
16,005,734 members
Home / Discussions / Java
   

Java

 
GeneralRe: jvm manager Pin
Richard MacCutchan30-Oct-09 6:06
mveRichard MacCutchan30-Oct-09 6:06 
GeneralRe: jvm manager Pin
aviparida30-Oct-09 6:38
aviparida30-Oct-09 6:38 
GeneralRe: jvm manager Pin
Richard MacCutchan30-Oct-09 7:40
mveRichard MacCutchan30-Oct-09 7:40 
GeneralRe: jvm manager Pin
aviparida30-Oct-09 7:58
aviparida30-Oct-09 7:58 
GeneralRe: jvm manager Pin
Richard MacCutchan30-Oct-09 8:05
mveRichard MacCutchan30-Oct-09 8:05 
GeneralRe: jvm manager Pin
aviparida30-Oct-09 8:25
aviparida30-Oct-09 8:25 
GeneralRe: jvm manager Pin
Richard MacCutchan30-Oct-09 23:16
mveRichard MacCutchan30-Oct-09 23:16 
QuestionWhy is my Java Code not compiling? Pin
srbruno27-Oct-09 16:47
srbruno27-Oct-09 16:47 
I am new to Java and need to know how to correct this function call parameter passing compiling error. Any ideas?

List.java compiles and here is the code.
//---------------------------------------------------------------------------- 
// List.java 
//---------------------------------------------------------------------------- 
class List 
{ 
   private class Node 
   {  int col; 
      double val; 
      Node next, prev; 
      
      Node (int c, double v) { col = c; val = v; next = prev = null; } 
      
      public String toString() { 
         return String.format (" (%2d, %5.2f)", col, val); 
      } 

      public boolean equals(Node E) { return (this.val == E.val); } 
      } 
    
   private Node front, back, current; 
   private int row, length; 

   List(int r) { front = back = current = null; row = r; length = 0; } 
    
   void insertAfterLast(Node N) 
   {  Node node = new Node(N.col, N.val); 
      
      if ( this.length == 0 ) 
      { this.front = this.back = node; 
      }else { 
         node.prev = this.back; 
         this.back.next = node; 
         this.back = node; 
         this.current = node; 
      } 
      this.length++; 
   } 

   public String toString() 
   {  String str = ""; 
      for(Node N = front; N != null;  N = N.next) 
      {  if ( N == front ) { str = String.format ("%3d:", row); } 
         str += N.toString() + (N.next==null?"\n":""); 
      } 
      return str; 
   } 
} 



ListTest.Java does not compile. Here are the error and code.

-bash-3.00$ javac ListTest.java
ListTest.java:20: non-static variable this cannot be referenced from a static context
Entry Ea = new Entry(0, 0.0);
^
ListTest.java:24: insertAfterLast(List.Node) in List cannot be applied to (ListTest.Entry)
A.insertAfterLast(Ea);
^
ListTest.java:26: insertAfterLast(List.Node) in List cannot be applied to (ListTest.Entry)
B.insertAfterLast(Ea);
^
ListTest.java:28: insertAfterLast(List.Node) in List cannot be applied to (ListTest.Entry)
B.insertAfterLast(Ea);
^
4 errors



//---------------------------------------------------------------------------- 
// ListTest.java - A test client for the List ADT 
//---------------------------------------------------------------------------- 
class ListTest 
{ 
   private class Entry 
   {  int col; 
      double val; 
      Entry next, prev; 
      
      // Entry Constructor 
      Entry (int c, double v) { col = c; val = v; next = prev = null; } 
   } 

   public static void main(String[] args) 
   {  int i; 
      List A = new List(1); 
      List B = new List(2); 
      
      Entry Ea = new Entry(0, 0.0); 
      for(i=1; i<=4; i++){ 
         Ea.col = i; 
         Ea.val = Double.parseDouble(Integer.toString(i)); 
         A.insertAfterLast(Ea); 
         Ea.val = Double.parseDouble(Integer.toString(10-2*i)); 
         B.insertAfterLast(Ea); 
         Ea.val = Double.parseDouble(Integer.toString(9-2*i)); 
         B.insertAfterLast(Ea); 
      } 
      
      System.out.println(" "); 
      System.out.println("Print Lists A and B which have been initialized");       
      System.out.println("A = " + A); 
      System.out.println("B = " + B); 
      
   } 
} 

AnswerRe: Why is my Java Code not compiling? Pin
Adam Maras27-Oct-09 18:28
Adam Maras27-Oct-09 18:28 
AnswerRe: Why is my Java Code not compiling? Pin
Richard MacCutchan28-Oct-09 0:30
mveRichard MacCutchan28-Oct-09 0:30 
QuestionCode explanatoin Pin
WebMaster26-Oct-09 5:02
WebMaster26-Oct-09 5:02 
AnswerRe: Code explanatoin Pin
Richard MacCutchan26-Oct-09 6:07
mveRichard MacCutchan26-Oct-09 6:07 
Questionlet me know the path for html pages Pin
kirancgi26-Oct-09 4:42
kirancgi26-Oct-09 4:42 
QuestionRE: Please Comment on the Java Code and Make Revisions If Necessary Pin
srbruno25-Oct-09 12:16
srbruno25-Oct-09 12:16 
AnswerRe: RE: Please Comment on the Java Code and Make Revisions If Necessary Pin
Nagy Vilmos25-Oct-09 22:54
professionalNagy Vilmos25-Oct-09 22:54 
Questioncount if statement Pin
Shakirin Amin25-Oct-09 11:18
Shakirin Amin25-Oct-09 11:18 
AnswerRe: count if statement Pin
Richard MacCutchan25-Oct-09 12:55
mveRichard MacCutchan25-Oct-09 12:55 
GeneralRe: count if statement Pin
Shakirin Amin26-Oct-09 5:11
Shakirin Amin26-Oct-09 5:11 
QuestionGantt Chart's Task Bar Pin
sorrol24-Oct-09 23:48
sorrol24-Oct-09 23:48 
AnswerRe: Gantt Chart's Task Bar Pin
427748025-Oct-09 0:00
427748025-Oct-09 0:00 
GeneralRe: Gantt Chart's Task Bar Pin
sorrol25-Oct-09 16:27
sorrol25-Oct-09 16:27 
QuestionPractical numbers Pin
rics 224-Oct-09 22:35
rics 224-Oct-09 22:35 
AnswerRe: Practical numbers Pin
Richard MacCutchan24-Oct-09 23:23
mveRichard MacCutchan24-Oct-09 23:23 
AnswerRe: Practical numbers Pin
427748025-Oct-09 0:01
427748025-Oct-09 0:01 
AnswerRe: Practical numbers Pin
yohoprashant7-Nov-09 5:37
yohoprashant7-Nov-09 5:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.