Jump to content

Syntax Error, insert ";" to complete return statement

I'm having a really weird problem with eclipse. I'm getting a syntax error saying I'm missing the ";" for the return statement even though there is one. I've checked the rest of my code and all the brackets seem to line up and there aren't any missing ";"s. Any ideas?

 

	public View getView(int position, View convertView, ViewGroup parent) {
		ImageView view;
		if (convertView == null) {
			view = new ImageView(context);
			view.setLayoutParams(new GridView.LayoutParams(160, 160));
			view.setScaleType(ImageView.ScaleType.CENTER_CROP);
			view.setPadding(8, 8, 8, 8);
		} 
		else {
			view = (ImageView) convertView;
		}

		view.setImageResource(id_Set[position]);
		return view;
    }

 

Intel® Core™ i7-12700 | GIGABYTE B660 AORUS MASTER DDR4 | Gigabyte Radeon™ RX 6650 XT Gaming OC | 32GB Corsair Vengeance® RGB Pro SL DDR4 | Samsung 990 Pro 1TB | WD Green 1.5TB | Windows 11 Pro | NZXT H510 Flow White
Sony MDR-V250 | GNT-500 | Logitech G610 Orion Brown | Logitech G402 | Samsung C27JG5 | ASUS ProArt PA238QR
iPhone 12 Mini (iOS 17.2.1) | iPhone XR (iOS 17.2.1) | iPad Mini (iOS 9.3.5) | KZ AZ09 Pro x KZ ZSN Pro X | Sennheiser HD450bt
Intel® Core™ i7-1265U | Kioxia KBG50ZNV512G | 16GB DDR4 | Windows 11 Enterprise | HP EliteBook 650 G9
Intel® Core™ i5-8520U | WD Blue M.2 250GB | 1TB Seagate FireCuda | 16GB DDR4 | Windows 11 Home | ASUS Vivobook 15 
Intel® Core™ i7-3520M | GT 630M | 16 GB Corsair Vengeance® DDR3 |
Samsung 850 EVO 250GB | macOS Catalina | Lenovo IdeaPad P580

Link to comment
Share on other sites

Link to post
Share on other sites

The problem is probably somewhere else. Otherwise, Eclipse does weird things sometimes. Try to close it and open it again.

Link to comment
Share on other sites

Link to post
Share on other sites

Is "view" a method or a variable or?

Link to comment
Share on other sites

Link to post
Share on other sites

public ImageView getView(int position, View convertView, ViewGroup parent) {
		...
    }

maybe?

i5 4670k @ 4.2GHz (Coolermaster Hyper 212 Evo); ASrock Z87 EXTREME4; 8GB Kingston HyperX Beast DDR3 RAM @ 2133MHz; Asus DirectCU GTX 560; Super Flower Golden King 550 Platinum PSU;1TB Seagate Barracuda;Corsair 200r case. 

Link to comment
Share on other sites

Link to post
Share on other sites

6 minutes ago, IAmLamp said:

Is "view" a method or a variable or?

Was following this so view is a ImageView object.

https://developer.android.com/guide/topics/ui/layout/gridview.html

 

17 minutes ago, IAmAndre said:

The problem is probably somewhere else. Otherwise, Eclipse does weird things sometimes. Try to close it and open it again.

Eclipse is still complaining about it after a restart.

 

5 minutes ago, Nineshadow said:

public ImageView getView(int position, View convertView, ViewGroup parent) {
		...
    }

maybe?

I'm using code supplied by Google in the link above. Just don't understand why Eclipse is not accepting it. Following tutorials on YouTube that use similar code in Eclipse and still getting the same result. Tried retyping it cause I know sometimes formatting gets all weird when copying and pasting code from websites. But no dice.

Intel® Core™ i7-12700 | GIGABYTE B660 AORUS MASTER DDR4 | Gigabyte Radeon™ RX 6650 XT Gaming OC | 32GB Corsair Vengeance® RGB Pro SL DDR4 | Samsung 990 Pro 1TB | WD Green 1.5TB | Windows 11 Pro | NZXT H510 Flow White
Sony MDR-V250 | GNT-500 | Logitech G610 Orion Brown | Logitech G402 | Samsung C27JG5 | ASUS ProArt PA238QR
iPhone 12 Mini (iOS 17.2.1) | iPhone XR (iOS 17.2.1) | iPad Mini (iOS 9.3.5) | KZ AZ09 Pro x KZ ZSN Pro X | Sennheiser HD450bt
Intel® Core™ i7-1265U | Kioxia KBG50ZNV512G | 16GB DDR4 | Windows 11 Enterprise | HP EliteBook 650 G9
Intel® Core™ i5-8520U | WD Blue M.2 250GB | 1TB Seagate FireCuda | 16GB DDR4 | Windows 11 Home | ASUS Vivobook 15 
Intel® Core™ i7-3520M | GT 630M | 16 GB Corsair Vengeance® DDR3 |
Samsung 850 EVO 250GB | macOS Catalina | Lenovo IdeaPad P580

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, IAmLamp said:

I don't think you can return an entire object in Java. 

Then I'm totally lost since this is the code that is provided by Google themselves... :dry: 

Intel® Core™ i7-12700 | GIGABYTE B660 AORUS MASTER DDR4 | Gigabyte Radeon™ RX 6650 XT Gaming OC | 32GB Corsair Vengeance® RGB Pro SL DDR4 | Samsung 990 Pro 1TB | WD Green 1.5TB | Windows 11 Pro | NZXT H510 Flow White
Sony MDR-V250 | GNT-500 | Logitech G610 Orion Brown | Logitech G402 | Samsung C27JG5 | ASUS ProArt PA238QR
iPhone 12 Mini (iOS 17.2.1) | iPhone XR (iOS 17.2.1) | iPad Mini (iOS 9.3.5) | KZ AZ09 Pro x KZ ZSN Pro X | Sennheiser HD450bt
Intel® Core™ i7-1265U | Kioxia KBG50ZNV512G | 16GB DDR4 | Windows 11 Enterprise | HP EliteBook 650 G9
Intel® Core™ i5-8520U | WD Blue M.2 250GB | 1TB Seagate FireCuda | 16GB DDR4 | Windows 11 Home | ASUS Vivobook 15 
Intel® Core™ i7-3520M | GT 630M | 16 GB Corsair Vengeance® DDR3 |
Samsung 850 EVO 250GB | macOS Catalina | Lenovo IdeaPad P580

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, BlueChinchillaEatingDorito said:

Then I'm totally lost since this is the code that is provided by Google themselves... :dry: 

I'm 95% Java does not allow returning of entire objects, but I might be wrong. I would recommend asking a higher knowledgeable programmer on the forums to be sure. I'm not sure who that would be though. 

Link to comment
Share on other sites

Link to post
Share on other sites

17 minutes ago, IAmLamp said:

Is "view" a method or a variable or?

look like Android API https://developer.android.com/reference/android/view/View.html

44 minutes ago, BlueChinchillaEatingDorito said:

I'm having a really weird problem with eclipse. I'm getting a syntax error saying I'm missing the ";" for the return statement even though there is one. I've checked the rest of my code and all the brackets seem to line up and there aren't any missing ";"s. Any ideas?

I dont see anything wrong with that code. try clean and rebuild the project

 

             ☼

ψ ︿_____︿_ψ_   

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, IAmLamp said:

I'm 95% Java does not allow returning of entire objects, but I might be wrong. I would recommend asking a higher knowledgeable programmer on the forums to be sure. I'm not sure who that would be though. 

@AluminiumTech you do Android programming right? Any ideas? hahahahaa

Intel® Core™ i7-12700 | GIGABYTE B660 AORUS MASTER DDR4 | Gigabyte Radeon™ RX 6650 XT Gaming OC | 32GB Corsair Vengeance® RGB Pro SL DDR4 | Samsung 990 Pro 1TB | WD Green 1.5TB | Windows 11 Pro | NZXT H510 Flow White
Sony MDR-V250 | GNT-500 | Logitech G610 Orion Brown | Logitech G402 | Samsung C27JG5 | ASUS ProArt PA238QR
iPhone 12 Mini (iOS 17.2.1) | iPhone XR (iOS 17.2.1) | iPad Mini (iOS 9.3.5) | KZ AZ09 Pro x KZ ZSN Pro X | Sennheiser HD450bt
Intel® Core™ i7-1265U | Kioxia KBG50ZNV512G | 16GB DDR4 | Windows 11 Enterprise | HP EliteBook 650 G9
Intel® Core™ i5-8520U | WD Blue M.2 250GB | 1TB Seagate FireCuda | 16GB DDR4 | Windows 11 Home | ASUS Vivobook 15 
Intel® Core™ i7-3520M | GT 630M | 16 GB Corsair Vengeance® DDR3 |
Samsung 850 EVO 250GB | macOS Catalina | Lenovo IdeaPad P580

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, BlueChinchillaEatingDorito said:

@AluminiumTech you do Android programming right? Any ideas? hahahahaa

He is a programmer, but I'm not sure if Java is his best strength. Might be worth a shot though. 

Link to comment
Share on other sites

Link to post
Share on other sites

maybe you're missing a closing } at the end of the class?

             ☼

ψ ︿_____︿_ψ_   

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, SCHISCHKA said:

maybe you're missing a closing } at the end of the class?

Spoiler

public class ImageAdapter extends BaseAdapter {
	
	private Context context;
	int[] id_Set = {R.drawable.photo1, R.drawable.photo2,
			R.drawable.photo3, R.drawable.photo4,
			R.drawable.photo5, R.drawable.photo6,
			R.drawable.photo7, R.drawable.sfuaerial};
	
	public ImageAdapter(Context c) {
		this.context = c;
	}
	
	public View getView(int position, View convertView, ViewGroup parent) {
		ImageView imageView;
		if (convertView == null) {
			imageView = new ImageView(context);
			imageView.setLayoutParams(new GridView.LayoutParams(160, 160));
			imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
			imageView.setPadding(8, 8, 8, 8);
		} 
		else {
			imageView = (ImageView) convertView;
		}
		imageView.setImageResource(id_Set[position]);
		return imageView;
    }
	

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return id_Set.length;
	}
	
	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}
	
	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}
}

 

I can't seem to find any. I'm not worried about implementing getItem and getItemID as they're not really required for me.

Intel® Core™ i7-12700 | GIGABYTE B660 AORUS MASTER DDR4 | Gigabyte Radeon™ RX 6650 XT Gaming OC | 32GB Corsair Vengeance® RGB Pro SL DDR4 | Samsung 990 Pro 1TB | WD Green 1.5TB | Windows 11 Pro | NZXT H510 Flow White
Sony MDR-V250 | GNT-500 | Logitech G610 Orion Brown | Logitech G402 | Samsung C27JG5 | ASUS ProArt PA238QR
iPhone 12 Mini (iOS 17.2.1) | iPhone XR (iOS 17.2.1) | iPad Mini (iOS 9.3.5) | KZ AZ09 Pro x KZ ZSN Pro X | Sennheiser HD450bt
Intel® Core™ i7-1265U | Kioxia KBG50ZNV512G | 16GB DDR4 | Windows 11 Enterprise | HP EliteBook 650 G9
Intel® Core™ i5-8520U | WD Blue M.2 250GB | 1TB Seagate FireCuda | 16GB DDR4 | Windows 11 Home | ASUS Vivobook 15 
Intel® Core™ i7-3520M | GT 630M | 16 GB Corsair Vengeance® DDR3 |
Samsung 850 EVO 250GB | macOS Catalina | Lenovo IdeaPad P580

Link to comment
Share on other sites

Link to post
Share on other sites

Have you tried adding another ';' just for the sake of it?

i5 4670k @ 4.2GHz (Coolermaster Hyper 212 Evo); ASrock Z87 EXTREME4; 8GB Kingston HyperX Beast DDR3 RAM @ 2133MHz; Asus DirectCU GTX 560; Super Flower Golden King 550 Platinum PSU;1TB Seagate Barracuda;Corsair 200r case. 

Link to comment
Share on other sites

Link to post
Share on other sites

20 minutes ago, BlueChinchillaEatingDorito said:
  Reveal hidden contents


public class ImageAdapter extends BaseAdapter {
	
	private Context context;
	int[] id_Set = {R.drawable.photo1, R.drawable.photo2,
			R.drawable.photo3, R.drawable.photo4,
			R.drawable.photo5, R.drawable.photo6,
			R.drawable.photo7, R.drawable.sfuaerial};
	
	public ImageAdapter(Context c) {
		this.context = c;
	}
	
	public View getView(int position, View convertView, ViewGroup parent) {
		ImageView imageView;
		if (convertView == null) {
			imageView = new ImageView(context);
			imageView.setLayoutParams(new GridView.LayoutParams(160, 160));
			imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
			imageView.setPadding(8, 8, 8, 8);
		} 
		else {
			imageView = (ImageView) convertView;
		}
		imageView.setImageResource(id_Set[position]);
		return imageView;
    }
	

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return id_Set.length;
	}
	
	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}
	
	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}
}

 

I can't seem to find any. I'm not worried about implementing getItem and getItemID as they're not really required for me.

i get no errors with this code. i think its eclipse being a buggy dick. try doing Project -> clean. This usually fixes false error messages. In eclipse theres another thing you can do to clear false errors, but I stopped using eclipse a long time ago, i need to google what it is called

             ☼

ψ ︿_____︿_ψ_   

Link to comment
Share on other sites

Link to post
Share on other sites

20 minutes ago, fizzlesticks said:

Post all of your code and the full error message.

13 minutes ago, SCHISCHKA said:

i get no errors with this code. i think its eclipse being a buggy dick. try doing Project -> clean. This usually fixes false error messages. In eclipse theres another thing you can do to clear false errors, but I stopped using eclipse a long time ago, i need to google what it is called

Yea I've tried cleaning and building the project multiple times. Restarted Eclipse multiple times as well.

**Project Package identifier has been censored out. **

Untitled.png

Intel® Core™ i7-12700 | GIGABYTE B660 AORUS MASTER DDR4 | Gigabyte Radeon™ RX 6650 XT Gaming OC | 32GB Corsair Vengeance® RGB Pro SL DDR4 | Samsung 990 Pro 1TB | WD Green 1.5TB | Windows 11 Pro | NZXT H510 Flow White
Sony MDR-V250 | GNT-500 | Logitech G610 Orion Brown | Logitech G402 | Samsung C27JG5 | ASUS ProArt PA238QR
iPhone 12 Mini (iOS 17.2.1) | iPhone XR (iOS 17.2.1) | iPad Mini (iOS 9.3.5) | KZ AZ09 Pro x KZ ZSN Pro X | Sennheiser HD450bt
Intel® Core™ i7-1265U | Kioxia KBG50ZNV512G | 16GB DDR4 | Windows 11 Enterprise | HP EliteBook 650 G9
Intel® Core™ i5-8520U | WD Blue M.2 250GB | 1TB Seagate FireCuda | 16GB DDR4 | Windows 11 Home | ASUS Vivobook 15 
Intel® Core™ i7-3520M | GT 630M | 16 GB Corsair Vengeance® DDR3 |
Samsung 850 EVO 250GB | macOS Catalina | Lenovo IdeaPad P580

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, IAmLamp said:

Is "view" a method or a variable or?

At the top it says "ImageView view;", meaning that it is declaring a variable. So view is a variable.

Link to comment
Share on other sites

Link to post
Share on other sites

13 minutes ago, BlueChinchillaEatingDorito said:

Yea I've tried cleaning and building the project multiple times. Restarted Eclipse multiple times as well.

**Project Package identifier has been censored out. **

 

try cut and re-paste the code if that does not work go into preferences and turn off Lint error checking, clean & build, then turn Lint back on

             ☼

ψ ︿_____︿_ψ_   

Link to comment
Share on other sites

Link to post
Share on other sites

14 minutes ago, BlueChinchillaEatingDorito said:

Yea I've tried cleaning and building the project multiple times. Restarted Eclipse multiple times as well.

**Project Package identifier has been censored out. **

-snip

Line 26 is interesting 

Link to comment
Share on other sites

Link to post
Share on other sites

17 minutes ago, BlueChinchillaEatingDorito said:

Yea I've tried cleaning and building the project multiple times. Restarted Eclipse multiple times as well.

**Project Package identifier has been censored out. **

Untitled.png

Perhaps it's not a problem with the semi-colon. The thing that stood out to me was that the function is promising to return a variable with the type of View, while the variable you return is of the type ImageView. That might be what's causing the error. I'm not familiar with what either of those are, and thus don't know if they are interchangeable, but it seems like that could be part of the problem. Please correct me if I'm wrong.

Link to comment
Share on other sites

Link to post
Share on other sites

Wait...just remembered something.

Have you, by any chance, used a Greek question mark (;) instead of a semi column(;) ? Yes, that's a thing.

 

I'm only asking because I did do this prank on a friend of mine...let's just say he wasn't very happy.

 

i5 4670k @ 4.2GHz (Coolermaster Hyper 212 Evo); ASrock Z87 EXTREME4; 8GB Kingston HyperX Beast DDR3 RAM @ 2133MHz; Asus DirectCU GTX 560; Super Flower Golden King 550 Platinum PSU;1TB Seagate Barracuda;Corsair 200r case. 

Link to comment
Share on other sites

Link to post
Share on other sites

15 minutes ago, Nineshadow said:

Wait...just remembered something.

Have you, by any chance, used a Greek question mark (;) instead of a semi column(;) ? Yes, that's a thing.

 

I'm only asking because I did do this prank on a friend of mine...let's just say he wasn't very happy.

 

I'm 99% that's the reason. Just try to copy and paste another ";" and you should be fine.

Link to comment
Share on other sites

Link to post
Share on other sites

58 minutes ago, Nineshadow said:

Wait...just remembered something.

Have you, by any chance, used a Greek question mark (;) instead of a semi column(;) ? Yes, that's a thing.

 

I'm only asking because I did do this prank on a friend of mine...let's just say he wasn't very happy.

 

Yea it's still bitching about it. Copied one from another line of code that doesn't seem to have an issue and same thing. It does seem like a good prank though, maybe I'll it to someone one day.

Intel® Core™ i7-12700 | GIGABYTE B660 AORUS MASTER DDR4 | Gigabyte Radeon™ RX 6650 XT Gaming OC | 32GB Corsair Vengeance® RGB Pro SL DDR4 | Samsung 990 Pro 1TB | WD Green 1.5TB | Windows 11 Pro | NZXT H510 Flow White
Sony MDR-V250 | GNT-500 | Logitech G610 Orion Brown | Logitech G402 | Samsung C27JG5 | ASUS ProArt PA238QR
iPhone 12 Mini (iOS 17.2.1) | iPhone XR (iOS 17.2.1) | iPad Mini (iOS 9.3.5) | KZ AZ09 Pro x KZ ZSN Pro X | Sennheiser HD450bt
Intel® Core™ i7-1265U | Kioxia KBG50ZNV512G | 16GB DDR4 | Windows 11 Enterprise | HP EliteBook 650 G9
Intel® Core™ i5-8520U | WD Blue M.2 250GB | 1TB Seagate FireCuda | 16GB DDR4 | Windows 11 Home | ASUS Vivobook 15 
Intel® Core™ i7-3520M | GT 630M | 16 GB Corsair Vengeance® DDR3 |
Samsung 850 EVO 250GB | macOS Catalina | Lenovo IdeaPad P580

Link to comment
Share on other sites

Link to post
Share on other sites

4 hours ago, BlueChinchillaEatingDorito said:

@AluminiumTech you do Android programming right? Any ideas? hahahahaa

I don't see anything inherently wrong with the Java. The code looks alright......

 

3 hours ago, BlueChinchillaEatingDorito said:

Yea I've tried cleaning and building the project multiple times. Restarted Eclipse multiple times as well.

**Project Package identifier has been censored out. **

Untitled.png

The variable/object you want to return is misspelled.

 

You reference it is as "imageView" instead of "ImageView"

Judge a product on its own merits AND the company that made it.

How to setup MSI Afterburner OSD | How to make your AMD Radeon GPU more efficient with Radeon Chill | (Probably) Why LMG Merch shipping to the EU is expensive

Oneplus 6 (Early 2023 to present) | HP Envy 15" x360 R7 5700U (Mid 2021 to present) | Steam Deck (Late 2022 to present)

 

Mid 2023 AlTech Desktop Refresh - AMD R7 5800X (Mid 2023), XFX Radeon RX 6700XT MBA (Mid 2021), MSI X370 Gaming Pro Carbon (Early 2018), 32GB DDR4-3200 (16GB x2) (Mid 2022

Noctua NH-D15 (Early 2021), Corsair MP510 1.92TB NVMe SSD (Mid 2020), beQuiet Pure Wings 2 140mm x2 & 120mm x1 (Mid 2023),

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×