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 6 of 6

Thread: Error in data types

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Error in data types

    sorry my earlier post got saved automatically and I could not finish my question.
    Below is the code with data types, when I run the code it is throwing error near main(String[] args)....can u please tell me why it throwing error.

    Below is the code...

    package test;

    public class test1 {

    class multipleAssignment
    {
    public static void main(String[] args)
    {
    int i,j,k;
    i=j=k=10;
    System.out.println("i="+i+" j="+j+" k="+k);
    }
    }

    }


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Error in data types

    I've deleted your other post, but you still aren't using the highlight tags or standard coding conventions.

    What error are you receiving? What does google suggest the cause of the error could be?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Sep 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Error in data types

    I tried in google but could not understand, also how do I figure out SCC and highlight tags is there any example.


    package test;

    public class test1 {

    class multipleAssignment
    {
    public static void main(String[] args) // Iam receiving error here, it is displaying message " method main could not be declared static; static methods can be declared in static or top level types."
    {
    int i,j,k;
    i=j=k=10;
    System.out.println("i="+i+" j="+j+" k="+k);
    }
    }

    }

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Error in data types

    Really the only naming convention you've missed is that your class name should use an upper case letter. You also shouldn't use compound assignment operators like that.

    The highlight tags are explained in the link in my signature, or you can try to quote somebody who has used them, or you can do a search of "highlight tags" in the forum search bar.

    You still haven't posted the actual error you're seeing.

    Edit: I see the error now, I missed it because you weren't using highlight tags.

    Your syntax is a bit off. Why do you have a class inside another class?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Junior Member
    Join Date
    Sep 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Error in data types

    sorry...I tried to highlight tags but it is not working....I will figure it out. In the mean time, I really need help with the below code. I removed the class ffrom another class it was the mistake I made. but, it is still throwing error "Error: Could not find or load main class Test3" is the error valid.

    package test;

    class multipleAssignment
    {
    public static void main(String[] args)
    {
    int i,j,k;
    i=j=k=10;
    System.out.println("i="+i+" j="+j+" k="+k);
    }
    }

    --- Update ---

    Testing highlight tags...please ignore this post.

    --- Update ---

    sorry...I tried to highlight tags but it is not working....I will figure it out. In the mean time, I really need help with the below code. I removed the class ffrom another class it was the mistake I made. but, it is still throwing error "Error: Could not find or load main class Test3" is the error valid.

    package test;

    class multipleAssignment
    {
    public static void main(String[] args)
    {
    int i,j,k;
    i=j=k=10;
    System.out.println("i="+i+" j="+j+" k="+k);
    }
    }

    --- Update ---

    sorry...I tried to highlight tags but it is not working....I will figure it out. In the mean time, I really need help with the below code. I removed the class ffrom another class it was the mistake I made. but, it is still throwing error "Error: Could not find or load main class Test3" is the error valid.

    package test;

    class multipleAssignment
    {
    public static void main(String[] args)
    {
    int i,j,k;
    i=j=k=10;
    System.out.println("i="+i+" j="+j+" k="+k);
    }
    }

    --- Update ---

    sorry...I tried to highlight tags but it is not working....I will figure it out. In the mean time, I really need help with the below code. I removed the class ffrom another class it was the mistake I made. but, it is still throwing error "Error: Could not find or load main class Test3" is the error valid.

    package test;

    class multipleAssignment
    {
    public static void main(String[] args)
    {
    int i,j,k;
    i=j=k=10;
    System.out.println("i="+i+" j="+j+" k="+k);
    }
    }

  6. #6
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Error in data types

    Read this link to understand formatting tags and other important things about this forum and the forum culture in general. Not that hard.

    Why is the compiler looking for a source file with a main method called Test3.java? Was that the name of your original source file before you started deleting things? There's something wrong with your project setup. What is the name of the file that contains the code you've posted? Are you compiling from the command line or using an IDE? If from the command line, show us the commands you're typing (just copy and paste the command line session). If using an IDE, which IDE? Are you using Windows or Linux or something else?

Similar Threads

  1. Help: Data Structures and Data Types
    By TheLawG14 in forum Java Code Snippets and Tutorials
    Replies: 2
    Last Post: July 19th, 2013, 09:55 AM
  2. Question about data types
    By ashl7 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 16th, 2013, 03:37 AM
  3. Very Basic Question: Reference Data Types
    By Bill123 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: July 14th, 2012, 10:39 PM
  4. Tutorial: Primitive Data Types
    By newbie in forum Java Programming Tutorials
    Replies: 3
    Last Post: July 5th, 2012, 11:56 PM