Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Type mismatch: cannot convert from void to ClassX.MethodX

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Type mismatch: cannot convert from void to ClassX.MethodX

    Trying to populate the Trans[] array with the methods in my transistor database (TransDBEE) and am getting the error as described in the title. Any suggestions would be much appreciated

    Class 1
    package TransistorBiasing;

    import javax.swing.JList; //creates a list box for your JFrame
    import TransistorBiasing.TransDBEE;

    public class UseDB extends JFrame
    {
    private JList TransJList;

    private final String TransNames[]={ "TIP120"};//an array of strings
    private final TransDBEE Trans[]={TransDBEE.tip120()}; //HERE IS THE ISSUE LINE



    public static void main( String args[])
    {
    }
    }



    Class 2
    package TransistorBiasing;

    class TransDBEE
    {
    public static int hfe;
    public static int VBE;
    public static int Icmax;

    //static void tip120(int hfe, int Icmax, int VBE)
    //static int tip120(hfe, Icmax, VBE)
    static void tip120()
    {
    hfe=1000;
    Icmax=5;
    VBE=3;
    }
    }


  2. #2
    Member
    Join Date
    Jan 2012
    Location
    Hellas
    Posts
    284
    Thanks
    11
    Thanked 59 Times in 57 Posts

    Default Re: Type mismatch: cannot convert from void to ClassX.MethodX

    Hello RevMoses77,
    Your Trans[] array is of type TransDBEE so it should be assigned with a TransDBEE variable (for example an instance of the TransDBEE class). You tip120() method is void (returns nothing) that's why you get this error.

Similar Threads

  1. [SOLVED] Cannot Convert from Void to JTextField
    By StandbyExplosion in forum What's Wrong With My Code?
    Replies: 2
    Last Post: August 24th, 2011, 04:56 PM
  2. How to convert from type double to type int?
    By rph in forum Object Oriented Programming
    Replies: 7
    Last Post: July 25th, 2011, 04:21 AM
  3. Typecasting of double variable to integer
    By JavaPF in forum Java Programming Tutorials
    Replies: 2
    Last Post: December 5th, 2010, 03:41 AM
  4. Typecasting of double variable to integer
    By JavaPF in forum Java Code Snippets and Tutorials
    Replies: 2
    Last Post: December 5th, 2010, 03:41 AM