Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7853117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:35:12+00:00 2026-06-02T19:35:12+00:00

If i have this in my main method: PrintWriter output = new PrintWriter(new FileWriter(args[1]));

  • 0

If i have this in my main method: PrintWriter output = new PrintWriter(new FileWriter(args[1]));

and this in another method: output.println(currentLine);

and import java.io.*; obviously,

does anyone know why I am getting

cannot find symbol
symbol  : variable output
location: class TestClass
        output.println(currentLine);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T19:35:14+00:00Added an answer on June 2, 2026 at 7:35 pm

    The compiler tells you that the name (symbol) output is not defined in the scope (and enclosing scopes) where you want to use it. Based on the definition

    PrintWriter output = new PrintWriter(new FileWriter(args[1]));
    

    it seems you define output in the main() function, but want to use it in a class TestClass, which is not valid as output is only defined within main()

    Assuming main() is defined within TestClass you could define output in the class, then assign its value in main() and use it within the class later:

    public class TestClass {
      PrintWriter output;
      public void write(String currentLine) {
        output.println(currentLine);
      }
    
      public static void main(String[] args) {
        TestClass tc = new TestClass();
        tc.output = new PrintWriter(new FileWriter(args[1]));
        tc.write("Sometext");
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 Classes. GUI (with main method in it) Parser (this reads files(csv),
This is Objective-C, in Xcode for the iPhone. I have a method in main.m:
I have this code : void Main() { System.Timers.Timer t = new System.Timers.Timer (1000);
Hi I have this in the main NetworkChange.NetworkAddressChanged += new NetworkAddressChangedEventHandler(AddressChangedCallback); //The main also
Newbie question, but I have this code: import java.util.*; import java.io.*; public class Welcome1
In the below shown html i have this main div as cxfeeditem feeditem and
I have this TreeView: Main Node Header=Main Sub Node Header=Sub1 Final Node Header=Item1 Final
I have this in my main.m: printf(make autorelease pool \n); NSAutoreleasePool * pool =
I have this declared on my main class: [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@atlas.plist]; CCSpriteBatchNode *batchNode =
I have a GridView like this( main.xml ): <?xml version=1.0 encoding=utf-8?> <GridView xmlns:android=http://schemas.android.com/apk/res/android android:id=@+id/gridView1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.