{"id":19764559,"url":"https://github.com/nisanth2004/java-generics","last_synced_at":"2026-05-09T06:05:10.361Z","repository":{"id":261783522,"uuid":"884246148","full_name":"Nisanth2004/Java-Generics","owner":"Nisanth2004","description":"This repository covers essential concepts and examples, from basic generics syntax to advanced type constraints. ","archived":false,"fork":false,"pushed_at":"2024-11-08T11:39:44.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-28T10:38:26.733Z","etag":null,"topics":["datatype","devlopment","devops","genrics","java","spring","springboot","t","type"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Nisanth2004.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-06T12:12:19.000Z","updated_at":"2024-11-10T17:10:34.000Z","dependencies_parsed_at":"2024-11-08T12:33:42.478Z","dependency_job_id":"0dcb217a-3363-4e26-8d3b-3f2aea13215e","html_url":"https://github.com/Nisanth2004/Java-Generics","commit_stats":null,"previous_names":["nisanth2004/java-generics"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Nisanth2004/Java-Generics","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nisanth2004%2FJava-Generics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nisanth2004%2FJava-Generics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nisanth2004%2FJava-Generics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nisanth2004%2FJava-Generics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Nisanth2004","download_url":"https://codeload.github.com/Nisanth2004/Java-Generics/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nisanth2004%2FJava-Generics/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268305898,"owners_count":24229491,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["datatype","devlopment","devops","genrics","java","spring","springboot","t","type"],"created_at":"2024-11-12T04:14:12.482Z","updated_at":"2026-05-09T06:05:05.329Z","avatar_url":"https://github.com/Nisanth2004.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Java Generics Example\n\nGenerics in Java allow us to create classes, interfaces, and methods with type parameters, improving type safety and reducing the need for explicit casting. This example demonstrates the basics of using generics in Java to handle different data types in a type-safe way.\n\n## Why Use Generics?\n\n- **Avoid `ClassCastException`**: Prevents errors that occur when trying to cast incompatible types.\n- **Type Safety**: Ensures that only the specified type can be used, catching type errors at compile-time.\n- **No Explicit Casting Needed**: Removes the need to cast objects to specific types.\n\n## Example: Generic Class `GenricsDemo\u003cT\u003e`\n\nThe `GenricsDemo` class is a generic class that can accept any data type (like `String`, `Integer`, etc.). It stores the object of type `T` and prints the class type of the object.\n\n### Code\n\n```java\n// Generic class with type parameter \u003cT\u003e\npublic class GenricsDemo\u003cT\u003e {\n    T t;\n\n    // Constructor to initialize the generic type\n    public GenricsDemo(T ob) {\n        this.t = ob;\n    }\n\n    // Method to display the object's class type\n    public void show() {\n        System.out.println(\"Class of the Object is: \" + t.getClass().getTypeName());\n    }\n}\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnisanth2004%2Fjava-generics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnisanth2004%2Fjava-generics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnisanth2004%2Fjava-generics/lists"}