1. #1
    LilWeezy's Avatar
    Registered
    22/07/11
    Location
    Bruxelles
    Posts
    45
    iTrader
    0
    Mentioned
    0 Post(s)
    Reputation
    0/0

    exception probleem

    Dag iedereen,

    De bedoeling is dat deze catch het bericht toont als er een andere bewerking is als * en -. Dus bijv: indien bewerkingteken: / dan moet hij het bericht tonen.

    Maar hij toont geen bericht maar enkel de IllegalArgumentException in de console.

    Het is gewoon om de exceptions en dergelijke onder de knie te krijgen

    code:
    Code:
    public static void main(String[] args) {
    		// TODO Auto-generated method stub
    
    		Calc calculator = new Calc (5,2,"/");
    		try{
    		System.out.println(calculator.toString());
    		}catch(IllegalArgumentException e)
    		{
    			JOptionPane.showMessageDialog(null, "Er is iets fout gelopen bij het bewerkingsteken");
    	}
    Melding in console :

    Code:
    Exception in thread "main" java.lang.IllegalArgumentException
    	at Calc.setbewerking(Calc.java:43)
    	at Calc.<init>(Calc.java:10)
    	at UI.main(UI.java:12)
    Alvast bedankt!
    Last edited by Fraggie; 19-04-2012 at 19:52. Reason: formatting
    no votes  

  2. #2
    NeverwinterX's Avatar
    Registered
    27/08/04
    Location
    Leuven
    Posts
    930
    iTrader
    0
    Mentioned
    0 Post(s)
    Reputation
    11/38
    Quote Originally Posted by LilWeezy View Post
    This quote is hidden because you are ignoring this member. Show
    Dag iedereen,

    De bedoeling is dat deze catch het bericht toont als er een andere bewerking is als * en -. Dus bijv: indien bewerkingteken: / dan moet hij het bericht tonen.

    Maar hij toont geen bericht maar enkel de IllegalArgumentException in de console.

    Het is gewoon om de exceptions en dergelijke onder de knie te krijgen

    code:

    public static void main(String[] args) {
    // TODO Auto-generated method stub

    Calc calculator = new Calc (5,2,"/");
    try{
    System.out.println(calculator.toString());
    }catch(IllegalArgumentException e)
    {
    JOptionPane.showMessageDialog(null, "Er is iets fout gelopen bij het bewerkingsteken");
    }

    Melding in console :

    Exception in thread "main" java.lang.IllegalArgumentException
    at Calc.setbewerking(Calc.java:43)
    at Calc.<init>(Calc.java:10)
    at UI.main(UI.java:12)

    Alvast bedankt!
    Bekijk de lijnen van de exception: die gebeurt bij de constructor, niet bij de tostring.
    I am thee and thou art me and all of one is the other.
    TED talk: Richard Dawkins on militant atheism
    no votes  

  3. #3
    LilWeezy's Avatar
    Registered
    22/07/11
    Location
    Bruxelles
    Posts
    45
    iTrader
    0
    Mentioned
    0 Post(s)
    Reputation
    0/0
    Oke thanks kheb het gevonden !
    no votes  

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Log in

Log in