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

Thread: '{' expected error please help

  1. #1
    Banned
    Join Date
    Apr 2012
    Posts
    38
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default '{' expected error please help



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

    Default Re: '{' expected error please help

    Quote Originally Posted by erdy_rezki View Post
    what should i do to solve this error ?
    Hello erdy_rezki!
    Can you post your code here? I saw some syntax errors in the attached photos but i can't be sure.
    Last edited by andreas90; April 9th, 2012 at 04:26 AM.

  3. #3
    Banned
    Join Date
    Apr 2012
    Posts
    38
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: '{' expected error please help

    Quote Originally Posted by andreas90 View Post
    Hello erdy_rezki!
    Can you post your code here? I saw some syntax errors in the attached photos but i can't be sure.
    yes of course andreas90 thanks before

    package toy;
    import java.io.*;
    public class MathExploreToy{
    /**create*/
    public class MathExploreToy(){
    }
    static void test {
    test E();
    testPI();
    testAbs();
    }
    static void betterTest(){
    testinAbs();

    }

    static void betterTest(){
    testIntAbs(){
    }
    static void test E
    System.out.println("Testing untuk math.E");
    System.out.println("Math.E= "+Math.E);
    System.out.println("");
    }

    static void test PI(){
    System.out.println("Testing untuk math.PI");

    System.out.println("Math.PI = "+Math.PI);
    System.out.println("");

    }
    static void testAbs(){
    System.out.println("Testing untuk Math.abs()");
    System.out.println("Math.abs(-23.7)="Math.abs(-23.7));
    System.out.println("Math.abs(0.0)="Math.abs(0.0));
    System.out.println("Math.abs(23.7)="Math.abs(23.7) ;
    System.out.println("Double.MIN_VALUE = "+Double.MIN.VALUE);
    System.out.println("Math.abs(Double.MIN_VALUE) ="Math.abs(Double.MIN_VALUE));
    System.out.println("Math.abs(-Double.MIN_VALUE) ="Math.abs(-Double.MIN_VALUE));
    System.out.println("Math.abs(Double.MAX_VALUE) ="+Double.MAX_VALUE);
    System.out.println("Math.abs(Double.MAX_VALUE) ="+Math.abs(Double.MAX_VALUE));
    System.out.println("Math.abs(-Double.MAX_VALUE)="+Math.abs(-Double.MAX_VALUE));
    System.out.println("");
    }

    static void testIntAbs(){
    System.out.println("cara pengujian yang lebih baik mendukung otomatisasi");
    System.out.println("Testing untuk Math.abs() bagi bilangan bulat");

    if (Math.abs(-23) !=23)System.out.println("Math(-23)::Error Hasil harus 23");
    else System.out.prinln(Math(-23):: Correct!");
    if (Math.abs(0) !=0)System.out.println("Math(0)::Error Hasil harus 0");
    else System.out.prinln(Math(0):: Correct!");
    if (Math.abs(23) !=23)System.out.println("Math(23)::Error Hasil harus 23");

    System.out.println("integer.MIN_VALUE) = "+integer.MIN_VALUE);
    System.out.println(Math.abs(Integer.MIN_VALUE) ="+math.abs(Integer.MIN_VALUE));
    System.out.println("integer.MAX_VALUE) = "+integer.MAX_VALUE);
    System.out.println(Math.abs(Integer.MAX_VALUE) ="+math.abs(Integer.MAX_VALUE));

    if (Math.abs(Integer.MIN_VALUE) != (-Integer.MIN_VALUE))
    System.out.println("Math(Integer.MIN_VALUE) :: Error!");
    else System.out.println("Math(Integer.MIN_VALUE) :: Correct!");
    if (Math.abs(Integer.MIN_VALUE) < 0)
    System.out.println("Math(Integer.MIN_VALUE) :: Error! hasil harus > 0");
    else System.out.println("Math(Integer.MIN_VALUE) :: Correct!");
    System.out.println("\n\nPERHATIAN!");
    System.out.println("Pengujian menunjukan hasil yang tidak sesuai dengan matematika\n"+"pada kondisi batas sangat sulit diprediksi, untuk itu kita harus mengacu dokumentasi bahasa\n"+
    "Pengujian otomatis kadang tidak dapat mengemukakan secara benar karena dibatasi juga\n"+
    "Oleh kemampuan bahasa itu sendiri bila kesalahan adalah pada spesifikasi bahasa itu sendiri!\n"+
    "Pengujian otomatis akan benar ditangan ahli, pengujian dapat ditambah abb\n"+
    "Berdasarkan kenyataan bahwa hasil fungsi abs tidak boleh kurang dari nol);
    System.out.println("\n"+ Di Java, Math.abs (Integer.MIN_VALUE) justru menghasilkan bilangan negatif.\n"+
    "melanggar rumus matematika dimana hasil fungsi absolut selalu bernilai positif. \n"+
    "Hasil ini dapat ditelusuri karena representasi int adalah two's complement \n"+
    "Versi yang dipakai penulis :: JDK 1.5");

    }

  4. #4
    Banned
    Join Date
    Apr 2012
    Posts
    38
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: '{' expected error please help

    error is in line 5,52,54,58,60,73,74,80
    erroe name: '{'expected , unclosed string lateral, unclosed string lateral, unclosed string lateral,unclosed string lateral, illegal character:\92, unclosed string lateral , '{'expected

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

    Default Re: '{' expected error please help

    You have many syntax errors. Inside your public class MathExploreToy and then you write
    public class MathExploreToy(){
    }
    What is this? If you are trying to make a constructor this is not the appropriate way. Check again your curly braces and try fixing your errors and ask a specific question if you have. I suggest you reading the java tutorials for defining methods.
    And please use the highlight tags for better readability.

  6. The Following User Says Thank You to andreas90 For This Useful Post:

    erdy_rezki (April 9th, 2012)

  7. #6
    Banned
    Join Date
    Apr 2012
    Posts
    38
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: '{' expected error please help

    okay thanks for your comments its really good for my learning

  8. #7
    Banned
    Join Date
    Apr 2012
    Posts
    38
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: '{' expected error please help

    Quote Originally Posted by andreas90 View Post
    You have many syntax errors. Inside your public class MathExploreToy and then you write
    public class MathExploreToy(){
    }
    What is this? If you are trying to make a constructor this is not the appropriate way. Check again your curly braces and try fixing your errors and ask a specific question if you have. I suggest you reading the java tutorials for defining methods.
    And please use the highlight tags for better readability.
    im sorry am i should add import java.io.*; under package parameter? what the function of java.io.*;?

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

    Default Re: '{' expected error please help

    Quote Originally Posted by erdy_rezki View Post
    im sorry am i should add import java.io.*; under package parameter? what the function of java.io.*;?
    You have it in the right place. java.io is not a function (method in java), it's a package. You can't import a method, you import packages (in the beginning of your code, before you declare your class). Here is java.io. If you are a begginner you should familiarize yourself with the Java API. And you should also google every question you have, you will find answers to almost everything.

  10. #9
    Banned
    Join Date
    Apr 2012
    Posts
    38
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: '{' expected error please help

    Quote Originally Posted by andreas90 View Post
    You have it in the right place. java.io is not a function (method in java), it's a package. You can't import a method, you import packages (in the beginning of your code, before you declare your class). Here is java.io. If you are a begginner you should familiarize yourself with the Java API. And you should also google every question you have, you will find answers to almost everything.
    okay thanks again for your help

Similar Threads

  1. Syntax error on token ";", { expected after this token please HELP
    By Creeper in forum What's Wrong With My Code?
    Replies: 6
    Last Post: March 1st, 2012, 03:12 PM
  2. un-expected error
    By arvindbis in forum What's Wrong With My Code?
    Replies: 0
    Last Post: October 21st, 2011, 09:02 AM
  3. Replies: 2
    Last Post: September 23rd, 2011, 07:09 AM
  4. [SOLVED] Error: Class,interface or enum expected
    By FJIW in forum What's Wrong With My Code?
    Replies: 10
    Last Post: September 18th, 2011, 03:08 PM
  5. Why the error said "few parameters expected 7" while i only have 6 fields?
    By Hafiz Mughni in forum What's Wrong With My Code?
    Replies: 3
    Last Post: August 9th, 2011, 10:45 AM