Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Printing some strings

Sir,
i want to print 3 strings through JDK 1.1
code is given below:
There are 2 errors
first is ::Can't make a static reference to nonstaitcc variable i in first_class.
second is:: system.out.println("first class"+i);
^
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
class first_class
{
int i=50;
public static void print()
{
System.out.prinln("first class"+i);
}
}
class second_class
{
static int i=70;
public static void print()
{
System.out.println("2nd class "+i);
}
}
public class mainclass
{
first_class first;
second_class second;
public static void main(String args[])
{
first.print();
second.print();
}

System.out.println("Main function ");
}

Comments

  • arb123arb123 Member Posts: 696
    : Sir,
    : i want to print 3 strings through JDK 1.1
    : code is given below:
    : There are 2 errors
    : first is ::Can't make a static reference to nonstaitcc variable i in first_class.
    : second is:: system.out.println("first class"+i);
    : ^
    : ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    : class first_class
    : {
    : int i=50;
    : public static void print()
    : {
    : System.out.prinln("first class"+i);
    : }
    : }
    : class second_class
    : {
    : static int i=70;
    : public static void print()
    : {
    : System.out.println("2nd class "+i);
    : }
    : }
    : public class mainclass
    : {
    : first_class first;
    : second_class second;
    : public static void main(String args[])
    : {
    : first.print();
    : second.print();
    : }
    :
    : System.out.println("Main function ");
    : }
    :
    :

    Look up the "new" operator on Sun's Java tutorial. To use non-static member methods, you must have an instance of a class.


    ---------------------------------
    [size=1](Its just my sig)
    HOWTO ask questions: http://catb.org/~esr/faqs/smart-questions.html[/size]

  • islam ahmadislam ahmad Member Posts: 47
    : : Sir,
    : : i want to print 3 strings through JDK 1.1
    : : code is given below:
    : : There are 2 errors
    : : first is ::Can't make a static reference to nonstaitcc variable i in first_class.
    : : second is:: system.out.println("first class"+i);
    : : ^
    : : ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    : : class first_class
    : : {
    : : int i=50;
    : : public static void print()
    : : {
    : : System.out.prinln("first class"+i);
    : : }
    : : }
    : : class second_class
    : : {
    : : static int i=70;
    : : public static void print()
    : : {
    : : System.out.println("2nd class "+i);
    : : }
    : : }
    : : public class mainclass
    : : {
    : : first_class first;
    : : second_class second;
    : : public static void main(String args[])
    : : {
    : : first.print();
    : : second.print();
    : : }
    : :
    : : System.out.println("Main function ");
    : : }
    : :
    : :
    :
    : Look up the "new" operator on Sun's Java tutorial. To use non-static member methods, you must have an instance of a class.
    :
    :
    : ---------------------------------
    :



    Still hava problem .sir what r u saying
    :

Sign In or Register to comment.