1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * See LICENSE.txt included in this distribution for the specific 9 * language governing permissions and limitations under the License. 10 * 11 * When distributing Covered Code, include this CDDL HEADER in each 12 * file and include the License file at LICENSE.txt. 13 * If applicable, add the following below this CDDL HEADER, with the 14 * fields enclosed by brackets "[]" replaced with your own identifying 15 * information: Portions Copyright [yyyy] [name of copyright owner] 16 * 17 * CDDL HEADER END 18 */ 19 20 /* 21 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. 22 */ 23 package org.opensolaris.opengrok.analysis.java; 24 25 public class Sample { 26 27 static private String MY_MEMBER = "value"; 28 Sample()29 public Sample() { 30 31 } 32 Method(int arg)33 public int Method(int arg) { 34 int res = 5; 35 36 res += arg; 37 38 InnerClass i = new InnerClass(); 39 40 return i.InnerMethod().length() * res; 41 } 42 AbstractMethod(int test)43 public int AbstractMethod(int test) { 44 return 0; 45 } 46 47 private class InnerClass { 48 InnerMethod()49 public String InnerMethod() { 50 // somthing } */ 51 /* }}} 52 multi-line comment }{} 53 */ 54 55 System.out.print("I'm so useless"); 56 57 return "Why do robots need to drink?"; 58 } 59 60 } 61 main(String args[])62 public static void main(String args[]) { 63 int num1, num2; 64 try { 65 // Try block to handle code that may cause exception 66 num1 = 0; 67 num2 = 62 * 0xFFFF / num1; 68 System.out.println("Try block message"); 69 } catch (ArithmeticException e) { 70 // This block is to catch divide-by-zero error 71 System.out.println("Error: Don't divide a number by zero"); 72 } 73 System.out.println("I'm out of try-catch block in Java."); 74 } 75 76 } 77 /*http://example.com*/ 78