Click here to Skip to main content
15,068,988 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
class GFG  
public static int search(int arr[], int x) 
    int n = arr.length; 
    for(int i = 0; i < n; i++) 
        if(arr[i] == x) 
            return i; 
    return -1; 
public static void main(String args[]) 
    int arr[] = { 2, 3, 4, 10, 40 };  
    int x = 10; 
    int result = search(arr, x); 
    if(result == -1) 
        System.out.print("Element is not present in array"); 
        System.out.print("Element is present at index " + result); 

What I have tried:

ive tried drawing my control graph but it doesnt fit the source code
Updated 21-Sep-19 1:23am

1 solution

Maybe you can try a diagram app that accepts Java, here is an overview: what-is-the-fastest-way-to-create-and-edit-uml-diagrams[^]
Also see: uml-tools-for-source-code[^]
Umbrello can import Java: Umbrello Project - Umbrello Features[^]
UML Designer can import Java: best-uml-applications-out-there~uml-designer[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900