Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Class, struct, or interface method must have a return type

Posted on 2006-11-28
3
813 Views
Last Modified: 2008-01-09
Not sure why I get this error, here's the code:

    private List<sss.DataTier.sss1.sss2> categoryList = new List<sss.DataTier.sss1.sss2>();
    LoadSSSList();

    private void LoadSSSList()
    {
        categoryList = sss.DataTier.sss1.sss2.GetCategoryList(sss.DataTier.sss1.sss2.Values.version, VID);
    }
0
Comment
Question by:dba123
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
petiex earned 500 total points
ID: 18034018

    // this will give you a compiler error, because, as an interface, java.util.List cannot be    
    // instantiated.
    // instantiate something that implements List, like java.util.ArrayList
    //private List<sss.DataTier.sss1.sss2> categoryList = new List<sss.DataTier.sss1.sss2>();
    private List<sss.DataTier.sss1.sss2> categoryList = new java.util.ArrayList<sss.DataTier.sss1.sss2>();
    // this was causing the "must have return type" error. The compiler sees it as an invalid method  
    // declaration. It looks like what you want is to invoke the method declared below in an init block:
    // LoadSSSList();
   {
       LoadSSSList();
   }

    private void LoadSSSList()
    {
        categoryList = sss.DataTier.sss1.sss2.GetCategoryList(sss.DataTier.sss1.sss2.Values.version, VID);
    }
0
 
LVL 11

Expert Comment

by:petiex
ID: 18034071
I was assuming you meant java.util.List. If it's actually a concrete class like in java.awt.List, then never mind the first part, and forgive my presumption. ;)

The part about the init block should fix the "must have return type" problem in any case.
0
 
LVL 1

Author Comment

by:dba123
ID: 18063606
this is C#....but thanks, same concept.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question