aspose file tools*
The moose likes Java in General and the fly likes String not sure where I am going wrong in a simple code snippet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "String not sure where I am going wrong in a simple code snippet" Watch "String not sure where I am going wrong in a simple code snippet" New topic
Author

String not sure where I am going wrong in a simple code snippet

Vishal Hegde
Ranch Hand

Joined: Aug 01, 2009
Posts: 1055

Hi Please adivce where I am going wrong



http://www.lifesbizzare.blogspot.com || OCJP:81%
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Vishal Hegde wrote:Hi Please adivce where I am going wrong


Where you're going wrong is 1) Not telling us clearly and precisely what you're trying to do and 2) Not telling us clearly and precisely exactly what problems you're encountering.
Vishal Hegde
Ranch Hand

Joined: Aug 01, 2009
Posts: 1055

I am getting compilation error


Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

All statements must be inside a method, constructor, or initializer block. The only things that can occur outside those contexts are member variable definitions and definition+initialization combinations.

The line

does not fit those criteria, so it has to be inside a method, constructor, or initialization block.
James X Peterson
Whizlabs Java Support
Ranch Hand

Joined: Feb 26, 2013
Posts: 158
Hi Vishal Hegde,


you can declare and intialize the instance variables but you cannot do assignments.

class A
{
String s="oh my god";
s="aaa";//this is error
}


check line number 9 in your program


Regards,
James
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: String not sure where I am going wrong in a simple code snippet