• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

help 4 abstract class

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi to all,
i have just faced a problem, which i think can be solved here !
i have written following code in
stat.java
// start of code

abstract class stat1
{
abstract public void method();
}
abstract class stat2 extends stat1
{
int f = 20; // these 2 lines says error
System.out.println(f);
}
public class stat
{
int a = 10;
static int b = 20;
public static void main (String args[])
{
int c = args.length;
System.out.println(c);
System.out.println(args[0]);
System.out.println(b);
stat d = new stat();
System.out.println(d.a);
}
}
// end of code
when i am compling it it is giving 2 errors
at line 10
<identifer> expected and
cannot resolve symbol System.out.println
please copy the code and try out at u r system.
thanks in advance
sachin kumar
sachinkkansal@rediffmail.com
------------------
 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
you get a compile time error because the statement
System.out.println(f);
must either be
1. within a method declaration as in
public void display()
{
System.out.println(f);
}
or
2. it must be within a static initializer block as in
static
{
System.out.println(f);
}
hope that helps
Samith.P.Nambiar
----------------------------------
harder u try luckier u get
reply
    Bookmark Topic Watch Topic
  • New Topic