Retrieve Child Record From Parent Record in Salesforce

In below example “Student” is the custom Master object, and “Project” is the custom Child object.


public class SampleController
    //Contact List Variable
    public List<Student__c> stuList {get;set;}
    public SampleController(){
        stuList = [SELECT Id, Name, (SELECT Id, Name FROM Projects__r) FROM Student__c LIMIT 10];

Visualforce Page:

<apex:page controller="SampleController">
        <apex:repeat value="{!stuList}" var="stu">
                <td><apex:outputText value="{!stu.Name}"/></td>
                <apex:repeat value="{!stu.Projects__r}" var="pro">
                    <td><apex:outputText value="{!pro.Name}"/></td>